mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-22 07:56:18 -05:00
Changing title_match to title_include for clarity.
This commit is contained in:
parent
4a0a9dd9a9
commit
37ff1ab2cd
7 changed files with 24 additions and 19 deletions
|
|
@ -251,12 +251,12 @@ export async function getVideosStatistics() {
|
|||
}
|
||||
}
|
||||
|
||||
export async function createChannelDownload(channelId, url, frequency, title_match, title_exclude, tag_names) {
|
||||
export async function createChannelDownload(channelId, url, frequency, title_include, title_exclude, tag_names) {
|
||||
const body = {
|
||||
url: url,
|
||||
frequency: frequency,
|
||||
settings: {
|
||||
title_match: title_match,
|
||||
title_include: title_include,
|
||||
title_exclude: title_exclude,
|
||||
tag_names: tag_names,
|
||||
},
|
||||
|
|
@ -284,12 +284,12 @@ export async function createChannelDownload(channelId, url, frequency, title_mat
|
|||
return response;
|
||||
}
|
||||
|
||||
export async function updateChannelDownload(channelId, downloadId, url, frequency, title_match, title_exclude, tag_names) {
|
||||
export async function updateChannelDownload(channelId, downloadId, url, frequency, title_include, title_exclude, tag_names) {
|
||||
const body = {
|
||||
url: url,
|
||||
frequency: frequency,
|
||||
settings: {
|
||||
title_match: title_match,
|
||||
title_include: title_include,
|
||||
title_exclude: title_exclude,
|
||||
tag_names: tag_names,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ export function ChannelDownloadForm({channel_id, afterSave, closeModal, download
|
|||
const [state, setState] = React.useState({
|
||||
frequency: download.frequency ? download.frequency : 604800,
|
||||
title_exclude: settings.title_exclude ? settings.title_exclude : '',
|
||||
title_match: settings.title_match ? settings.title_match : '',
|
||||
title_include: settings.title_include ? settings.title_include : '',
|
||||
url: download ? download.url : '',
|
||||
})
|
||||
const [disabled, setDisabled] = React.useState(useWROLMode());
|
||||
|
|
@ -447,7 +447,7 @@ export function ChannelDownloadForm({channel_id, afterSave, closeModal, download
|
|||
download.id,
|
||||
state.url,
|
||||
state.frequency,
|
||||
state.title_match,
|
||||
state.title_include,
|
||||
state.title_exclude,
|
||||
tagNames,
|
||||
);
|
||||
|
|
@ -456,7 +456,7 @@ export function ChannelDownloadForm({channel_id, afterSave, closeModal, download
|
|||
channel_id,
|
||||
state.url,
|
||||
state.frequency,
|
||||
state.title_match,
|
||||
state.title_include,
|
||||
state.title_exclude,
|
||||
tagNames,
|
||||
);
|
||||
|
|
@ -544,11 +544,11 @@ export function ChannelDownloadForm({channel_id, afterSave, closeModal, download
|
|||
popupPosition='bottom center'
|
||||
/>
|
||||
<FormInput
|
||||
name="title_match"
|
||||
name="title_include"
|
||||
type="text"
|
||||
disabled={disabled}
|
||||
placeholder='Shelter,Solar Power'
|
||||
value={state.title_match}
|
||||
value={state.title_include}
|
||||
onChange={handleInputChange}
|
||||
/>
|
||||
</Grid.Column>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1766,7 +1766,7 @@ def format_html_file(file: pathlib.Path):
|
|||
replace_file(file, pretty)
|
||||
|
||||
|
||||
def html_screenshot(html: bytes) -> bytes:
|
||||
def html_screenshot(html: bytes | str) -> bytes:
|
||||
"""Return a PNG screenshot of the provided HTML."""
|
||||
# Set Chromium to headless. Use a wide window size so that screenshot will be the "desktop" version of the page.
|
||||
options = webdriver.ChromeOptions()
|
||||
|
|
@ -1775,7 +1775,7 @@ def html_screenshot(html: bytes) -> bytes:
|
|||
options.add_argument('window-size=1280x720')
|
||||
|
||||
with tempfile.NamedTemporaryFile('wb', suffix='.html') as fh:
|
||||
fh.write(html)
|
||||
fh.write(html.encode() if isinstance(html, str) else html)
|
||||
fh.flush()
|
||||
|
||||
with webdriver.Chrome(chrome_options=options) as driver:
|
||||
|
|
|
|||
|
|
@ -864,3 +864,8 @@ async def test_log_level(test_async_client, test_config):
|
|||
request, response = await test_async_client.patch('/api/settings', json=body)
|
||||
assert response.status_code == HTTPStatus.NO_CONTENT, response.json
|
||||
assert api_app.shared_ctx.log_level.value == 10
|
||||
|
||||
|
||||
@skip_circleci
|
||||
def test_html_screenshot(singlefile_contents_factory):
|
||||
assert common.html_screenshot(singlefile_contents_factory())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue