]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[soulanime] Fix under Python 3
authorPhilipp Hagemeister <phihag@phihag.de>
Sun, 4 Jan 2015 01:20:45 +0000 (02:20 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Sun, 4 Jan 2015 01:20:45 +0000 (02:20 +0100)
youtube_dl/extractor/soulanime.py
youtube_dl/utils.py

index 7adb10c039e878c7734006c4aef962b89314ea4f..feef33e27597ce5ee306f077e8e5965df5e6d545 100644 (file)
@@ -3,6 +3,10 @@ from __future__ import unicode_literals
 import re
 
 from .common import InfoExtractor
+from ..utils import (
+    HEADRequest,
+    urlhandle_detect_ext,
+)
 
 
 class SoulAnimeWatchingIE(InfoExtractor):
@@ -31,8 +35,10 @@ class SoulAnimeWatchingIE(InfoExtractor):
             r'<div id="download">[^<]*<a href="(?P<url>[^"]+)"', page, 'url')
         video_url = "http://www.soul-anime." + domain + video_url_encoded
 
-        vid = self._request_webpage(video_url, video_id)
-        ext = vid.info().gettype().split("/")[1]
+        ext_req = HEADRequest(video_url)
+        ext_handle = self._request_webpage(
+            ext_req, video_id, note='Determining extension')
+        ext = urlhandle_detect_ext(ext_handle)
 
         return {
             'id': video_id,
index efbe64fb315dba92383f8b1053a80558f4a12d7b..bdfe053a73341ee05c494507ae0a63c51865e2f6 100644 (file)
@@ -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]
+