<?php
-function sendPodcastList()
+function sendPodcast($path)
{
- $files = glob(__DIR__ . '/../var/podcasts/*.url');
- if (count($files) == 0) {
- sendMessage('Keine Podcasts');
- return;
- }
-
- $listItems = array();
- foreach ($files as $file) {
- $title = basename($file, '.url');
- $listItems[] = '<Item>'
- . '<ItemType>ShowOnDemand</ItemType>'
- . '<ShowOnDemandName>' . htmlspecialchars($title) . '</ShowOnDemandName>'
- . '<ShowOnDemandURL>http://radio567.vtuner.com/podcasts/' . urlencode(basename($file)) . '</ShowOnDemandURL>'
- . '</Item>';
- }
- sendListItems($listItems);
-}
+ global $varDir, $host1;
-function sendPodcast($file)
-{
- //strip /podcasts/
- $file = substr(urldecode($file), 10);
+ $file = urldecode($path);
if (strpos($file, '..') !== false) {
sendMessage('No');
return;
}
- $path = __DIR__ . '/../var/podcasts/' . $file;
- if (!file_exists($path)) {
- return sendMessage('File does not exist: ' . $file);
+ $fullPath = $varDir . $path;
+ if (!file_exists($fullPath)) {
+ return sendMessage('File does not exist: ' . $path);
}
- $url = trim(file_get_contents($path));
+ $url = trim(file_get_contents($fullPath));
- $cacheFile = '/tmp/podcast-' . md5($file) . '.xml';
+ $cacheFile = '/tmp/podcast-' . md5($path) . '.xml';
downloadIfNewer($url, $cacheFile);
$sx = simplexml_load_file($cacheFile);
$listItems = array();
+
foreach ($sx->channel->item as $item) {
$title = (string) $item->title;
$desc = (string) $item->description;
$url = $item->enclosure['url'];
- $listItems[] = '<Item>'
- . '<ItemType>ShowEpisode</ItemType>'
- . '<ShowEpisodeName>' . utf8_decode(htmlspecialchars($title)) . '</ShowEpisodeName>'
- . '<ShowEpisodeURL>http://radio567.vtuner.com/play-url?url=' . urlencode($url) . '</ShowEpisodeURL>'
- //. '<ShowEpisodeURL>' . htmlspecialchars($url) . '</ShowEpisodeURL>'
- . '<ShowDesc>' . utf8_decode(htmlspecialchars($desc)) . '</ShowDesc>'
- . '<ShowMime>MP3</ShowMime>'
- . '</Item>';
+ $listItems[] = getEpisodeItem(
+ $title,
+ $host1 . 'deredirect.php?url=' . urlencode($url),
+ $desc,
+ 'MP3'
+ );
}
- sendListItems($listItems);
+ sendListItems($listItems, buildPreviousItem($path));
}