mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Patch bug in Pafy when fetching audiostreams with latest youtube-dl
This commit is contained in:
@@ -20,12 +20,25 @@ def _getbestthumb(self):
|
||||
if self._content_available(url):
|
||||
return url
|
||||
|
||||
def _process_streams(self):
|
||||
for format_index in range(len(self._ydl_info['formats'])):
|
||||
try:
|
||||
self._ydl_info['formats'][format_index]['url'] = self._ydl_info['formats'][format_index]['fragment_base_url']
|
||||
except KeyError:
|
||||
pass
|
||||
return pafy.backend_youtube_dl.YtdlPafy._old_process_streams(self)
|
||||
|
||||
@classmethod
|
||||
def _content_available(cls, url):
|
||||
return internals.content_available(url)
|
||||
|
||||
def patch_pafy():
|
||||
pafy.backend_shared.BasePafy._bestthumb = None
|
||||
pafy.backend_shared.BasePafy._content_available = _content_available
|
||||
pafy.backend_shared.BasePafy.getbestthumb = _getbestthumb
|
||||
|
||||
class PatchPafy:
|
||||
def patch_getbestthumb(self):
|
||||
pafy.backend_shared.BasePafy._bestthumb = None
|
||||
pafy.backend_shared.BasePafy._content_available = _content_available
|
||||
pafy.backend_shared.BasePafy.getbestthumb = _getbestthumb
|
||||
|
||||
def patch_process_streams(self):
|
||||
pafy.backend_youtube_dl.YtdlPafy._old_process_streams = pafy.backend_youtube_dl.YtdlPafy._process_streams
|
||||
pafy.backend_youtube_dl.YtdlPafy._process_streams = _process_streams
|
||||
|
||||
@@ -18,7 +18,9 @@ pafy.g.opener.addheaders.append(("Range", "bytes=0-"))
|
||||
# More info: https://github.com/mps-youtube/pafy/pull/211
|
||||
if pafy.__version__ <= "0.5.4":
|
||||
from spotdl import patcher
|
||||
patcher.patch_pafy()
|
||||
pafy_patcher = patcher.PatchPafy()
|
||||
pafy_patcher.patch_getbestthumb()
|
||||
pafy_patcher.patch_process_streams()
|
||||
|
||||
|
||||
def set_api_key():
|
||||
|
||||
Reference in New Issue
Block a user