YouTube Downloader and Feed Parser
So I decided to spend a bit of time over the holidays scratching an itch and writing some PHP code. The result is a new open source project: YouTube Downloader.
Its main purpose, for me, was to enable me to subscribe to a user’s YouTube videos as a podcast, and have the episodes downloaded in Downcast on my iPad. In the process though I also found it useful to make it usable as a form-based script, where you input a video’s ID and get a list of the available formats for download. So, the project does both.
Here’s the form (thanks to Twitter Bootstrap for the look & feel):
Once you’ve put a video id in the appropriate field and submitted, you’ll get a result that looks something like this:
You can right-click and choose “Save link as” (or whatever your browser calls it) to save any of the files. Unfortunately you have to set the filename and extension yourself.
To use it on a feed, take a look at feed_parser.php provided in the download. You can set a few variables at the top – including what feed it is you want to process – and then it will output an XML file which can be consumed in a podcatcher / podcast client.
Once you’ve got it working (outputting correctly to screen), set it to write out to a file in cron – for example:
/usr/bin/php /var/www/html/feed_parser.php > /var/www/html/feed.xml
If you want to manage multiple different feeds just duplicate feed_parser.php and rename it, and make sure to save the output to different filenames. There’s nothing specific about the name feed_parser.php or the output to feed.xml, so you can have many different ones running.
Feel free to use it, fork it on Github, and send me some pull requests!