Created
August 25, 2019 01:51
-
-
Save unex/88c6226d532ec2c062d5190b4d8fc1d1 to your computer and use it in GitHub Desktop.
fix erroneous radarr paths cuz im a dumbass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fix erroneous radarr paths cuz im a dumbass | |
import requests | |
import json | |
API_BASE = 'https://example.com/radarr/api' | |
API_KEY = '1234567890' | |
class Radarr(requests.Session): | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
self.headers = {'X-Api-Key': API_KEY} | |
radarr = Radarr() | |
movies = radarr.get(f'{API_BASE}/movie').json() | |
print(f'{len(movies)} movies') | |
for movie in movies: | |
if not movie["path"].startswith('/mnt/media/Movies'): | |
print(movie["path"]) | |
movie["path"] = f'/mnt/media/Movies{movie["path"]}' | |
print(radarr.put(f'{API_BASE}/movie', data=json.dumps(movie)).status_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment