diff --git a/modules/videos/common.py b/modules/videos/common.py index 0f4ba034..fb7f03a0 100644 --- a/modules/videos/common.py +++ b/modules/videos/common.py @@ -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) diff --git a/modules/videos/downloader.py b/modules/videos/downloader.py index 9e23d196..77467cb0 100755 --- a/modules/videos/downloader.py +++ b/modules/videos/downloader.py @@ -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", } diff --git a/modules/videos/lib.py b/modules/videos/lib.py index c8d302d4..888b2313 100644 --- a/modules/videos/lib.py +++ b/modules/videos/lib.py @@ -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: diff --git a/modules/videos/test/test_downloader.py b/modules/videos/test/test_downloader.py index 52477c7d..7aa2d90b 100644 --- a/modules/videos/test/test_downloader.py +++ b/modules/videos/test/test_downloader.py @@ -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):