16b0ced56f5be5228a5ef788467e35fdb6c6410c
[noxon-gateway.git] / src / mediatomb.php
1 <?php
2 require_once 'Services/MediaTomb.php';
3
4 function handleRequestMediatomb($fullPath, $prefix)
5 {
6     global $mediatomb;
7
8     extract($mediatomb);
9     $smt = new Services_MediaTomb($user, $pass, $host, $port);
10
11     $path = substr($fullPath, strlen($prefix));
12     $container = $smt->getContainerByPath($path);
13     $listItems = array();
14     addPreviousItem($listItems, $fullPath);
15
16     foreach ($container->getContainers() as $subContainer) {
17         $listItems[] = getDirItem(
18             $subContainer->title,
19             $fullPath . $subContainer->title . '/'
20         );
21     }
22
23     foreach ($container->getItemIterator(false) as $item) {
24         $listItems[] = getEpisodeItem(
25             $item->title,
26             $item->url,
27             '',
28             'MP3'
29         );
30     }
31
32     sendListItems($listItems);
33 }
34 ?>