Refetch missing media from catalog source
This commit is contained in:
@@ -1104,7 +1104,7 @@ const SAVE_DEFAULT_FORMAT =
|
||||
// again) share ONE yt-dlp run instead of spawning another each time.
|
||||
const inflightDownloads = new Map(); // key -> { promise, waiters, tmpBase }
|
||||
|
||||
async function ytdlpDownloadResponse(videoId, fp, formatArgs, signal) {
|
||||
async function ytdlpDownloadResponse(videoId, fp, formatArgs, signal, sourceUrl = null) {
|
||||
await assertNotLive(videoId);
|
||||
const key = videoId + '|' + formatArgs.join(' ');
|
||||
let entry = inflightDownloads.get(key);
|
||||
@@ -1116,7 +1116,7 @@ async function ytdlpDownloadResponse(videoId, fp, formatArgs, signal) {
|
||||
entry.promise = withSaveSlot(() => {
|
||||
if (ctl.signal.aborted) throw new Error('save cancelled');
|
||||
return runYtdlpResilient([
|
||||
`https://www.youtube.com/watch?v=${videoId}`,
|
||||
sourceUrl || await videoCatalog.getSourceUrl(videoId) || `https://www.youtube.com/watch?v=${videoId}`,
|
||||
'--no-warnings', '--no-playlist',
|
||||
...formatArgs,
|
||||
'--limit-rate', DOWNLOAD_RATE,
|
||||
@@ -1187,7 +1187,7 @@ async function ytdlpEditedDownloadResponse(videoId, fp, keep, signal, cachedSrc
|
||||
// 1) Grab the full source (video+audio merged) so ffmpeg has both streams
|
||||
// — unless the server cache already holds it.
|
||||
if (!cachedSrc) await withSaveSlot(() => runYtdlpResilient([
|
||||
`https://www.youtube.com/watch?v=${videoId}`,
|
||||
await videoCatalog.getSourceUrl(videoId) || `https://www.youtube.com/watch?v=${videoId}`,
|
||||
'--no-warnings', '--no-playlist',
|
||||
'-f', SAVE_MUX_FORMAT,
|
||||
'--merge-output-format', 'mp4',
|
||||
@@ -1243,6 +1243,7 @@ if (!MEDIA_VOLUME_MARKER || existsSync(MEDIA_VOLUME_MARKER)) mkdirSync(MEDIA_DIR
|
||||
const media = createMediaCache({
|
||||
dir: MEDIA_DIR,
|
||||
volumeMarker: MEDIA_VOLUME_MARKER,
|
||||
getSourceUrl: videoCatalog.getSourceUrl,
|
||||
db: {
|
||||
getMedia, upsertMedia, deleteMedia, listMedia, listMediaLru, touchMedia, mediaStats,
|
||||
// Retention (docs/p2p-architecture.md flow 9): cold copies go before popular ones.
|
||||
@@ -1251,9 +1252,9 @@ const media = createMediaCache({
|
||||
}),
|
||||
},
|
||||
getInfo: async (videoId) => (await resolveStreams(videoId)).info,
|
||||
download: async (videoId, out) => {
|
||||
download: async (videoId, out, sourceUrl) => {
|
||||
await withSaveSlot(() => runYtdlpResilient([
|
||||
`https://www.youtube.com/watch?v=${videoId}`,
|
||||
sourceUrl || `https://www.youtube.com/watch?v=${videoId}`,
|
||||
'--no-warnings', '--no-playlist',
|
||||
'-f', SAVE_MUX_FORMAT,
|
||||
'--merge-output-format', 'mp4',
|
||||
|
||||
Reference in New Issue
Block a user