Skip to content

Conversation

Copy link

Copilot AI commented Nov 19, 2025

Fix Download Error - Complete ✅

Changes Made:

  • Analyze the issue and understand the code
  • Fix format selection to be more robust with better fallback options
  • Ensure consistent flags between primary and fallback commands
  • Improve error handling with multi-layer fallback strategy
  • Test the changes (syntax, error detection, security)
  • Run code review and security check

Problem Summary:

Users encountered "Requested format is not available" errors when downloading YouTube videos with download_clips.py, resulting in empty subdirectories despite the script attempting downloads.

Root Causes:

  1. Restrictive format selection: Primary format string bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best was too specific
  2. Inconsistent flags: Fallback used -c while primary used --no-continue
  3. Single fallback layer: Only one fallback wasn't enough for edge cases
  4. Narrow error detection: Only caught "Requested format is not available"

Solution Implemented:

1. Improved Primary Format Selection (Line 232):

# Before: "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"
# After:  "bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio/best"

Allows any video+audio combination as fallback before going to single best format.

2. Fixed Flag Inconsistency (Line 260):

# Before: "-c", "--no-overwrites"
# After:  "--no-continue", "--no-overwrites"

Maintains consistency with primary command.

3. Multi-Layer Fallback Strategy:

  • Primary: Preferred mp4+m4a → any video+audio → best
  • Fallback 1: Simple "best" with all features (audio, subs, etc.)
  • Fallback 2: Minimal "best" with no optional features

4. Enhanced Error Detection (Line 252):

# Before: if "Requested format is not available" in err_msg:
# After:  if "Requested format is not available" in err_msg or "format" in err_msg.lower():

Catches more format-related errors with case-insensitive matching.

Validation Complete:

Syntax Check: Passed
Security Scan: 0 vulnerabilities found
Error Detection: All test patterns correctly detected
Function Signature: Verified and unchanged

Testing Instructions:

Create a test JSON with the problematic video:

[
  {
    "info": {
      "Video Link": "https://www.youtube.com/watch?v=3kAiPSEnrHI"
    },
    "start-time": 246.846,
    "end-time": 251.888
  }
]

Run: python download_clips.py --input test.json --output test_output --limit 1

The script will now gracefully handle format availability issues through three progressive fallback attempts.

Original prompt

This section details on the original issue you should resolve

<issue_title>Download error</issue_title>
<issue_description>I use filtered_video_clips_with_captions.json as input json, and use download_clips.py to download the video, than it tell me that FAIL https://www.youtube.com/watch?v=3kAiPSEnrHI 246.846 251.888 ERROR: [youtube] 3kAiPSEnrHI: Requested format is not available. Use --list-formats for a list of available formats, and the dir like:

Image but I see nothing in the subdir.

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Download error

2 participants