As mentioned before, I want to automatically extract the video from my Pocketed content and sync it to my phone. To achieve this, I’m going to:
Scan my Pocketed items for video, download the videos to my PC
Sync the videos from my PC to the phone
Here’s how to do the former.
Step 1. Download required tooling
Download and install the following tools on your machine. You’ll need to make sure they’re in your PATH too (this might help).
cURL - “a command line tool and library for transferring data with URL syntax”
jq - “a lightweight and flexible command-line JSON processor”
youtube-dl - “a small command-line program to download videos from YouTube.com and a few more sites”
Step 2. Get a Pocket Access token
You’ll need a Pocket Access token before you can make authenticated requests against the Pocket API. Follow my guide here to get one.
Step 3. Ask the Pocket API which of your items have embedded videos
Using cURL, make an authenticated request against the Pocket API and download all the items which have a contentType of “video”. You’ll need to swap out the consumer key and access token below for your own.
Method URL
https://getpocket.com/v3/get
Example HTTP Request
Example HTTP Request (cURL)
Example HTTP Response
See the video URLs above? We want to download from each one of those. But first we need to parse them out somehow.
Step 4. Parse out video URLs using jq
jq is a command line JSON processor. We can use it to separate out our previous video URLs from all that other JSON data - and dump the results into a file. Here’s how:
This command line call …
… dumps all the video URLs in the response body to output.txt
If you’re interested in jq, you can find out more here. But back to the task at hand. We have a bunch of video URLs. How do we download them?
Step 5. Download videos using youtube-dl
Youtube-dl is an open source video downloader. It was initially built for YouTube only, but it’s expanded over time to support many online video sites and formats.
This command line call …
… downloads all the videos referenced in output.txt to the current directory
That’s it! Pretty easy right? To make things even easier, copy and paste the lines below into a new cmd script (I called mine video-downloader.cmd) and leave it minimized and running on your PC. Any videos you add to Pocket will be automatically downloaded to your PC - ace!
Comments