gpt-4-1106-preview· openai
Suzhen/CodeChat
i want yt-dlp to query an url until format 251 is available then download it
- User
i want yt-dlp to query an url until format 251 is available then download it
- Assistant
To use
yt-dlpto query a URL repeatedly until a certain format (in your case format 251, which typically is a webm audio format) becomes available, you can write a small script that continuously checks for the availability of the desired format.Here's a basic example of such a script in Bash:
#!/bin/bash URL="YOUR_VIDEO_URL_HERE" # Replace with the URL you want to check FORMAT_CODE="251" # Format code to check for # Function to check if the format is available is_format_available() { yt-dlp -F "$URL" | grep -q "format code $FORMAT_CODE" return $? } # Main loop, keep querying until the format is available while true; do if is_format_available; then echo "Format $FORMAT_CODE is available, starting download..." yt-dlp -f "$FORMAT_CODE" "$URL" break else echo "Format $FORMAT_CODE is not available yet, retrying in 30 seconds..." sleep 30 fi done