X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Futils.py;h=bdfe053a73341ee05c494507ae0a63c51865e2f6;hb=2ccd1b10e58cc8e5173dc1aeedc2b3f0ef9b55bf;hp=efbe64fb315dba92383f8b1053a80558f4a12d7b;hpb=b3013681ff49712d5b5437efdff117ca544caadb;p=youtube-dl diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index efbe64fb3..bdfe053a7 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1550,3 +1550,14 @@ def ytdl_is_updateable(): def args_to_str(args): # Get a short string representation for a subprocess command return ' '.join(shlex_quote(a) for a in args) + + +def urlhandle_detect_ext(url_handle): + try: + url_handle.headers + getheader = lambda h: url_handle.headers[h] + except AttributeError: # Python < 3 + getheader = url_handle.info().getheader + + return getheader('Content-Type').split("/")[1] +