1 from __future__ import unicode_literals
5 from .common import InfoExtractor
8 class DiscoveryIE(InfoExtractor):
9 _VALID_URL = r'http://dsc\.discovery\.com\/[a-zA-Z0-9\-]*/[a-zA-Z0-9\-]*/videos/(?P<id>[a-zA-Z0-9\-]*)(.htm)?'
11 'url': 'http://dsc.discovery.com/tv-shows/mythbusters/videos/mission-impossible-outtakes.htm',
12 'file': 'mission-impossible-outtakes.mp4',
13 'md5': 'e12614f9ee303a6ccef415cb0793eba2',
15 'title': 'MythBusters: Mission Impossible Outtakes'
19 def _real_extract(self, url):
20 mobj = re.match(self._VALID_URL, url)
21 video_id = mobj.group('id')
22 webpage = self._download_webpage(url, video_id)
23 title = self._search_regex(
24 r'(?<=\"name\": ")(?P<title>.*?)(?=\"\,)', webpage, r'Filename')
25 duration = int(self._search_regex(
26 r'(?<=\"duration\"\: )(?P<duration>.*?)(?=,)', webpage, r'Duration'))
27 formats_raw = self._search_regex(
28 r'(?<=\"mp4\":)(.*?)(}])', webpage, r'formats') + '}]'
29 formats_json = json.loads(formats_raw)
31 for f in formats_json:
33 {'url': f['src'], r'ext': r'mp4', 'tbr': int(f['bitrate'][:-1])})