Use a temporary directory for testing formats

This commit is contained in:
tcely 2025-03-09 22:31:56 -04:00 committed by GitHub
parent 84d42fb2ab
commit 4b3605f65e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -146,6 +146,14 @@ def get_media_info(url, days=None):
f'yesterday-{days!s}days' if days else None
)
opts = get_yt_opts()
paths = opts.get('paths', dict())
if 'temp' in paths:
temp_dir_obj = TemporaryDirectory(prefix='.yt_dlp-', dir=paths['temp'])
temp_dir_path = Path(temp_dir_obj.name)
(temp_dir_path / '.ignore').touch(exist_ok=True)
paths.update({
'temp': str(temp_dir_path),
})
opts.update({
'ignoreerrors': False, # explicitly set this to catch exceptions
'ignore_no_formats_error': False, # we must fail first to try again with this enabled
@ -158,6 +166,7 @@ def get_media_info(url, days=None):
'extractor_args': {
'youtubetab': {'approximate_date': ['true']},
},
'paths': paths,
'sleep_interval_requests': 2,
'verbose': True if settings.DEBUG else False,
})