How to sync PyCon videos to your iPhone

Note, this article was published over 4 years ago and hence the content may be stale. Consume with a pinch of salt.

Problem

You want to all the PyCon videos on your iPhone for offline viewing.

Solution

Use the following Python script to fetch pycon videos from YouTube and convert them to M4V format so they can be imported to iTunes.

Warning

This gist is stale now - the code for downloading videos has been expanding into a Github repository.

To run the script:

  1. Ensure you have requests and BeautifulSoup installed in your Python environment;
  2. Ensure you have ffmpeg available on your path;
  3. Download youtube-dl to the same directory as this script

Run this script using:

python fetch_pyvideo.py

The script will display the title and description of each available PyCon video and prompt you as to whether you want to download it. Once all videos have been reviewed, each selected one will be downloaded and converted. When all videos have been processed, you can import the files into iTunes and sync them onto your Apple device.

Discussion

As is plain to see, the script is a hacky bit of Python plumbing that:

  • Scrapes the PyCon category and video pages of pyvideo.org;
  • Prompts the user to choose which videos to download;
  • Fetches the Flash content from YouTube using the youtube-dl utility;
  • Converts the .flv files to the M4V QuickTime format.