Including process logs in video result. Upgrading yt-dlp.

This commit is contained in:
Roland 2022-06-26 15:45:45 -06:00
parent d617c88343
commit fa83728f52
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
3 changed files with 20 additions and 6 deletions

View file

@ -187,7 +187,7 @@ def mock_video_prepare_filename():
@pytest.fixture
def mock_video_process_runner():
with mock.patch('modules.videos.downloader.VideoDownloader.process_runner') as mock_process_runner:
mock_process_runner.return_value = (0, {})
mock_process_runner.return_value = (0, {'stdout': None, 'stderr': None})
yield mock_process_runner

View file

@ -89,7 +89,7 @@ class ChannelDownloader(Downloader, ABC):
channel_source_id = info['channel_id']
channel = get_or_create_channel(channel_source_id, download.url, name)
channel.dict() # get all attributes while we have the session.
# Resolve all entries.
# Resolve the entries generator.
info['entries'] = list(info['entries'])
if self.is_a_playlist(info):
@ -128,6 +128,8 @@ class ChannelDownloader(Downloader, ABC):
try:
# Playlists require more information to download.
info = extract_info(download.url, process=True)
# Resolve the entries generator.
info['entries'] = list(info['entries'])
# Get all Video.source_id of this Channel.
with get_db_session() as session:
@ -246,11 +248,23 @@ class VideoDownloader(Downloader, ABC):
)
return_code, logs = self.process_runner(url, cmd, out_dir)
stdout = logs['stdout'].decode() if hasattr(logs['stdout'], 'decode') else logs['stdout']
stderr = logs['stderr'].decode() if hasattr(logs['stderr'], 'decode') else logs['stderr']
if return_code != 0:
raise ValueError(f'video downloader process exited with {return_code}')
error = f'{stdout}\n\n\n{stderr}\n\nvideo downloader process exited with {return_code}'
return DownloadResult(
success=False,
error=error,
)
if not video_path.is_file():
raise ValueError(f'Video file could not be found! {video_path}')
error = f'{stdout}\n\n\n{stderr}\n\n' \
f'Video file could not be found! {video_path}'
return DownloadResult(
success=False,
error=error,
)
with get_db_session(commit=True) as session:
# If the video is from a channel, it will already be in the database.
@ -369,7 +383,7 @@ def update_channel_catalog(channel: Channel, info: dict):
logger.info(f'Downloading video list for {channel.name} at {channel.url} This may take several minutes.')
# Resolve all entries to dictionaries.
entries = info['entries']
entries = info['entries'] = list(info['entries'])
# yt-dlp may hand back a list of URLs, lets use the "Uploads" URL, if available.
try:

View file

@ -21,4 +21,4 @@ SQLAlchemy==1.3.22
srt==3.5.1
websockets==10.1
webvtt-py==0.4.6
yt-dlp==2022.5.18
yt-dlp==2022.6.22.1