Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. <?php
  2.  
  3. include "topline.php";
  4. include "config.php";
  5.  
  6. //get arguments
  7. if(empty($_GET['start'])) {
  8. $start = 0;
  9. } elseif( $_GET['start'] >= 0) {
  10. $start = $_GET['start'];
  11. }
  12. if (empty($_GET['end'])) {
  13. $end = $start + 15;
  14. } elseif( $_GET['end'] > 0) {
  15. $end = $_GET['end'];
  16. }
  17.  
  18. $recentepisode = $_GET['recentepisode'];
  19.  
  20. //json rpc call procedure
  21. $ch = curl_init();
  22. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  23. curl_setopt($ch, CURLOPT_POST, 1);
  24. curl_setopt($ch, CURLOPT_URL, $xbmcjsonservice);
  25.  
  26. //get the results from the directory
  27. $request2 = '{"jsonrpc" : "2.0", "method" : "VideoLibrary.GetRecentlyAddedEpisodes", "params" : { "start" : ' . $start . ', "end" : ' . $end . ', "fields": [ "showtitle", "season", "episode" ] }, "id" : 1 }';
  28.  
  29. curl_setopt($ch, CURLOPT_POSTFIELDS, $request2);
  30. $array2 = json_decode(curl_exec($ch),true);
  31.  
  32. //query below contains episodes
  33. $xbmcresults = $array2['result'];
  34.  
  35. //play selected video
  36. if(!empty($_GET['recentepisode'])) {
  37.  
  38. //get selected video
  39. $playvideo = $_GET['recentepisode'];
  40.  
  41. //get filenames from results
  42. $episodes = $xbmcresults['episodes'];
  43.  
  44. //set i at 0
  45. $i = 0;
  46.  
  47. //For Each file in the directory
  48. foreach ($episodes as $value) {
  49. $video = $value['label'];
  50.  
  51. //Check if label equals selected video
  52. if ($video == $playvideo) {
  53.  
  54. //Get location of selected video
  55. $arrayvideos = $episodes[$i];
  56. $videolocation = $arrayvideos['file'];
  57.  
  58. //Play video
  59. $request = '{"jsonrpc" : "2.0", "method": "XBMC.Play", "params" : { "file" : "' . $videolocation . '"}, "id": 1}';
  60. curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
  61. $array = json_decode(curl_exec($ch),true);
  62. }
  63.  
  64. //increase value of i by 1
  65. $i++;
  66. }
  67. }
  68.  
  69. echo "<div id=\"utility\"><ul>";
  70.  
  71. if (array_key_exists('episodes', $xbmcresults)) {
  72. $episodes = $xbmcresults['episodes'];
  73. foreach ($episodes as $value) {
  74. $label = $value['label'];
  75. $label2 = urlencode($label);
  76. $showtitle = $value['showtitle'];
  77. $season = $value['season'];
  78. $episode = $value['episode'];
  79. echo "<li><a href=getrecentepisodes.php?recentepisode=$label2&start=$start&end=$end>$showtitle - ".$season."x".$episode." - $label</a></li>";
  80. }
  81. }
  82.  
  83. echo "</ul></div>";
  84.  
  85. include "downline.php";
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement