From 0ebcf15f9112232a6a62d30fe409c28e2c9fc450 Mon Sep 17 00:00:00 2001 From: GladistonXD <50533550+GladistonXD@users.noreply.github.com> Date: Thu, 5 Feb 2026 20:26:05 -0300 Subject: [PATCH] Update downloader_audio.py --- votify/downloader_audio.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/votify/downloader_audio.py b/votify/downloader_audio.py index efce78f..420c517 100644 --- a/votify/downloader_audio.py +++ b/votify/downloader_audio.py @@ -1,6 +1,7 @@ from __future__ import annotations import subprocess +import time from pathlib import Path from Crypto.Cipher import AES @@ -92,16 +93,25 @@ class DownloaderAudio: return stream_info + def get_decryption_key(self, stream_info: StreamInfoAudio) -> str: - if self.audio_quality in AAC_AUDIO_QUALITIES: - _, decryption_key = self.downloader.get_widevine_decryption_key( - stream_info.widevine_pssh, - "audio", - ) - else: - decryption_key = self.downloader.get_playplay_decryption_key( - stream_info.file_id - ) + decryption_key = None + for attempt in range(10): + try: + if self.audio_quality in AAC_AUDIO_QUALITIES: + _, decryption_key = self.downloader.get_widevine_decryption_key( + stream_info.widevine_pssh, + "audio", + ) + else: + decryption_key = self.downloader.get_playplay_decryption_key( + stream_info.file_id + ) + if decryption_key: + return decryption_key + + except Exception as e: + time.sleep(attempt + 10) return decryption_key def download_stream_url(self, input_path: Path, stream_url: str):