summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheTroll <trolldev@gmail.com>2010-02-25 00:18:20 +0100
committerTheTroll <trolldev@gmail.com>2010-02-25 00:18:20 +0100
commit808f2a389fb96a3e86be616aaa3cb3b351933088 (patch)
tree84d317bff5d0d65a9f3865deb1e4fa1acc0062e1
parentc47d063ff2076ee38daded85fedacd02055b63a2 (diff)
downloadistreamdev-808f2a389fb96a3e86be616aaa3cb3b351933088.tar.gz
istreamdev-808f2a389fb96a3e86be616aaa3cb3b351933088.tar.bz2
M3u generator
-rwxr-xr-xgenplaylist.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/genplaylist.php b/genplaylist.php
new file mode 100755
index 0000000..17c083b
--- /dev/null
+++ b/genplaylist.php
@@ -0,0 +1,56 @@
+<?php
+ header('Content-Type: text/xml');
+ echo "<?xml version=\"1.0\"?>\n";
+ echo "<status>\n";
+
+ $path = $_REQUEST['path'];
+ $name = $_REQUEST['name'];
+
+ exec('rm playlist/*');
+ exec('ln -s ' .addcslashes(quotemeta($path), " &") .'* playlist');
+
+ $dir_handle = @opendir($path);
+ if (!$dir_handle)
+ echo "<m3u>error</m3u>";
+ else
+ {
+ $found = 0;
+ while ($medianame = readdir($dir_handle))
+ {
+ if (mediagettype($path .$name) == 2)
+ {
+ if ($medianame == $name)
+ $found = 1;
+
+ if ($found)
+ $medianame_array[] = $medianame;
+ }
+ }
+
+ if ($medianame_array[0])
+ {
+
+ // Alphabetical sorting
+ sort($medianame_array);
+
+ $plfile = fopen("playlist/playlist.m3u", 'w');
+ if (!$plfile)
+ echo "<m3u>error</m3u>";
+ else
+ {
+ $count = count($medianame_array);
+ for ($cnt=0; $cnt < $count; $cnt++)
+ fwrite($plfile, "playlist/" .$medianame_array[$cnt] ."\n");
+
+ fclose($plfile);
+
+ echo "<m3u>ok</m3u>\n";
+ }
+ }
+ else
+ echo "<m3u>error</m3u>";
+ }
+
+ echo "</status>\n";
+
+?>