X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fcommon.py;h=e5245ec3f29eb914b4a311bdf5f3c735e32d2f61;hb=674fb0fcc54c72448f80a0573f7fd116f220827e;hp=4fe99d25de7d615aeca56a1f9608e5053a77d522;hpb=637570326bfa12575fe210e52e2a39d6585891d8;p=youtube-dl diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index 4fe99d25d..e5245ec3f 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -767,6 +767,10 @@ class InfoExtractor(object): formats) def _is_valid_url(self, url, video_id, item='video'): + url = self._proto_relative_url(url, scheme='http:') + # For now assume non HTTP(S) URLs always valid + if not (url.startswith('http://') or url.startswith('https://')): + return True try: self._request_webpage(url, video_id, 'Checking %s URL' % item) return True @@ -835,7 +839,7 @@ class InfoExtractor(object): m3u8_id=None): formats = [{ - 'format_id': '-'.join(filter(None, [m3u8_id, 'm3u8-meta'])), + 'format_id': '-'.join(filter(None, [m3u8_id, 'meta'])), 'url': m3u8_url, 'ext': ext, 'protocol': 'm3u8', @@ -879,8 +883,13 @@ class InfoExtractor(object): formats.append({'url': format_url(line)}) continue tbr = int_or_none(last_info.get('BANDWIDTH'), scale=1000) + format_id = [] + if m3u8_id: + format_id.append(m3u8_id) + last_media_name = last_media.get('NAME') if last_media else None + format_id.append(last_media_name if last_media_name else '%d' % (tbr if tbr else len(formats))) f = { - 'format_id': '-'.join(filter(None, [m3u8_id, 'm3u8-%d' % (tbr if tbr else len(formats))])), + 'format_id': '-'.join(format_id), 'url': format_url(line.strip()), 'tbr': tbr, 'ext': ext, @@ -923,18 +932,18 @@ class InfoExtractor(object): rtmp_count = 0 if smil.findall('./body/seq/video'): video = smil.findall('./body/seq/video')[0] - fmts, rtmp_count = self._parse_smil_video(video, base, rtmp_count) + fmts, rtmp_count = self._parse_smil_video(video, video_id, base, rtmp_count) formats.extend(fmts) else: for video in smil.findall('./body/switch/video'): - fmts, rtmp_count = self._parse_smil_video(video, base, rtmp_count) + fmts, rtmp_count = self._parse_smil_video(video, video_id, base, rtmp_count) formats.extend(fmts) self._sort_formats(formats) return formats - def _parse_smil_video(self, video, base, rtmp_count): + def _parse_smil_video(self, video, video_id, base, rtmp_count): src = video.get('src') if not src: return ([], rtmp_count) @@ -963,6 +972,14 @@ class InfoExtractor(object): 'width': width, 'height': height, }], rtmp_count) + elif proto.startswith('http'): + return ([{ + 'url': base + src, + 'ext': ext or 'flv', + 'tbr': bitrate, + 'width': width, + 'height': height, + }], rtmp_count) def _live_title(self, name): """ Generate the title for a live video """ @@ -1045,6 +1062,9 @@ class InfoExtractor(object): def _get_automatic_captions(self, *args, **kwargs): raise NotImplementedError("This method must be implemented by subclasses") + def _subtitles_timecode(self, seconds): + return '%02d:%02d:%02d.%03d' % (seconds / 3600, (seconds % 3600) / 60, seconds % 60, (seconds % 1) * 1000) + class SearchInfoExtractor(InfoExtractor): """