Podcast feed generator
<?php | |
// Config | |
$serverAddr = 'http://192.168.1.107:8080/lectures'; | |
$podcastTitle = 'Лекции'; | |
// Podcast description | |
// Got from standard WP RSS feed | |
echo '<?xml version="1.0" encoding="UTF-8"?> | |
<rss version="2.0" | |
xmlns:content="http://purl.org/rss/1.0/modules/content/" | |
xmlns:wfw="http://wellformedweb.org/CommentAPI/" | |
xmlns:dc="http://purl.org/dc/elements/1.1/" | |
xmlns:atom="http://www.w3.org/2005/Atom" | |
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" | |
xmlns:slash="http://purl.org/rss/1.0/modules/slash/" | |
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" | |
>'; | |
echo '<channel> | |
<title>' . $podcastTitle . '</title> | |
<atom:link href="' . $serverAddr . '" rel="self" type="application/rss+xml" />'; | |
// Files list | |
$files = scandir('./'); | |
$files = array_reverse($files); | |
if ( ! empty($files)) { | |
foreach ($files as $fileName) { | |
if (strpos($fileName, 'mp3') == null) continue; | |
$newName = str_replace(' ', '_', $fileName); | |
rename($fileName, $newName); | |
$parts = explode('.mp3', $fileName); | |
$title = $parts[0]; | |
$encodedURL = urlencode($newName); | |
echo '<item>'; | |
echo "<title>$title</title>"; | |
echo "<enclosure url=\"$serverAddr/$encodedURL\" length=\"\" type=\"audio/mpeg\" />"; | |
echo '</item>'; | |
} | |
} | |
echo '</channel> | |
</rss>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment