mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-29 03:16:22 -05:00
Testing that downloads have absolute destinations. Handling 'undefined', 'null', etc, dates.
This commit is contained in:
parent
2728e1bf50
commit
399cb0f107
6 changed files with 25 additions and 6 deletions
|
|
@ -19,7 +19,7 @@ from yt_dlp.extractor import YoutubeTabIE # noqa
|
|||
|
||||
from wrolpi.cmd import YT_DLP_BIN
|
||||
from wrolpi.common import logger, get_media_directory, escape_file_name, resolve_generators, background_task, \
|
||||
trim_file_name, cached_multiprocessing_result
|
||||
trim_file_name, cached_multiprocessing_result, get_absolute_media_path
|
||||
from wrolpi.dates import now
|
||||
from wrolpi.db import get_db_session
|
||||
from wrolpi.db import optional_session
|
||||
|
|
@ -182,7 +182,8 @@ class ChannelDownloader(Downloader, ABC):
|
|||
if channel:
|
||||
settings.update(dict(channel_id=channel.id, channel_url=download.url))
|
||||
if download.destination:
|
||||
settings['destination'] = str(download.destination) # Need str for JSON conversion
|
||||
destination = get_absolute_media_path(download.destination)
|
||||
settings['destination'] = str(destination) # Need str for JSON conversion
|
||||
if download.tag_names:
|
||||
settings['tag_names'] = download.tag_names
|
||||
if video_resolutions := download_settings.get('video_resolutions'):
|
||||
|
|
@ -370,6 +371,7 @@ class VideoDownloader(Downloader, ABC):
|
|||
|
||||
# Make output directory. (Maybe string from settings)
|
||||
out_dir = out_dir if isinstance(out_dir, pathlib.Path) else pathlib.Path(out_dir)
|
||||
out_dir = get_absolute_media_path(out_dir)
|
||||
out_dir.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
if tag_names and logger.isEnabledFor(logging.DEBUG):
|
||||
|
|
|
|||
|
|
@ -20,7 +20,11 @@ from ..lib import save_channels_config, get_channels_config, import_channels_con
|
|||
|
||||
def test_get_absolute_media_path(test_directory):
|
||||
path = get_absolute_media_path('videos')
|
||||
assert str(path).endswith('videos')
|
||||
assert str(path) == f'{test_directory}/videos'
|
||||
|
||||
# An absolute path is not changed.
|
||||
path = get_absolute_media_path(path)
|
||||
assert str(path) == f'{test_directory}/videos'
|
||||
|
||||
|
||||
def test_extract_video_duration(test_directory, corrupted_video_file):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue