]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/discovery.py
[discovery] extract more info using BrightcoveNewIE
[yt-dlp.git] / youtube_dl / extractor / discovery.py
CommitLineData
53bfd6b2 1from __future__ import unicode_literals
2
33a1ec95 3import re
4
53bfd6b2 5from .common import InfoExtractor
9298d4e3 6from ..utils import (
65ba8b23 7 parse_duration,
9298d4e3 8 parse_iso8601,
9298d4e3 9)
33a1ec95 10from ..compat import (
11 compat_str,
12 compat_urlparse,
13)
53bfd6b2 14
15
16class DiscoveryIE(InfoExtractor):
96a9f22d 17 _VALID_URL = r'''(?x)https?://(?:www\.)?(?:
fec040e7 18 discovery|
19 investigationdiscovery|
20 discoverylife|
21 animalplanet|
22 ahctv|
23 destinationamerica|
24 sciencechannel|
25 tlc|
26 velocity
b05641ce 27 )\.com/(?:[^/]+/)*(?P<id>[^./?#]+)'''
65ba8b23 28 _TESTS = [{
cea2582d 29 'url': 'http://www.discovery.com/tv-shows/mythbusters/videos/mission-impossible-outtakes.htm',
53bfd6b2 30 'info_dict': {
65ba8b23
YCH
31 'id': '20769',
32 'ext': 'mp4',
9298d4e3 33 'title': 'Mission Impossible Outtakes',
9b05bd42 34 'description': ('Watch Jamie Hyneman and Adam Savage practice being'
9e1a5b84
JW
35 ' each other -- to the point of confusing Jamie\'s dog -- and '
36 'don\'t miss Adam moon-walking as Jamie ... behind Jamie\'s'
37 ' back.'),
9b05bd42 38 'duration': 156,
fec040e7 39 'timestamp': 1302032462,
40 'upload_date': '20110405',
d00b93d5 41 'uploader_id': '103207',
9b05bd42 42 },
65ba8b23
YCH
43 'params': {
44 'skip_download': True, # requires ffmpeg
45 }
46 }, {
47 'url': 'http://www.discovery.com/tv-shows/mythbusters/videos/mythbusters-the-simpsons',
48 'info_dict': {
49 'id': 'mythbusters-the-simpsons',
50 'title': 'MythBusters: The Simpsons',
51 },
fec040e7 52 'playlist_mincount': 10,
53 }, {
54 'url': 'http://www.animalplanet.com/longfin-eels-maneaters/',
55 'info_dict': {
56 'id': '78326',
57 'ext': 'mp4',
58 'title': 'Longfin Eels: Maneaters?',
59 '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.',
60 'upload_date': '20140725',
61 'timestamp': 1406246400,
62 'duration': 116,
d00b93d5 63 'uploader_id': '103207',
fec040e7 64 },
d00b93d5 65 'params': {
66 'skip_download': True, # requires ffmpeg
67 }
65ba8b23 68 }]
53bfd6b2 69
70 def _real_extract(self, url):
fec040e7 71 display_id = self._match_id(url)
72 info = self._download_json(url + '?flat=1', display_id)
9b05bd42 73
65ba8b23 74 video_title = info.get('playlist_title') or info.get('video_title')
53bfd6b2 75
19dbaeec
S
76 entries = []
77
78 for idx, video_info in enumerate(info['playlist']):
93f7a31b 79 subtitles = []
80 caption_url = video_info.get('captionsUrl')
81 if caption_url:
82 subtitles = {
83 'en': [{
84 'url': caption_url,
85 }]
86 }
87
19dbaeec 88 entries.append({
d00b93d5 89 '_type': 'url_transparent',
90 'url': 'http://players.brightcove.net/103207/default_default/index.html?videoId=ref:%s' % video_info['referenceId'],
19dbaeec 91 'id': compat_str(video_info['id']),
19dbaeec
S
92 'title': video_info['title'],
93 'description': video_info.get('description'),
94 'duration': parse_duration(video_info.get('video_length')),
95 'webpage_url': video_info.get('href') or video_info.get('url'),
96 'thumbnail': video_info.get('thumbnailURL'),
97 'alt_title': video_info.get('secondary_title'),
98 'timestamp': parse_iso8601(video_info.get('publishedDate')),
93f7a31b 99 'subtitles': subtitles,
19dbaeec 100 })
65ba8b23 101
fec040e7 102 return self.playlist_result(entries, display_id, video_title)