Associating Video files when downloaded.

This commit is contained in:
Roland 2022-10-25 08:15:35 -06:00
parent 76a9c0d88c
commit d575b087b3
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
3 changed files with 17 additions and 1 deletions

View file

@ -663,3 +663,9 @@ async def test_archive_download_index(test_session, test_directory, image_file):
assert archive.title == 'the singlefile', 'Did not get the title from the singlefile'
assert archive.screenshot_path and archive.screenshot_file and archive.screenshot_path.is_file(), \
'Did not store the screenshot'
assert not archive.singlefile_file.associated
assert archive.readability_txt_file.associated \
and archive.readability_json_file.associated \
and archive.readability_file.associated \
and archive.screenshot_file.associated, 'Archive files must be associated'

View file

@ -289,10 +289,13 @@ class Video(ModelHelper, Base):
if poster_file:
poster_file.do_index()
poster_file.associated = True
if caption_file:
caption_file.do_index()
caption_file.associated = True
if info_json_file:
info_json_file.do_index()
info_json_file.associated = True
session.flush([i for i in files])

View file

@ -413,12 +413,13 @@ async def test_video_download_1(test_session, test_directory, simple_channel, vi
@pytest.mark.asyncio
async def test_download_result(test_session, test_directory, video_download_manager, mock_video_process_runner,
mock_video_extract_info):
mock_video_extract_info, image_file):
"""VideoDownloader returns a DownloadResult when complete."""
channel_directory = test_directory / 'videos/channel name'
channel_directory.mkdir(parents=True)
video_file = channel_directory / 'the video.mp4'
shutil.copy(PROJECT_DIR / 'test/big_buck_bunny_720p_1mb.mp4', video_file)
image_file.rename(video_file.with_suffix('.jpg'))
mock_video_extract_info.return_value = example_video_json
with mock.patch('modules.videos.downloader.VideoDownloader.prepare_filename') as mock_prepare_filename:
@ -430,6 +431,12 @@ async def test_download_result(test_session, test_directory, video_download_mana
assert download.url == 'https://example.com'
assert download.location == '/videos/channel/1/video/1'
# Video files are associated.
video = test_session.query(Video).one()
assert not video.video_file.associated, 'Video file should not be associated.'
assert video.poster_path.is_file(), 'Poster file was not found.'
assert video.poster_file.associated, 'Poster file was not associated.'
example_playlist_json = {
'_type': 'playlist',