mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-22 07:56:18 -05:00
Skipping video when download URL is bad.
This commit is contained in:
parent
a190348263
commit
0c2250ea12
4 changed files with 15 additions and 2 deletions
|
|
@ -455,7 +455,7 @@ async def get_bulk_video_info_json(video_ids: List[int]):
|
|||
# Get duration from info_json without reading video file.
|
||||
video.duration = info_json.get('duration')
|
||||
# Trust the info_json title before the video path title.
|
||||
video.title = info_json.get('title', video.title)
|
||||
video.title = info_json.get('title')
|
||||
if not video.duration:
|
||||
# As a last resort, get duration from the video file.
|
||||
video.duration = get_video_duration(video.video_path.path)
|
||||
|
|
|
|||
|
|
@ -188,6 +188,9 @@ class VideoDownloader(Downloader, ABC):
|
|||
with get_db_session(commit=True) as session:
|
||||
channel = session.query(Channel).filter_by(id=channel.id).one()
|
||||
channel.add_video_to_skip_list(source_id)
|
||||
|
||||
# Skipped downloads should not be tried again.
|
||||
raise UnrecoverableDownloadError() from e
|
||||
return
|
||||
|
||||
with get_db_session(commit=True) as session:
|
||||
|
|
@ -451,6 +454,7 @@ UNRECOVERABLE_ERRORS = {
|
|||
'Sign in',
|
||||
'This live stream recording is not available.',
|
||||
'members-only content',
|
||||
"You've asked yt-dlp to download the URL",
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ def _refresh_videos(channel_links: list = None):
|
|||
elif not channels:
|
||||
raise Exception(f'No channels in DB. Have you created any?')
|
||||
|
||||
for idx, channel in enumerate(channels):
|
||||
for channel in channels:
|
||||
try:
|
||||
refresh_channel_videos(channel)
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -270,13 +270,22 @@ class TestVideosDownloaders(TestAPI):
|
|||
|
||||
@wrap_test_db
|
||||
def test_invalid_download_url(self):
|
||||
"""
|
||||
An invalid url should not be attempted again.
|
||||
"""
|
||||
_, session = get_db_context()
|
||||
with mock.patch('modules.videos.downloader.VideoDownloader.valid_url') as mock_valid_url, \
|
||||
mock.patch('wrolpi.downloader.DownloadManager.get_downloader') as mock_get_downloader, \
|
||||
mock.patch('modules.videos.downloader.YDL') as mock_ydl:
|
||||
mock_get_downloader.return_value = (VideoDownloader, {'channel': 'foo', 'id': 'some id'})
|
||||
mock_valid_url.return_value = (True, None)
|
||||
mock_ydl.extract_info.side_effect = UnsupportedError('oops')
|
||||
self.mgr.create_download('url', session)
|
||||
|
||||
with get_db_session() as session:
|
||||
download = self.mgr.get_downloads(session)[0]
|
||||
assert download.status == 'failed'
|
||||
|
||||
@wrap_test_db
|
||||
@mock.patch('modules.videos.channel.lib.today', lambda: local_timezone(datetime(2020, 1, 1, 0, 0, 0)))
|
||||
def test_spread_channel_downloads(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue