fix(downloader): prevent truncated videos from being reported as comp… - #66
Open
JunayedMh wants to merge 1 commit into
Open
fix(downloader): prevent truncated videos from being reported as comp…#66JunayedMh wants to merge 1 commit into
JunayedMh wants to merge 1 commit into
Conversation
…lete Episodes could finish "successfully" as a 1-3 minute file instead of the full ~23 minutes. Four independent defects combined to silently drop most of the video while the run still reported success: - download_segment padded truncated or empty HTTP bodies with NUL bytes and saved them, producing corrupt segments that made ffmpeg stop mid-video. It now rejects any empty or non-16-byte-aligned body and writes nothing, so the segment is retried instead of poisoning the merge. - 0-byte segment leftovers from a prior failed run were treated as "already downloaded" and skipped forever. Only non-empty files are skipped now. - The GUI download path discarded failed segments with no retry and no error, then compiled whatever was on disk. Segment downloading is now a single shared Downloader.download_segments() used by both CLI and GUI, which retries failing segments and reports incompleteness to the caller. - compile_video used ffmpeg's concat demuxer (which can reset per-file timestamps and truncate the output while still exiting 0) and never checked completeness. It now verifies every segment is present and non-empty, binary-concatenates the TS segments then remuxes, and rejects an output shorter than the playlist's expected duration (via ffprobe). On any failure, segments are kept on disk so the next run resumes instead of overwriting a good partial download, and the playlist is fetched atomically. Adds tests/test_download_integrity.py: 8 regression tests covering segment rejection, retry/failure reporting, and compile refusal. No network or ffmpeg required. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
…lete
Episodes could finish "successfully" as a 1-3 minute file instead of the full ~23 minutes. Four independent defects combined to silently drop most of the video while the run still reported success:
On any failure, segments are kept on disk so the next run resumes instead of overwriting a good partial download, and the playlist is fetched atomically.
Adds tests/test_download_integrity.py: 8 regression tests covering segment rejection, retry/failure reporting, and compile refusal. No network or ffmpeg required.
Pull Request
Description
Type of Change
Related Issues
Fixes #
Relates to #
Changes Made
Testing
Test Configuration
Test Results
Checklist
Screenshots (if applicable)
Performance Impact
Breaking Changes
Additional Notes
Reviewer Checklist