X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Futils.py;h=d4951c406c73d8216803f5d9149200787883676b;hb=799d88d3d8a9337fb0b7a858ec4ffb3aaacbc974;hp=43b7c94ba4d49f523565a6959b211063c3a6b04c;hpb=7af808a5ef4cc17ca30c8c4636660589e0e915ec;p=youtube-dl diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 43b7c94ba..d4951c406 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -464,6 +464,13 @@ class ExtractorError(Exception): return ''.join(traceback.format_tb(self.traceback)) +class UnsupportedError(ExtractorError): + def __init__(self, url): + super(UnsupportedError, self).__init__( + 'Unsupported URL: %s' % url, expected=True) + self.url = url + + class RegexNotFoundError(ExtractorError): """Error when a regex didn't match""" pass @@ -1543,3 +1550,13 @@ 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]