aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2015-01-04 02:20:45 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2015-01-04 02:20:45 +0100
commit2ccd1b10e58cc8e5173dc1aeedc2b3f0ef9b55bf (patch)
tree11fdba237df3f60d58698f4a602adf6b77da10e6 /youtube_dl/utils.py
parent788fa208c86d7196c75bdc74d8106a489723c054 (diff)
[soulanime] Fix under Python 3
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py11
1 files changed, 11 insertions, 0 deletions
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]
+