Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <?php
- $host = "127.0.0.1"; // Radarr hostname
- $port = "7878"; // Radarr port
- $api_key = "xxxxxx"; // Radarr API Key
- $movie_quality = $_SERVER['radarr_moviefile_quality'];
- $movie_path = $_SERVER['radarr_movie_path'];
- $movie_id = $_SERVER['radarr_movie_id'];
- $qualities = array("Bluray-720p", "Bluray-1080p", "DVD"); //qualities to move to 'movies' instead of 'bootleg'
- if(!$movie_path || !$movie_id || !$movie_quality) die("Missing data");
- 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
- 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
- // Look up movie in Radarr
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "http://".$host.":".$port."/api/movie/".$movie_id);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Api-Key: ".$api_key));
- $data = curl_exec($ch);
- curl_close($ch);
- $data = json_decode($data);
- $old_dir = $data->path;
- $new_dir = str_replace("/bootleg/", "/movies/", $old_dir);
- $data->path = $new_dir;
- $data = json_encode($data);
- print_r($data);
- rename($old_dir, $new_dir); // move actual files
- // Edit movie directory in radarr
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "http://".$host.":".$port."/api/movie/".$movie_id);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Api-Key: ".$api_key));
- $newdata = curl_exec($ch);
- curl_close($ch);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement