]>
Commit | Line | Data |
---|---|---|
53bfd6b2 | 1 | from __future__ import unicode_literals |
2 | ||
53bfd6b2 | 3 | from .common import InfoExtractor |
9298d4e3 PH |
4 | from ..utils import ( |
5 | parse_iso8601, | |
6 | int_or_none, | |
7 | ) | |
53bfd6b2 | 8 | |
9 | ||
10 | class DiscoveryIE(InfoExtractor): | |
9298d4e3 | 11 | _VALID_URL = r'http://www\.discovery\.com\/[a-zA-Z0-9\-]*/[a-zA-Z0-9\-]*/videos/(?P<id>[a-zA-Z0-9_\-]*)(?:\.htm)?' |
53bfd6b2 | 12 | _TEST = { |
cea2582d | 13 | 'url': 'http://www.discovery.com/tv-shows/mythbusters/videos/mission-impossible-outtakes.htm', |
9298d4e3 | 14 | 'md5': '3c69d77d9b0d82bfd5e5932a60f26504', |
53bfd6b2 | 15 | 'info_dict': { |
9298d4e3 PH |
16 | 'id': 'mission-impossible-outtakes', |
17 | 'ext': 'flv', | |
18 | 'title': 'Mission Impossible Outtakes', | |
9b05bd42 | 19 | 'description': ('Watch Jamie Hyneman and Adam Savage practice being' |
9e1a5b84 JW |
20 | ' each other -- to the point of confusing Jamie\'s dog -- and ' |
21 | 'don\'t miss Adam moon-walking as Jamie ... behind Jamie\'s' | |
22 | ' back.'), | |
9b05bd42 | 23 | 'duration': 156, |
9298d4e3 PH |
24 | 'timestamp': 1303099200, |
25 | 'upload_date': '20110418', | |
9b05bd42 | 26 | }, |
53bfd6b2 | 27 | } |
28 | ||
29 | def _real_extract(self, url): | |
9298d4e3 | 30 | video_id = self._match_id(url) |
53bfd6b2 | 31 | webpage = self._download_webpage(url, video_id) |
9b05bd42 | 32 | |
9298d4e3 PH |
33 | info = self._parse_json(self._search_regex( |
34 | r'(?s)<script type="application/ld\+json">(.*?)</script>', | |
35 | webpage, 'video info'), video_id) | |
53bfd6b2 | 36 | |
37 | return { | |
9298d4e3 PH |
38 | 'id': video_id, |
39 | 'title': info['name'], | |
40 | 'url': info['contentURL'], | |
41 | 'description': info.get('description'), | |
42 | 'thumbnail': info.get('thumbnailUrl'), | |
43 | 'timestamp': parse_iso8601(info.get('uploadDate')), | |
44 | 'duration': int_or_none(info.get('duration')), | |
53bfd6b2 | 45 | } |