]>
Commit | Line | Data |
---|---|---|
53bfd6b2 | 1 | from __future__ import unicode_literals |
2 | ||
53bfd6b2 | 3 | from .common import InfoExtractor |
9298d4e3 | 4 | from ..utils import ( |
65ba8b23 | 5 | parse_duration, |
9298d4e3 | 6 | parse_iso8601, |
9298d4e3 | 7 | ) |
65ba8b23 | 8 | from ..compat import compat_str |
53bfd6b2 | 9 | |
10 | ||
11 | class DiscoveryIE(InfoExtractor): | |
fec040e7 | 12 | _VALID_URL = r'''(?x)http://(?:www\.)?(?: |
13 | discovery| | |
14 | investigationdiscovery| | |
15 | discoverylife| | |
16 | animalplanet| | |
17 | ahctv| | |
18 | destinationamerica| | |
19 | sciencechannel| | |
20 | tlc| | |
21 | velocity | |
b05641ce | 22 | )\.com/(?:[^/]+/)*(?P<id>[^./?#]+)''' |
65ba8b23 | 23 | _TESTS = [{ |
cea2582d | 24 | 'url': 'http://www.discovery.com/tv-shows/mythbusters/videos/mission-impossible-outtakes.htm', |
53bfd6b2 | 25 | 'info_dict': { |
65ba8b23 YCH |
26 | 'id': '20769', |
27 | 'ext': 'mp4', | |
9298d4e3 | 28 | 'title': 'Mission Impossible Outtakes', |
9b05bd42 | 29 | 'description': ('Watch Jamie Hyneman and Adam Savage practice being' |
9e1a5b84 JW |
30 | ' each other -- to the point of confusing Jamie\'s dog -- and ' |
31 | 'don\'t miss Adam moon-walking as Jamie ... behind Jamie\'s' | |
32 | ' back.'), | |
9b05bd42 | 33 | 'duration': 156, |
fec040e7 | 34 | 'timestamp': 1302032462, |
35 | 'upload_date': '20110405', | |
9b05bd42 | 36 | }, |
65ba8b23 YCH |
37 | 'params': { |
38 | 'skip_download': True, # requires ffmpeg | |
39 | } | |
40 | }, { | |
41 | 'url': 'http://www.discovery.com/tv-shows/mythbusters/videos/mythbusters-the-simpsons', | |
42 | 'info_dict': { | |
43 | 'id': 'mythbusters-the-simpsons', | |
44 | 'title': 'MythBusters: The Simpsons', | |
45 | }, | |
fec040e7 | 46 | 'playlist_mincount': 10, |
47 | }, { | |
48 | 'url': 'http://www.animalplanet.com/longfin-eels-maneaters/', | |
49 | 'info_dict': { | |
50 | 'id': '78326', | |
51 | 'ext': 'mp4', | |
52 | 'title': 'Longfin Eels: Maneaters?', | |
53 | 'description': 'Jeremy Wade tests whether or not New Zealand\'s longfin eels are man-eaters by covering himself in fish guts and getting in the water with them.', | |
54 | 'upload_date': '20140725', | |
55 | 'timestamp': 1406246400, | |
56 | 'duration': 116, | |
57 | }, | |
65ba8b23 | 58 | }] |
53bfd6b2 | 59 | |
60 | def _real_extract(self, url): | |
fec040e7 | 61 | display_id = self._match_id(url) |
62 | info = self._download_json(url + '?flat=1', display_id) | |
9b05bd42 | 63 | |
65ba8b23 | 64 | video_title = info.get('playlist_title') or info.get('video_title') |
53bfd6b2 | 65 | |
65ba8b23 YCH |
66 | entries = [{ |
67 | 'id': compat_str(video_info['id']), | |
68 | 'formats': self._extract_m3u8_formats( | |
fec040e7 | 69 | video_info['src'], display_id, 'mp4', 'm3u8_native', m3u8_id='hls', |
65ba8b23 YCH |
70 | note='Download m3u8 information for video %d' % (idx + 1)), |
71 | 'title': video_info['title'], | |
72 | 'description': video_info.get('description'), | |
73 | 'duration': parse_duration(video_info.get('video_length')), | |
fec040e7 | 74 | 'webpage_url': video_info.get('href') or video_info.get('url'), |
65ba8b23 YCH |
75 | 'thumbnail': video_info.get('thumbnailURL'), |
76 | 'alt_title': video_info.get('secondary_title'), | |
77 | 'timestamp': parse_iso8601(video_info.get('publishedDate')), | |
78 | } for idx, video_info in enumerate(info['playlist'])] | |
79 | ||
fec040e7 | 80 | return self.playlist_result(entries, display_id, video_title) |