Handle raise_no_formats exception

Catching this and checking the message may be the best way to skip members only videos.
This commit is contained in:
tcely 2024-12-20 10:07:24 -05:00 committed by GitHub
parent 52865cb5b4
commit 394f937fcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -83,6 +83,7 @@ def get_media_info(url):
'''
opts = get_yt_opts()
opts.update({
'ignore_no_formats_error': False,
'skip_download': True,
'forcejson': True,
'simulate': True,
@ -93,6 +94,11 @@ def get_media_info(url):
with yt_dlp.YoutubeDL(opts) as y:
try:
response = y.extract_info(url, download=False)
except yt_dlp.utils.ExtractorError as e:
if not e.expected:
raise e
log.warn(e.msg)
pass
except yt_dlp.utils.DownloadError as e:
raise YouTubeError(f'Failed to extract_info for "{url}": {e}') from e
if not response: