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.
To run the script:
- Ensure you have requests and BeautifulSoup installed in your Python environment;
- Ensure you have
ffmpeg
available on your path; - 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.