Changing title_match to title_include for clarity.

This commit is contained in:
Roland 2024-07-14 09:44:18 -06:00
parent 4a0a9dd9a9
commit 37ff1ab2cd
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
7 changed files with 24 additions and 19 deletions

View file

@ -169,14 +169,14 @@ class ChannelDownloader(Downloader, ABC):
downloads = download.info_json['entries']
total_downloads = len(downloads)
title_match = download.settings.get('title_match') if download.settings else None
if title_match:
title_include = download.settings.get('title_include') if download.settings else None
if title_include:
# Only download Videos that have title match words in title.
title_match = [i.strip() for i in title_match.split(',')]
title_include = [i.strip() for i in title_include.split(',')]
new_downloads = []
for i in downloads:
if (title := i.get('title', '')) and any(j for j in title_match if j in title):
logger.debug(f'Video with title {title} matches {title_match}')
if (title := i.get('title', '')) and any(j for j in title_include if j in title):
logger.debug(f'Video with title {title} matches {title_include}')
new_downloads.append(i)
downloads = new_downloads
@ -188,7 +188,6 @@ class ChannelDownloader(Downloader, ABC):
for i in downloads:
if (title := i.get('title', '')) and any(j for j in title_exclude if j in title):
logger.debug(f'Video with title {title} matches EXCLUDE {title_exclude}')
continue
else:
new_downloads.append(i)
downloads = new_downloads

View file

@ -157,13 +157,13 @@ async def test_download_channel(test_session, simple_channel, video_download_man
reset_downloads()
# A channel with `title_match` only returns matching video URLs.
# A channel with `title_include` only returns matching video URLs.
test_session.commit()
with mock.patch('modules.videos.downloader.get_channel') as mock_get_channel:
mock_get_channel.return_value = simple_channel
cd = simple_channel.get_or_create_download(url, test_session)
cd.download.frequency = 100
cd.download.settings = {'title_match': '2'}
cd.download.settings = {'title_include': '2'}
await video_download_manager.wait_for_all_downloads()
downloads = video_download_manager.get_once_downloads(test_session)
assert {i.url for i in downloads} == {'https://youtube.com/watch?v=video_2_url'}

View file

@ -164,6 +164,7 @@ def test_link_channel_and_downloads(test_session, channel_factory):
assert test_session.query(Download).count() == 2
assert test_session.query(ChannelDownload).count() == 0
# `link_channel_and_downloads` creates missing ChannelDownloads.
lib.link_channel_and_downloads(session=test_session)
assert test_session.query(Download).count() == 2
assert test_session.query(ChannelDownload).count() == 2