✨ Fully converted to slash commands
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import requests, imdb, discord, json, math, time, asyncio
|
||||
from funcs import logThis
|
||||
|
||||
class BedreNetflix():
|
||||
def __init__(self,bot):
|
||||
@ -14,7 +13,7 @@ class BedreNetflix():
|
||||
|
||||
#Returns a list of no more than 5 options when user requests a movie
|
||||
async def requestMovie(self, ctx, movieName):
|
||||
logThis("Searching for "+movieName)
|
||||
self.bot.log("Searching for "+movieName)
|
||||
movieList = imdb.IMDb().search_movie(movieName)
|
||||
movies = []
|
||||
for movie in movieList:
|
||||
@ -41,7 +40,7 @@ class BedreNetflix():
|
||||
messageText += "Error"
|
||||
imdbIds.append(movie.movieID)
|
||||
|
||||
logThis("Returning a list of "+str(len(movies))+" possible movies: "+str(imdbIds))
|
||||
self.bot.log("Returning a list of "+str(len(movies))+" possible movies: "+str(imdbIds), level = 10)
|
||||
|
||||
em = discord.Embed(title=messageTitle,description=messageText,colour=0x00FF00)
|
||||
|
||||
@ -63,10 +62,10 @@ class BedreNetflix():
|
||||
#Adds the requested movie to Bedre Netflix
|
||||
async def addMovie(self,channel,imdbId):
|
||||
if imdbId == None:
|
||||
logThis("Did not find what the user was searching for")
|
||||
self.bot.log("Did not find what the user was searching for")
|
||||
await channel.send("Try searching for the IMDB id")
|
||||
else:
|
||||
logThis("Trying to add movie "+str(imdbId))
|
||||
self.bot.log("Trying to add movie "+str(imdbId))
|
||||
apiKey = self.bot.credentials.radarrKey
|
||||
response = requests.get(self.radarrURL+"movie/lookup/imdb?imdbId=tt"+imdbId+"&apiKey="+apiKey)
|
||||
lookupData = response.json()
|
||||
@ -81,16 +80,16 @@ class BedreNetflix():
|
||||
|
||||
if r.status_code == 201:
|
||||
await channel.send(postData["title"]+" successfully added to Bedre Netflix")
|
||||
logThis("Added "+postData["title"]+" to Bedre Netflix")
|
||||
self.bot.log("Added "+postData["title"]+" to Bedre Netflix")
|
||||
elif r.status_code == 400:
|
||||
await channel.send("The movie is already requested for or added to Bedre Netflix")
|
||||
else:
|
||||
await channel.send("Something went wrong")
|
||||
logThis(str(r.status_code)+" "+r.reason)
|
||||
self.bot.log(str(r.status_code)+" "+r.reason)
|
||||
|
||||
#Returns a list of no more than 5 options when user requests a show
|
||||
async def requestShow(self, ctx, showName):
|
||||
logThis("Searching for "+showName)
|
||||
self.bot.log("Searching for "+showName)
|
||||
movies = imdb.IMDb().search_movie(showName) #Replace with tvdb
|
||||
shows = []
|
||||
for movie in movies:
|
||||
@ -117,7 +116,7 @@ class BedreNetflix():
|
||||
messageText += "Error"
|
||||
imdbNames.append(show["title"])
|
||||
|
||||
logThis("Returning a list of "+str(len(shows))+" possible shows: "+str(imdbNames))
|
||||
self.bot.log("Returning a list of "+str(len(shows))+" possible shows: "+str(imdbNames), level = 10)
|
||||
|
||||
em = discord.Embed(title=messageTitle,description=messageText,colour=0x00FF00)
|
||||
|
||||
@ -139,10 +138,10 @@ class BedreNetflix():
|
||||
#Adds the requested show to Bedre Netflix
|
||||
async def addShow(self,channel,imdbName):
|
||||
if imdbName == None:
|
||||
logThis("Did not find what the user was searching for")
|
||||
self.bot.log("Did not find what the user was searching for")
|
||||
await channel.send("Try searching for the IMDB id")
|
||||
else:
|
||||
logThis("Trying to add show "+str(imdbName))
|
||||
self.bot.log("Trying to add show "+str(imdbName))
|
||||
apiKey = self.bot.credentials.sonarrKey
|
||||
response = requests.get(self.sonarrURL+"series/lookup?term="+imdbName.replace(" ","%20")+"&apiKey="+apiKey)
|
||||
lookupData = response.json()[0]
|
||||
@ -157,16 +156,16 @@ class BedreNetflix():
|
||||
|
||||
if r.status_code == 201:
|
||||
await channel.send(postData["title"]+" successfully added to Bedre Netflix")
|
||||
logThis("Added a "+postData["title"]+" to Bedre Netflix")
|
||||
self.bot.log("Added a "+postData["title"]+" to Bedre Netflix")
|
||||
elif r.status_code == 400:
|
||||
await channel.send("The show is already requested for or added to Bedre Netflix")
|
||||
else:
|
||||
await channel.send("Something went wrong")
|
||||
logThis(str(r.status_code)+" "+r.reason)
|
||||
self.bot.log(str(r.status_code)+" "+r.reason)
|
||||
|
||||
#Generates a list of all torrents and returns formatted list and whether all torrents are downloaded
|
||||
async def genDownloadList(self, showDM, showMovies, showShows, episodes):
|
||||
logThis("Generating torrent list")
|
||||
self.bot.log("Generating torrent list")
|
||||
titleWidth = 100
|
||||
message = []
|
||||
allDownloaded = True
|
||||
@ -366,10 +365,10 @@ class BedreNetflix():
|
||||
|
||||
if messageText.startswith("```"):
|
||||
if allDownloaded:
|
||||
logThis("All torrents are downloaded")
|
||||
self.bot.log("All torrents are downloaded")
|
||||
else:
|
||||
messageText = messageText[:-3]+"\nThis message will not update anymore\n```"
|
||||
logThis("The message updated 20 times")
|
||||
self.bot.log("The message updated 20 times")
|
||||
|
||||
await oldMessage.edit(content = messageText)
|
||||
|
||||
|
Reference in New Issue
Block a user