diff --git a/app/src/components/Channels.js b/app/src/components/Channels.js index 06ef3e8c..dc5a4297 100644 --- a/app/src/components/Channels.js +++ b/app/src/components/Channels.js @@ -413,9 +413,9 @@ function ChannelPage({create, header}) { - + + + } diff --git a/app/src/components/Theme.js b/app/src/components/Theme.js index 7b31ea4a..671aaf5e 100644 --- a/app/src/components/Theme.js +++ b/app/src/components/Theme.js @@ -37,9 +37,11 @@ export function ThemeWrapper({children, ...props}) { } // Properties to manipulate elements with theme. - // Example

This paragraph changes style

+ // Invert when Semantic supports it. Example: const [i, setI] = useState({}); + // Invert style when Semantic does not support it. Example:

This paragraph changes style

const [s, setS] = useState({}); + // Invert text when Semantic does not support it. const [t, setT] = useState({}); const [inverted, setInverted] = useState(''); @@ -55,7 +57,7 @@ export function ThemeWrapper({children, ...props}) { setT({style: {color: '#dddddd'}}); setInverted('inverted'); setTheme(darkTheme); - document.body.style.background = '#1B1C1D'; + document.body.style.background = '#171616'; if (save) { saveTheme(darkTheme); } @@ -130,8 +132,8 @@ export function ThemeWrapper({children, ...props}) { const themeValue = { i, // Used for Semantic elements which support "inverted". - t, // Used to invert text. s, // Used to invert the style some elements. + t, // Used to invert text. inverted, // Used to add "invert" to className. theme, savedTheme, @@ -256,6 +258,7 @@ export function Statistic(props) { export function StatisticGroup(props) { const {i} = useContext(ThemeContext); props = {...i, ...props}; + props['style'] = {...props['style'], marginLeft: 0, marginRight: 0}; return } diff --git a/app/src/components/VideoPlayer.js b/app/src/components/VideoPlayer.js index eef7bdbb..23315ead 100644 --- a/app/src/components/VideoPlayer.js +++ b/app/src/components/VideoPlayer.js @@ -2,7 +2,7 @@ import React, {useContext, useState} from 'react'; import {deleteVideos} from "../api"; import {Link, useNavigate, useParams} from "react-router-dom"; import _ from "lodash"; -import {API_URI, humanFileSize, humanNumber, PageContainer, secondsToTimestamp, uploadDate, useTitle} from "./Common"; +import {humanFileSize, humanNumber, PageContainer, uploadDate, useTitle} from "./Common"; import {Confirm} from "semantic-ui-react"; import Grid from "semantic-ui-react/dist/commonjs/collections/Grid"; import Container from "semantic-ui-react/dist/commonjs/elements/Container"; @@ -15,6 +15,20 @@ import {VideoCard} from "./Videos"; const MEDIA_PATH = '/media'; +function videoFileLink(video, name, directory = false) { + const path = video[name]; + if (path) { + const href = directory ? + `${MEDIA_PATH}/${encodeURIComponent(path)}/` : + `${MEDIA_PATH}/${encodeURIComponent(path)}`; + return +
{path}
+
+ } else { + return 'Unknown' + } +} + function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) { const {theme} = useContext(ThemeContext); @@ -59,11 +73,14 @@ function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) { let posterUrl = video.poster_path ? `${MEDIA_PATH}/${encodeURIComponent(video.poster_path)}` : null; let captionsUrl = video.caption_path ? `${MEDIA_PATH}/${encodeURIComponent(video.caption_path)}` : null; + let vttCaptions = video.caption_path.endsWith('.vtt'); let description = 'No description available.'; let viewCount = video.view_count; - if (video.info_json) { + if (video.info_json && video.info_json['description']) { + // Only replace empty description if there is one available. description = video.info_json['description']; + description = chaptersInDescription(description, setVideoTime) viewCount = viewCount || video.info_json['view_count']; } @@ -86,7 +103,7 @@ function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) { let descriptionPane = { menuItem: 'Description', render: () =>
-                {description ? chaptersInDescription(description, setVideoTime) : 'No description'}
+                {description}
             
}; @@ -104,12 +121,6 @@ function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) {

Censored

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

- -

File Name

-
{video.video_path}
- -

File Modification Time

-

{video.modification_datetime ? secondsToTimestamp(video.modification_datetime) : null}

} @@ -119,7 +130,26 @@ function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) { }; - let tabPanes = [descriptionPane, aboutPane, captionsPane]; + let filesPane = { + menuItem: 'Files', render: () => +

Video File

+ {videoFileLink(video, 'video_path')} + +

Info JSON File

+ {videoFileLink(video, 'info_json_path')} + +

Caption File

+ {videoFileLink(video, 'caption_path')} + +

Poster File

+ {videoFileLink(video, 'poster_path')} + +

Directory

+ {videoFileLink(video, 'directory', true)} +
+ } + + let tabPanes = [descriptionPane, aboutPane, filesPane, captionsPane]; const tabMenu = theme === darkTheme ? {inverted: true, attached: true} : {attached: true}; return (<> @@ -142,7 +172,9 @@ function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) { ref={videoRef} > - + {/* Only WebVTT captions can be displayed. */} + {vttCaptions && + } @@ -181,16 +213,18 @@ function VideoPage({videoFile, prevFile, nextFile, setFavorite, ...props}) { - - - - {prevFile && <>
Older
} -
- - {nextFile && <>
Newer
} -
-
-
+ + + + + {prevFile && <>
Older
} +
+ + {nextFile && <>
Newer
} +
+
+
+
) } diff --git a/app/src/components/admin/Status.js b/app/src/components/admin/Status.js index 5f2b4edc..23ba71d7 100644 --- a/app/src/components/admin/Status.js +++ b/app/src/components/admin/Status.js @@ -1,4 +1,4 @@ -import {Header, Progress, Statistic, StatisticGroup} from "../Theme"; +import {Header, Progress, Segment, Statistic, StatisticGroup} from "../Theme"; import React, {useContext} from "react"; import {humanBandwidth, humanFileSize, LoadStatistic, useTitle} from "../Common"; import {Divider, Responsive} from "semantic-ui-react"; @@ -196,8 +196,6 @@ export function Status() { - -
Network Bandwidth
{bandwidth ? bandwidth.map(i => ) : diff --git a/modules/videos/__init__.py b/modules/videos/__init__.py index f4ccef73..caee9857 100644 --- a/modules/videos/__init__.py +++ b/modules/videos/__init__.py @@ -118,11 +118,16 @@ class VideoIndexer(Indexer, ABC): a = cls.get_title(file) c = cls.get_description(file) - # Detect the associated caption file. - caption_path = file.path.with_suffix('.en.vtt') + # Detect the associated caption files. d = None - if caption_path.is_file(): - d = read_captions(caption_path) + if (en_vtt := file.path.with_suffix('.en.vtt')).is_file(): + d = read_captions(en_vtt) + elif (vtt := file.path.with_suffix('.vtt')).is_file(): + d = read_captions(vtt) + elif (en_srt := file.path.with_suffix('.en.srt')).is_file(): + d = read_captions(en_srt) + elif (srt := file.path.with_suffix('.srt')).is_file(): + d = read_captions(srt) elif EXTRACT_SUBTITLES: d = extract_captions(file.path) or '' diff --git a/modules/videos/models.py b/modules/videos/models.py index 4bd346a4..db42c74a 100644 --- a/modules/videos/models.py +++ b/modules/videos/models.py @@ -245,11 +245,13 @@ class Video(ModelHelper, Base): censored=self.censored, channel=self.channel, channel_id=self.channel_id, + directory=self.video_path.parent if self.video_path else None, modification_datetime=self.modification_datetime, duration=self.duration, favorite=self.favorite, id=self.id, info_json=info_json, + info_json_path=self.info_json_path, poster_path=self.poster_path, size=self.size, source_id=self.source_id, diff --git a/wrolpi/files/models.py b/wrolpi/files/models.py index 43c447cf..e1764bd3 100644 --- a/wrolpi/files/models.py +++ b/wrolpi/files/models.py @@ -98,11 +98,11 @@ class File(ModelHelper, Base): # Get the indexer on a separate line for debugging. indexer = self.indexer # Only read the contents of the file once. - self.a_text, self.b_text, self.c_text, self.d_text = indexer.create_index(self) - self.a_text = truncate_object_bytes(self.a_text, MAX_TEXT_FILE_BYTES) - self.b_text = truncate_object_bytes(self.b_text, MAX_TEXT_FILE_BYTES) - self.c_text = truncate_object_bytes(self.c_text, MAX_TEXT_FILE_BYTES) - self.d_text = truncate_object_bytes(self.d_text, MAX_TEXT_FILE_BYTES) + a_text, b_text, c_text, d_text = indexer.create_index(self) + self.a_text = truncate_object_bytes(a_text, MAX_TEXT_FILE_BYTES) + self.b_text = truncate_object_bytes(b_text, MAX_TEXT_FILE_BYTES) + self.c_text = truncate_object_bytes(c_text, MAX_TEXT_FILE_BYTES) + self.d_text = truncate_object_bytes(d_text, MAX_TEXT_FILE_BYTES) self.indexed = True except Exception as e: