2025-11-08-codemcp-feat-add-playlist-and-history-export-scripts.md 2.2 KB

2025-11-08 - Add Playlist and History Export Scripts

User Request

given the format of the json export of playlists and history, write a couple small scripts (in jq and/or bash) that will convert a json exported file, and present the data in a plaintext format. one script prints the title of each playlist then outputs the url and title of each video in the playlist (unviewed ones first, then the "done" ones). another script outputs the history data, but condensed: the url and title of each video viewed, plus the date and time of the most recent activity of that video, ordered by that date and time; optional space-separated arguments filter only the videos containing all the tags given by the arguments.

Context

The Firefox extension exports data in JSON format with the following structure:

{
  "playlists": {
    "playlist-name": [
      {
        "url": "...",
        "title": "...",
        "status": "done" // optional, omitted for unviewed videos
      }
    ]
  },
  "playbackHistory": {
    "video-id": {
      "url": "...",
      "title": "...",
      "history": [
        {
          "timestamp": 1234567890000,
          "action": "play|pause|ended",
          "position": 123.45
        }
      ],
      "tags": ["tag1", "tag2"] // optional
    }
  },
  "openTabs": [...],
  "exportDate": "..."
}

Implementation

Script 1: format-playlists.sh

  • Takes a JSON export file as argument
  • Uses jq to parse and format playlists
  • Groups videos by status (pending/done)
  • Outputs unviewed videos first, then done videos
  • Format: Playlist title (# header), tab-separated URL and title per video, "## Done" subtitle before done videos

Script 2: format-history.sh

  • Takes a JSON export file as first argument
  • Optional additional arguments are tag filters (all must match)
  • Uses jq to parse playback history
  • Finds most recent timestamp for each video
  • Sorts by most recent activity (descending)
  • Filters by tags if provided
  • Format: Single line per video with tab-separated timestamp, URL, and title

Both scripts:

  • Are executable bash scripts
  • Include usage messages for invalid input
  • Use jq for JSON processing
  • Handle missing files gracefully