Upload app.py
Browse files
app.py
CHANGED
@@ -76,11 +76,27 @@ def get_youtube_content(url):
|
|
76 |
'extract_flat': True,
|
77 |
'quiet': True,
|
78 |
'no_warnings': True,
|
79 |
-
'cookiefile': 'youtube_cookies.txt' #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
}
|
81 |
|
82 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
title = info.get('title', '')
|
86 |
description = info.get('description', '')
|
|
|
76 |
'extract_flat': True,
|
77 |
'quiet': True,
|
78 |
'no_warnings': True,
|
79 |
+
'cookiefile': 'youtube_cookies.txt', # Primary cookie method
|
80 |
+
'cookiesfrombrowser': ('chrome',), # Backup cookie method
|
81 |
+
'extractor_args': { # Additional arguments to help bypass restrictions
|
82 |
+
'youtube': {
|
83 |
+
'skip': ['dash', 'hls'],
|
84 |
+
'player_skip': ['js', 'configs', 'webpage']
|
85 |
+
}
|
86 |
+
},
|
87 |
+
'no_check_certificate': True,
|
88 |
}
|
89 |
|
90 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
91 |
+
try:
|
92 |
+
info = ydl.extract_info(url, download=False)
|
93 |
+
except Exception as yt_error:
|
94 |
+
if "Sign in to confirm your age" in str(yt_error):
|
95 |
+
ydl_opts['format'] = 'best[height<=480]' # Try a different format
|
96 |
+
ydl = yt_dlp.YoutubeDL(ydl_opts)
|
97 |
+
info = ydl.extract_info(url, download=False)
|
98 |
+
else:
|
99 |
+
raise yt_error
|
100 |
|
101 |
title = info.get('title', '')
|
102 |
description = info.get('description', '')
|