X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fonionstudios.py;h=6e843c327603f19560e2bb35a2d5d462fe4516c3;hb=33a1ff7113d9dd656b3c56cb404de85646caa559;hp=8fa507dec7e3b8fc0e48bc679d03192a2cc63bf4;hpb=d80891efc47d3965695f76a24694c1f0bd748bd6;p=youtube-dl diff --git a/youtube_dl/extractor/onionstudios.py b/youtube_dl/extractor/onionstudios.py index 8fa507dec..6e843c327 100644 --- a/youtube_dl/extractor/onionstudios.py +++ b/youtube_dl/extractor/onionstudios.py @@ -4,7 +4,10 @@ from __future__ import unicode_literals import re from .common import InfoExtractor -from ..utils import determine_ext +from ..utils import ( + determine_ext, + int_or_none, +) class OnionStudiosIE(InfoExtractor): @@ -17,7 +20,7 @@ class OnionStudiosIE(InfoExtractor): 'id': '2937', 'ext': 'mp4', 'title': 'Hannibal charges forward, stops for a cocktail', - 'description': 'md5:545299bda6abf87e5ec666548c6a9448', + 'description': 'md5:e786add7f280b7f0fe237b64cc73df76', 'thumbnail': 're:^https?://.*\.jpg$', 'uploader': 'The A.V. Club', 'uploader_id': 'TheAVClub', @@ -42,26 +45,38 @@ class OnionStudiosIE(InfoExtractor): formats = [] for src in re.findall(r']+src="([^"]+)"', webpage): - if determine_ext(src) != 'm3u8': # m3u8 always results in 403 + ext = determine_ext(src) + if ext == 'm3u8': + formats.extend(self._extract_m3u8_formats( + src, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)) + else: + height = int_or_none(self._search_regex( + r'/(\d+)\.%s' % ext, src, 'height', default=None)) formats.append({ + 'format_id': ext + ('-%sp' % height if height else ''), 'url': src, + 'height': height, + 'ext': ext, + 'preference': 1, }) self._sort_formats(formats) title = self._search_regex( - r'share_title\s*=\s*"([^"]+)"', webpage, 'title') + r'share_title\s*=\s*(["\'])(?P[^\1]+?)\1', + webpage, 'title', group='title') description = self._search_regex( - r'share_description\s*=\s*"([^"]+)"', webpage, - 'description', default=None) + r'share_description\s*=\s*(["\'])(?P<description>[^\1]+?)\1', + webpage, 'description', default=None, group='description') thumbnail = self._search_regex( - r'poster="([^"]+)"', webpage, 'thumbnail', default=False) + r'poster\s*=\s*(["\'])(?P<thumbnail>[^\1]+?)\1', + webpage, 'thumbnail', default=False, group='thumbnail') uploader_id = self._search_regex( - r'twitter_handle\s*=\s*"([^"]+)"', - webpage, 'uploader id', fatal=False) + r'twitter_handle\s*=\s*(["\'])(?P<uploader_id>[^\1]+?)\1', + webpage, 'uploader id', fatal=False, group='uploader_id') uploader = self._search_regex( - r'window\.channelName\s*=\s*"Embedded:([^"]+)"', - webpage, 'uploader', default=False) + r'window\.channelName\s*=\s*(["\'])Embedded:(?P<uploader>[^\1]+?)\1', + webpage, 'uploader', default=False, group='uploader') return { 'id': video_id,