From a04dd9c11ba5bb50829f9c50fbdaea1617f7b834 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Thu, 13 Jun 2019 17:41:05 -0500 Subject: [PATCH] File extension when downloading will be determined by the extractor itself. Fixed an issue in youtube that was making VLC to receive encrypted streams only --- src/extractors/tidal.py | 4 ++++ src/extractors/youtube.py | 8 +++++--- src/extractors/zaycev.py | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/extractors/tidal.py b/src/extractors/tidal.py index 0a4ae75..fd5cdba 100644 --- a/src/extractors/tidal.py +++ b/src/extractors/tidal.py @@ -23,6 +23,10 @@ class interface(object): log.debug("Using quality: %s" % (quality,)) self.session = tidalapi.Session(config=_config) self.session.login(username=username, password=password) + if config.app["services"]["tidal"]["quality"] == "lossless": + self.file_extension = "flac" + else: + self.file_extension = "mp3" def search(self, text, page=1): if text == "" or text == None: diff --git a/src/extractors/youtube.py b/src/extractors/youtube.py index 0ee1c6d..bad70a2 100644 --- a/src/extractors/youtube.py +++ b/src/extractors/youtube.py @@ -21,6 +21,7 @@ class interface(object): self.results = [] self.needs_transcode = True log.debug("started extraction service for {0}".format(self.name,)) + self.file_extension = "mp3" def search(self, text, page=1): if text == "" or text == None: @@ -50,7 +51,7 @@ class interface(object): log.debug("Getting download URL for {0}".format(url,)) if "playlist?list=" in url: return self.search_from_playlist(url) - ydl = youtube_dl.YoutubeDL({'quiet': True, 'no_warnings': True, 'logger': log, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'}) + ydl = youtube_dl.YoutubeDL({'quiet': True, 'no_warnings': True, 'logger': log, 'prefer-free-formats': True, 'format': 'bestaudio', 'outtmpl': u'%(id)s%(ext)s'}) with ydl: result = ydl.extract_info(url, download=False) if 'entries' in result: @@ -95,8 +96,9 @@ class interface(object): video = result['entries'][0] else: video = result - log.debug("Download URL: {0}".format(video["url"],)) - return video["url"] + # From here we should extract the first format so it will contain audio only. + log.debug("Download URL: {0}".format(video["formats"][0]["url"],)) + return video["formats"][0]["url"] def format_track(self, item): return "{0} {1}".format(item.title, item.duration) \ No newline at end of file diff --git a/src/extractors/zaycev.py b/src/extractors/zaycev.py index 12fcafd..2d2da3f 100644 --- a/src/extractors/zaycev.py +++ b/src/extractors/zaycev.py @@ -17,6 +17,7 @@ class interface(object): self.results = [] self.needs_transcode = False log.debug("Started extraction service for zaycev.net") + self.file_extension = "mp3" def search(self, text, page=1): if text == "" or text == None: