Skip to content

Instantly share code, notes, and snippets.

@hubgit
Created July 10, 2012 09:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hubgit/3082367 to your computer and use it in GitHub Desktop.
Save hubgit/3082367 to your computer and use it in GitHub Desktop.
Download media files from an RSS feed
<?php
$feed = 'https://www.box.com/shared/58ee78a0c5a9cfcf5cfc/a34f97e67c/rss.xml';
$dom = new DOMDocument();
$dom->load($feed);
$xpath = new DOMXPath($dom);
$xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
$nodes = $xpath->query('channel/item');
$file = fopen('urls.txt', 'w');
foreach ($nodes as $node) {
$url = $xpath->query('media:content/@url', $node)->item(0)->nodeValue;
fwrite($file, "$url\n");
$name = $xpath->query('title', $node)->item(0)->textContent;
if (!$name) $name = $url;
fwrite($file, "\tout=$name\n");
}
//aria2c --dir=files --max-concurrent-downloads=3 --input-file=urls.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment