2024-11-02 15:14:02 -06:00
|
|
|
export const API_URI = process.env && process.env.REACT_APP_API_URI ? process.env.REACT_APP_API_URI : `https://${window.location.host}/api`;
|
|
|
|
|
export const VIDEOS_API = `${API_URI}/videos`;
|
|
|
|
|
export const ARCHIVES_API = `${API_URI}/archive`;
|
2025-10-29 22:16:33 -06:00
|
|
|
export const COLLECTIONS_API = `${API_URI}/collections`;
|
2024-11-02 15:14:02 -06:00
|
|
|
export const ZIM_API = `${API_URI}/zim`;
|
|
|
|
|
export const DEFAULT_LIMIT = 20;
|
|
|
|
|
export const NAME = process.env && process.env.REACT_APP_NAME ? process.env.REACT_APP_NAME : null;
|
|
|
|
|
|
|
|
|
|
// Other services on a WROLPi.
|
2024-12-20 11:14:01 -07:00
|
|
|
const port = window.location.port ? `${window.location.port.replace(/^/, '')}` : '';
|
2026-04-07 20:01:49 -06:00
|
|
|
export const FILES_MEDIA_URI = `https://${window.location.hostname}${port ? ':' + port : ''}/media/`;
|
2024-11-02 15:14:02 -06:00
|
|
|
export const MAP_VIEWER_URI = `https://${window.location.hostname}:8084`;
|
|
|
|
|
export const ZIM_VIEWER_URI = `https://${window.location.hostname}:8085`;
|
|
|
|
|
export const HELP_VIEWER_URI = `https://${window.location.hostname}:8086`;
|
2026-04-07 20:01:49 -06:00
|
|
|
// Docker: 8080; native: 80 (default, no port needed).
|
|
|
|
|
const controllerPort = window.location.port === '8443' ? ':8080' : '';
|
|
|
|
|
export const CONTROLLER_URI = `http://${window.location.hostname}${controllerPort}`;
|
2025-01-26 12:44:16 -07:00
|
|
|
export const API_ARCHIVE_UPLOAD_URI = `http://${window.location.hostname}:8081/api/archive/upload`;
|
2024-11-02 15:14:02 -06:00
|
|
|
|
|
|
|
|
export let defaultFileOrder = '-published_datetime'; // Most recently published files first.
|
|
|
|
|
export let defaultSearchOrder = 'rank'; // Most relevant files first.
|
|
|
|
|
|
|
|
|
|
// Download frequencies.
|
|
|
|
|
export const nullOption = {key: null, text: '', value: null};
|
|
|
|
|
export const onceOption = {key: 0, text: 'Once', value: 0};
|
|
|
|
|
export const hourlyOption = {key: 3600, text: 'Hourly', value: 3600};
|
|
|
|
|
export const threeHoursOption = {key: 10800, text: '3 hours', value: 10800};
|
|
|
|
|
export const twelveHoursOption = {key: 43200, text: '12 hours', value: 43200};
|
|
|
|
|
export const dailyOption = {key: 86400, text: 'Daily', value: 86400};
|
|
|
|
|
export const weeklyOption = {key: 604800, text: 'Weekly', value: 604800};
|
|
|
|
|
export const biweeklyOption = {key: 1209600, text: 'Biweekly', value: 1209600};
|
|
|
|
|
export const days30Option = {key: 2592000, text: '30 Days', value: 2592000};
|
|
|
|
|
export const days90Option = {key: 7776000, text: '90 Days', value: 7776000};
|
|
|
|
|
export const days180Option = {key: 15552000, text: '180 Days', value: 15552000};
|
|
|
|
|
|
|
|
|
|
export const frequencyOptions = [
|
|
|
|
|
dailyOption,
|
|
|
|
|
weeklyOption,
|
|
|
|
|
biweeklyOption,
|
|
|
|
|
days30Option,
|
|
|
|
|
days90Option,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const longFrequencyOptions = [
|
|
|
|
|
dailyOption,
|
|
|
|
|
weeklyOption,
|
|
|
|
|
biweeklyOption,
|
|
|
|
|
days30Option,
|
|
|
|
|
days90Option,
|
|
|
|
|
days180Option,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const channelFrequencyOptions = [
|
|
|
|
|
onceOption, // A Channel/Playlist can be downloaded once.
|
|
|
|
|
...longFrequencyOptions,
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
export const extendedFrequencyOptions = [
|
|
|
|
|
onceOption,
|
|
|
|
|
hourlyOption,
|
|
|
|
|
threeHoursOption,
|
|
|
|
|
twelveHoursOption,
|
|
|
|
|
...longFrequencyOptions,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const allFrequencyOptions = {
|
|
|
|
|
[nullOption.value]: nullOption,
|
|
|
|
|
[onceOption.value]: onceOption,
|
|
|
|
|
[hourlyOption.value]: hourlyOption,
|
|
|
|
|
[threeHoursOption.value]: threeHoursOption,
|
|
|
|
|
[twelveHoursOption.value]: twelveHoursOption,
|
|
|
|
|
[dailyOption.value]: dailyOption,
|
|
|
|
|
[weeklyOption.value]: weeklyOption,
|
|
|
|
|
[biweeklyOption.value]: biweeklyOption,
|
|
|
|
|
[days30Option.value]: days30Option,
|
|
|
|
|
[days90Option.value]: days90Option,
|
|
|
|
|
[days180Option.value]: days180Option,
|
|
|
|
|
};
|
|
|
|
|
|
ui: the last of Semantic UI, in name and in dead CSS
The library has been uninstalled for some time, but the codebase still read as
though it were there: identifiers named after it, rules written against its
class names, and about 180 comments explaining a rule in terms of a thing that
is no longer installed.
Renamed, keeping the vocabulary the app actually uses: semanticUIColorMap ->
navColorHexMap, semanticColorNames -> paletteColorNames, semanticNames ->
iconNameAliases, semanticSizes -> sizeAliases, and SemanticUIColors ->
NavColors in wrolpi/schema.py, which is what validates nav_color on the way in.
ColorToSemanticHexColor had no callers at all and is gone.
The baseline ratchet has done its job -- the list reached zero, so the JSON is
deleted and the guard keeps only the checks with teeth: no package, no import,
no `className="ui "`, no toast library. Its Theme.tsx check went with the
wrappers it was watching for. It also asserts its own walk found files, so a
clean result cannot mean it scanned nothing.
Deleted from App.css: every rule requiring `.ui`, `.inverted`, `.segment` or
`.modal`, none of which any component has set since the stylesheet stopped
loading, plus the form skeletons, ui-alerts and progress-text rules that
nothing renders. Two of them were doing harm rather than nothing: the drag
tints had a dark-theme variant under `.inverted` that stopped applying, leaving
15% of a fixed blue over a dark row, and now mix a token instead.
Two selectors naming markup that no longer exists were live bugs. The file
browser's filter had `.ui.input.file-browser-filter`, so it rendered at the
browser default width on a bar laid out to give it 34em -- now qualified by its
container, because `.wrolpi-action-input` sets `width: 100%` at the same
specificity and is loaded later. And SearchBox takes named props rather than a
rest spread, so the `id` DestinationForm hands it was dropped in silence and
the label it renders pointed at nothing; the download forms' Destination field
has had no associated label since the migration.
"Semantic roles" survives in four places, where it means what it says.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 19:15:57 -06:00
|
|
|
/*
|
|
|
|
|
* The named colors a user can pick for the navigation bar, and the fixed hex each one is.
|
|
|
|
|
*
|
|
|
|
|
* Fixed, and deliberately not tokens: these are the colors of the favicon files in
|
|
|
|
|
* `public/favicon-<color>.svg`, which `scripts/generate-favicons.js` writes from this very
|
|
|
|
|
* object, and of the `theme-color` meta tag the mobile browser paints its own chrome with.
|
|
|
|
|
* Neither can read a CSS variable, so both need a literal that cannot drift from the bar.
|
|
|
|
|
*
|
|
|
|
|
* The palette is a colorblind-friendly one and is shared with `themes/navColors.ts`, which
|
|
|
|
|
* measures a legible foreground against each.
|
|
|
|
|
*/
|
|
|
|
|
export const navColorHexMap = {
|
2024-11-02 15:14:02 -06:00
|
|
|
red: '#db2828',
|
|
|
|
|
orange: '#f2711c',
|
|
|
|
|
yellow: '#fbbd08',
|
|
|
|
|
olive: '#b5cc18',
|
|
|
|
|
green: '#21ba45',
|
|
|
|
|
teal: '#00b5ad',
|
|
|
|
|
blue: '#2185d0',
|
|
|
|
|
violet: '#6435c9',
|
|
|
|
|
purple: '#a333c8',
|
|
|
|
|
pink: '#e03997',
|
|
|
|
|
brown: '#a5673f',
|
|
|
|
|
grey: '#767676',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const validUrlRegex = /^(http|https):\/\/[^ "]+$/;
|
|
|
|
|
|
|
|
|
|
export const downloadOrderOptions = [
|
|
|
|
|
{key: 'newest', text: 'Newest', value: 'newest'},
|
|
|
|
|
{key: 'oldest', text: 'Oldest', value: 'oldest'},
|
2026-07-07 15:40:37 -06:00
|
|
|
{key: 'views', text: 'Most Views', value: 'views'},
|
2024-11-02 15:14:02 -06:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const downloadResolutionOptions = [
|
|
|
|
|
{key: '360p', text: '360p', value: '360p'},
|
|
|
|
|
{key: '480p', text: '480p', value: '480p'},
|
|
|
|
|
{key: '720p', text: '720p', value: '720p'},
|
|
|
|
|
{key: '1080p', text: '1080p', value: '1080p'},
|
|
|
|
|
{key: '1440p', text: '1440p', value: '1440p'},
|
|
|
|
|
{key: '2160p', text: '2160p', value: '2160p'},
|
|
|
|
|
{key: 'maximum', text: 'Maximum', value: 'maximum'},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
export const defaultVideoResolutionOptions = ['1080p', '720p', '480p', 'maximum'];
|
|
|
|
|
|
|
|
|
|
export const downloadFormatOptions = [
|
|
|
|
|
{key: 'mp4', text: '.mp4', value: 'mp4'},
|
|
|
|
|
{key: 'mkv', text: '.mkv', value: 'mkv'},
|
2026-04-14 15:00:49 -06:00
|
|
|
{key: 'ogg', text: '.ogg', value: 'ogg'},
|
|
|
|
|
{key: 'webm', text: '.webm', value: 'webm'},
|
2024-11-02 15:14:02 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
export const defaultVideoFormatOption = 'mp4';
|
|
|
|
|
|
2026-04-14 15:00:49 -06:00
|
|
|
export const downloadAudioFormatOptions = [
|
|
|
|
|
{key: 'mp3', text: '.mp3', value: 'mp3'},
|
|
|
|
|
{key: 'opus', text: '.opus', value: 'opus'},
|
|
|
|
|
{key: 'm4a', text: '.m4a', value: 'm4a'},
|
|
|
|
|
{key: 'flac', text: '.flac', value: 'flac'},
|
|
|
|
|
{key: 'vorbis', text: '.ogg', value: 'vorbis'},
|
|
|
|
|
{key: 'wav', text: '.wav', value: 'wav'},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const defaultAudioFormatOption = 'mp3';
|
|
|
|
|
|
videos: codec download preferences with transcode and strict-fail options (#701)
* videos: codec download preferences with transcode and strict-fail options
Add video_codecs/audio_codecs ordered preference lists to the video,
channel, and RSS downloaders, alongside the existing resolution
selector. Codec preference is codec-major: a preferred codec at a
lower resolution beats another codec at a higher resolution.
When 'transcode' is enabled, a downloaded file whose streams do not
match the preferences is re-encoded with ffmpeg after download (only
the mismatching stream; targets are extensible maps, currently h264
and aac/opus/mp3). When 'strict_codecs' is enabled and transcode is
not, a download with no matching format fails permanently instead of
falling back.
Empty codec lists produce a byte-identical yt-dlp command to before.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* videos: honor strict_codecs when transcode cannot produce the preference
Review fixes:
- strict_codecs is now suppressed only when transcoding can produce a
preferred codec for every non-empty preference list (new
transcode_can_satisfy_codecs); av1-only preferences with transcode
enabled fail under strict instead of silently keeping the file.
- No partial transcode: an unfixable video mismatch blocks an
audio-only conversion (and vice versa); the mismatch falls through
to strict/keep.
- fsync the transcode output before rename, and the directory after,
so power loss on a Pi cannot leave a truncated final file.
- mp3 yt-dlp pattern matches mp4a.6B as well as mp4a.6b.
- ffmpeg maps use 0:V:0 (excludes attached pictures) and 0:a:0?
(tolerates missing audio).
- Strict toggle is no longer disabled by transcode in the UI; popup
wording corrected.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* videos: serialize transcodes machine-wide via shared_ctx lock
Sanic runs multiple worker processes, so an asyncio primitive cannot
serialize transcodes across download workers. A multiprocessing.Lock
in shared_ctx now guarantees only one ffmpeg transcode runs at a time
on the machine; waiting workers poll the lock asynchronously so the
event loop stays responsive while a transcode holds it for hours.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* videos: transcode-lock review fixes
- Document that a crashed lock holder requires an API restart; this is
accepted rather than adding owner-death recovery.
- Move the 'Transcoding' user notification to after the lock is
acquired, so it fires when work begins rather than before a
potentially hours-long wait.
- Soften the lock test docstring to what it measures (in-process
wait/release); trim the acquire docstring to the polling rationale.
- Give transcode_lock its own section header in contexts.py.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-07 09:11:39 -06:00
|
|
|
export const downloadVideoCodecOptions = [
|
|
|
|
|
{key: 'h264', text: 'h264 (avc1)', value: 'h264'},
|
|
|
|
|
{key: 'vp9', text: 'vp9', value: 'vp9'},
|
|
|
|
|
{key: 'av1', text: 'av1', value: 'av1'},
|
|
|
|
|
{key: 'vp8', text: 'vp8', value: 'vp8'},
|
|
|
|
|
{key: 'hevc', text: 'hevc (h265)', value: 'hevc'},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const downloadAudioCodecOptions = [
|
|
|
|
|
{key: 'aac', text: 'aac', value: 'aac'},
|
|
|
|
|
{key: 'opus', text: 'opus', value: 'opus'},
|
|
|
|
|
{key: 'mp3', text: 'mp3', value: 'mp3'},
|
|
|
|
|
{key: 'vorbis', text: 'vorbis', value: 'vorbis'},
|
|
|
|
|
];
|
|
|
|
|
|
Jobs queue, video Edit dropdown: transcode/remux, edit title & description (#711)
* Jobs queue and video transcode from the video page
Add an in-memory FIFO Job queue (wrolpi/jobs.py): functions register by
name, callers enqueue by name with JSON kwargs, and the perpetual-tasks
owner runs them one at a time. Logging emitted inside a Job and the
output of its subprocesses are captured into a per-Job log; Jobs report
progress and can be cancelled (a running Job's subprocess is killed).
Jobs are not persisted; an API restart forgets them.
Add a transcode Job and POST /api/videos/<id>/transcode. ffmpeg reports
progress via -progress pipe:1. The existing FileGroup is pointed at the
new file before the refresh so tags and history survive a container
change.
Replace the video page Refresh button with an Edit dropdown (Refresh,
Transcode). The Transcode modal pre-fills from the preferred codecs in
the Videos settings and shows the Job's progress, log tail and Cancel.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: move Delete into the Edit dropdown
The Edit dropdown now holds Refresh, Transcode and Delete, so the action
row is Download / Edit / Add to Playlist. Delete keeps its confirmation
(a Confirm dialog) and the tagged-files prompt, and is disabled in WROL
Mode like the other items.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: Edit > Edit to change a video's title
PUT /api/videos/<file_group_id> writes the title (and fulltitle) into the
Video's info json, creating the file when the video has none, then
validates the Video again so its title and search text follow. Files
stay the source of truth: the edit survives a refresh, and a re-download
of the metadata replaces it (the modal says so).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: edit the description in Edit > Edit
PUT /api/videos/<file_group_id> now takes optional title and description
and changes only the fields given; an empty description clears it. The
modal sends only what changed and refetches the description after saving.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode modal: allow a container-only remux
Keeping both streams is no longer refused: ffmpeg copies them into the
chosen container with fast start. The container select starts at the
file's own container, the hint explains what a remux does, and the button
reads Remux when nothing is re-encoded.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* WROL Mode: refuse video edits and transcodes past the API
The routes already returned 403, but a transcode Job queued before WROL
Mode was enabled still ran, update_video could be called from anywhere,
and the Edit modal's Save button stayed live. The Job now fails before
ffmpeg starts, update_video carries wrol_mode_check, and the modal
disables Save with a notice.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode: verify the output before replacing the original
After ffmpeg exits, the output is probed and compared with the source
(container, presence of video/audio streams, codec per stream, duration
within 1s or 1%) and its last 30 seconds are decoded to a null output.
Any failure removes the output and keeps the original.
The tail decode replaces the download-time completeness check, which
grabbed a single frame near the end: one ffmpeg_video_complete (sync for
the downloader, async for Jobs) now serves both, and is stricter, since
every frame of the tail plus the audio must decode.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Jobs: claim atomically, cap pending, own-session subprocesses; retarget before delete
Review fixes. The worker read a Job's status and wrote RUNNING as two
steps, so a cancel landing between them was overwritten and the Job ran;
_claim_job now does both under the lock. enqueue_job refuses past
JOB_PENDING_LIMIT pending Jobs. JobContext.run_command starts the
subprocess in its own session and raises CancelledError when the command
was killed, so a handler cannot mistake it for a normal exit.
The transcode Job now retargets the FileGroup (committed) while the
original file still exists, and deletes the original afterwards
(transcode_video_file gained keep_original). A crash in between leaves
both files with the database pointing at a real one.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: the Edit menu owns the transcode Job; polling survives Close and errors
Review fixes. The transcode Job's id and polling (useJob) move from the
modal to VideoEditMenu, so closing the modal no longer stops the page
from learning the Job finished (and refetching the video, whose path may
have changed). While a Job runs the menu shows Transcoding..., reopening
shows its progress instead of the form, and Delete waits. A failed poll
request is retried instead of ending the polling. getJobs checks the
response like its siblings. Design narration trimmed from comments.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode: audio files, and Remove video to turn a video into an audio file
video_codec 'none' (REMOVE_VIDEO) drops the video stream (-vn, audio
required); an audio-only source is audio-only output whatever the video
target says, and a video target on it is refused. Audio output gets an
audio container (m4a/ogg/mp3) checked against the codec it will hold, and
a video container asked for audio output is replaced by the codec's
natural one. faststart only for mp4/m4a. Verification learned the
audio-only shape and ffprobe's container names (mkv reports matroska).
The modal offers 'Remove video (audio only)', switches to audio
containers and follows the audio codec, reads Extract Audio, and opens
for audio files (no video codec select).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: yellow Edit button
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode: remove the temp output on cancel; tell the user when a closed-modal Job fails or is lost
Review fixes. The temp output was only removed on Exception, but a
cancelled Job's run_command raises CancelledError (a BaseException), so a
cancel left the partial file for a refresh to index. Closing the modal
during a Job that then failed showed nothing; it now toasts the error
(and a cancellation). Polling gives up on a 404 or five failures in a
row (the API restarted and forgot its Jobs), warning the user and
unlocking Transcode and Delete instead of reading Transcoding... forever.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Jobs: _claim_job docstring states the invariant, not the old race
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode: fragmented mp4 option for very long videos
A whole-file mp4 index grows with the frame count; for a many-hour video
it reaches tens of MB, which a phone must fetch and parse before the
first frame, and every seek walks it. `fragmented` writes the file with
-movflags +frag_keyframe+empty_moov+default_base_moof+global_sidx and
10s fragments: a ~1 KB moov plus a global seek index, so playback starts
and seeks quickly. mp4/m4a only; a remux, so it takes seconds per GB.
Measured on an 11-hour h264/aac file: moov 40 MB -> 1.4 KB, seek index
2 x 120 KB, 10k fragments, duration and codecs unchanged, remux in 25s.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode modal: the Fragmented label says audio for audio output
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video edits keep the original: custom_title/custom_description in the info json's wrolpi section
Editing a title or description no longer overwrites yt-dlp's keys. The
values go into the info json's `wrolpi` section (custom_title,
custom_description); the modeler prefers them when deriving the Video, so
a refresh keeps the edit while the original title and description stay in
the file. An empty custom description means none.
Both re-download paths carry the wrolpi section over: the metadata-only
refresh merges it into the fresh info json, and a full re-download
snapshots it before yt-dlp overwrites the file and restores it (then
re-validates) in finalize_download. FileGroup.get_wrolpi_json reads it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-16 19:25:23 -06:00
|
|
|
// Codecs WROLPi's ffmpeg step can produce. Mirrors TRANSCODE_VIDEO_TARGETS / TRANSCODE_AUDIO_TARGETS /
|
|
|
|
|
// TRANSCODE_CONTAINERS in modules/videos/transcode.py; the API rejects anything else.
|
|
|
|
|
export const TRANSCODE_COPY = 'copy';
|
|
|
|
|
// REMOVE_VIDEO in modules/videos/transcode.py: drop the video stream, the result is an audio file.
|
|
|
|
|
export const TRANSCODE_REMOVE_VIDEO = 'none';
|
|
|
|
|
export const transcodeVideoCodecOptions = [
|
|
|
|
|
{value: TRANSCODE_COPY, label: 'Keep (copy)'},
|
|
|
|
|
{value: 'h264', label: 'h264 (avc1)'},
|
|
|
|
|
{value: TRANSCODE_REMOVE_VIDEO, label: 'Remove video (audio only)'},
|
|
|
|
|
];
|
2026-09-26 17:49:00 -06:00
|
|
|
// REMOVE_AUDIO in modules/videos/transcode.py: drop the audio stream, the result is a silent video.
|
|
|
|
|
export const TRANSCODE_REMOVE_AUDIO = 'none';
|
Jobs queue, video Edit dropdown: transcode/remux, edit title & description (#711)
* Jobs queue and video transcode from the video page
Add an in-memory FIFO Job queue (wrolpi/jobs.py): functions register by
name, callers enqueue by name with JSON kwargs, and the perpetual-tasks
owner runs them one at a time. Logging emitted inside a Job and the
output of its subprocesses are captured into a per-Job log; Jobs report
progress and can be cancelled (a running Job's subprocess is killed).
Jobs are not persisted; an API restart forgets them.
Add a transcode Job and POST /api/videos/<id>/transcode. ffmpeg reports
progress via -progress pipe:1. The existing FileGroup is pointed at the
new file before the refresh so tags and history survive a container
change.
Replace the video page Refresh button with an Edit dropdown (Refresh,
Transcode). The Transcode modal pre-fills from the preferred codecs in
the Videos settings and shows the Job's progress, log tail and Cancel.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: move Delete into the Edit dropdown
The Edit dropdown now holds Refresh, Transcode and Delete, so the action
row is Download / Edit / Add to Playlist. Delete keeps its confirmation
(a Confirm dialog) and the tagged-files prompt, and is disabled in WROL
Mode like the other items.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: Edit > Edit to change a video's title
PUT /api/videos/<file_group_id> writes the title (and fulltitle) into the
Video's info json, creating the file when the video has none, then
validates the Video again so its title and search text follow. Files
stay the source of truth: the edit survives a refresh, and a re-download
of the metadata replaces it (the modal says so).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: edit the description in Edit > Edit
PUT /api/videos/<file_group_id> now takes optional title and description
and changes only the fields given; an empty description clears it. The
modal sends only what changed and refetches the description after saving.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode modal: allow a container-only remux
Keeping both streams is no longer refused: ffmpeg copies them into the
chosen container with fast start. The container select starts at the
file's own container, the hint explains what a remux does, and the button
reads Remux when nothing is re-encoded.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* WROL Mode: refuse video edits and transcodes past the API
The routes already returned 403, but a transcode Job queued before WROL
Mode was enabled still ran, update_video could be called from anywhere,
and the Edit modal's Save button stayed live. The Job now fails before
ffmpeg starts, update_video carries wrol_mode_check, and the modal
disables Save with a notice.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode: verify the output before replacing the original
After ffmpeg exits, the output is probed and compared with the source
(container, presence of video/audio streams, codec per stream, duration
within 1s or 1%) and its last 30 seconds are decoded to a null output.
Any failure removes the output and keeps the original.
The tail decode replaces the download-time completeness check, which
grabbed a single frame near the end: one ffmpeg_video_complete (sync for
the downloader, async for Jobs) now serves both, and is stricter, since
every frame of the tail plus the audio must decode.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Jobs: claim atomically, cap pending, own-session subprocesses; retarget before delete
Review fixes. The worker read a Job's status and wrote RUNNING as two
steps, so a cancel landing between them was overwritten and the Job ran;
_claim_job now does both under the lock. enqueue_job refuses past
JOB_PENDING_LIMIT pending Jobs. JobContext.run_command starts the
subprocess in its own session and raises CancelledError when the command
was killed, so a handler cannot mistake it for a normal exit.
The transcode Job now retargets the FileGroup (committed) while the
original file still exists, and deletes the original afterwards
(transcode_video_file gained keep_original). A crash in between leaves
both files with the database pointing at a real one.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: the Edit menu owns the transcode Job; polling survives Close and errors
Review fixes. The transcode Job's id and polling (useJob) move from the
modal to VideoEditMenu, so closing the modal no longer stops the page
from learning the Job finished (and refetching the video, whose path may
have changed). While a Job runs the menu shows Transcoding..., reopening
shows its progress instead of the form, and Delete waits. A failed poll
request is retried instead of ending the polling. getJobs checks the
response like its siblings. Design narration trimmed from comments.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode: audio files, and Remove video to turn a video into an audio file
video_codec 'none' (REMOVE_VIDEO) drops the video stream (-vn, audio
required); an audio-only source is audio-only output whatever the video
target says, and a video target on it is refused. Audio output gets an
audio container (m4a/ogg/mp3) checked against the codec it will hold, and
a video container asked for audio output is replaced by the codec's
natural one. faststart only for mp4/m4a. Verification learned the
audio-only shape and ffprobe's container names (mkv reports matroska).
The modal offers 'Remove video (audio only)', switches to audio
containers and follows the audio codec, reads Extract Audio, and opens
for audio files (no video codec select).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: yellow Edit button
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode: remove the temp output on cancel; tell the user when a closed-modal Job fails or is lost
Review fixes. The temp output was only removed on Exception, but a
cancelled Job's run_command raises CancelledError (a BaseException), so a
cancel left the partial file for a refresh to index. Closing the modal
during a Job that then failed showed nothing; it now toasts the error
(and a cancellation). Polling gives up on a 404 or five failures in a
row (the API restarted and forgot its Jobs), warning the user and
unlocking Transcode and Delete instead of reading Transcoding... forever.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Jobs: _claim_job docstring states the invariant, not the old race
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode: fragmented mp4 option for very long videos
A whole-file mp4 index grows with the frame count; for a many-hour video
it reaches tens of MB, which a phone must fetch and parse before the
first frame, and every seek walks it. `fragmented` writes the file with
-movflags +frag_keyframe+empty_moov+default_base_moof+global_sidx and
10s fragments: a ~1 KB moov plus a global seek index, so playback starts
and seeks quickly. mp4/m4a only; a remux, so it takes seconds per GB.
Measured on an 11-hour h264/aac file: moov 40 MB -> 1.4 KB, seek index
2 x 120 KB, 10k fragments, duration and codecs unchanged, remux in 25s.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode modal: the Fragmented label says audio for audio output
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video edits keep the original: custom_title/custom_description in the info json's wrolpi section
Editing a title or description no longer overwrites yt-dlp's keys. The
values go into the info json's `wrolpi` section (custom_title,
custom_description); the modeler prefers them when deriving the Video, so
a refresh keeps the edit while the original title and description stay in
the file. An empty custom description means none.
Both re-download paths carry the wrolpi section over: the metadata-only
refresh merges it into the fresh info json, and a full re-download
snapshots it before yt-dlp overwrites the file and restores it (then
re-validates) in finalize_download. FileGroup.get_wrolpi_json reads it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-16 19:25:23 -06:00
|
|
|
export const transcodeAudioCodecOptions = [
|
|
|
|
|
{value: TRANSCODE_COPY, label: 'Keep (copy)'},
|
|
|
|
|
{value: 'aac', label: 'aac'},
|
|
|
|
|
{value: 'opus', label: 'opus'},
|
|
|
|
|
{value: 'mp3', label: 'mp3'},
|
2026-09-26 17:49:00 -06:00
|
|
|
{value: TRANSCODE_REMOVE_AUDIO, label: 'Remove audio (silent video)'},
|
Jobs queue, video Edit dropdown: transcode/remux, edit title & description (#711)
* Jobs queue and video transcode from the video page
Add an in-memory FIFO Job queue (wrolpi/jobs.py): functions register by
name, callers enqueue by name with JSON kwargs, and the perpetual-tasks
owner runs them one at a time. Logging emitted inside a Job and the
output of its subprocesses are captured into a per-Job log; Jobs report
progress and can be cancelled (a running Job's subprocess is killed).
Jobs are not persisted; an API restart forgets them.
Add a transcode Job and POST /api/videos/<id>/transcode. ffmpeg reports
progress via -progress pipe:1. The existing FileGroup is pointed at the
new file before the refresh so tags and history survive a container
change.
Replace the video page Refresh button with an Edit dropdown (Refresh,
Transcode). The Transcode modal pre-fills from the preferred codecs in
the Videos settings and shows the Job's progress, log tail and Cancel.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: move Delete into the Edit dropdown
The Edit dropdown now holds Refresh, Transcode and Delete, so the action
row is Download / Edit / Add to Playlist. Delete keeps its confirmation
(a Confirm dialog) and the tagged-files prompt, and is disabled in WROL
Mode like the other items.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: Edit > Edit to change a video's title
PUT /api/videos/<file_group_id> writes the title (and fulltitle) into the
Video's info json, creating the file when the video has none, then
validates the Video again so its title and search text follow. Files
stay the source of truth: the edit survives a refresh, and a re-download
of the metadata replaces it (the modal says so).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: edit the description in Edit > Edit
PUT /api/videos/<file_group_id> now takes optional title and description
and changes only the fields given; an empty description clears it. The
modal sends only what changed and refetches the description after saving.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode modal: allow a container-only remux
Keeping both streams is no longer refused: ffmpeg copies them into the
chosen container with fast start. The container select starts at the
file's own container, the hint explains what a remux does, and the button
reads Remux when nothing is re-encoded.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* WROL Mode: refuse video edits and transcodes past the API
The routes already returned 403, but a transcode Job queued before WROL
Mode was enabled still ran, update_video could be called from anywhere,
and the Edit modal's Save button stayed live. The Job now fails before
ffmpeg starts, update_video carries wrol_mode_check, and the modal
disables Save with a notice.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode: verify the output before replacing the original
After ffmpeg exits, the output is probed and compared with the source
(container, presence of video/audio streams, codec per stream, duration
within 1s or 1%) and its last 30 seconds are decoded to a null output.
Any failure removes the output and keeps the original.
The tail decode replaces the download-time completeness check, which
grabbed a single frame near the end: one ffmpeg_video_complete (sync for
the downloader, async for Jobs) now serves both, and is stricter, since
every frame of the tail plus the audio must decode.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Jobs: claim atomically, cap pending, own-session subprocesses; retarget before delete
Review fixes. The worker read a Job's status and wrote RUNNING as two
steps, so a cancel landing between them was overwritten and the Job ran;
_claim_job now does both under the lock. enqueue_job refuses past
JOB_PENDING_LIMIT pending Jobs. JobContext.run_command starts the
subprocess in its own session and raises CancelledError when the command
was killed, so a handler cannot mistake it for a normal exit.
The transcode Job now retargets the FileGroup (committed) while the
original file still exists, and deletes the original afterwards
(transcode_video_file gained keep_original). A crash in between leaves
both files with the database pointing at a real one.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: the Edit menu owns the transcode Job; polling survives Close and errors
Review fixes. The transcode Job's id and polling (useJob) move from the
modal to VideoEditMenu, so closing the modal no longer stops the page
from learning the Job finished (and refetching the video, whose path may
have changed). While a Job runs the menu shows Transcoding..., reopening
shows its progress instead of the form, and Delete waits. A failed poll
request is retried instead of ending the polling. getJobs checks the
response like its siblings. Design narration trimmed from comments.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode: audio files, and Remove video to turn a video into an audio file
video_codec 'none' (REMOVE_VIDEO) drops the video stream (-vn, audio
required); an audio-only source is audio-only output whatever the video
target says, and a video target on it is refused. Audio output gets an
audio container (m4a/ogg/mp3) checked against the codec it will hold, and
a video container asked for audio output is replaced by the codec's
natural one. faststart only for mp4/m4a. Verification learned the
audio-only shape and ffprobe's container names (mkv reports matroska).
The modal offers 'Remove video (audio only)', switches to audio
containers and follows the audio codec, reads Extract Audio, and opens
for audio files (no video codec select).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video page: yellow Edit button
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode: remove the temp output on cancel; tell the user when a closed-modal Job fails or is lost
Review fixes. The temp output was only removed on Exception, but a
cancelled Job's run_command raises CancelledError (a BaseException), so a
cancel left the partial file for a refresh to index. Closing the modal
during a Job that then failed showed nothing; it now toasts the error
(and a cancellation). Polling gives up on a 404 or five failures in a
row (the API restarted and forgot its Jobs), warning the user and
unlocking Transcode and Delete instead of reading Transcoding... forever.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Jobs: _claim_job docstring states the invariant, not the old race
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode: fragmented mp4 option for very long videos
A whole-file mp4 index grows with the frame count; for a many-hour video
it reaches tens of MB, which a phone must fetch and parse before the
first frame, and every seek walks it. `fragmented` writes the file with
-movflags +frag_keyframe+empty_moov+default_base_moof+global_sidx and
10s fragments: a ~1 KB moov plus a global seek index, so playback starts
and seeks quickly. mp4/m4a only; a remux, so it takes seconds per GB.
Measured on an 11-hour h264/aac file: moov 40 MB -> 1.4 KB, seek index
2 x 120 KB, 10k fragments, duration and codecs unchanged, remux in 25s.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Transcode modal: the Fragmented label says audio for audio output
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Video edits keep the original: custom_title/custom_description in the info json's wrolpi section
Editing a title or description no longer overwrites yt-dlp's keys. The
values go into the info json's `wrolpi` section (custom_title,
custom_description); the modeler prefers them when deriving the Video, so
a refresh keeps the edit while the original title and description stay in
the file. An empty custom description means none.
Both re-download paths carry the wrolpi section over: the metadata-only
refresh merges it into the fresh info json, and a full re-download
snapshots it before yt-dlp overwrites the file and restores it (then
re-validates) in finalize_download. FileGroup.get_wrolpi_json reads it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-16 19:25:23 -06:00
|
|
|
];
|
|
|
|
|
// Containers for output with a video stream ...
|
|
|
|
|
export const transcodeContainerOptions = [
|
|
|
|
|
{value: 'mp4', label: 'mp4'},
|
|
|
|
|
{value: 'mkv', label: 'mkv'},
|
|
|
|
|
];
|
|
|
|
|
// ... and for audio-only output. AUDIO_CONTAINER_CODECS in transcode.py says what each holds.
|
|
|
|
|
export const transcodeAudioContainerOptions = [
|
|
|
|
|
{value: 'm4a', label: 'm4a (aac)'},
|
|
|
|
|
{value: 'ogg', label: 'ogg (opus)'},
|
|
|
|
|
{value: 'mp3', label: 'mp3'},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/** The audio container a player expects for a codec (default_audio_container in transcode.py). */
|
|
|
|
|
export function audioContainerForCodec(codec) {
|
|
|
|
|
if (codec === 'mp3') return 'mp3';
|
|
|
|
|
if (['opus', 'vorbis', 'flac'].includes(codec)) return 'ogg';
|
|
|
|
|
return 'm4a';
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-02 15:14:02 -06:00
|
|
|
export const Downloaders = {
|
|
|
|
|
Archive: 'archive',
|
|
|
|
|
File: 'file',
|
|
|
|
|
KiwixCatalog: 'kiwix_catalog',
|
|
|
|
|
KiwixZim: 'kiwix_zim',
|
2026-03-29 18:58:31 -06:00
|
|
|
MapCatalog: 'map_catalog',
|
|
|
|
|
MapExtract: 'map_extract',
|
2024-11-02 15:14:02 -06:00
|
|
|
RSS: 'rss',
|
|
|
|
|
ScrapeHtml: 'scrape_html',
|
|
|
|
|
Video: 'video',
|
|
|
|
|
VideoChannel: 'video_channel',
|
2026-02-03 16:36:44 -07:00
|
|
|
};
|