⬇️ !downloading
This commit is contained in:
@ -131,6 +131,11 @@ class MiscCog(commands.Cog):
|
||||
async def requestshow(self, ctx, *, content):
|
||||
await self.bedreNetflix.requestShow(ctx,content)
|
||||
|
||||
#Returns currently downloading torrents
|
||||
@commands.command(aliases = ["downloads"])
|
||||
async def downloading(self,ctx):
|
||||
await self.bedreNetflix.downloading(ctx)
|
||||
|
||||
#Looks up on Wolfram Alpha
|
||||
@commands.command()
|
||||
async def wolf(self, ctx, *, content):
|
||||
|
@ -1,8 +1,9 @@
|
||||
import requests, imdb, discord, json
|
||||
import requests, imdb, discord, json, math, time
|
||||
from funcs import logThis
|
||||
|
||||
radarrURL = "http://localhost:7878/api/v3/"
|
||||
sonarrURL = "http://192.168.0.40:8989/api/"
|
||||
sonarrURL = "http://localhost:8989/api/"
|
||||
qbittorrentURL = "http://localhost:1340/api/v2/"
|
||||
moviePath = "/media/plex/Server/movies/"
|
||||
showPath = "/media/plex/Server/Shows/"
|
||||
|
||||
@ -161,3 +162,55 @@ class BedreNetflix():
|
||||
else:
|
||||
await channel.send("Something went wrong")
|
||||
logThis(str(r.status_code)+" "+r.reason)
|
||||
|
||||
async def downloading(self,ctx):
|
||||
response = requests.get(qbittorrentURL+"torrents/info")
|
||||
|
||||
torrentList = response.json()
|
||||
|
||||
message = []
|
||||
|
||||
for torrent in torrentList:
|
||||
torrentName = torrent["name"]
|
||||
if len(torrentName) > 30:
|
||||
if torrentName[26] == " ":
|
||||
torrentName = torrentName[:26]+"...."
|
||||
else:
|
||||
torrentName = torrentName[:27]+"..."
|
||||
if torrent["size"] == 0:
|
||||
downloadedRatio = 0
|
||||
else:
|
||||
downloadedRatio = min(torrent["downloaded"]/torrent["size"],1)
|
||||
progressBar = "|"+("█"*math.floor(downloadedRatio*20))
|
||||
while len(progressBar) < 21:
|
||||
progressBar += " "
|
||||
|
||||
progressBar += "| "+str(math.floor(downloadedRatio*100))+"%"
|
||||
|
||||
while len(progressBar) < 27:
|
||||
progressBar += " "
|
||||
|
||||
etaInSeconds = torrent["eta"]
|
||||
|
||||
if etaInSeconds >= 8640000:
|
||||
eta = "∞"
|
||||
else:
|
||||
eta = ""
|
||||
if etaInSeconds >= 86400:
|
||||
eta += str(math.floor(etaInSeconds/86400))+"d "
|
||||
if etaInSeconds >= 3600:
|
||||
eta += str(math.floor((etaInSeconds%86400)/3600))+"h "
|
||||
if etaInSeconds >= 60:
|
||||
eta += str(math.floor((etaInSeconds%3600)/60))+"m "
|
||||
|
||||
eta += str(etaInSeconds%60)+"s"
|
||||
|
||||
torrentInfo = torrentName+" "+progressBar+" (Eta: "+eta+")"
|
||||
|
||||
if not (downloadedRatio == 1 and torrent["added_on"] < time.time()-86400):
|
||||
message.append(torrentInfo)
|
||||
|
||||
messageText = "```"+"\n".join(message)+"```"
|
||||
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."
|
||||
await ctx.send(messageText)
|
||||
|
@ -42,4 +42,6 @@
|
||||
|
||||
`!addshow` - Lader dig tilføje tv shows til Bedre Netflix.
|
||||
|
||||
`!downloading` - Viser dig hvor langt de torrents der er ved at downloade er kommet.
|
||||
|
||||
Du kan få ekstra information om kommandoerne med "!help [kommando]".
|
||||
|
Reference in New Issue
Block a user