Created
December 20, 2016 03:57
-
-
Save seppo0010/4cb446e06ed351763e6a2457d148c7e5 to your computer and use it in GitHub Desktop.
This file contains 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 | |
// sample usage: php gutenberg.php 20687 "Pride and Prejudice" > prideandprejudice.xml | |
$baseurl = 'http://www.gutenberg.org/files/' . $argv[1] . '/mp3/'; | |
$name = $argv[2]; | |
$data = file_get_contents($baseurl); | |
preg_match_all('/href="(.*?\.mp3)"/', $data, $matches); | |
$ep = 0; | |
?> | |
<?xml version="1.0" encoding="UTF-8"?> | |
<rss> | |
<channel> | |
<title><?php echo $name; ?></title> | |
<pubDate>Mon, 19 Dec 2016 07:55:53 -0000</pubDate> | |
<language>en</language> | |
<description><?php echo $name; ?></description> | |
<?php foreach ($matches[1] as $match) { $url = $baseurl . $match; $ep++; ?> | |
<item> | |
<guid isPermaLink="false"><?php echo md5($url); ?></guid> | |
<title>Part <?php echo $ep; ?></title> | |
<pubDate>Mon, 19 Dec 2016 07:53:41 -0000</pubDate> | |
<link /> | |
<enclosure url="<?php echo $url; ?>" length="0" type="audio/mpeg" /> | |
</item> | |
<?php } ?> | |
</channel> | |
</rss> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment