1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00

Fix player ignoring existing songs

This commit is contained in:
Steffo 2018-03-11 18:23:18 +01:00
parent 0b86fd1ce4
commit f4804276d9
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: C27544372FBB445D

View file

@ -56,6 +56,8 @@ class Video:
info = info["entries"][0] info = info["entries"][0]
file_id = info.get("title", str(hash(self.ytdl_url))) file_id = info.get("title", str(hash(self.ytdl_url)))
file_id = re.sub(r"(?:\/|\\|\?|\*|\"|<|>|\||:)", "_", file_id) file_id = re.sub(r"(?:\/|\\|\?|\*|\"|<|>|\||:)", "_", file_id)
# Set the filename to the downloaded video
self.filename = file_id
if os.path.exists(f"opusfiles/{file_id}.opus"): if os.path.exists(f"opusfiles/{file_id}.opus"):
return return
if info.get("duration", 1) > int(config["YouTube"]["max_duration"]): if info.get("duration", 1) > int(config["YouTube"]["max_duration"]):
@ -75,8 +77,6 @@ class Video:
# Download the video # Download the video
with youtube_dl.YoutubeDL(ytdl_args) as ytdl: with youtube_dl.YoutubeDL(ytdl_args) as ytdl:
await loop.run_in_executor(executor, functools.partial(ytdl.download, [self.ytdl_url])) await loop.run_in_executor(executor, functools.partial(ytdl.download, [self.ytdl_url]))
# Set the filename to the downloaded video
self.filename = file_id
if __debug__: if __debug__: