Retrieve YouTube video format available
I'm currently trying to patch the Totem Youtube plug-in and I'd like to determine the best quality available for the current played video (&fmt parameter). It's possible in JavaScript but the plug-in is developped in C.
开发者_如何学JAVAIs that possible?
Are you playing the videos in the YouTube video player?
If so, you can query the quality levels through the ActionScript or JavaScript API, see http://code.google.com/apis/youtube/js_api_reference.html#Playback_quality.
I found the solution thanks to youtube-dl python script. The test is to form the final url and try to open it (with curl for example), if the format is available it will return HTTP code 303 (See other location) with the real url into the headers. If it's not available, it will return 404 (Not found).
精彩评论