From: Marcel van der Veldt Date: Wed, 6 Jul 2022 21:09:51 +0000 (+0200) Subject: run blocking call in executor X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=d3c41ec3651a64a169b6529a410ca0d80e4de20d;p=music-assistant-server.git run blocking call in executor --- diff --git a/music_assistant/music_providers/ytmusic.py b/music_assistant/music_providers/ytmusic.py index 0f0da013..3280d008 100644 --- a/music_assistant/music_providers/ytmusic.py +++ b/music_assistant/music_providers/ytmusic.py @@ -674,12 +674,15 @@ class YoutubeMusicProvider(MusicProvider): raise MediaNotFoundError("No stream found for this track") return stream_format - @classmethod - async def _decipher_signature(cls, ciphered_signature: str, item_id: str): + async def _decipher_signature(self, ciphered_signature: str, item_id: str): """Decipher the signature, required to build the Stream URL.""" - embed_url = f"https://www.youtube.com/embed/{item_id}" - embed_html = pytube.request.get(embed_url) - js_url = pytube.extract.js_url(embed_html) - ytm_js = pytube.request.get(js_url) - cipher = pytube.cipher.Cipher(js=ytm_js) - return cipher.get_signature(ciphered_signature) + + def _decipher(): + embed_url = f"https://www.youtube.com/embed/{item_id}" + embed_html = pytube.request.get(embed_url) + js_url = pytube.extract.js_url(embed_html) + ytm_js = pytube.request.get(js_url) + cipher = pytube.cipher.Cipher(js=ytm_js) + return cipher.get_signature(ciphered_signature) + + return await self.mass.loop.run_in_executor(None, _decipher)