X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Ftubitv.py;h=c6572defbcf7a732d58d5fa3003993d063a8be3e;hb=05bddcc512cd5058f1af1d5985979b70bdcf4711;hp=2c4b21807ce1dc276e8625463ac38fb63c8ff211;hpb=ad49fe7c8f22c78a001eb1a53d7df9ef54424b89;p=youtube-dl diff --git a/youtube_dl/extractor/tubitv.py b/youtube_dl/extractor/tubitv.py index 2c4b21807..c6572defb 100644 --- a/youtube_dl/extractor/tubitv.py +++ b/youtube_dl/extractor/tubitv.py @@ -1,33 +1,32 @@ # coding: utf-8 from __future__ import unicode_literals -import codecs import re from .common import InfoExtractor -from ..compat import ( - compat_urllib_parse, - compat_urllib_request -) from ..utils import ( ExtractorError, int_or_none, + sanitized_Request, + urlencode_postdata, + parse_iso8601, ) class TubiTvIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?tubitv\.com/video\?id=(?P[0-9]+)' + _VALID_URL = r'https?://(?:www\.)?tubitv\.com/video/(?P[0-9]+)' _LOGIN_URL = 'http://tubitv.com/login' _NETRC_MACHINE = 'tubitv' _TEST = { - 'url': 'http://tubitv.com/video?id=54411&title=The_Kitchen_Musical_-_EP01', + 'url': 'http://tubitv.com/video/283829/the_comedian_at_the_friday', 'info_dict': { - 'id': '54411', + 'id': '283829', 'ext': 'mp4', - 'title': 'The Kitchen Musical - EP01', - 'thumbnail': 're:^https?://.*\.png$', - 'description': 'md5:37532716166069b353e8866e71fefae7', - 'duration': 2407, + 'title': 'The Comedian at The Friday', + 'description': 'A stand up comedian is forced to look at the decisions in his life while on a one week trip to the west coast.', + 'uploader': 'Indie Rights Films', + 'upload_date': '20160111', + 'timestamp': 1452555979, }, 'params': { 'skip_download': 'HLS download', @@ -43,8 +42,8 @@ class TubiTvIE(InfoExtractor): 'username': username, 'password': password, } - payload = compat_urllib_parse.urlencode(form_data).encode('utf-8') - request = compat_urllib_request.Request(self._LOGIN_URL, payload) + payload = urlencode_postdata(form_data) + request = sanitized_Request(self._LOGIN_URL, payload) request.add_header('Content-Type', 'application/x-www-form-urlencoded') login_page = self._download_webpage( request, None, False, 'Wrong login info') @@ -57,28 +56,31 @@ class TubiTvIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) + video_data = self._download_json( + 'http://tubitv.com/oz/videos/%s/content' % video_id, video_id) + title = video_data['n'] - webpage = self._download_webpage(url, video_id) - if re.search(r"<(?:DIV|div) class='login-required-screen'>", webpage): - raise ExtractorError( - 'This video requires login, use --username and --password ' - 'options to provide account credentials.', expected=True) - - title = self._og_search_title(webpage) - description = self._og_search_description(webpage) - thumbnail = self._og_search_thumbnail(webpage) - duration = int_or_none(self._html_search_meta( - 'video:duration', webpage, 'duration')) + formats = self._extract_m3u8_formats( + video_data['mh'], video_id, 'mp4', 'm3u8_native') + self._sort_formats(formats) - apu = self._search_regex(r"apu='([^']+)'", webpage, 'apu') - m3u8_url = codecs.decode(apu, 'rot_13')[::-1] - formats = self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4') + subtitles = {} + for sub in video_data.get('sb', []): + sub_url = sub.get('u') + if not sub_url: + continue + subtitles.setdefault(sub.get('l', 'en'), []).append({ + 'url': sub_url, + }) return { 'id': video_id, 'title': title, 'formats': formats, - 'thumbnail': thumbnail, - 'description': description, - 'duration': duration, + 'subtitles': subtitles, + 'thumbnail': video_data.get('ph'), + 'description': video_data.get('d'), + 'duration': int_or_none(video_data.get('s')), + 'timestamp': parse_iso8601(video_data.get('u')), + 'uploader': video_data.get('on'), }