-from __future__ import unicode_literals
-
import random
import re
compat_urlparse,
)
from ..utils import (
- encode_data_uri,
ExtractorError,
- int_or_none,
+ encode_data_uri,
float_or_none,
+ int_or_none,
+ join_nonempty,
mimetype2ext,
str_or_none,
)
class UstreamIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?(?:ustream\.tv|video\.ibm\.com)/(?P<type>recorded|embed|embed/recorded)/(?P<id>\d+)'
IE_NAME = 'ustream'
+ _EMBED_REGEX = [r'<iframe[^>]+?src=(["\'])(?P<url>https?://(?:www\.)?(?:ustream\.tv|video\.ibm\.com)/embed/.+?)\1']
_TESTS = [{
'url': 'http://www.ustream.tv/recorded/20274954',
'md5': '088f151799e8f572f84eb62f17d73e5c',
'only_matching': True,
}]
- @staticmethod
- def _extract_url(webpage):
- mobj = re.search(
- r'<iframe[^>]+?src=(["\'])(?P<url>https?://(?:www\.)?(?:ustream\.tv|video\.ibm\.com)/embed/.+?)\1', webpage)
- if mobj is not None:
- return mobj.group('url')
-
def _get_stream_info(self, url, video_id, app_id_ver, extra_note=None):
def num_to_hex(n):
return hex(n)[2:]
content_type = stream['contentType']
kind = content_type.split('/')[0]
f = {
- 'format_id': '-'.join(filter(None, [
- 'dash', kind, str_or_none(stream.get('bitrate'))])),
+ 'format_id': join_nonempty(
+ 'dash', kind, str_or_none(stream.get('bitrate'))),
'protocol': 'http_dash_segments',
# TODO: generate a MPD doc for external players?
'url': encode_data_uri(b'<MPD/>', 'text/xml'),
return formats
def _real_extract(self, url):
- m = re.match(self._VALID_URL, url)
+ m = self._match_valid_url(url)
video_id = m.group('id')
# some sites use this embed format (see: https://github.com/ytdl-org/youtube-dl/issues/2990)
formats.extend(self._parse_segmented_mp4(dash_streams))
'''
- self._sort_formats(formats)
-
description = video.get('description')
timestamp = int_or_none(video.get('created_at'))
duration = float_or_none(video.get('length'))
}
def _real_extract(self, url):
- m = re.match(self._VALID_URL, url)
+ m = self._match_valid_url(url)
display_id = m.group('slug')
webpage = self._download_webpage(url, display_id)
channel_id = self._html_search_meta('ustream:channel_id', webpage)