2026-07-30 13:07:09 -06:00
|
|
|
import React, {useEffect, useState} from 'react';
|
2026-02-23 17:29:09 -07:00
|
|
|
import {useHotkeys} from 'react-hotkeys-hook';
|
2026-05-03 18:50:22 -06:00
|
|
|
import {deleteFileGroups, downloadVideoMetadata, tagFileGroup, untagFileGroup} from "../api";
|
2025-12-07 11:54:20 -07:00
|
|
|
import {Link, useNavigate, useParams} from "react-router";
|
2022-11-15 15:03:12 -07:00
|
|
|
import _ from "lodash";
|
2023-02-17 16:30:25 -07:00
|
|
|
import {
|
2023-07-21 15:14:09 -06:00
|
|
|
APIButton,
|
2023-02-17 16:30:25 -07:00
|
|
|
BackButton,
|
2026-03-28 14:19:09 -06:00
|
|
|
DirectoryLink,
|
2023-03-29 13:46:39 -06:00
|
|
|
encodeMediaPath,
|
2023-02-17 16:30:25 -07:00
|
|
|
humanFileSize,
|
2024-11-02 15:14:02 -06:00
|
|
|
humanNumber,
|
|
|
|
|
isoDatetimeToAgoPopup,
|
2024-02-27 18:54:14 -07:00
|
|
|
MultilineText,
|
2023-02-17 16:30:25 -07:00
|
|
|
PageContainer,
|
|
|
|
|
PreviewPath,
|
2026-03-08 09:22:50 -06:00
|
|
|
useMediaSession,
|
2023-02-17 16:30:25 -07:00
|
|
|
useTitle
|
|
|
|
|
} from "./Common";
|
2022-08-06 05:22:07 +00:00
|
|
|
import {VideoPlaceholder} from "./Placeholder";
|
2026-03-21 16:50:27 -06:00
|
|
|
import {useChannel, useVideoCaptions, useVideoExtras} from "../hooks/customHooks";
|
2026-07-30 13:07:09 -06:00
|
|
|
import {Button, Grid, Header, Icon, Label, Loading, Panel, Tabs, TextInput} from "./ui";
|
2022-11-04 09:58:38 -06:00
|
|
|
import {VideoCard} from "./Videos";
|
2023-04-05 14:48:13 -06:00
|
|
|
import {TagsSelector} from "../Tags";
|
Add ordered collections (playlists): polymorphic items + item API (#475)
* Add Playlists: ordered, mixed-type collections
A playlist (Collection kind='playlist') is a manually-curated, ordered list that
mixes item types. Squash of the playlists feature branch (24 commits).
Data model & API:
- CollectionItem is polymorphic via item_kind: 'file' (FileGroup), 'zim'
(zim_id + zim_entry), or 'url' (link to anything the WROLPi browser opens,
e.g. /map?lat=&lon=&z=). CHECK constraint enforces exactly one kind; per-kind
unique constraints; migration a7b1c2d3e4f5.
- Endpoints: create playlist; add/remove/reorder items (idempotent adds: 201 new,
200 existing); GET returns the ordered items. All mutations wrol_mode_check'd.
Config (source of truth):
- playlists.yaml (PlaylistsConfig) stores each playlist's metadata AND ordered
items (file by relative path, zim by path+entry, url inline); round-trips a
DB wipe. Supports backup import (DB_CONFIG_FILE_NAMES).
- The redundant generic CollectionsConfig (collections.yaml) is deleted:
channels/domains own their configs, authors/subjects are re-derived.
On-disk sync (sync_playlists_directory switch):
- Each playlist materializes into the configurable Playlists Directory
(playlists_destination, Settings UI input, excluded from indexing) with
position-prefixed entries: NNNN_<file> hard links (copy fallback across
filesystems) and NNNN_<title>.html stubs for zim/url items.
- Tagged playlists are namespaced like channels: <playlists>/<tag>/<name>;
a tag change moves the directory and prunes the empty old tag dir.
- Deletion safety: managed files are only removed when they are our marked
stubs or still have another hard link (st_nlink > 1) -- never a last copy.
Stray loose files at the playlists root are removed; stub URLs are
scheme-allowlisted (no javascript:/data:).
Frontend:
- /playlists list page (CollectionTable, name filter, New Playlist modal, Tag
column) between Files and Zim in the nav.
- View-only detail page (Name link) and edit page (Edit button): themed table
with model icons/colors + poster thumbnails, items link to their model page
(video/archive/doc) or preview, up/down reorder, remove, add-URL form,
single-tag selector; all editing disabled in WROL Mode.
- Reusable green "Add to Playlist" button on Video/Archive/Doc detail pages,
the FilePreview toolbar, Zim search results, and Map pins (added as a /map
URL item with a map-marker icon).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Playlist edit page parity: rename, custom directory, tag modal move suggestion
Match the ChannelEditPage/DomainEditPage UX on the playlist edit page:
Back/View buttons, an edit form (name, description, directory), and the
shared CollectionTagModal with the violet "Tag" button. The tag modal now
suggests moving the playlist to its managed tag location
(playlists/<tag>/<name>); accepting the suggestion stores directory=None so
the sync keeps auto-managing the location. Tag buttons on the Channel and
Domain edit pages are now violet to match.
Backend: update_collection learns rename (with per-kind validation and
duplicate checks) and playlist custom directories (cleanup of the abandoned
directory, config round-trip, commit-before-switch to avoid the background
sync racing pre-commit state). tag_collection's duplicated untag/tag
branches are merged, and the per-kind config-save dispatch is consolidated
into _activate_config_save().
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Deduplicate Collection error handling and Tag creation
Delete the duplicate UnknownCollection in wrolpi/collections/errors.py and
re-export the canonical one from wrolpi/errors.py, which carries
status_code=NOT_FOUND (the local copy inherited 500). Replace the repeated
query/raise pattern in reorganize.py with Collection.find_by_id.
Add Tag.get_or_create_tag and use it for collection tagging; flush the new
Tag before returning so callers can read .id immediately -- previously
tagging a collection with a brand-new tag name set tag_id=None. Regression
test included.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 19:37:34 -06:00
|
|
|
import {AddToPlaylistButton} from "./AddToPlaylist";
|
2026-05-03 17:28:06 -06:00
|
|
|
import {TaggedDeleteConfirmModal} from "./TaggedDeleteConfirmModal";
|
2026-07-30 13:07:09 -06:00
|
|
|
import {IconPlayerPause, IconPlayerPlay} from "@tabler/icons-react";
|
2021-11-01 16:42:52 -06:00
|
|
|
|
|
|
|
|
const MEDIA_PATH = '/media';
|
|
|
|
|
|
|
|
|
|
|
2022-11-30 18:26:38 -07:00
|
|
|
|
2026-07-16 17:43:40 -06:00
|
|
|
// YouTube auto-generated captions (downloaded via yt-dlp) stamp every cue with `align:start position:0%`,
|
|
|
|
|
// which pins the text to the bottom-left of the player and makes it hard to read. Detect that signature and
|
|
|
|
|
// reset those cues to the browser's centered default. This mutates only the in-memory VTTCue objects the
|
|
|
|
|
// browser parsed; the .vtt file on disk is never modified. Cues that were deliberately positioned (anything
|
2026-07-16 17:51:37 -06:00
|
|
|
// other than the auto-caption signature) are left untouched. YouTube auto-captions never set `line`, so we
|
|
|
|
|
// require `line === 'auto'` too; that leaves a deliberately placed cue (e.g. `line:0` for top-edge) alone even
|
|
|
|
|
// if it happens to also be `align:start position:0%`.
|
2026-07-16 17:43:40 -06:00
|
|
|
export function centerAutoCaptions(track) {
|
|
|
|
|
if (!track || !track.cues) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
let changed = 0;
|
|
|
|
|
for (const cue of track.cues) {
|
2026-07-16 17:51:37 -06:00
|
|
|
if (cue.align === 'start' && cue.position === 0 && cue.line === 'auto') {
|
2026-07-16 17:43:40 -06:00
|
|
|
cue.align = 'center';
|
|
|
|
|
cue.position = 'auto';
|
|
|
|
|
changed++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleCaptionTrackLoad(event) {
|
|
|
|
|
const track = event.target.track;
|
|
|
|
|
if (!track) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (track.cues && track.cues.length > 0) {
|
|
|
|
|
centerAutoCaptions(track);
|
|
|
|
|
} else {
|
|
|
|
|
// A non-default track has mode 'disabled' at load time, so its cues are not parsed yet. Normalize
|
2026-07-16 17:51:37 -06:00
|
|
|
// them once the browser populates the cue list (when the user selects the track and playback advances
|
|
|
|
|
// into a cue). Only detach after cues actually exist, in case a cuechange fires before they load.
|
2026-07-16 17:43:40 -06:00
|
|
|
const onCueChange = () => {
|
2026-07-16 17:51:37 -06:00
|
|
|
if (track.cues && track.cues.length > 0) {
|
|
|
|
|
centerAutoCaptions(track);
|
|
|
|
|
track.removeEventListener('cuechange', onCueChange);
|
|
|
|
|
}
|
2026-07-16 17:43:40 -06:00
|
|
|
};
|
|
|
|
|
track.addEventListener('cuechange', onCueChange);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-03 22:36:27 -06:00
|
|
|
export function CaptionTrack({src, ...props}) {
|
2026-07-16 17:43:40 -06:00
|
|
|
// Center YouTube auto-generated captions once the browser parses the cues (see centerAutoCaptions).
|
|
|
|
|
props = {onLoad: handleCaptionTrackLoad, ...props};
|
2023-08-03 22:36:27 -06:00
|
|
|
if (src.endsWith('.de.vtt')) {
|
|
|
|
|
return <track kind="captions" label="German" src={src} srcLang="de" {...props}/>
|
|
|
|
|
} else if (src.endsWith('.es.vtt')) {
|
|
|
|
|
return <track kind="captions" label="Spanish" src={src} srcLang="es" {...props}/>
|
|
|
|
|
} else if (src.endsWith('.fr.vtt')) {
|
|
|
|
|
return <track kind="captions" label="French" src={src} srcLang="fr" {...props}/>
|
|
|
|
|
} else if (src.endsWith('.id.vtt')) {
|
|
|
|
|
return <track kind="captions" label="Indonesian" src={src} srcLang="id" {...props}/>
|
|
|
|
|
} else if (src.endsWith('.it.vtt')) {
|
|
|
|
|
return <track kind="captions" label="Italian" src={src} srcLang="it" {...props}/>
|
|
|
|
|
} else if (src.endsWith('.ja.vtt')) {
|
|
|
|
|
return <track kind="captions" label="Japanese" src={src} srcLang="ja" {...props}/>
|
|
|
|
|
} else if (src.endsWith('.pl.vtt')) {
|
|
|
|
|
return <track kind="captions" label="Polish" src={src} srcLang="pl" {...props}/>
|
|
|
|
|
} else if (src.endsWith('.pt.vtt')) {
|
|
|
|
|
return <track kind="captions" label="Portuguese" src={src} srcLang="pt" {...props}/>
|
|
|
|
|
} else if (src.endsWith('.ro.vtt')) {
|
|
|
|
|
return <track kind="captions" label="Romanian" src={src} srcLang="ro" {...props}/>
|
2023-08-17 19:31:21 -06:00
|
|
|
} else if (src.endsWith('.ru.vtt')) {
|
2023-08-03 22:36:27 -06:00
|
|
|
return <track kind="captions" label="Russian" src={src} srcLang="ru" {...props}/>
|
|
|
|
|
} else if (src.endsWith('.th.vtt')) {
|
|
|
|
|
return <track kind="captions" label="Thai" src={src} srcLang="th" {...props}/>
|
|
|
|
|
}
|
|
|
|
|
return <track kind="captions" label="English" src={src} srcLang="en" default {...props}/>
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-20 13:47:12 -07:00
|
|
|
const NoComments = ({video}) => {
|
|
|
|
|
const videoUrl = video.url;
|
|
|
|
|
|
|
|
|
|
const handleRefresh = async () => {
|
2026-03-19 15:02:32 -06:00
|
|
|
await downloadVideoMetadata(videoUrl);
|
2024-02-20 13:47:12 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (videoUrl) {
|
|
|
|
|
return <React.Fragment>
|
|
|
|
|
<p>No comments have been been downloaded. Refresh the video?</p>
|
|
|
|
|
|
|
|
|
|
<APIButton
|
2026-07-30 13:07:09 -06:00
|
|
|
role='primary'
|
2024-02-20 13:47:12 -07:00
|
|
|
size='large'
|
|
|
|
|
onClick={handleRefresh}
|
|
|
|
|
>Refresh</APIButton>
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
} else {
|
|
|
|
|
return <React.Fragment>
|
|
|
|
|
<p>No comment have been downloaded. WROLPi does not know the URL of this video, so it cannot download
|
|
|
|
|
the comments.</p>
|
|
|
|
|
|
|
|
|
|
<big>Try finding and downloading the video again.</big>
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 13:07:09 -06:00
|
|
|
// Semantic's <Comment>/<CommentGroup> have no equivalent in the token library -- this is a nested
|
|
|
|
|
// comment thread, not a reusable widget, so it is built here from plain elements and tokens.
|
2024-02-20 13:47:12 -07:00
|
|
|
const VideoComment = ({comment, children}) => {
|
2024-02-27 18:54:14 -07:00
|
|
|
const {is_favorited, like_count, author, timestamp, text, author_is_uploader} = comment;
|
|
|
|
|
|
|
|
|
|
// Author comments and favorited comments are important.
|
|
|
|
|
let specialIcon = null;
|
|
|
|
|
if (author_is_uploader) {
|
2026-07-30 13:07:09 -06:00
|
|
|
specialIcon = <Icon name='star' label='Uploader' style={{color: 'var(--green)'}}/>;
|
2024-02-27 18:54:14 -07:00
|
|
|
} else if (is_favorited) {
|
2026-07-30 13:07:09 -06:00
|
|
|
specialIcon = <Icon name='heart' label='Favorited' style={{color: 'var(--red)'}}/>;
|
2024-02-27 18:54:14 -07:00
|
|
|
}
|
|
|
|
|
|
2026-07-30 13:07:09 -06:00
|
|
|
return <div style={{marginBottom: '1.2em'}}>
|
|
|
|
|
<div style={{fontWeight: 600, display: 'flex', alignItems: 'center', gap: '0.3em'}}>
|
|
|
|
|
{specialIcon}<span>{author}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={{display: 'flex', gap: '1em', fontSize: '0.85em', color: 'var(--muted)'}}>
|
|
|
|
|
<div>{isoDatetimeToAgoPopup(timestamp * 1000)}</div>
|
|
|
|
|
{like_count ? <div>
|
|
|
|
|
<Icon name='thumbs up' size={14}/> {humanNumber(comment['like_count'])}
|
|
|
|
|
</div> : null}
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<MultilineText text={text} style={{marginLeft: '0.5em'}}/>
|
|
|
|
|
</div>
|
2024-02-20 13:47:12 -07:00
|
|
|
{children && !_.isEmpty(children) &&
|
2026-07-30 13:07:09 -06:00
|
|
|
<div style={{
|
|
|
|
|
marginLeft: '1.5em',
|
|
|
|
|
marginTop: '0.7em',
|
|
|
|
|
paddingLeft: '1em',
|
|
|
|
|
borderLeft: '1px solid var(--border)',
|
|
|
|
|
}}>
|
2024-02-20 13:47:12 -07:00
|
|
|
{children.map((i, key) => <VideoComment key={key} comment={i}/>)}
|
2026-07-30 13:07:09 -06:00
|
|
|
</div>
|
2024-02-20 13:47:12 -07:00
|
|
|
}
|
2026-07-30 13:07:09 -06:00
|
|
|
</div>
|
2024-02-20 13:47:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Comments = ({comments, video}) => {
|
|
|
|
|
if (!comments || _.isEmpty(comments)) {
|
|
|
|
|
return <NoComments video={video}/>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
comments.sort((a, b) => {
|
|
|
|
|
// Treat undefined like_count as 0
|
|
|
|
|
const likeA = a.like_count ?? 0;
|
|
|
|
|
const likeB = b.like_count ?? 0;
|
|
|
|
|
|
|
|
|
|
// For descending order
|
|
|
|
|
return likeB - likeA;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const rootComments = comments.filter(i => i['parent'] === 'root');
|
|
|
|
|
|
2024-10-15 17:02:59 -06:00
|
|
|
// Comments are in an array, convert it to a dict, grouped by their parent.
|
|
|
|
|
const groupedByParent = {};
|
2024-02-20 13:47:12 -07:00
|
|
|
comments.forEach(obj => {
|
2024-10-15 17:02:59 -06:00
|
|
|
if (!groupedByParent[obj.parent]) {
|
|
|
|
|
groupedByParent[obj.parent] = [];
|
2024-02-20 13:47:12 -07:00
|
|
|
}
|
2024-10-15 17:02:59 -06:00
|
|
|
groupedByParent[obj.parent].push(obj);
|
|
|
|
|
})
|
|
|
|
|
// Sort replies to each parent by the time they were created.
|
|
|
|
|
comments.forEach(obj => {
|
|
|
|
|
const children = groupedByParent[obj.parent];
|
|
|
|
|
groupedByParent[obj.parent] = _.sortBy(children, ['timestamp']);
|
2024-02-20 13:47:12 -07:00
|
|
|
})
|
|
|
|
|
|
2026-07-30 13:07:09 -06:00
|
|
|
return <div>
|
2024-10-15 17:02:59 -06:00
|
|
|
{rootComments.map((i, key) => <VideoComment key={key} comment={i} children={groupedByParent[i.id]}/>)}
|
2026-07-30 13:07:09 -06:00
|
|
|
</div>
|
2024-02-20 13:47:12 -07:00
|
|
|
}
|
|
|
|
|
|
2026-02-23 17:29:09 -07:00
|
|
|
// Generate a video page URL for a file object.
|
|
|
|
|
function getVideoLink(file) {
|
|
|
|
|
if (!file || !file.video) return null;
|
2026-03-20 15:38:32 -06:00
|
|
|
return `/videos/${file.id}`;
|
2026-02-23 17:29:09 -07:00
|
|
|
}
|
|
|
|
|
|
2023-03-24 08:58:18 -06:00
|
|
|
function VideoPage({videoFile, prevFile, nextFile, fetchVideo, ...props}) {
|
2022-08-06 05:22:07 +00:00
|
|
|
const navigate = useNavigate();
|
2022-11-15 15:03:12 -07:00
|
|
|
const videoRef = React.useRef();
|
2026-05-03 17:28:06 -06:00
|
|
|
const [taggedFileGroups, setTaggedFileGroups] = useState(null);
|
2026-07-30 13:07:09 -06:00
|
|
|
const [activeTab, setActiveTab] = useState('comments');
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2023-10-24 10:20:06 -06:00
|
|
|
useTitle(videoFile ? videoFile.title ? videoFile.title : videoFile.name : null);
|
2022-08-06 05:22:07 +00:00
|
|
|
let video;
|
|
|
|
|
if (videoFile) {
|
|
|
|
|
video = videoFile.video;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-15 15:03:12 -07:00
|
|
|
// Seeks to the `seconds` on video player.
|
|
|
|
|
const setVideoTime = (seconds) => {
|
|
|
|
|
videoRef.current.currentTime = seconds;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-06 05:22:07 +00:00
|
|
|
// Get the Video's channel, fallback to the URL's channel id.
|
|
|
|
|
const {channelId} = useParams();
|
|
|
|
|
const {channel} = useChannel(video && video.channel_id ? video.channel_id : channelId);
|
2026-03-21 16:50:27 -06:00
|
|
|
const {comments} = useVideoExtras(videoFile?.id);
|
|
|
|
|
const {captions, captionsLoading, fetchCaptions} = useVideoCaptions(videoFile?.id);
|
2022-08-06 05:22:07 +00:00
|
|
|
|
2026-03-08 09:22:50 -06:00
|
|
|
const mediaTitle = videoFile ? (videoFile.title || videoFile.stem || videoFile.name) : null;
|
|
|
|
|
const mediaArtworkUrl = video && video.poster_path ? `${MEDIA_PATH}/${encodeMediaPath(video.poster_path)}` : null;
|
|
|
|
|
useMediaSession(mediaTitle, channel ? channel.name : null, mediaArtworkUrl);
|
|
|
|
|
|
2026-02-23 17:29:09 -07:00
|
|
|
// Keyboard shortcuts for video player controls
|
|
|
|
|
// k: Play/pause
|
|
|
|
|
useHotkeys('k', () => {
|
|
|
|
|
if (videoRef.current) {
|
|
|
|
|
if (videoRef.current.paused) {
|
|
|
|
|
videoRef.current.play();
|
|
|
|
|
} else {
|
|
|
|
|
videoRef.current.pause();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, {enableOnFormTags: false});
|
|
|
|
|
|
|
|
|
|
// j: Jump back 15 seconds
|
|
|
|
|
useHotkeys('j', () => {
|
|
|
|
|
if (videoRef.current) {
|
|
|
|
|
videoRef.current.currentTime = Math.max(0, videoRef.current.currentTime - 15);
|
|
|
|
|
}
|
|
|
|
|
}, {enableOnFormTags: false});
|
|
|
|
|
|
|
|
|
|
// l: Jump forward 30 seconds
|
|
|
|
|
useHotkeys('l', () => {
|
|
|
|
|
if (videoRef.current) {
|
|
|
|
|
videoRef.current.currentTime = Math.min(
|
|
|
|
|
videoRef.current.duration || Infinity,
|
|
|
|
|
videoRef.current.currentTime + 30
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}, {enableOnFormTags: false});
|
|
|
|
|
|
|
|
|
|
// n: Navigate to newer video
|
|
|
|
|
useHotkeys('n', () => {
|
|
|
|
|
const link = getVideoLink(nextFile);
|
|
|
|
|
if (link) {
|
|
|
|
|
navigate(link);
|
|
|
|
|
}
|
|
|
|
|
}, {enableOnFormTags: false}, [nextFile, navigate]);
|
|
|
|
|
|
|
|
|
|
// p: Navigate to older video
|
|
|
|
|
useHotkeys('p', () => {
|
|
|
|
|
const link = getVideoLink(prevFile);
|
|
|
|
|
if (link) {
|
|
|
|
|
navigate(link);
|
|
|
|
|
}
|
|
|
|
|
}, {enableOnFormTags: false}, [prevFile, navigate]);
|
|
|
|
|
|
2026-03-27 17:59:36 -06:00
|
|
|
// f: Toggle fullscreen
|
|
|
|
|
useHotkeys('f', () => {
|
|
|
|
|
if (videoRef.current) {
|
|
|
|
|
if (document.fullscreenElement) {
|
|
|
|
|
document.exitFullscreen();
|
|
|
|
|
} else {
|
|
|
|
|
videoRef.current.requestFullscreen();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, {enableOnFormTags: false});
|
|
|
|
|
|
2026-04-14 15:00:49 -06:00
|
|
|
const isAudioFile = videoFile?.mimetype?.startsWith('audio/');
|
|
|
|
|
const [showAudioOverlay, setShowAudioOverlay] = useState(!!isAudioFile);
|
|
|
|
|
const [audioPosterHover, setAudioPosterHover] = useState(false);
|
|
|
|
|
const [audioPlaying, setAudioPlaying] = useState(false);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!isAudioFile) return;
|
|
|
|
|
setShowAudioOverlay(true);
|
|
|
|
|
const timer = setTimeout(() => setShowAudioOverlay(false), 3000);
|
|
|
|
|
return () => clearTimeout(timer);
|
|
|
|
|
}, [isAudioFile]);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const el = videoRef.current;
|
|
|
|
|
if (!isAudioFile || !el) return;
|
|
|
|
|
const onPlay = () => setAudioPlaying(true);
|
|
|
|
|
const onPause = () => setAudioPlaying(false);
|
|
|
|
|
el.addEventListener('play', onPlay);
|
|
|
|
|
el.addEventListener('pause', onPause);
|
|
|
|
|
return () => { el.removeEventListener('play', onPlay); el.removeEventListener('pause', onPause); };
|
|
|
|
|
}, [isAudioFile]);
|
|
|
|
|
|
2022-08-06 05:22:07 +00:00
|
|
|
if (videoFile === null) {
|
|
|
|
|
return <VideoPlaceholder/>;
|
|
|
|
|
}
|
|
|
|
|
if (videoFile === undefined) {
|
2022-09-28 09:38:05 -06:00
|
|
|
return <PageContainer><Header as='h4'>Could not find video</Header></PageContainer>;
|
2022-08-06 05:22:07 +00:00
|
|
|
}
|
|
|
|
|
|
2026-05-03 18:50:22 -06:00
|
|
|
const handleDeleteVideo = async (fileGroupId, force = false) => {
|
|
|
|
|
const result = await deleteFileGroups([fileGroupId], force);
|
2026-05-03 17:28:06 -06:00
|
|
|
if (result && result.tagged) {
|
|
|
|
|
setTaggedFileGroups(result.file_groups);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-08-06 05:22:07 +00:00
|
|
|
navigate(-1);
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
2024-02-20 13:47:12 -07:00
|
|
|
const handleRefresh = async () => {
|
2026-03-19 15:02:32 -06:00
|
|
|
await downloadVideoMetadata(videoFile.url);
|
2024-02-20 13:47:12 -07:00
|
|
|
};
|
|
|
|
|
|
2023-03-29 13:46:39 -06:00
|
|
|
let videoUrl = `${MEDIA_PATH}/${encodeMediaPath(video.video_path)}`;
|
|
|
|
|
let downloadUrl = `/download/${encodeMediaPath(video.video_path)}`;
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2023-03-29 13:46:39 -06:00
|
|
|
let posterUrl = video.poster_path ? `${MEDIA_PATH}/${encodeMediaPath(video.poster_path)}` : null;
|
2023-04-02 16:30:01 -06:00
|
|
|
const {caption_files} = video;
|
|
|
|
|
const captionUrls = caption_files && caption_files.length > 0 ?
|
|
|
|
|
caption_files.filter(i => i['mimetype'] === 'text/vtt').map(i => `${MEDIA_PATH}/${encodeMediaPath(i['path'])}`)
|
|
|
|
|
: [];
|
2021-11-01 16:42:52 -06:00
|
|
|
|
|
|
|
|
let description = 'No description available.';
|
2023-03-24 08:58:18 -06:00
|
|
|
if (video && video['description']) {
|
2022-11-30 18:26:38 -07:00
|
|
|
// Only replace empty description if there is one available.
|
2023-03-24 08:58:18 -06:00
|
|
|
description = video['description'];
|
2023-09-07 13:00:54 -06:00
|
|
|
description = formatVideoDescription(description, setVideoTime)
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
2026-02-08 10:29:08 -07:00
|
|
|
const getFile = (suffix) => videoFile.files.find(i => i.path.toLowerCase().endsWith(suffix));
|
2026-03-28 14:19:09 -06:00
|
|
|
const fileSize = (file) => file && file.size
|
2026-07-30 13:07:09 -06:00
|
|
|
? <span style={{marginLeft: '1em', color: 'var(--muted)'}}>({humanFileSize(file.size)})</span>
|
2026-03-28 14:19:09 -06:00
|
|
|
: null;
|
2026-02-08 10:29:08 -07:00
|
|
|
|
2025-01-26 12:44:16 -07:00
|
|
|
const {poster_file, info_json_file} = video;
|
2026-03-28 14:19:09 -06:00
|
|
|
const videoPathFile = videoFile.files.find(i => i.path === video['video_path']);
|
2026-02-08 10:29:08 -07:00
|
|
|
const ffprobeJsonFile = getFile('.ffprobe.json');
|
2026-03-28 14:19:09 -06:00
|
|
|
const tableStyle = {width: '100%', borderCollapse: 'separate', borderSpacing: '0 0.7em'};
|
|
|
|
|
const labelStyle = {whiteSpace: 'nowrap', paddingRight: '1.5em', verticalAlign: 'top'};
|
2024-02-20 15:13:18 -07:00
|
|
|
|
2023-04-02 16:30:01 -06:00
|
|
|
const localAddTag = async (name) => {
|
2023-05-29 18:04:03 -06:00
|
|
|
await tagFileGroup(videoFile, name);
|
2023-04-02 16:30:01 -06:00
|
|
|
await fetchVideo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const localRemoveTag = async (name) => {
|
2023-05-29 18:04:03 -06:00
|
|
|
await untagFileGroup(videoFile, name);
|
2023-04-02 16:30:01 -06:00
|
|
|
await fetchVideo();
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-27 15:53:47 -06:00
|
|
|
let videoSource = <source src={videoUrl}/>;
|
2026-04-14 15:00:49 -06:00
|
|
|
const isAudio = videoFile.mimetype && videoFile.mimetype.startsWith('audio/');
|
2023-07-27 15:53:47 -06:00
|
|
|
|
2026-07-30 13:07:09 -06:00
|
|
|
let prevNextVideosPanel = <Panel><p>No related videos found.</p></Panel>;
|
2023-08-17 19:31:21 -06:00
|
|
|
if (prevFile || nextFile) {
|
2026-07-30 13:07:09 -06:00
|
|
|
prevNextVideosPanel = <Panel>
|
|
|
|
|
<Grid>
|
|
|
|
|
<Grid.Col span={{base: 12, sm: 6}}>
|
|
|
|
|
{prevFile && <><Header as='h3'>Older</Header><VideoCard file={prevFile}/></>}
|
|
|
|
|
</Grid.Col>
|
|
|
|
|
<Grid.Col span={{base: 12, sm: 6}}>
|
|
|
|
|
{nextFile && <><Header as='h3'>Newer</Header><VideoCard file={nextFile}/></>}
|
|
|
|
|
</Grid.Col>
|
2023-08-17 19:31:21 -06:00
|
|
|
</Grid>
|
2026-07-30 13:07:09 -06:00
|
|
|
</Panel>
|
2023-08-17 19:31:21 -06:00
|
|
|
}
|
|
|
|
|
|
2023-09-07 13:00:54 -06:00
|
|
|
let title = video.video_path;
|
|
|
|
|
if (videoFile.title) {
|
|
|
|
|
title = hashtagLinks(videoFile.title);
|
|
|
|
|
} else if (videoFile.stem) {
|
|
|
|
|
title = videoFile.stem;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 13:07:09 -06:00
|
|
|
const audioPlayPauseLabel = audioPlaying ? 'Pause' : 'Play';
|
|
|
|
|
|
2023-02-17 16:09:24 -07:00
|
|
|
return <>
|
ui: a Back button is a row of one, not a stretched flex child
Reported: the Back button fills the page width on the domain and channel edit
pages. It fills it on all nine pages that have one, and this is mine from the
last PR.
`.wrolpi-stack` is a flex column at `align-items: stretch`, deliberately -- a
panel was full-width as a block element and has to stay that way. A BARE button
as a direct child of that stack is stretched too, and every page's Back button
was one. On the domain, channel and playlist edit pages it also pushed the
button beside it onto its own line, where the two had been inline.
Wrapping each in a `.wrolpi-button-row` fixes both without touching the stack:
the row is the stretched child, and it lays its buttons out at their own width.
The three pages that have a second button get one row holding both, which is how
they read before.
Also the Videos, Archives and Documents select bars, whose Tag/Delete/Invert/
Clear were four touching buttons in a bare div. They are inline elements rather
than interpolations, which is the shape the bare-siblings scan does not see.
Guarded twice: the row keeps its buttons their own width inside a stack while
itself stretching (both halves, since a row that refused to stretch would pass a
test that only looked at the button), and every `<BackButton/>` in the app is
inside a row.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 16:47:33 -06:00
|
|
|
<div className='wrolpi-button-row' style={{margin: '1em'}}>
|
2022-11-30 19:31:18 -07:00
|
|
|
<BackButton/>
|
2026-07-30 13:07:09 -06:00
|
|
|
</div>
|
2022-08-06 05:22:07 +00:00
|
|
|
|
2026-04-14 15:00:49 -06:00
|
|
|
{isAudio ? <>
|
|
|
|
|
{posterUrl && <div
|
2026-07-30 13:07:09 -06:00
|
|
|
// A wrapper whose custom play/pause/volume glyphs are drawn over the poster image: the whole
|
|
|
|
|
// composite must be tinted as one unit in night mode, so it carries `.media` even though the
|
|
|
|
|
// <img/> inside is already a filtered leaf on its own.
|
|
|
|
|
className='audio-poster-container media'
|
|
|
|
|
role='button'
|
|
|
|
|
tabIndex={0}
|
|
|
|
|
aria-label={audioPlaying ? 'Pause audio' : 'Play audio'}
|
2026-04-14 15:00:49 -06:00
|
|
|
onClick={() => {
|
|
|
|
|
if (videoRef.current) {
|
|
|
|
|
videoRef.current.paused ? videoRef.current.play() : videoRef.current.pause();
|
|
|
|
|
}
|
|
|
|
|
}}
|
2026-07-30 13:07:09 -06:00
|
|
|
onKeyDown={(e) => {
|
|
|
|
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (videoRef.current) {
|
|
|
|
|
videoRef.current.paused ? videoRef.current.play() : videoRef.current.pause();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}}
|
2026-04-14 15:00:49 -06:00
|
|
|
onMouseEnter={() => setAudioPosterHover(true)}
|
|
|
|
|
onMouseLeave={() => setAudioPosterHover(false)}
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
src={posterUrl}
|
|
|
|
|
alt={mediaTitle || 'Audio thumbnail'}
|
|
|
|
|
style={{maxWidth: '100%', maxHeight: '400px', cursor: 'pointer'}}
|
|
|
|
|
/>
|
2026-07-30 13:07:09 -06:00
|
|
|
<div
|
|
|
|
|
className='audio-poster-overlay'
|
|
|
|
|
aria-hidden='true'
|
|
|
|
|
style={{opacity: showAudioOverlay ? 1 : 0, transition: 'opacity 500ms ease'}}
|
|
|
|
|
>
|
|
|
|
|
<Icon name='volume up' size={64}/>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
className='audio-poster-overlay'
|
|
|
|
|
aria-hidden='true'
|
|
|
|
|
style={{
|
|
|
|
|
opacity: (audioPosterHover && !showAudioOverlay) ? 1 : 0,
|
|
|
|
|
transition: 'opacity 200ms ease',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Icon component={audioPlaying ? IconPlayerPause : IconPlayerPlay} size={64}
|
|
|
|
|
label={audioPlayPauseLabel}/>
|
|
|
|
|
</div>
|
2026-04-14 15:00:49 -06:00
|
|
|
</div>}
|
|
|
|
|
<audio controls
|
|
|
|
|
autoPlay={props.autoplay !== undefined ? props.autoplay : true}
|
|
|
|
|
id="player"
|
|
|
|
|
style={{width: '100%', marginTop: posterUrl ? '0.5em' : 0}}
|
|
|
|
|
ref={videoRef}
|
|
|
|
|
>
|
|
|
|
|
{videoSource}
|
|
|
|
|
</audio>
|
|
|
|
|
</> : <video controls
|
2024-10-15 17:02:59 -06:00
|
|
|
className='video-player'
|
2022-08-06 05:22:07 +00:00
|
|
|
autoPlay={props.autoplay !== undefined ? props.autoplay : true}
|
|
|
|
|
poster={posterUrl}
|
|
|
|
|
id="player"
|
|
|
|
|
playsInline={true}
|
|
|
|
|
style={{maxWidth: '100%'}}
|
2022-11-15 15:03:12 -07:00
|
|
|
ref={videoRef}
|
2022-08-06 05:22:07 +00:00
|
|
|
>
|
2023-07-27 15:53:47 -06:00
|
|
|
{videoSource}
|
2022-11-30 18:26:38 -07:00
|
|
|
{/* Only WebVTT captions can be displayed. */}
|
2023-08-03 22:36:27 -06:00
|
|
|
{captionUrls.map(i => <CaptionTrack key={i} src={i}/>)}
|
2026-04-14 15:00:49 -06:00
|
|
|
</video>}
|
2022-08-06 05:22:07 +00:00
|
|
|
|
ui: pages own the space between their blocks
Panels shared edges: two 1px borders meeting, which reads as one tall
surface with a rule across it rather than a seam between two.
Done as `margin-bottom` on the panel first, which is the anti-pattern, and
it failed in both of the ways that rule is known to fail before the reading
was done. It compounded with the gap of every Stack that already held
panels -- four of them, spacing those lists at 35.2px against the app's
17.6px -- and the `:last-child` reset meant to keep trailing space off the
bottom of a container silently did nothing, because Media wrapping makes a
panel the only child of its own wrapper. On Status that separated four
pairs out of five and left the first touching.
So the space belongs to whatever stacks the blocks. `.wrolpi-stack` is on
PageContainer, which every page uses, and on the three wrappers that stack
blocks somewhere the page's own stack cannot reach: Settings' panel wrapper,
the block below the video player, and the Zim and Map route wrappers, which
hold their tab bar outside PageContainer.
A gap rather than `> * + * { margin-top }`, which was tried and is quietly
broken here: Media injects `.fresnel-container { margin: 0; padding: 0 }` at
runtime, same specificity, later source order, so every wrapped block threw
the margin away. A child cannot zero its parent's gap. It also means
Media's hidden half contributes nothing, where the owl selector spaced
around something invisible.
With the page owning the spacing, the blocks that owned some of it had to
give it up, or their margin was added to the gap: the tab bar (33px against
17.6 everywhere else), the shared search control bar and paginator on
Videos/Archives/Docs/Files, the card grid, the file browser's filter row and
the inventory search. Two margins deliberately stay -- the file browser's
4em, which reserves room for the sticky buttons (62645831), and heading
margins, which bind a heading to the content below it.
Tests plant each of the three failures: the wrapped block, a child that
zeroes its own margin, and a hidden Media half. Verified in the browser on
sixteen routes and in all four themes -- every stacked pair 17.6px, the
map's 85vh box and the video player unchanged, no horizontal overflow.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 15:40:27 -06:00
|
|
|
{/* `wrolpi-stack`: everything below the player is stacked in here rather than in the
|
|
|
|
|
page, so this is what spaces it. */}
|
|
|
|
|
<div className='wrolpi-stack' style={{marginTop: '1em'}}>
|
2026-07-30 13:07:09 -06:00
|
|
|
<Panel>
|
2022-08-06 05:22:07 +00:00
|
|
|
|
2023-09-07 13:00:54 -06:00
|
|
|
<Header as='h2'>{title}</Header>
|
2024-10-08 17:15:48 -06:00
|
|
|
{videoFile.published_datetime && <h3>{isoDatetimeToAgoPopup(videoFile.published_datetime)}</h3>}
|
2022-08-06 05:22:07 +00:00
|
|
|
<h3>
|
|
|
|
|
{channel && <Link to={`/videos/channel/${channel.id}/video`}>
|
|
|
|
|
{channel.name}
|
|
|
|
|
</Link>}
|
|
|
|
|
</h3>
|
|
|
|
|
|
review: the scan the first two commits needed
Five findings, all valid. The substantive one: the video page's Download /
Delete / Refresh / AddToPlaylist strip was still four bare buttons in a `<p>` --
the direct analogue of the archive row this PR started with -- and the scan that
was supposed to catch exactly that reported the app clean.
It only ever saw `{fooButton}` interpolations, and most of the app writes its
buttons out in place. Scanning for adjacent button ELEMENTS finds twelve more
rows in the same state: reorder icons in the playlist and field-schema tables,
both service tables on the controller page, its hotspot Save/QR pair and its
Restart/Shutdown pair, the downloads footer, the one-time pad's Generate/Cheat
Sheet, and the ration calculator's CSV/Print. All rowed.
Two holes had to be closed before that scan could be trusted, because a scan
that reports noise is worse than one with a stated limit:
- `tagsIn` never captured the tag NAME, so `ROW_COMPONENTS.has(undefined)` was
false for every tag and the list of components that lay out their own
children -- Group, ButtonGroup, Modal.Actions -- silently accepted none of
them. 56 false positives, every modal footer in the app among them.
- A row whose style is a const (`style={seasonRowStyle}`) says nothing in its
own attributes. Resolved now; the dates selector's seasons row is a
four-column grid with a gap and was reported three times.
Also from review: the row body is found by walking to the MATCHING close rather
than the first `</div>`, which one nested div would have truncated -- and the
collection form now nests one, so this was about to matter. Cancel and Save
travel together in a row of their own pushed to the end; `margin-left: auto` on
Save alone was right for a row that could not wrap, and would now drop Save onto
a second line by itself with Cancel left among the action buttons. The doc
page's comment no longer implies the picker's 1em separation was not a change.
One more found on the way: the file browser's filter row is flex with no gap, and
its collapse-all button carried `margin-left: 0.5em` for it. The gap is the
container's.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 17:06:56 -06:00
|
|
|
<div className='wrolpi-button-row'>
|
2026-07-30 13:07:09 -06:00
|
|
|
<Button component='a' href={downloadUrl} icon='download'>
|
2023-07-21 15:14:09 -06:00
|
|
|
Download
|
|
|
|
|
</Button>
|
|
|
|
|
<APIButton
|
2026-07-30 13:07:09 -06:00
|
|
|
role='danger'
|
2023-07-21 15:14:09 -06:00
|
|
|
confirmContent='Are you sure you want to delete this video? All files related to this video will be deleted. It will not be downloaded again!'
|
2022-08-06 05:22:07 +00:00
|
|
|
confirmButton='Delete'
|
2026-03-20 15:38:32 -06:00
|
|
|
onClick={async () => await handleDeleteVideo(videoFile.id)}
|
2023-07-21 15:14:09 -06:00
|
|
|
obeyWROLMode={true}
|
|
|
|
|
>Delete</APIButton>
|
2024-02-20 13:47:12 -07:00
|
|
|
<APIButton
|
2026-07-30 13:07:09 -06:00
|
|
|
role='primary'
|
2024-02-20 13:47:12 -07:00
|
|
|
onClick={handleRefresh}
|
2024-02-20 15:15:23 -07:00
|
|
|
obeyWROLMode={true}
|
|
|
|
|
disabled={!videoFile.url}
|
2024-02-20 13:47:12 -07:00
|
|
|
>Refresh</APIButton>
|
Add ordered collections (playlists): polymorphic items + item API (#475)
* Add Playlists: ordered, mixed-type collections
A playlist (Collection kind='playlist') is a manually-curated, ordered list that
mixes item types. Squash of the playlists feature branch (24 commits).
Data model & API:
- CollectionItem is polymorphic via item_kind: 'file' (FileGroup), 'zim'
(zim_id + zim_entry), or 'url' (link to anything the WROLPi browser opens,
e.g. /map?lat=&lon=&z=). CHECK constraint enforces exactly one kind; per-kind
unique constraints; migration a7b1c2d3e4f5.
- Endpoints: create playlist; add/remove/reorder items (idempotent adds: 201 new,
200 existing); GET returns the ordered items. All mutations wrol_mode_check'd.
Config (source of truth):
- playlists.yaml (PlaylistsConfig) stores each playlist's metadata AND ordered
items (file by relative path, zim by path+entry, url inline); round-trips a
DB wipe. Supports backup import (DB_CONFIG_FILE_NAMES).
- The redundant generic CollectionsConfig (collections.yaml) is deleted:
channels/domains own their configs, authors/subjects are re-derived.
On-disk sync (sync_playlists_directory switch):
- Each playlist materializes into the configurable Playlists Directory
(playlists_destination, Settings UI input, excluded from indexing) with
position-prefixed entries: NNNN_<file> hard links (copy fallback across
filesystems) and NNNN_<title>.html stubs for zim/url items.
- Tagged playlists are namespaced like channels: <playlists>/<tag>/<name>;
a tag change moves the directory and prunes the empty old tag dir.
- Deletion safety: managed files are only removed when they are our marked
stubs or still have another hard link (st_nlink > 1) -- never a last copy.
Stray loose files at the playlists root are removed; stub URLs are
scheme-allowlisted (no javascript:/data:).
Frontend:
- /playlists list page (CollectionTable, name filter, New Playlist modal, Tag
column) between Files and Zim in the nav.
- View-only detail page (Name link) and edit page (Edit button): themed table
with model icons/colors + poster thumbnails, items link to their model page
(video/archive/doc) or preview, up/down reorder, remove, add-URL form,
single-tag selector; all editing disabled in WROL Mode.
- Reusable green "Add to Playlist" button on Video/Archive/Doc detail pages,
the FilePreview toolbar, Zim search results, and Map pins (added as a /map
URL item with a map-marker icon).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Playlist edit page parity: rename, custom directory, tag modal move suggestion
Match the ChannelEditPage/DomainEditPage UX on the playlist edit page:
Back/View buttons, an edit form (name, description, directory), and the
shared CollectionTagModal with the violet "Tag" button. The tag modal now
suggests moving the playlist to its managed tag location
(playlists/<tag>/<name>); accepting the suggestion stores directory=None so
the sync keeps auto-managing the location. Tag buttons on the Channel and
Domain edit pages are now violet to match.
Backend: update_collection learns rename (with per-kind validation and
duplicate checks) and playlist custom directories (cleanup of the abandoned
directory, config round-trip, commit-before-switch to avoid the background
sync racing pre-commit state). tag_collection's duplicated untag/tag
branches are merged, and the per-kind config-save dispatch is consolidated
into _activate_config_save().
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Deduplicate Collection error handling and Tag creation
Delete the duplicate UnknownCollection in wrolpi/collections/errors.py and
re-export the canonical one from wrolpi/errors.py, which carries
status_code=NOT_FOUND (the local copy inherited 500). Replace the repeated
query/raise pattern in reorganize.py with Collection.find_by_id.
Add Tag.get_or_create_tag and use it for collection tagging; flush the new
Tag before returning so callers can read .id immediately -- previously
tagging a collection with a brand-new tag name set tag_id=None. Regression
test included.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 19:37:34 -06:00
|
|
|
<AddToPlaylistButton fileGroupId={videoFile.id}/>
|
review: the scan the first two commits needed
Five findings, all valid. The substantive one: the video page's Download /
Delete / Refresh / AddToPlaylist strip was still four bare buttons in a `<p>` --
the direct analogue of the archive row this PR started with -- and the scan that
was supposed to catch exactly that reported the app clean.
It only ever saw `{fooButton}` interpolations, and most of the app writes its
buttons out in place. Scanning for adjacent button ELEMENTS finds twelve more
rows in the same state: reorder icons in the playlist and field-schema tables,
both service tables on the controller page, its hotspot Save/QR pair and its
Restart/Shutdown pair, the downloads footer, the one-time pad's Generate/Cheat
Sheet, and the ration calculator's CSV/Print. All rowed.
Two holes had to be closed before that scan could be trusted, because a scan
that reports noise is worse than one with a stated limit:
- `tagsIn` never captured the tag NAME, so `ROW_COMPONENTS.has(undefined)` was
false for every tag and the list of components that lay out their own
children -- Group, ButtonGroup, Modal.Actions -- silently accepted none of
them. 56 false positives, every modal footer in the app among them.
- A row whose style is a const (`style={seasonRowStyle}`) says nothing in its
own attributes. Resolved now; the dates selector's seasons row is a
four-column grid with a gap and was reported three times.
Also from review: the row body is found by walking to the MATCHING close rather
than the first `</div>`, which one nested div would have truncated -- and the
collection form now nests one, so this was about to matter. Cancel and Save
travel together in a row of their own pushed to the end; `margin-left: auto` on
Save alone was right for a row that could not wrap, and would now drop Save onto
a second line by itself with Cancel left among the action buttons. The doc
page's comment no longer implies the picker's 1em separation was not a change.
One more found on the way: the file browser's filter row is flex with no gap, and
its collapse-all button carried `margin-left: 0.5em` for it. The gap is the
container's.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 17:06:56 -06:00
|
|
|
</div>
|
2026-07-30 13:07:09 -06:00
|
|
|
</Panel>
|
2023-03-24 08:58:18 -06:00
|
|
|
|
2026-07-30 13:07:09 -06:00
|
|
|
<Panel>
|
2023-04-05 14:48:13 -06:00
|
|
|
<TagsSelector selectedTagNames={videoFile['tags']} onAdd={localAddTag} onRemove={localRemoveTag}/>
|
2026-07-30 13:07:09 -06:00
|
|
|
</Panel>
|
|
|
|
|
|
|
|
|
|
<Panel>
|
|
|
|
|
<Header as='h2'>About Video</Header>
|
|
|
|
|
|
|
|
|
|
<Grid>
|
|
|
|
|
<Grid.Col span={6}>
|
|
|
|
|
<h3>Size</h3>
|
|
|
|
|
<p>{videoFile.size ? humanFileSize(videoFile.size) : 'Unknown'}</p>
|
|
|
|
|
</Grid.Col>
|
|
|
|
|
<Grid.Col span={6}>
|
|
|
|
|
<h3>View Count</h3>
|
|
|
|
|
<p>{video.view_count ? humanNumber(video.view_count) : 'N/A'}</p>
|
|
|
|
|
</Grid.Col>
|
|
|
|
|
<Grid.Col span={6}>
|
|
|
|
|
<h3>Codec Names</h3>
|
|
|
|
|
<>{video.codec_names ? video.codec_names.map(i => <Label key={i}>{i}</Label>) : 'N/A'}</>
|
|
|
|
|
</Grid.Col>
|
|
|
|
|
<Grid.Col span={6}>
|
|
|
|
|
<h3>Censored</h3>
|
|
|
|
|
<p>{videoFile.censored ? 'Yes' : 'No'}</p>
|
|
|
|
|
</Grid.Col>
|
|
|
|
|
<Grid.Col span={12}>
|
|
|
|
|
<h3>Source URL</h3>
|
|
|
|
|
<p>{videoFile.url ? <a href={videoFile.url}>{videoFile.url}</a> : 'N/A'}</p>
|
|
|
|
|
</Grid.Col>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Panel>
|
|
|
|
|
|
|
|
|
|
<Tabs value={activeTab} onChange={setActiveTab} keepMounted={false}>
|
|
|
|
|
<Tabs.List>
|
|
|
|
|
<Tabs.Tab value='comments'>Comments</Tabs.Tab>
|
|
|
|
|
<Tabs.Tab value='description'>Description</Tabs.Tab>
|
|
|
|
|
<Tabs.Tab value='files'>Files</Tabs.Tab>
|
|
|
|
|
<Tabs.Tab value='captions'>Captions</Tabs.Tab>
|
|
|
|
|
</Tabs.List>
|
|
|
|
|
|
|
|
|
|
<Tabs.Panel value='comments' style={{paddingTop: '1em'}}>
|
|
|
|
|
<Header as='h3'>Top Comments</Header>
|
|
|
|
|
<Comments comments={comments} video={videoFile}/>
|
|
|
|
|
</Tabs.Panel>
|
|
|
|
|
|
|
|
|
|
<Tabs.Panel value='description' style={{paddingTop: '1em'}}>
|
|
|
|
|
<pre className="wrap-text">
|
|
|
|
|
{description}
|
|
|
|
|
</pre>
|
|
|
|
|
</Tabs.Panel>
|
|
|
|
|
|
|
|
|
|
<Tabs.Panel value='files' style={{paddingTop: '1em'}}>
|
|
|
|
|
<table style={tableStyle}>
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style={labelStyle}><strong>{isAudio ? 'Audio File' : 'Video File'}</strong></td>
|
|
|
|
|
<td>
|
|
|
|
|
{video['video_path']
|
|
|
|
|
? <><PreviewPath path={video['video_path']} mimetype={isAudio ? 'audio/*' : 'video/*'} taggable={false}>
|
|
|
|
|
{video['video_path']}
|
|
|
|
|
</PreviewPath>{fileSize(videoPathFile)}</>
|
|
|
|
|
: 'Unknown'}
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
<td style={labelStyle}><strong>Caption Files</strong></td>
|
|
|
|
|
<td>
|
|
|
|
|
{caption_files
|
|
|
|
|
? caption_files.map(i => <div key={i['path']} style={{marginBottom: '0.3em'}}>
|
|
|
|
|
<PreviewPath {...i} taggable={false}>{i['path']}</PreviewPath>
|
|
|
|
|
{fileSize(i)}
|
|
|
|
|
</div>)
|
|
|
|
|
: 'No caption files'}
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
<td style={labelStyle}><strong>Poster File</strong></td>
|
|
|
|
|
<td>
|
|
|
|
|
{poster_file
|
|
|
|
|
? <><PreviewPath path={poster_file['path']} mimetype={poster_file['mimetype']}
|
|
|
|
|
taggable={false}>
|
|
|
|
|
{poster_file['path']}
|
|
|
|
|
</PreviewPath>{fileSize(poster_file)}</>
|
|
|
|
|
: 'No poster file'}
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
<td style={labelStyle}><strong>Info JSON File</strong></td>
|
|
|
|
|
<td>
|
|
|
|
|
{info_json_file
|
|
|
|
|
? <><PreviewPath path={info_json_file['path']} mimetype={info_json_file['mimetype']}
|
|
|
|
|
taggable={false}>
|
|
|
|
|
{info_json_file['path']}
|
|
|
|
|
</PreviewPath>{fileSize(info_json_file)}</>
|
|
|
|
|
: 'No yt-dlp info json file'}
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
<td style={labelStyle}><strong>ffprobe JSON File</strong></td>
|
|
|
|
|
<td>
|
|
|
|
|
{ffprobeJsonFile
|
|
|
|
|
? <><PreviewPath path={ffprobeJsonFile['path']} mimetype={ffprobeJsonFile['mimetype']}
|
|
|
|
|
taggable={false}>
|
|
|
|
|
{ffprobeJsonFile['path']}
|
|
|
|
|
</PreviewPath>{fileSize(ffprobeJsonFile)}</>
|
|
|
|
|
: 'No ffprobe json file'}
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
|
<td style={labelStyle}><strong>Directory</strong></td>
|
|
|
|
|
<td><DirectoryLink path={videoFile['directory']}/></td>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</Tabs.Panel>
|
|
|
|
|
|
|
|
|
|
<Tabs.Panel value='captions' style={{paddingTop: '1em'}}>
|
|
|
|
|
<CaptionsPane
|
|
|
|
|
captions={captions}
|
|
|
|
|
captionsLoading={captionsLoading}
|
|
|
|
|
fetchCaptions={fetchCaptions}
|
|
|
|
|
setVideoTime={setVideoTime}
|
|
|
|
|
/>
|
|
|
|
|
</Tabs.Panel>
|
|
|
|
|
</Tabs>
|
|
|
|
|
|
|
|
|
|
{prevNextVideosPanel}
|
|
|
|
|
</div>
|
2026-05-03 17:28:06 -06:00
|
|
|
<TaggedDeleteConfirmModal
|
|
|
|
|
open={taggedFileGroups !== null}
|
|
|
|
|
taggedFileGroups={taggedFileGroups}
|
|
|
|
|
onCancel={() => setTaggedFileGroups(null)}
|
|
|
|
|
onConfirm={async () => {
|
|
|
|
|
setTaggedFileGroups(null);
|
|
|
|
|
await handleDeleteVideo(videoFile.id, true);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-02-17 16:09:24 -07:00
|
|
|
</>
|
2021-11-01 16:42:52 -06:00
|
|
|
}
|
|
|
|
|
|
2026-03-21 16:50:27 -06:00
|
|
|
function formatCaptionTimestamp(totalSeconds) {
|
|
|
|
|
totalSeconds = Math.floor(totalSeconds);
|
|
|
|
|
const hours = Math.floor(totalSeconds / 3600);
|
|
|
|
|
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
|
|
|
const seconds = totalSeconds % 60;
|
|
|
|
|
const pad2 = (n) => String(n).padStart(2, '0');
|
|
|
|
|
if (hours > 0) {
|
|
|
|
|
return `${hours}:${pad2(minutes)}:${pad2(seconds)}`;
|
|
|
|
|
}
|
|
|
|
|
return `${minutes}:${pad2(seconds)}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function CaptionsPane({captions, captionsLoading, fetchCaptions, setVideoTime}) {
|
|
|
|
|
const [filter, setFilter] = useState('');
|
|
|
|
|
|
|
|
|
|
// Trigger fetch on first render of this pane.
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
fetchCaptions();
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
if (captionsLoading) {
|
2026-07-30 13:07:09 -06:00
|
|
|
return <Loading/>;
|
2026-03-21 16:50:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!captions || captions.length === 0) {
|
2026-07-30 13:07:09 -06:00
|
|
|
return <div>No captions available.</div>;
|
2026-03-21 16:50:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let filtered = captions;
|
|
|
|
|
if (filter.trim()) {
|
|
|
|
|
const words = filter.toLowerCase().split(/\s+/).filter(Boolean);
|
|
|
|
|
filtered = captions.filter(chunk => {
|
|
|
|
|
const text = chunk.text.toLowerCase();
|
|
|
|
|
return words.every(word => text.includes(word));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 13:07:09 -06:00
|
|
|
return <>
|
|
|
|
|
<TextInput
|
|
|
|
|
leftSection={<Icon name='filter' size={14}/>}
|
2026-03-21 16:50:27 -06:00
|
|
|
placeholder='Filter captions...'
|
|
|
|
|
value={filter}
|
2026-07-30 13:07:09 -06:00
|
|
|
onChange={(e) => setFilter(e.currentTarget.value)}
|
|
|
|
|
style={{marginBottom: '1em', width: '100%'}}
|
2026-03-21 16:50:27 -06:00
|
|
|
/>
|
|
|
|
|
<div style={{maxHeight: '400px', overflowY: 'auto'}}>
|
|
|
|
|
{filtered.map((chunk, idx) => (
|
|
|
|
|
<div key={idx} style={{display: 'flex', gap: '1em', marginBottom: '0.4em'}}>
|
|
|
|
|
<a href='#'
|
|
|
|
|
onClick={(e) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
setVideoTime(chunk.start_seconds);
|
|
|
|
|
}}
|
2026-07-30 13:07:09 -06:00
|
|
|
style={{whiteSpace: 'nowrap', fontFamily: 'var(--font-mono)'}}
|
2026-03-21 16:50:27 -06:00
|
|
|
>
|
|
|
|
|
{formatCaptionTimestamp(chunk.start_seconds)}
|
|
|
|
|
</a>
|
|
|
|
|
<span>{chunk.text}</span>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
2026-07-30 13:07:09 -06:00
|
|
|
</>;
|
2026-03-21 16:50:27 -06:00
|
|
|
}
|
|
|
|
|
|
2021-11-01 16:42:52 -06:00
|
|
|
export default VideoPage;
|
2022-11-15 15:03:12 -07:00
|
|
|
|
2023-10-31 10:20:45 -06:00
|
|
|
const chapterRegex = new RegExp('^(\\(?(?:((\\d?\\d):)?(?:(\\d?\\d):(\\d\\d)))\\)?)\.?\\s+(.*)$', 'i');
|
2022-11-15 15:03:12 -07:00
|
|
|
|
2023-09-07 13:00:54 -06:00
|
|
|
function formatVideoDescription(description, setVideoTime) {
|
|
|
|
|
// Convert timestamps to links which change the video's playback location. Change hashtags to search links.
|
2022-11-15 15:03:12 -07:00
|
|
|
if (description && description.length > 0) {
|
|
|
|
|
try {
|
|
|
|
|
const lines = _.split(description, '\n');
|
|
|
|
|
let newLines = [];
|
|
|
|
|
for (let i = 0; i <= lines.length; i++) {
|
|
|
|
|
const line = lines[i];
|
|
|
|
|
const match = line ? line.match(chapterRegex) : null;
|
|
|
|
|
let link;
|
|
|
|
|
if (match) {
|
2022-11-16 12:50:38 -07:00
|
|
|
// This line in the description starts with a chapter timestamp, parse it and create a link.
|
2022-11-15 15:03:12 -07:00
|
|
|
try {
|
|
|
|
|
const timestamp = match[1];
|
|
|
|
|
const title = match[6];
|
2022-11-16 12:50:38 -07:00
|
|
|
// Assume 0 if no part of timestamp could be found.
|
2022-11-15 15:03:12 -07:00
|
|
|
const [hour, minute, second] = match.slice(3, 6).map(i => parseInt(i) || 0);
|
2022-11-16 12:50:38 -07:00
|
|
|
// Convert timestamp to seconds.
|
2022-11-15 15:03:12 -07:00
|
|
|
const seconds = (((hour * 60) + minute) * 60) + second;
|
|
|
|
|
link = <>
|
|
|
|
|
<a href='#' onClick={() => setVideoTime(seconds)}>{timestamp}</a>
|
|
|
|
|
{title}
|
|
|
|
|
</>;
|
|
|
|
|
} catch (e) {
|
2022-11-16 12:50:38 -07:00
|
|
|
// Report an error while creating timestamp link.
|
2022-11-15 15:03:12 -07:00
|
|
|
console.error(e);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-16 12:50:38 -07:00
|
|
|
// Use the link if we could create it, otherwise fallback to the original `line`.
|
2023-09-07 13:00:54 -06:00
|
|
|
newLines = [...newLines, link || hashtagLinks(line)];
|
2022-11-15 15:03:12 -07:00
|
|
|
} else if (line !== undefined) {
|
2022-11-16 12:50:38 -07:00
|
|
|
// Line does not start with a timestamp.
|
2023-09-07 13:00:54 -06:00
|
|
|
newLines = [...newLines, hashtagLinks(line)];
|
2022-11-15 15:03:12 -07:00
|
|
|
}
|
|
|
|
|
}
|
2022-11-16 12:50:38 -07:00
|
|
|
// Map all lines and links with a break between.
|
2022-11-15 15:03:12 -07:00
|
|
|
return <>
|
|
|
|
|
{newLines.map((i, idx) => <div key={idx}>{i}<br/></div>)}
|
|
|
|
|
</>;
|
|
|
|
|
} catch (e) {
|
2022-11-16 12:50:38 -07:00
|
|
|
// Some error happened while parsing description. Report it but don't fail.
|
2022-11-15 15:03:12 -07:00
|
|
|
console.error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-16 12:50:38 -07:00
|
|
|
// Error occurred, or no description, don't fail.
|
2022-11-15 15:03:12 -07:00
|
|
|
return description;
|
2023-09-07 13:00:54 -06:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const hashtagRegex = /(#+[_a-zA-Z0-9]+)/ig;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function hashtagLinks(text) {
|
|
|
|
|
// Converts a string into a div which has hashtags converted to search links.
|
|
|
|
|
// Example: Some text <a href="/search?q=#hashtag">#hashtag</a> the rest of the text
|
|
|
|
|
if (text && text.length > 0) {
|
|
|
|
|
const parts = text.split(hashtagRegex);
|
|
|
|
|
let newParts = '';
|
|
|
|
|
for (let i = 0; i < parts.length; i++) {
|
|
|
|
|
let part = parts[i];
|
|
|
|
|
part = part.startsWith('#') ?
|
|
|
|
|
// Part is a hashtag.
|
|
|
|
|
<a key={i} href={`/search?q=${encodeURIComponent(part)}`} target="_self">{part}</a>
|
|
|
|
|
// Part is not a hashtag.
|
|
|
|
|
: <span key={i}>{part}</span>;
|
|
|
|
|
newParts = [...newParts, part];
|
|
|
|
|
}
|
|
|
|
|
return <React.Fragment>{newParts}</React.Fragment>;
|
|
|
|
|
}
|
|
|
|
|
return text;
|
2022-11-15 15:03:12 -07:00
|
|
|
}
|