From 5e8756df2d9fee4c8f21dae5d4ef4cac7f1e3c1d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 15 Oct 2019 17:26:02 +0200 Subject: [PATCH] Music improvements --- royalnet/audio/ytdldiscord.py | 2 +- royalnet/audio/ytdlfile.py | 4 ++-- royalnet/audio/ytdlinfo.py | 7 ++++--- royalnet/commands/royalmusic/play.py | 2 +- royalnet/commands/royalmusic/soundcloud.py | 2 +- royalnet/commands/royalmusic/youtube.py | 2 +- royalnet/commands/royalmusic/zawarudo.py | 2 +- royalnet/version.py | 2 +- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/royalnet/audio/ytdldiscord.py b/royalnet/audio/ytdldiscord.py index 1d8a8e2d..f178b07f 100644 --- a/royalnet/audio/ytdldiscord.py +++ b/royalnet/audio/ytdldiscord.py @@ -28,7 +28,7 @@ class YtdlDiscord: ffmpeg.input(self.ytdl_file.filename) .output(destination_filename, format="s16le", ac=2, ar="48000") .overwrite_output() - .run(quiet=True) + .run(quiet=not __debug__) ) self.pcm_filename = destination_filename diff --git a/royalnet/audio/ytdlfile.py b/royalnet/audio/ytdlfile.py index ec13ff05..0a851592 100644 --- a/royalnet/audio/ytdlfile.py +++ b/royalnet/audio/ytdlfile.py @@ -10,9 +10,9 @@ class YtdlFile: """Information about a youtube-dl downloaded file.""" _default_ytdl_args = { - "quiet": True, # Do not print messages to stdout. + "quiet": not __debug__, # Do not print messages to stdout. "noplaylist": True, # Download single video instead of a playlist if in doubt. - "no_warnings": True, # Do not print out anything for warnings. + "no_warnings": not __debug__, # Do not print out anything for warnings. "outtmpl": "%(epoch)s-%(title)s-%(id)s.%(ext)s", # Use the default outtmpl. "ignoreerrors": True # Ignore unavailable videos } diff --git a/royalnet/audio/ytdlinfo.py b/royalnet/audio/ytdlinfo.py index bd7c0ae3..cd08f6a5 100644 --- a/royalnet/audio/ytdlinfo.py +++ b/royalnet/audio/ytdlinfo.py @@ -92,7 +92,7 @@ class YtdlInfo: if first_info is None: return [] # If it is a playlist, create multiple videos! - if "entries" in first_info: + if "entries" in first_info and first_info["entries"][0] is not None: second_info_list = [] for second_info in first_info["entries"]: if second_info is None: @@ -107,11 +107,12 @@ class YtdlInfo: "youtube": 0xCC0000, "soundcloud": 0xFF5400, "Clyp": 0x3DBEB3, - "Bandcamp": 0x1DA0C3 + "Bandcamp": 0x1DA0C3, + "Peertube": 0x0A193C, } embed = discord.Embed(title=self.title, colour=discord.Colour(colors.get(self.extractor, 0x4F545C)), - url=self.webpage_url if self.webpage_url is not None else discord.embeds.EmptyEmbed) + url=self.webpage_url if self.webpage_url is not None and self.webpage_url.startswith("http") else discord.embeds.EmptyEmbed) if self.thumbnail: embed.set_thumbnail(url=self.thumbnail) if self.uploader: diff --git a/royalnet/commands/royalmusic/play.py b/royalnet/commands/royalmusic/play.py index 3def487f..c833020a 100644 --- a/royalnet/commands/royalmusic/play.py +++ b/royalnet/commands/royalmusic/play.py @@ -36,7 +36,7 @@ class PlayNH(NetworkHandler): raise Exception("No music_data for this guild") # Create url ytdl_args = { - "format": "bestaudio", + "format": "bestaudio/best", "outtmpl": f"./downloads/{datetime.datetime.now().timestamp()}_%(title)s.%(ext)s" } # Start downloading diff --git a/royalnet/commands/royalmusic/soundcloud.py b/royalnet/commands/royalmusic/soundcloud.py index 89c0d671..3940134c 100644 --- a/royalnet/commands/royalmusic/soundcloud.py +++ b/royalnet/commands/royalmusic/soundcloud.py @@ -36,7 +36,7 @@ class SoundcloudNH(NetworkHandler): raise KeyError("No music data available for this guild.") # Create url ytdl_args = { - "format": "bestaudio", + "format": "bestaudio/best", "outtmpl": f"./downloads/{datetime.datetime.now().timestamp()}_%(title)s.%(ext)s" } # Start downloading diff --git a/royalnet/commands/royalmusic/youtube.py b/royalnet/commands/royalmusic/youtube.py index 1f3948e2..a181af9f 100644 --- a/royalnet/commands/royalmusic/youtube.py +++ b/royalnet/commands/royalmusic/youtube.py @@ -35,7 +35,7 @@ class YoutubeNH(NetworkHandler): raise KeyError("No music data available for this guild.") # Create url ytdl_args = { - "format": "bestaudio", + "format": "bestaudio/best", "outtmpl": f"./downloads/{datetime.datetime.now().timestamp()}_%(title)s.%(ext)s" } # Start downloading diff --git a/royalnet/commands/royalmusic/zawarudo.py b/royalnet/commands/royalmusic/zawarudo.py index 04c9bb4b..0d9f2986 100644 --- a/royalnet/commands/royalmusic/zawarudo.py +++ b/royalnet/commands/royalmusic/zawarudo.py @@ -19,7 +19,7 @@ class ZawarudoNH(NetworkHandler): message_type = "music_zawarudo" ytdl_args = { - "format": "bestaudio", + "format": "bestaudio/best", "outtmpl": f"./downloads/%(title)s.%(ext)s" } diff --git a/royalnet/version.py b/royalnet/version.py index c5700044..4b30e4ec 100644 --- a/royalnet/version.py +++ b/royalnet/version.py @@ -1 +1 @@ -semantic = "5.0a65" +semantic = "5.0a66"