youtube-dl

Another place where youtube-dl lives on
git clone git://git.oshgnacknak.de/youtube-dl.git
Log | Files | Refs | README | LICENSE

commit 2ccd1b10e58cc8e5173dc1aeedc2b3f0ef9b55bf
parent 788fa208c86d7196c75bdc74d8106a489723c054
Author: Philipp Hagemeister <phihag@phihag.de>
Date:   Sun,  4 Jan 2015 02:20:45 +0100

[soulanime] Fix under Python 3

Diffstat:
Myoutube_dl/extractor/soulanime.py | 10++++++++--
Myoutube_dl/utils.py | 11+++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/youtube_dl/extractor/soulanime.py b/youtube_dl/extractor/soulanime.py @@ -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, diff --git 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] +