-
Notifications
You must be signed in to change notification settings - Fork 0
/
getvideofiles.php
149 lines (118 loc) · 3.19 KB
/
getvideofiles.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
include 'topline.php';
require_once 'jsonquery.php';
require_once 'm3u_func.php';
require_once 'server_func.php';
include 'top.php';
//array_sort function
function array_sort($a, $b)
{
return strnatcmp($a['label'], $b['label']);
}
echo "<div id=\"content\"><ul>";
if(!empty($_GET['source']))
{
//get argument of the source
$location = $_GET['source'];
//get the results from the directory
$request2 = '{"jsonrpc" : "2.0", "method" : "Files.GetDirectory", "params" : { "directory" : "' . $location . '" }, "id" : 1}';
//$array2 = json_decode(curl_exec($ch),true);
$array2 = jsonQuery($request2);
//query below contains both files and directories
$xbmcresults = $array2['result'];
//if the directory has content call AudioPlaylist.ttt
if(!empty($_GET['directorycontent']))
{
//get selected songs
$addplaylist = $_GET['directorycontent'];
//only the files
$files = $xbmcresults['files'];
//sort files on name
usort($files, 'array_sort');
//count the number of songs
$songcount = count($files);
//put counter on zero
$i = 0;
//search the array_key of the selected song
foreach ($files as $value)
{
$song = utf8_decode($value['label']);
//there's a match
if ($song == $addplaylist)
{
//count remaining songs
$songqueue = $songcount - $i;
//we still need i
$y = $i;
$arraysongs = $files[$y];
$songlocations = utf8_decode($arraysongs['file']);
$request = '{"jsonrpc" : "2.0", "method": "XBMC.Play", "params" : { "file" : "' . $songlocations . '"}, "id": 1}';
$array = jsonQuery($request);
}
//loop for array_key
$i++;
}
// ajout 08/12/2012 : retour sur la télécommande une fois la vidéo lancé
echo '<script language="javascript">document.location = "remote.php"; </script>';
// fin 08/12/2012
//end for argument empty
}
echo "<ul>";
//show directories
if (array_key_exists('directories', $xbmcresults))
{
$directories = $xbmcresults['directories'];
//sort directories
usort($directories, 'array_sort');
foreach ($directories as $value)
{
$inhoud = utf8_decode($value['label']);
$display = urlencode($value['file']);
echo "<li><a href=getvideofiles.php?source=$display>$inhoud</a></li>";
}
}
echo "</ul>";
echo "<ul>";
//show files in directory
if (array_key_exists('files', $xbmcresults))
{
$files = $xbmcresults['files'];
//sort on name
usort($files, 'array_sort');
foreach ($files as $value)
{
if ($value['filetype']=='file')
{
$inhoud = utf8_decode($value['label']);
$display = urlencode($value['file']);
//make directory and mp3 name url friendly
$location2 = urlencode($location);
$inhoud2 = urlencode($inhoud);
echo "<li><a href=getvideofiles.php?source=$location2&directorycontent=$inhoud2>$inhoud</a></li>";
}
else
{
//DIRECTORY
$inhoud = utf8_decode($value['label']);
$display = urlencode(utf8_decode($value['file']));
echo '<li>
<table width="100%">
<tr>
<td>
<a href=getvideofiles.php?source='.$display.'>'.$inhoud.'</a>
</td>
</tr>
</table>
</li>';
// }
}
}
}
echo "</ul></div>";
}
else
{
echo "No source given!";
}
include "downline.php";
?>