-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetmovies.php
More file actions
61 lines (44 loc) · 1.65 KB
/
getmovies.php
File metadata and controls
61 lines (44 loc) · 1.65 KB
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
<?php
include "topline.php";
include "config.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $xbmcjsonservice);
//prepare the field values being posted to the service
$request = '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params" : { "sortorder" : "ascending" }, "id": 1}';
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$array = json_decode(curl_exec($ch),true);
//results movies
$results = $array['result']['movies'];
if(!empty($_GET['playlist'])) {
//get selected video
$addplaylist = $_GET['playlist'];
//clear video playlist
$data = '{"jsonrpc": "2.0", "method": "VideoPlaylist.Clear", "id": 1}';
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$array = json_decode(curl_exec($ch),true);
//add video to playlist
$requestedfile = "$location$addplaylist";
// to be replaced with video id
$request = '{"jsonrpc" : "2.0", "method": "VideoPlaylist.Add", "params" : { "file" : "' . $requestedfile . '" }, "id": 1}';
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$array = json_decode(curl_exec($ch),true);
//play item
$playdata = '{"jsonrpc": "2.0", "method": "VideoPlaylist.Play", "id": 1}';
curl_setopt($ch, CURLOPT_POSTFIELDS, $playdata);
$array = json_decode(curl_exec($ch),true);
}
echo "<div id=\"utility\"><ul>";
//loop video sources
foreach ($results as $value)
{
//show video sources
$sourcename = $value['label'];
$sourcelocation = urlencode($value['file']);
//change location to video id
echo "<li><a href=getmovies.php?playlist=$sourcelocation>$sourcename</a><li>";
}
echo "</ul></div>";
include "downline.php";
?>