X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fhotnewhiphop.py;h=34163725f8c9562380a3ea30a17780e599f3b0a7;hb=685e87b61f785b096745cda5ea64ea0b950f56d1;hp=a106f81d2b24ef3589f4ef98cbbaa930dfe5fc0b;hpb=50317b111dadccba73bcdd828d9997d1da78a5f1;p=youtube-dl diff --git a/youtube_dl/extractor/hotnewhiphop.py b/youtube_dl/extractor/hotnewhiphop.py index a106f81d2..34163725f 100644 --- a/youtube_dl/extractor/hotnewhiphop.py +++ b/youtube_dl/extractor/hotnewhiphop.py @@ -1,47 +1,45 @@ from __future__ import unicode_literals -import re import base64 from .common import InfoExtractor from ..utils import ( - compat_urllib_parse, - compat_urllib_request, ExtractorError, HEADRequest, + sanitized_Request, + urlencode_postdata, ) class HotNewHipHopIE(InfoExtractor): - _VALID_URL = r'http://www\.hotnewhiphop.com/.*\.(?P.*)\.html' + _VALID_URL = r'https?://(?:www\.)?hotnewhiphop\.com/.*\.(?P.*)\.html' _TEST = { 'url': 'http://www.hotnewhiphop.com/freddie-gibbs-lay-it-down-song.1435540.html', - 'file': '1435540.mp3', 'md5': '2c2cd2f76ef11a9b3b581e8b232f3d96', 'info_dict': { + 'id': '1435540', + 'ext': 'mp3', 'title': 'Freddie Gibbs - Lay It Down' } } def _real_extract(self, url): - m = re.match(self._VALID_URL, url) - video_id = m.group('id') - - webpage_src = self._download_webpage(url, video_id) + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) video_url_base64 = self._search_regex( - r'data-path="(.*?)"', webpage_src, u'video URL', fatal=False) + r'data-path="(.*?)"', webpage, 'video URL', default=None) if video_url_base64 is None: video_url = self._search_regex( - r'"contentUrl" content="(.*?)"', webpage_src, u'video URL') + r'"contentUrl" content="(.*?)"', webpage, 'content URL') return self.url_result(video_url, ie='Youtube') - reqdata = compat_urllib_parse.urlencode([ + reqdata = urlencode_postdata([ ('mediaType', 's'), ('mediaId', video_id), ]) - r = compat_urllib_request.Request( + r = sanitized_Request( 'http://www.hotnewhiphop.com/ajax/media/getActions/', data=reqdata) r.add_header('Content-Type', 'application/x-www-form-urlencoded') mkd = self._download_json( @@ -59,11 +57,11 @@ class HotNewHipHopIE(InfoExtractor): if video_url.endswith('.html'): raise ExtractorError('Redirect failed') - video_title = self._og_search_title(webpage_src).strip() + video_title = self._og_search_title(webpage).strip() return { 'id': video_id, 'url': video_url, 'title': video_title, - 'thumbnail': self._og_search_thumbnail(webpage_src), + 'thumbnail': self._og_search_thumbnail(webpage), }