Catch mediatomb browse errors
[noxon-gateway.git] / src / mediatomb.php
index 532bbef892ed36d7fc2adc71863907e93c713a14..33b9bd87305fbeedf076e65d341c4a3cbd72223e 100644 (file)
@@ -25,6 +25,11 @@ function mediatombBrowse(Services_MediaTomb $smt, $fullPath, $prefix)
 
     $path = substr($fullPath, strlen($prefix));
     $container = $smt->getContainerByPath($path);
+    if ($container === null) {
+        sendMessage('Error accessing ' . $fullPath);
+        return;
+    }
+
     $listItems = array();
 
     $it = $container->getItemIterator(false);
@@ -68,8 +73,13 @@ function mediatombAddFile(&$listItems, $item)
     if (!clientSupportsType($di->mimetype)) {
         //client wants transcoded file
         //noxon iRadio cube does not want to play .ogg files
-        $itemUrl = $host1 . 'transcode-nocache.php'
-            . '?url=' . urlencode($itemUrl);
+        if (isset($GLOBALS['cacheDir']) && $GLOBALS['cacheDir'] != '') {
+            $itemUrl = $host1 . 'transcode-cache.php'
+                . '?url=' . urlencode($itemUrl);
+        } else {
+            $itemUrl = $host1 . 'transcode-nocache.php'
+                . '?url=' . urlencode($itemUrl);
+        }
     }
     $listItems[] = getEpisodeItem(
         $item->title,