2 from __future__ import unicode_literals
4 from .common import InfoExtractor
14 class EllenTubeBaseIE(InfoExtractor):
15 def _extract_data_config(self, webpage, video_id):
16 details = self._search_regex(
17 r'(<[^>]+\bdata-component=(["\'])[Dd]etails.+?></div>)', webpage,
19 return self._parse_json(
20 extract_attributes(details)['data-config'], video_id)
22 def _extract_video(self, data, video_id):
27 for entry in data.get('media'):
28 if entry.get('id') == 'm3u8':
29 formats = self._extract_m3u8_formats(
30 entry['url'], video_id, 'mp4',
31 entry_protocol='m3u8_native', m3u8_id='hls')
32 duration = int_or_none(entry.get('duration'))
34 self._sort_formats(formats)
36 def get_insight(kind):
37 return int_or_none(try_get(
38 data, lambda x: x['insight']['%ss' % kind]))
41 'extractor_key': EllenTubeIE.ie_key(),
44 'description': data.get('description'),
46 'thumbnail': data.get('thumbnail'),
47 'timestamp': float_or_none(data.get('publishTime'), scale=1000),
48 'view_count': get_insight('view'),
49 'like_count': get_insight('like'),
54 class EllenTubeIE(EllenTubeBaseIE):
58 https://api-prod\.ellentube\.com/ellenapi/api/item/
60 (?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})
63 'url': 'https://api-prod.ellentube.com/ellenapi/api/item/0822171c-3829-43bf-b99f-d77358ae75e3',
64 'md5': '2fabc277131bddafdd120e0fc0f974c9',
66 'id': '0822171c-3829-43bf-b99f-d77358ae75e3',
68 'title': 'Ellen Meets Las Vegas Survivors Jesus Campos and Stephen Schuck',
69 'description': 'md5:76e3355e2242a78ad9e3858e5616923f',
70 'thumbnail': r're:^https?://.+?',
72 'timestamp': 1508505120,
73 'upload_date': '20171020',
78 'url': 'ellentube:734a3353-f697-4e79-9ca9-bfc3002dc1e0',
79 'only_matching': True,
82 def _real_extract(self, url):
83 video_id = self._match_id(url)
84 data = self._download_json(
85 'https://api-prod.ellentube.com/ellenapi/api/item/%s' % video_id,
87 return self._extract_video(data, video_id)
90 class EllenTubeVideoIE(EllenTubeBaseIE):
91 _VALID_URL = r'https?://(?:www\.)?ellentube\.com/video/(?P<id>.+?)\.html'
93 'url': 'https://www.ellentube.com/video/ellen-meets-las-vegas-survivors-jesus-campos-and-stephen-schuck.html',
94 'only_matching': True,
97 def _real_extract(self, url):
98 display_id = self._match_id(url)
99 webpage = self._download_webpage(url, display_id)
100 video_id = self._extract_data_config(webpage, display_id)['id']
101 return self.url_result(
102 'ellentube:%s' % video_id, ie=EllenTubeIE.ie_key(),
106 class EllenTubePlaylistIE(EllenTubeBaseIE):
107 _VALID_URL = r'https?://(?:www\.)?ellentube\.com/(?:episode|studios)/(?P<id>.+?)\.html'
109 'url': 'https://www.ellentube.com/episode/dax-shepard-jordan-fisher-haim.html',
111 'id': 'dax-shepard-jordan-fisher-haim',
112 'title': "Dax Shepard, 'DWTS' Team Jordan Fisher & Lindsay Arnold, HAIM",
113 'description': 'md5:bfc982194dabb3f4e325e43aa6b2e21c',
117 'url': 'https://www.ellentube.com/studios/macey-goes-rving0.html',
118 'only_matching': True,
121 def _real_extract(self, url):
122 display_id = self._match_id(url)
123 webpage = self._download_webpage(url, display_id)
124 data = self._extract_data_config(webpage, display_id)['data']
125 feed = self._download_json(
126 'https://api-prod.ellentube.com/ellenapi/api/feed/?%s'
127 % data['filter'], display_id)
129 self._extract_video(elem, elem['id'])
130 for elem in feed if elem.get('type') == 'VIDEO' and elem.get('id')]
131 return self.playlist_result(
132 entries, display_id, data.get('title'),
133 clean_html(data.get('description')))