mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-22 16:06:19 -05:00
* 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🅰️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>
172 lines
6.3 KiB
JavaScript
172 lines
6.3 KiB
JavaScript
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`;
|
|
export const COLLECTIONS_API = `${API_URI}/collections`;
|
|
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.
|
|
const port = window.location.port ? `${window.location.port.replace(/^/, '')}` : '';
|
|
export const FILES_MEDIA_URI = `https://${window.location.hostname}${port ? ':' + port : ''}/media/`;
|
|
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`;
|
|
// Docker: 8080; native: 80 (default, no port needed).
|
|
const controllerPort = window.location.port === '8443' ? ':8080' : '';
|
|
export const CONTROLLER_URI = `http://${window.location.hostname}${controllerPort}`;
|
|
export const API_ARCHIVE_UPLOAD_URI = `http://${window.location.hostname}:8081/api/archive/upload`;
|
|
|
|
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,
|
|
};
|
|
|
|
/*
|
|
* 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 = {
|
|
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'},
|
|
{key: 'views', text: 'Most Views', value: 'views'},
|
|
];
|
|
|
|
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'},
|
|
{key: 'ogg', text: '.ogg', value: 'ogg'},
|
|
{key: 'webm', text: '.webm', value: 'webm'},
|
|
]
|
|
|
|
export const defaultVideoFormatOption = 'mp4';
|
|
|
|
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';
|
|
|
|
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'},
|
|
];
|
|
|
|
export const Downloaders = {
|
|
Archive: 'archive',
|
|
File: 'file',
|
|
KiwixCatalog: 'kiwix_catalog',
|
|
KiwixZim: 'kiwix_zim',
|
|
MapCatalog: 'map_catalog',
|
|
MapExtract: 'map_extract',
|
|
RSS: 'rss',
|
|
ScrapeHtml: 'scrape_html',
|
|
Video: 'video',
|
|
VideoChannel: 'video_channel',
|
|
};
|