From affe79e23a8b656a343064d1f4f02bee870cfd54 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 25 Nov 2015 00:54:02 +0100 Subject: [PATCH] show mediatomb server contents in internetradio --- .gitignore | 1 + data/config.php.dist | 10 ++++++++++ src/mediatomb.php | 34 ++++++++++++++++++++++++++++++++++ src/podcasts.php | 13 ++++++------- www/index.php | 30 +++++++++++++++++++++++++++--- 5 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 data/config.php.dist create mode 100644 src/mediatomb.php diff --git a/.gitignore b/.gitignore index ba75088..b0e72d9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /var/mynoxon/* /var/podcasts/* /README.html +/data/config.php diff --git a/data/config.php.dist b/data/config.php.dist new file mode 100644 index 0000000..42936be --- /dev/null +++ b/data/config.php.dist @@ -0,0 +1,10 @@ + 'fixme', + 'pass' => 'fixme', + 'host' => 'fixme', + 'port' => '49152' +); +?> diff --git a/src/mediatomb.php b/src/mediatomb.php new file mode 100644 index 0000000..16b0ced --- /dev/null +++ b/src/mediatomb.php @@ -0,0 +1,34 @@ +getContainerByPath($path); + $listItems = array(); + addPreviousItem($listItems, $fullPath); + + foreach ($container->getContainers() as $subContainer) { + $listItems[] = getDirItem( + $subContainer->title, + $fullPath . $subContainer->title . '/' + ); + } + + foreach ($container->getItemIterator(false) as $item) { + $listItems[] = getEpisodeItem( + $item->title, + $item->url, + '', + 'MP3' + ); + } + + sendListItems($listItems); +} +?> diff --git a/src/podcasts.php b/src/podcasts.php index 1756ed5..68d133c 100644 --- a/src/podcasts.php +++ b/src/podcasts.php @@ -28,13 +28,12 @@ function sendPodcast($path) $desc = (string) $item->description; $url = $item->enclosure['url']; - $listItems[] = '' - . 'ShowEpisode' - . '' . utf8_decode(htmlspecialchars($title)) . '' - . '' . $host1 . 'play-url?url=' . urlencode($url) . '' - . '' . utf8_decode(htmlspecialchars($desc)) . '' - . 'MP3' - . ''; + $listItems[] = getEpisodeItem( + $title, + $host1 . 'play-url?url=' . urlencode($url), + $desc, + 'MP3' + ); } sendListItems($listItems); } diff --git a/www/index.php b/www/index.php index 3f06722..4db5f2e 100644 --- a/www/index.php +++ b/www/index.php @@ -14,6 +14,10 @@ if ($_SERVER['HTTP_HOST'] !== '') { $host1 = 'http://' . $_SERVER['HTTP_HOST'] . '/'; $host2 = 'http://' . $_SERVER['HTTP_HOST'] . '/'; } +$cfgFile = $dataDir . 'config.php'; +if (file_exists($cfgFile)) { + include $cfgFile; +} if (strtolower($fullUri) == '/setupapp/radio567/asp/browsexpa/loginxml.asp?token=0') { //initial login for "internet radio" and podcasts @@ -29,17 +33,19 @@ if (strtolower($fullUri) == '/setupapp/radio567/asp/browsexpa/loginxml.asp?token exit(); } else if ($path == '/setupapp/radio567/asp/BrowseXPA/LoginXML.asp') { //"Internet Radio" - $path = '/internetradio'; + $path = '/internetradio/'; } else if ($path == '/setupapp/radio567/asp/BrowseXPA/navXML.asp') { //"Podcasts" - $path = '/podcasts'; + $path = '/podcasts/'; } else if ($path == '/RadioNative.php') { //"My Noxon" - $path = '/mynoxon'; + $path = '/mynoxon/'; } else if ($path == '/setupapp/radio567/asp/BrowseXML/FavXML.asp') { //Internet Radio Station favorites favorited on device + sendMessage('Unsupported'); } else if ($path == '/RadioNativeFavorites.php') { //Favorites, defined via web interface + sendMessage('Unsupported'); } else if (substr($path, 0, 9) == '/play-url') { //play a given URL, but first follow all redirects //noxon iRadio Cube does not like too many redirections @@ -60,6 +66,13 @@ function handleRequest($path) return; } + if (substr($path, 0, 14) == 'internetradio/') { + require_once 'mediatomb.php'; + handleRequestMediatomb($path, 'internetradio/'); + return; + } + + $fullPath = $varDir . $path; if (!file_exists($fullPath)) { sendMessage('Not found: ' . $path); @@ -140,6 +153,17 @@ function getDirItem($title, $urlPath) . ''; } +function getEpisodeItem($title, $fullUrl, $desc, $type) +{ + return '' + . 'ShowEpisode' + . '' . utf8_decode(htmlspecialchars($title)) . '' + . '' . $fullUrl . '' + . '' . utf8_decode(htmlspecialchars($desc)) . '' + . '' . $type . '' + . ''; +} + function getPodcastItem($title, $urlPath) { global $host1; -- 2.30.2