|
|
@@ -0,0 +1,33 @@
|
|
|
+# 2025-02-24 - jq filter tags
|
|
|
+
|
|
|
+## User Request
|
|
|
+given the format of the json file generated by the "export" function, give me a `jq` command to find all the playback history entries that have "tags".
|
|
|
+
|
|
|
+generate an additional command that will do the same thing (as the third example), but only filtering the entries that have the "plus one" tag
|
|
|
+
|
|
|
+## Export JSON Structure
|
|
|
+From `popup/popup.js` lines 768-774:
|
|
|
+```javascript
|
|
|
+const exportData = {
|
|
|
+ playlists,
|
|
|
+ playbackHistory,
|
|
|
+ openTabs,
|
|
|
+ exportDate: new Date().toISOString(),
|
|
|
+};
|
|
|
+```
|
|
|
+
|
|
|
+The `playbackHistory` object has:
|
|
|
+- Keys: video IDs
|
|
|
+- Values: objects containing `history` array, `tags` array, `title`, etc.
|
|
|
+
|
|
|
+## jq Commands Provided
|
|
|
+
|
|
|
+### All entries with any tags:
|
|
|
+```bash
|
|
|
+jq '.playbackHistory | to_entries | map(select(.value.tags | length > 0)) | map({videoId: .key, tags: .value.tags, title: .value.title})' export.json
|
|
|
+```
|
|
|
+
|
|
|
+### Only entries with "plus one" tag:
|
|
|
+```bash
|
|
|
+jq '.playbackHistory | to_entries | map(select(.value.tags | index("plus one"))) | map({videoId: .key, tags: .value.tags, title: .value.title})' export.json
|
|
|
+```
|