Require youtube PO token

This commit is contained in:
insert 2025-01-18 15:14:23 -05:00
parent 35c9bda23f
commit 4fd92f7834
Signed by: insert
GPG key ID: A70775C389ACF105
3 changed files with 7 additions and 1 deletions

View file

@ -1,4 +1,6 @@
TOKEN=""
PO_TOKEN=""
COOKIES_FILE=""
GUILD_ID=""
QUEUE_PATH=""
MAX_MIN="8"

1
.gitignore vendored
View file

@ -31,6 +31,7 @@ share/python-wheels/
*.egg
*.mp4
*.vtt
cookies*
testing/
*.db
next*

View file

@ -81,6 +81,9 @@ ydl_opts = {
'match_filter': video_check,
'hls_prefer_native': True,
'extract_flat': 'discard_in_playlist',
'cookiefile': f'{os.getenv("COOKIES_FILE")}',
'extractor_args': {'youtube': {'player_client': ['web', 'default'],
'po_token': [f'web+{os.getenv("PO_TOKEN")}']}},
'format': 'bestvideo[height<=1080][vcodec!*=av01][ext=mp4]+bestaudio[abr<=256][ext=m4a]/best[ext=mp4]/best',
'fragment_retries': 10,
'noplaylist': True,
@ -154,7 +157,7 @@ def download_video(index):
sleep(2) #allow ytdlp to fully cleanup
except Exception as e:
print("handling youtube exception")
if "Sign in to confirm" in str(e):
if "Sign in to confirm" in str(e) or "forbidden" in str(e).lower():
print("youtube ban detected")
#This is the worst possible case and therefore all activity must halt
obs.set_current_program_scene("banned")