diff --git a/app/src/components/VideoPlayer.js b/app/src/components/VideoPlayer.js index c670e896..46f20549 100644 --- a/app/src/components/VideoPlayer.js +++ b/app/src/components/VideoPlayer.js @@ -214,25 +214,6 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) { }; - const aboutPane = { - menuItem: 'About', render: () => -

Size

-

{videoFile.size ? humanFileSize(videoFile.size) : 'Unknown'}

- -

Source URL

-

{videoFile.url ? {videoFile.url} : 'N/A'}

- -

View Count

-

{video.view_count ? humanNumber(video.view_count) : 'N/A'}

- -

Censored

-

{video.censored ? 'Yes' : 'No'}

- -

Codec Names

- <>{video.codec_names ? video.codec_names.map(i => ) : 'N/A'} -
- } - const captionsPane = { menuItem: 'Captions', render: () =>
{video.caption || 'No captions available.'}
@@ -278,9 +259,27 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
, }; - const tabPanes = [commentsPane, descriptionPane, aboutPane, filesPane, captionsPane]; + const tabPanes = [commentsPane, descriptionPane, filesPane, captionsPane]; const tabMenu = theme === darkTheme ? {inverted: true, attached: true} : {attached: true}; + const aboutSegment = +
About Video
+

Size

+

{videoFile.size ? humanFileSize(videoFile.size) : 'Unknown'}

+ +

Source URL

+

{videoFile.url ? {videoFile.url} : 'N/A'}

+ +

View Count

+

{video.view_count ? humanNumber(video.view_count) : 'N/A'}

+ +

Censored

+

{video.censored ? 'Yes' : 'No'}

+ +

Codec Names

+ <>{video.codec_names ? video.codec_names.map(i => ) : 'N/A'} +
; + const localAddTag = async (name) => { await tagFileGroup(videoFile, name); await fetchVideo(); @@ -371,6 +370,8 @@ function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) { + {aboutSegment} + {prevNextVideosSegment} diff --git a/modules/videos/downloader.py b/modules/videos/downloader.py index d956731c..8ea699b3 100755 --- a/modules/videos/downloader.py +++ b/modules/videos/downloader.py @@ -451,6 +451,14 @@ class VideoDownloader(Downloader, ABC): Replace existing metadata files only after successful download.""" url = download.url + with get_db_session(commit=True) as session: + # Find the existing video, replace its info json. + video = Video.get_by_url(url, session) + + location = f'/videos/video/{video.id}' + if video.channel_id: + location = f'/videos/channel/{video.channel_id}/video/{video.id}' + # Download metadata files into temporary directory so yt-dlp always downloads the latest files. with tempfile.TemporaryDirectory() as tmp_dir: tmp_dir = pathlib.Path(tmp_dir) @@ -483,6 +491,7 @@ class VideoDownloader(Downloader, ABC): return DownloadResult( success=False, error=error, + location=location, ) # Find the info json file in the temporary directory. @@ -490,12 +499,14 @@ class VideoDownloader(Downloader, ABC): if len(info_json_paths) == 0: return DownloadResult( success=False, - error='No info json file was downloaded.' + error='No info json file was downloaded.', + location=location, ) elif len(info_json_paths) > 1: return DownloadResult( success=False, - error='More than one info json file was downloaded.' + error='More than one info json file was downloaded.', + location=location, ) info_json_path = info_json_paths[0] @@ -504,6 +515,7 @@ class VideoDownloader(Downloader, ABC): return DownloadResult( success=False, error='Video info json file was empty', + location=location, ) # Reformat new info json file for human reading. @@ -512,8 +524,6 @@ class VideoDownloader(Downloader, ABC): with get_db_session(commit=True) as session: # Find the existing video, replace its info json. video = Video.get_by_url(url, session) - video_id = video.id - channel_id = video.channel_id if video.info_json_path and video.info_json_path.is_file(): # Move old file temporarily. Only delete old data if the swap is successful. @@ -543,11 +553,6 @@ class VideoDownloader(Downloader, ABC): new_info_json_path.write_text(info_json_path.read_text()) video.file_group.append_files(new_info_json_path) - if channel_id: - location = f'/videos/channel/{channel_id}/video/{video_id}' - else: - location = f'/videos/video/{video_id}' - logger.debug(f'Downloaded video info json {location=}') logger.info(f'Successfully downloaded video info json {url} {video}') diff --git a/wrolpi/files/test/test_api.py b/wrolpi/files/test/test_api.py index 7724cc3d..6438cf39 100644 --- a/wrolpi/files/test/test_api.py +++ b/wrolpi/files/test/test_api.py @@ -220,17 +220,17 @@ def test_file_statistics(test_session, test_client, test_directory, example_pdf, assert response.status_code == HTTPStatus.OK assert response.json['file_statistics'] == { 'archive_count': 0, - 'total_size': 0, 'audio_count': 0, 'ebook_count': 0, 'image_count': 0, 'pdf_count': 0, - 'total_count': 0, - 'video_count': 0, - 'zip_count': 0, 'tagged_files': 0, 'tagged_zims': 0, 'tags_count': 0, + 'total_count': 0, + 'total_size': 0, + 'video_count': 0, + 'zip_count': 0, } test_client.post('/api/files/refresh') @@ -245,12 +245,12 @@ def test_file_statistics(test_session, test_client, test_directory, example_pdf, 'ebook_count': 2, 'image_count': 0, 'pdf_count': 1, - 'total_count': 5, # extracted cover - 'video_count': 1, - 'zip_count': 0, 'tagged_files': 0, 'tagged_zims': 0, 'tags_count': 0, + 'total_count': 5, # extracted cover + 'video_count': 1, + 'zip_count': 0, }