summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheTroll <trolldev@gmail.com>2010-03-17 18:23:56 +0100
committerTheTroll <trolldev@gmail.com>2010-03-17 18:23:56 +0100
commit5a82ce8d05eb30148d8079aed01c503c73dd58d6 (patch)
treee410b38831fe03b68a84b136cf09505ba1d55add
parent9f94e565988c2cd5bf765b4d21584b1ac2fcb64f (diff)
downloadistreamdev-5a82ce8d05eb30148d8079aed01c503c73dd58d6.tar.gz
istreamdev-5a82ce8d05eb30148d8079aed01c503c73dd58d6.tar.bz2
File browsing
-rwxr-xr-xbin/backend.php20
-rwxr-xr-xbin/files.php86
-rwxr-xr-xbin/jsonapi.php11
-rwxr-xr-xbin/vdr.php3
-rwxr-xr-xconfig_default.php2
5 files changed, 81 insertions, 41 deletions
diff --git a/bin/backend.php b/bin/backend.php
index 3eaa127..cf37e2e 100755
--- a/bin/backend.php
+++ b/bin/backend.php
@@ -111,22 +111,10 @@ switch ($action)
break;
case ("browseFolder"):
- $path = $_REQUEST['path'];
- if ( $path == "/video/" ) {
- $tree = file_get_contents("textfiles/browseFolder-rec.txt");
- }
- else if ( $path == "/mnt/media/Videos/" ) {
- $tree = file_get_contents("textfiles/browseFolder-vid.txt");
- }
- else if ( $path == "/mnt/media/Music/" ) {
- $tree = file_get_contents("textfiles/browseFolder-aud.txt");
- }
- else
- {
- $tree = file_get_contents("textfiles/browseFolder-rec.txt");
- }
- print $tree;
- break;
+ $path = $_REQUEST['path'];
+ $tree = browseFolder($_REQUEST['path']);
+ print $tree;
+ break;
case ("browseRec"):
$tree = file_get_contents("textfiles/browseRec.txt");
diff --git a/bin/files.php b/bin/files.php
index ae2507d..dfcda00 100755
--- a/bin/files.php
+++ b/bin/files.php
@@ -1,7 +1,5 @@
<?php
-$audiotypes='mp3 aac wav ';
-
function mediagetinfostream($stream)
{
// Get info
@@ -83,7 +81,7 @@ function mediagetwidth($file)
return $fileinfo['video']['resolution_x'];
}
-function mediagettype($file)
+function filegettype($file)
{
global $videotypes, $audiotypes;
@@ -92,30 +90,20 @@ function mediagettype($file)
$file = str_replace("\\'", "'", $file);
if (is_dir($file))
- return 3;
+ {
+ if ($fileext == "rec")
+ return "rec";
+ else
+ return 'folder';
+ }
else if (preg_match("$/$", $fileext))
- return 0;
+ return 'none';
else if (preg_match("/" .$fileext ." /", $videotypes))
- return 'tv';
+ return 'video';
else if (preg_match("/" .$fileext ." /", $audiotypes))
- return 'rec';
+ return 'audio';
else
- return 'vid';
-}
-
-function mediadirhasaudio($dir)
-{
- global $audiotypes;
-
- $audioextarray = explode(' ', $audiotypes);
-
- foreach ($audioextarray as $num => $audioext)
- {
- if (glob($dir .'*.' .$audioext))
- return 1;
- }
-
- return 0;
+ return 'unknown';
}
function mediagetmusicinfo($file ="")
@@ -169,4 +157,56 @@ function generatelogo($type, $name, $dest)
}
}
+function filesgetlisting($dir)
+{
+ $listing = array();
+
+ $dir_handle = @opendir($dir);
+ if (!$dir_handle)
+ return $listing;
+
+ while ($medianame = readdir($dir_handle))
+ {
+ if($medianame == "." || $medianame == ".." || $medianame == 'lost+found')
+ continue;
+
+ $medianame_array[] = $medianame;
+ }
+
+ if ($medianame_array[0] == NULL)
+ return $listing;
+
+ // Alphabetical sorting
+ sort($medianame_array);
+
+ foreach($medianame_array as $value)
+ {
+ $newentry = array();
+
+ $newentry['name'] = $value;
+ $newentry['path'] = $dir ."/" .$value;
+
+ $type = filegettype($dir ."/" .$value);
+
+ switch ($type)
+ {
+ case 'audio':
+ // More info
+ case 'video':
+ case 'rec':
+ case 'folder':
+ $newentry['type'] = $type;
+ break;
+ default:
+ continue;
+
+ }
+
+ // Add new entry
+ $listing[] = $newentry;
+ }
+
+ return $listing;
+}
+
?>
diff --git a/bin/jsonapi.php b/bin/jsonapi.php
index dcc3dd4..eba9725 100755
--- a/bin/jsonapi.php
+++ b/bin/jsonapi.php
@@ -7,8 +7,8 @@ function getGlobals()
$ret = array();
$ret['streamdev_server'] = $vdrstreamdev;
$ret['rec_path'] = $vdrrecpath;
- $ret['video_path'] = "/mnt/media/Video/";
- $ret['audio_path'] = "/mnt/media/Music/";
+ $ret['video_path'] = "/home/storage/Foot/";
+ $ret['audio_path'] = "/home/www/mp3/";
return json_encode($ret);
}
@@ -113,5 +113,12 @@ function getRunningSessions()
}
+function browseFolder($path)
+{
+ $ret = array();
+ $ret['list'] = filesgetlisting($path);
+
+ return json_encode($ret);
+}
?>
diff --git a/bin/vdr.php b/bin/vdr.php
index 4eb1906..e10a139 100755
--- a/bin/vdr.php
+++ b/bin/vdr.php
@@ -61,6 +61,7 @@ function vdrgetcategories()
if (!is_utf8($curcat))
$curcat = utf8_encode($curcat);
+// $curcat = rawurlencode($curcat);
}
else if ($line[0] != "")
$curcatchancount++;
@@ -178,6 +179,8 @@ function vdrgetchannels($category, $now)
if (!is_utf8($tmpchan['name']))
$tmpchan['name'] = utf8_encode($tmpchan['name']);
+// $tmpchan['name'] = rawurlencode($tmpchan['name']);
+
$chanlist[] = $tmpchan;
}
diff --git a/config_default.php b/config_default.php
index 93d6e7f..ebf96fd 100755
--- a/config_default.php
+++ b/config_default.php
@@ -15,6 +15,8 @@
// Media configuration
$videotypes='avi mkv ts mov mp4 wmv flv mpg mpeg mpeg2 mpv '; // Supported video extensions (must finish with a space)
+ $audiotypes='mp3 aac wav '; // Supported audio extensions
+
// 1:vid 2:aud Source name Source path
$mediasource=array();
$mediasources[]=array ( 1, 'Video', '/mnt/media/movies');