From 81b4eec1908c2198dda390dd50ed5c40228038a9 Mon Sep 17 00:00:00 2001 From: NikolajDanger Date: Sat, 27 Mar 2021 15:05:25 +0100 Subject: [PATCH] :sparkles: Server IP based on testing mode --- funcs/other/bedreNetflix.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/funcs/other/bedreNetflix.py b/funcs/other/bedreNetflix.py index 88434be..ac13937 100644 --- a/funcs/other/bedreNetflix.py +++ b/funcs/other/bedreNetflix.py @@ -1,15 +1,16 @@ import requests, imdb, discord, json, math, time, asyncio from funcs import logThis -radarrURL = "http://localhost:7878/api/v3/" -sonarrURL = "http://localhost:8989/api/" -qbittorrentURL = "http://localhost:1340/api/v2/" -moviePath = "/media/plex/Server/movies/" -showPath = "/media/plex/Server/Shows/" - class BedreNetflix(): def __init__(self,bot): self.bot = bot + ip = ["localhost", "192.168.0.40"][self.bot.options.testing] + + self.radarrURL = "http://"+ip+":7878/api/v3/" + self.sonarrURL = "http://"+ip+":8989/api/" + self.qbittorrentURL = "http://"+ip+":1340/api/v2/" + self.moviePath = "/media/plex/Server/movies/" + self.showPath = "/media/plex/Server/Shows/" #Returns a list of no more than 5 options when user requests a movie async def requestMovie(self, ctx, movieName): @@ -67,16 +68,16 @@ class BedreNetflix(): else: logThis("Trying to add movie "+str(imdbId)) apiKey = self.bot.credentials.radarrKey - response = requests.get(radarrURL+"movie/lookup/imdb?imdbId=tt"+imdbId+"&apiKey="+apiKey) + response = requests.get(self.radarrURL+"movie/lookup/imdb?imdbId=tt"+imdbId+"&apiKey="+apiKey) lookupData = response.json() postData = {"qualityProfileId": 1, - "rootFolderPath" : moviePath, + "rootFolderPath" : self.moviePath, "monitored" : True, "addOptions": {"searchForMovie": True}} for key in ["tmdbId","title","titleSlug","images","year"]: postData.update({key : lookupData[key]}) - r = requests.post(url= radarrURL+"movie?apikey="+apiKey,json = postData) + r = requests.post(url= self.radarrURL+"movie?apikey="+apiKey,json = postData) if r.status_code == 201: await channel.send(postData["title"]+" successfully added to Bedre Netflix") @@ -143,16 +144,16 @@ class BedreNetflix(): else: logThis("Trying to add show "+str(imdbName)) apiKey = self.bot.credentials.sonarrKey - response = requests.get(sonarrURL+"series/lookup?term="+imdbName.replace(" ","%20")+"&apiKey="+apiKey) + response = requests.get(self.sonarrURL+"series/lookup?term="+imdbName.replace(" ","%20")+"&apiKey="+apiKey) lookupData = response.json()[0] postData = {"ProfileId" : 1, - "rootFolderPath" : showPath, + "rootFolderPath" : self.showPath, "monitored" : True, "addOptions" : {"searchForMissingEpisodes" : True}} for key in ["tvdbId","title","titleSlug","images","seasons"]: postData.update({key : lookupData[key]}) - r = requests.post(url= sonarrURL+"series?apikey="+apiKey,json = postData) + r = requests.post(url= self.sonarrURL+"series?apikey="+apiKey,json = postData) if r.status_code == 201: await channel.send(postData["title"]+" successfully added to Bedre Netflix") @@ -175,7 +176,7 @@ class BedreNetflix(): DMSectionTitle = "*Torrent Downloads*" DMSectionTitleLine = "-"*((titleWidth-len(DMSectionTitle))//2) message.append(DMSectionTitleLine+DMSectionTitle+DMSectionTitleLine) - response = requests.get(qbittorrentURL+"torrents/info") + response = requests.get(self.qbittorrentURL+"torrents/info") torrentList = response.json() if len(torrentList) > 0: @@ -237,8 +238,8 @@ class BedreNetflix(): movieSectionTitle = "*Missing movies not downloading*" movieSectionTitleLine = "-"*((titleWidth-len(movieSectionTitle))//2) message.append(movieSectionTitleLine+movieSectionTitle+movieSectionTitleLine) - movieList = requests.get(radarrURL+"movie?apiKey="+self.bot.credentials.radarrKey).json() - movieQueue = requests.get(radarrURL+"queue?apiKey="+self.bot.credentials.radarrKey).json() + movieList = requests.get(self.radarrURL+"movie?apiKey="+self.bot.credentials.radarrKey).json() + movieQueue = requests.get(self.radarrURL+"queue?apiKey="+self.bot.credentials.radarrKey).json() movieQueueIDs = [] for queueItem in movieQueue["records"]: @@ -270,7 +271,7 @@ class BedreNetflix(): showSectionTitleLine = "-"*((titleWidth-len(showSectionTitle))//2) message.append(showSectionTitleLine+showSectionTitle+showSectionTitleLine) - showList = requests.get(sonarrURL+"series?apiKey="+self.bot.credentials.sonarrKey).json() + showList = requests.get(self.sonarrURL+"series?apiKey="+self.bot.credentials.sonarrKey).json() for show in showList: if show["seasons"][0]["seasonNumber"] == 0: