X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fscreenwavemedia.py;h=220d39078fab15e0e4191a1d1a33b162f342ffb8;hb=42e7373bd3c819ee7cebf5898e4bdd33730dde6f;hp=3bc84989e2b4d4c842714a1d815070eeb05e45c9;hpb=89faae660ffaad735699157edc7965713f3cad1b;p=youtube-dl diff --git a/youtube_dl/extractor/screenwavemedia.py b/youtube_dl/extractor/screenwavemedia.py index 3bc84989e..220d39078 100644 --- a/youtube_dl/extractor/screenwavemedia.py +++ b/youtube_dl/extractor/screenwavemedia.py @@ -1,6 +1,8 @@ # encoding: utf-8 from __future__ import unicode_literals +import re + from .common import InfoExtractor from ..utils import ( int_or_none, @@ -35,30 +37,52 @@ class ScreenwaveMediaIE(InfoExtractor): sources = self._parse_json( js_to_json( - self._search_regex( - r"sources\s*:\s*(\[[^\]]+?\])", playerconfig, - 'sources', - ).replace( - "' + thisObj.options.videoserver + '", - videoserver - ).replace( - "' + playerVidId + '", - video_id + re.sub( + r'(?s)/\*.*?\*/', '', + self._search_regex( + r"sources\s*:\s*(\[[^\]]+?\])", playerconfig, + 'sources', + ).replace( + "' + thisObj.options.videoserver + '", + videoserver + ).replace( + "' + playerVidId + '", + video_id + ) ) ), - video_id + video_id, fatal=False ) + # Fallback to hardcoded sources if JS changes again + if not sources: + sources = [{ + 'file': 'http://%s/vod/%s_%s.mp4' % (videoserver, video_id, format_id), + 'type': 'mp4', + 'label': format_label, + } for format_id, format_label in ( + ('low', '144p Low'), ('med', '160p Med'), ('high', '360p High'), ('hd1', '720p HD1'))] + sources.append({ + 'file': 'http://%s/vod/smil:%s.smil/playlist.m3u8' % (videoserver, video_id), + 'type': 'hls', + }) + formats = [] for source in sources: if source['type'] == 'hls': formats.extend(self._extract_m3u8_formats(source['file'], video_id)) else: + file_ = source.get('file') + if not file_: + continue format_label = source.get('label') + format_id = self._search_regex( + r'_(.+?)\.[^.]+$', file_, 'format id', default=None) height = int_or_none(self._search_regex( r'^(\d+)[pP]', format_label, 'height', default=None)) formats.append({ 'url': source['file'], + 'format_id': format_id, 'format': format_label, 'ext': source.get('type'), 'height': height,