Repository navigation
fix: find a combined mp4/mkv download in audio mode - #142
Merged
Merged
Conversation
When a video offers no audio-only format, the audio selector's `ba/b` fallback downloads a combined file. Audio mode only accepted audio-only suffixes, so a combined .mp4 or .mkv was never found and the job failed with "No .mkv found after download." while the file sat in the cache. Audio mode now accepts `_AUDIO_MODE_EXTS` (the audio-only suffixes plus .mp4/.mkv/.webm), both from the parsed Destination line and in the cache snapshot fallback. Matching stays suffix-exact, so .part and .ytdl leftovers are never picked, and the pre-download snapshot still excludes older files. Video mode still accepts only .mkv. An audio-mode miss now names the suffixes it looked for instead of saying ".mkv". Closes #141
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #141
What was wrong
If a video has no audio-only format, the audio selector's
ba/bfallback downloads a combined file (format 18, a.mp4).Audio mode only accepted audio-only suffixes (
_AUDIO_EXTS), so it threw away the parsedDestination:path and the cache fallback never globbed*.mp4.The job then failed with
No .mkv found after download.even though the file was in the cache.The new tests reproduced that exact error before the fix.
Change
fetchforge/ytdlp.py: new_COMBINED_EXTS = {.mp4, .mkv, .webm}and_AUDIO_MODE_EXTS = _AUDIO_EXTS | _COMBINED_EXTS._cache_snapshot_patterns(True)uses it.fetchforge/items.py: audio mode'sallowed_suffixesis_AUDIO_MODE_EXTS. If nothing is found in audio mode, the error lists the suffixes it looked for. Video mode is unchanged:.mkvonly, same message.ba/bfallback itself is unchanged.Danger zone (shared cache)
Matching is still suffix-exact globbing (
*.mp4etc.), sox.mp4.part,x.f18.mp4.part,x.webm.partandx.mp4.ytdlnever match.Older files are still excluded by the pre-download snapshot, which now also covers
.mp4/.mkvin audio mode.AudioModeCacheLookupTest.test_ignores_part_files_and_older_unrelated_videoschecks this: with only an older.mp4/.mkvand four leftovers in the cache, the lookup returnsNone, then it picks this job's new file.test_audio_mode_nothing_downloaded_names_what_was_looked_forchecks it end to end: only a.partlands, the older.mkvis not used, and nothing is written to the output dir.Tests (
tests/test_download_fallback.py)AudioModeCacheLookupTest: the audio path's lookup against a real temp cache dir, no network, for.mp4/.mkv/.webm, plus the danger-zone case.test_audio_mode_extracts_from_a_combined_file(ffmpeg-gated): the fake yt-dlp drops a real combined.mp4/.mkv/.webm, with and without aDestination:line, for WAV and MP3. It checks via ffprobe that the output has a single audio stream with the expected codec (pcm_s16le/mp3).test_video_mode_still_rejects_a_combined_mp4: video mode still saysNo .mkv found._AUDIO_MODE_EXTS(the widened set), and the fake yt-dlp gained optionalcopy_from/destconfig.Verify
.venv/bin/python -m unittest tests.test_download_fallback -v:Full gate, run the way
test.ymlruns it:unittest discover -s tests383 OK,-s tools/tests14 OK,ruff checkclean, frontend 47/47 pass, 16/16 mutations caught.