✨ More info in !downloading command
This commit is contained in:
@@ -133,8 +133,8 @@ class MiscCog(commands.Cog):
|
|||||||
|
|
||||||
#Returns currently downloading torrents
|
#Returns currently downloading torrents
|
||||||
@commands.command(aliases = ["downloads"])
|
@commands.command(aliases = ["downloads"])
|
||||||
async def downloading(self,ctx):
|
async def downloading(self, ctx, *, content = "-d"):
|
||||||
await self.bedreNetflix.downloading(ctx)
|
await self.bedreNetflix.downloading(ctx, content)
|
||||||
|
|
||||||
#Looks up on Wolfram Alpha
|
#Looks up on Wolfram Alpha
|
||||||
@commands.command()
|
@commands.command()
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import requests, imdb, discord, json, math, time, asyncio
|
import requests, imdb, discord, json, math, time, asyncio
|
||||||
from funcs import logThis
|
from funcs import logThis
|
||||||
|
|
||||||
radarrURL = "http://localhost:7878/api/v3/"
|
radarrURL = "http://192.168.0.40:7878/api/v3/"
|
||||||
sonarrURL = "http://localhost:8989/api/"
|
sonarrURL = "http://192.168.0.40:8989/api/"
|
||||||
qbittorrentURL = "http://localhost:1340/api/v2/"
|
qbittorrentURL = "http://192.168.0.40:1340/api/v2/"
|
||||||
moviePath = "/media/plex/Server/movies/"
|
moviePath = "/media/plex/Server/movies/"
|
||||||
showPath = "/media/plex/Server/Shows/"
|
showPath = "/media/plex/Server/Shows/"
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ class BedreNetflix():
|
|||||||
await channel.send(postData["title"]+" successfully added to Bedre Netflix")
|
await channel.send(postData["title"]+" successfully added to Bedre Netflix")
|
||||||
logThis("Added "+postData["title"]+" to Bedre Netflix")
|
logThis("Added "+postData["title"]+" to Bedre Netflix")
|
||||||
elif r.status_code == 400:
|
elif r.status_code == 400:
|
||||||
await channel.send("The movie is already on Bedre Netflix")
|
await channel.send("The movie is already requested for Bedre Netflix")
|
||||||
else:
|
else:
|
||||||
await channel.send("Something went wrong")
|
await channel.send("Something went wrong")
|
||||||
logThis(str(r.status_code)+" "+r.reason)
|
logThis(str(r.status_code)+" "+r.reason)
|
||||||
@@ -158,21 +158,27 @@ class BedreNetflix():
|
|||||||
await channel.send(postData["title"]+" successfully added to Bedre Netflix")
|
await channel.send(postData["title"]+" successfully added to Bedre Netflix")
|
||||||
logThis("Added a "+postData["title"]+" to Bedre Netflix")
|
logThis("Added a "+postData["title"]+" to Bedre Netflix")
|
||||||
elif r.status_code == 400:
|
elif r.status_code == 400:
|
||||||
await channel.send("The show is already on Bedre Netflix")
|
await channel.send("The show is already requested for Bedre Netflix")
|
||||||
else:
|
else:
|
||||||
await channel.send("Something went wrong")
|
await channel.send("Something went wrong")
|
||||||
logThis(str(r.status_code)+" "+r.reason)
|
logThis(str(r.status_code)+" "+r.reason)
|
||||||
|
|
||||||
#Generates a list of all torrents and returns formatted list and whether all torrents are downloaded
|
#Generates a list of all torrents and returns formatted list and whether all torrents are downloaded
|
||||||
async def genDownloadList(self):
|
async def genDownloadList(self, showDM, showMovies, showShows, episodes):
|
||||||
logThis("Generating torrent list")
|
logThis("Generating torrent list")
|
||||||
response = requests.get(qbittorrentURL+"torrents/info")
|
titleWidth = 100
|
||||||
|
|
||||||
torrentList = response.json()
|
|
||||||
|
|
||||||
message = []
|
message = []
|
||||||
allDownloaded = True
|
allDownloaded = True
|
||||||
|
|
||||||
|
if showDM:
|
||||||
|
message.append("")
|
||||||
|
DMSectionTitle = "*Torrent Downloads*"
|
||||||
|
DMSectionTitleLine = "-"*((titleWidth-len(DMSectionTitle))//2)
|
||||||
|
message.append(DMSectionTitleLine+DMSectionTitle+DMSectionTitleLine)
|
||||||
|
response = requests.get(qbittorrentURL+"torrents/info")
|
||||||
|
torrentList = response.json()
|
||||||
|
|
||||||
|
if len(torrentList) > 0:
|
||||||
for torrent in torrentList:
|
for torrent in torrentList:
|
||||||
torrentName = torrent["name"]
|
torrentName = torrent["name"]
|
||||||
if len(torrentName) > 30:
|
if len(torrentName) > 30:
|
||||||
@@ -221,39 +227,158 @@ class BedreNetflix():
|
|||||||
if not (downloadedRatio == 1 and torrent["last_activity"] < time.time()-7200):
|
if not (downloadedRatio == 1 and torrent["last_activity"] < time.time()-7200):
|
||||||
message.append(torrentInfo)
|
message.append(torrentInfo)
|
||||||
|
|
||||||
if downloadedRatio < 1: allDownloaded = False
|
if downloadedRatio < 1 and torrent["state"] != "stalledDL":
|
||||||
|
allDownloaded = False
|
||||||
|
else:
|
||||||
|
message.append("No torrents currently downloading")
|
||||||
|
|
||||||
messageText = "```"+"\n".join(message)+"```"
|
if showMovies:
|
||||||
|
message.append("")
|
||||||
|
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()
|
||||||
|
movieQueueIDs = []
|
||||||
|
|
||||||
|
for queueItem in movieQueue["records"]:
|
||||||
|
movieQueueIDs.append(queueItem["movieId"])
|
||||||
|
|
||||||
|
for movie in movieList:
|
||||||
|
if not movie["hasFile"]:
|
||||||
|
if movie["id"] not in movieQueueIDs:
|
||||||
|
movieName = movie["title"]
|
||||||
|
if len(movieName) > 40:
|
||||||
|
if movieName[36] == " ":
|
||||||
|
movieName = movieName[:36]+"...."
|
||||||
|
else:
|
||||||
|
movieName = movieName[:37]+"..."
|
||||||
|
|
||||||
|
while len(movieName) < 41:
|
||||||
|
movieName += " "
|
||||||
|
|
||||||
|
if movie["monitored"]:
|
||||||
|
movieInfo = movieName+"Could not find a torrent"
|
||||||
|
else:
|
||||||
|
movieInfo = movieName+"No torrent exists. Likely because the movie is not yet released on DVD"
|
||||||
|
|
||||||
|
message.append(movieInfo)
|
||||||
|
|
||||||
|
if showShows:
|
||||||
|
message.append("")
|
||||||
|
showSectionTitle = "*Missing shows not downloading*"
|
||||||
|
showSectionTitleLine = "-"*((titleWidth-len(showSectionTitle))//2)
|
||||||
|
message.append(showSectionTitleLine+showSectionTitle+showSectionTitleLine)
|
||||||
|
|
||||||
|
showList = requests.get(sonarrURL+"series?apiKey="+self.bot.credentials.sonarrKey).json()
|
||||||
|
|
||||||
|
for show in showList:
|
||||||
|
if show["seasons"][0]["seasonNumber"] == 0:
|
||||||
|
seasons = show["seasons"][1:]
|
||||||
|
else:
|
||||||
|
seasons = show["seasons"]
|
||||||
|
if any(i["statistics"]["episodeCount"] != i["statistics"]["totalEpisodeCount"] for i in seasons):
|
||||||
|
if all(i["statistics"]["episodeCount"] == 0 for i in seasons):
|
||||||
|
message.append(show["title"] + " (all episodes)")
|
||||||
|
else:
|
||||||
|
if episodes:
|
||||||
|
missingEpisodes = sum(i["statistics"]["totalEpisodeCount"] - i["statistics"]["episodeCount"] for i in seasons)
|
||||||
|
message.append(show["title"] + f" ({missingEpisodes} episodes)")
|
||||||
|
|
||||||
|
message.append("-"*titleWidth)
|
||||||
|
|
||||||
|
messageText = "```"+"\n".join(message[1:])+"```"
|
||||||
if messageText == "``````":
|
if messageText == "``````":
|
||||||
messageText = "There are no torrents downloading right. If the torrent you're looking for was added more than 24 hours ago, it might already be on Bedre Netflix."
|
messageText = "There are no torrents downloading right. If the torrent you're looking for was added more than 24 hours ago, it might already be on Bedre Netflix."
|
||||||
return messageText, allDownloaded
|
return messageText, allDownloaded
|
||||||
|
|
||||||
async def downloading(self,ctx):
|
async def downloading(self, ctx, content):
|
||||||
messageText, allDownloaded = await self.genDownloadList()
|
async def SendLongMessage(ctx,messageText):
|
||||||
|
if len(messageText) <= 1994:
|
||||||
|
await ctx.send("```"+messageText+"```")
|
||||||
|
else:
|
||||||
|
cutOffIndex = messageText[:1994].rfind("\n")
|
||||||
|
await ctx.send("```"+messageText[:cutOffIndex]+"```")
|
||||||
|
await SendLongMessage(ctx,messageText[cutOffIndex+1:])
|
||||||
|
|
||||||
|
# showDM, showMovies, showShows, episodes
|
||||||
|
params = [False, False, False, False]
|
||||||
|
showDMArgs = ["d", "dm", "downloading", "downloadmanager"]
|
||||||
|
showMoviesArgs = ["m", "movies"]
|
||||||
|
showShowsArgs = ["s", "shows", "series"]
|
||||||
|
episodesArgs = ["e", "episodes"]
|
||||||
|
argList = [showDMArgs, showMoviesArgs, showShowsArgs, episodesArgs]
|
||||||
|
inputArgs = []
|
||||||
|
validArguments = True
|
||||||
|
|
||||||
|
while content != "" and validArguments:
|
||||||
|
if content[0] == " ":
|
||||||
|
content = content[1:]
|
||||||
|
elif content[0] == "-":
|
||||||
|
if content[1] == "-":
|
||||||
|
argStart = 2
|
||||||
|
if " " in content:
|
||||||
|
argStop = content.find(" ")
|
||||||
|
else:
|
||||||
|
argStop = None
|
||||||
|
else:
|
||||||
|
argStart = 1
|
||||||
|
argStop = 2
|
||||||
|
|
||||||
|
inputArgs.append(content[argStart:argStop])
|
||||||
|
if argStop is None:
|
||||||
|
content = ""
|
||||||
|
else:
|
||||||
|
content = content[argStop:]
|
||||||
|
else:
|
||||||
|
validArguments = False
|
||||||
|
|
||||||
|
if validArguments:
|
||||||
|
for x, argAliases in enumerate(argList):
|
||||||
|
argInInput = [i in inputArgs for i in argAliases]
|
||||||
|
if any(argInInput):
|
||||||
|
inputArgs.remove(argAliases[argInInput.index(True)])
|
||||||
|
params[x] = True
|
||||||
|
|
||||||
|
if len(inputArgs) != 0 or (params[2] == False and params[3] == True):
|
||||||
|
validArguments = False
|
||||||
|
|
||||||
|
showAnything = any(i for i in params)
|
||||||
|
if validArguments and showAnything:
|
||||||
|
messageText, allDownloaded = await self.genDownloadList(*params)
|
||||||
if messageText.startswith("```"):
|
if messageText.startswith("```"):
|
||||||
|
|
||||||
|
if len(messageText) <= 2000:
|
||||||
|
if not allDownloaded:
|
||||||
updatesLeft = 60
|
updatesLeft = 60
|
||||||
messageText = messageText[:-3]+"\nThis message will update every 10 seconds for "+str(math.ceil(updatesLeft/6))+" more minutes\n```"
|
messageText = messageText[:-3]+"\nThis message will update every 10 seconds for "+str(math.ceil(updatesLeft/6))+" more minutes\n```"
|
||||||
|
|
||||||
oldMessage = await ctx.send(messageText)
|
oldMessage = await ctx.send(messageText)
|
||||||
|
|
||||||
while ((not allDownloaded) and updatesLeft > 0):
|
while ((not allDownloaded) and updatesLeft > 0):
|
||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
updatesLeft -= 1
|
updatesLeft -= 1
|
||||||
messageText, allDownloaded = await self.genDownloadList()
|
messageText, allDownloaded = await self.genDownloadList(*params)
|
||||||
messageText = messageText[:-3]+"\nThis message will update every 10 seconds for "+str(math.ceil(updatesLeft/6))+" more minutes\n```"
|
messageText = messageText[:-3]+"\nThis message will update every 10 seconds for "+str(math.ceil(updatesLeft/6))+" more minutes\n```"
|
||||||
await oldMessage.edit(content = messageText)
|
await oldMessage.edit(content = messageText)
|
||||||
|
|
||||||
messageText, allDownloaded = await self.genDownloadList()
|
messageText, allDownloaded = await self.genDownloadList(*params)
|
||||||
|
|
||||||
if messageText.startswith("```"):
|
if messageText.startswith("```"):
|
||||||
if allDownloaded:
|
if allDownloaded:
|
||||||
messageText = messageText[:-3]+"\nThis message will not update because all torrents are downloaded.\n```"
|
|
||||||
logThis("All torrents are downloaded")
|
logThis("All torrents are downloaded")
|
||||||
else:
|
else:
|
||||||
messageText = messageText[:-3]+"\nThis message will not update anymore\n```"
|
messageText = messageText[:-3]+"\nThis message will not update anymore\n```"
|
||||||
logThis("The message updated 20 times")
|
logThis("The message updated 20 times")
|
||||||
|
|
||||||
await oldMessage.edit(content = messageText)
|
await oldMessage.edit(content = messageText)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
await ctx.send(messageText)
|
await ctx.send(messageText)
|
||||||
|
else:
|
||||||
|
messageText = messageText[3:-3]
|
||||||
|
await SendLongMessage(ctx,messageText)
|
||||||
|
else:
|
||||||
|
await ctx.send(messageText)
|
||||||
|
else:
|
||||||
|
await ctx.send("Invalid or repeated parameters. Use '!help downloading' to see valid parameters.")
|
||||||
|
|
||||||
|
|||||||
9
resources/help/help-downloading.txt
Normal file
9
resources/help/help-downloading.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
Viser dig de film og serier der er "requested" men ikke endnu på Bedre Netflix. Kommandoen kan tage imod op til 4 parametre:
|
||||||
|
|
||||||
|
`-d`, `--downloading`, `--dm`, `--downloadManager` - Viser de torrents der er _ved_ at downloade. Hvis ingen parametre er givet, bliver det her parameter givet automatisk som det eneste.
|
||||||
|
|
||||||
|
`-m`, `--movies` - Viser de film der mangler.
|
||||||
|
|
||||||
|
`-s`, `--shows`, `--series` - Viser serier hvor alle afsnit mangler.
|
||||||
|
|
||||||
|
`-e`, `--episodes` - Viser de serier der mangler mindst 1 episode. Kan kun bruges hvis `-s` også bruges.
|
||||||
Reference in New Issue
Block a user