Spaces:
Sleeping
Sleeping
Update utils/audio_processing.py
Browse files
utils/audio_processing.py
CHANGED
@@ -31,10 +31,16 @@ def download_audio_as_wav(url, max_filesize_mb=70):
|
|
31 |
cookies_b64 = os.getenv("cookies")
|
32 |
if not cookies_b64:
|
33 |
raise EnvironmentError("cookies environment variable not set.")
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
with open(temp_cookie_path, "wb") as f:
|
37 |
-
f.write(
|
38 |
|
39 |
# yt-dlp download command
|
40 |
download_cmd = [
|
|
|
31 |
cookies_b64 = os.getenv("cookies")
|
32 |
if not cookies_b64:
|
33 |
raise EnvironmentError("cookies environment variable not set.")
|
34 |
+
|
35 |
+
def safe_base64_decode(data):
|
36 |
+
# Fix padding if necessary
|
37 |
+
missing_padding = len(data) % 4
|
38 |
+
if missing_padding:
|
39 |
+
data += "=" * (4 - missing_padding)
|
40 |
+
return base64.b64decode(data)
|
41 |
+
# Decode and write cookies.txt
|
42 |
with open(temp_cookie_path, "wb") as f:
|
43 |
+
f.write(safe_base64_decode(cookies_b64))
|
44 |
|
45 |
# yt-dlp download command
|
46 |
download_cmd = [
|