Add podcast proxy support for Martin
[noxon-gateway.git] / src / podcasts.php
index 1756ed5ad426c501568ba5f60cf90859c3017343..707d3506f229d87468cacbb42d9a5cc471495481 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 function sendPodcast($path)
 {
-    global $varDir, $host1;
+    global $varDir, $host1, $enablePodcastProxy;
 
     $file = urldecode($path);
     if (strpos($file, '..') !== false) {
@@ -21,22 +21,25 @@ function sendPodcast($path)
     
     $sx = simplexml_load_file($cacheFile);
     $listItems = array();
-    addPreviousItem($listItems, $path);
+
+    $urlHandler = $host1 . 'deredirect.php';
+    if ($enablePodcastProxy) {
+        $urlHandler = $host1 . 'proxy.php';
+    }
 
     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>' . $host1 . 'play-url?url=' . urlencode($url) . '</ShowEpisodeURL>'
-            . '<ShowDesc>' . utf8_decode(htmlspecialchars($desc)) . '</ShowDesc>'
-            . '<ShowMime>MP3</ShowMime>' 
-            . '</Item>';
+        $listItems[] = getEpisodeItem(
+            $title,
+            $urlHandler . '?url=' . urlencode($url),
+            $desc,
+            'MP3'
+        );
     }
-    sendListItems($listItems);
+    sendListItems($listItems, buildPreviousItem($path));
 }
 
 
@@ -67,4 +70,4 @@ function downloadIfNewer($url, $file)
     }
 }
 
-?>
\ No newline at end of file
+?>