Created
July 10, 2012 09:48
-
-
Save hubgit/3082367 to your computer and use it in GitHub Desktop.
Download media files from an RSS feed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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