Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3. $host = "127.0.0.1"; // Radarr hostname
  4. $port = "7878"; // Radarr port
  5. $api_key = "xxxxxx"; // Radarr API Key
  6.  
  7. $movie_quality = $_SERVER['radarr_moviefile_quality'];
  8. $movie_path = $_SERVER['radarr_movie_path'];
  9. $movie_id = $_SERVER['radarr_movie_id'];
  10.  
  11. $qualities = array("Bluray-720p", "Bluray-1080p", "DVD"); //qualities to move to 'movies' instead of 'bootleg'
  12.  
  13. if(!$movie_path || !$movie_id || !$movie_quality) die("Missing data");
  14.  
  15. if(strpos($movie_path, "/bootleg/") === false) die("This movie is not currently in bootleg"); // movie is not in bootleg and thus does not need to be moved
  16. if(!in_array($movie_quality, $qualities)) die("Quality should not be moved to movies"); // movie is not of a quality that should be moved out of bootleg
  17.  
  18. // Look up movie in Radarr
  19. $ch = curl_init();
  20. curl_setopt($ch, CURLOPT_URL, "http://".$host.":".$port."/api/movie/".$movie_id);
  21. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  22. curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Api-Key: ".$api_key));
  23. $data = curl_exec($ch);
  24. curl_close($ch);
  25.  
  26. $data = json_decode($data);
  27. $old_dir = $data->path;
  28. $new_dir = str_replace("/bootleg/", "/movies/", $old_dir);
  29. $data->path = $new_dir;
  30. $data = json_encode($data);
  31.  
  32. print_r($data);
  33.  
  34. rename($old_dir, $new_dir); // move actual files
  35.  
  36. // Edit movie directory in radarr
  37. $ch = curl_init();
  38. curl_setopt($ch, CURLOPT_URL, "http://".$host.":".$port."/api/movie/".$movie_id);
  39. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  40. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  41. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  42. curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Api-Key: ".$api_key));
  43. $newdata = curl_exec($ch);
  44. curl_close($ch);
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement