2 from __future__ import unicode_literals
4 from .common import InfoExtractor
11 class EllenTubeIE(InfoExtractor):
14 https://api-prod\.ellentube\.com/ellenapi/api/item/
18 [\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}
22 'url': 'https://api-prod.ellentube.com/ellenapi/api/item/75c64c16-aefd-4558-b4f5-3de09b22e6fc',
25 'url': 'ellentube:734a3353-f697-4e79-9ca9-bfc3002dc1e0',
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
31 data = self._download_json(
32 'https://api-prod.ellentube.com/ellenapi/api/item/%s' % video_id, video_id)
34 description = data.get('description')
35 publish_time = int_or_none(data.get('publishTime'))
36 thumbnail = data.get('thumbnail')
40 for entry in data.get('media'):
41 if entry.get('id') == 'm3u8':
42 formats = self._extract_m3u8_formats(
43 entry.get('url'), video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls')
44 duration = int_or_none(entry.get('duration'))
46 self._sort_formats(formats)
50 'description': description,
52 'thumbnail': thumbnail,
53 'timestamp': publish_time,
58 class EllenTubeVideoIE(InfoExtractor):
59 _VALID_URL = r'https?://(?:www\.)?ellentube\.com/video/(?P<id>.+)\.html'
62 'url': 'https://www.ellentube.com/video/ellen-meets-las-vegas-survivors-jesus-campos-and-stephen-schuck.html',
63 'md5': '2fabc277131bddafdd120e0fc0f974c9',
65 'id': '0822171c-3829-43bf-b99f-d77358ae75e3',
67 'title': 'Ellen Meets Las Vegas Survivors Jesus Campos and Stephen Schuck',
68 'description': 'md5:76e3355e2242a78ad9e3858e5616923f',
70 'timestamp': 1508505120000,
71 'thumbnail': 'https://warnerbros-h.assetsadobe.com/is/image/content/dam/ellen/videos/episodes/season15/32/video--2728751654987218111',
75 def _real_extract(self, url):
76 display_id = self._match_id(url)
77 webpage = self._download_webpage(url, display_id)
78 video_id = self._html_search_regex(
79 r'(?s)<!--\s*CONTENT\s*-->.*data-config.+([\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})',
81 return self.url_result('ellentube:%s' % video_id, 'EllenTube')
84 class EllenTubePlaylistIE(InfoExtractor):
85 def _extract_videos_from_json(self, data, display_id):
86 return [self.url_result('ellentube:%s' % elem['id'], 'EllenTube')
87 for elem in data if elem.get('type') == 'VIDEO']
89 def _extract_playlist(self, url, display_id, extract_description=True):
90 webpage = self._download_webpage(url, display_id)
91 playlist_data = self._html_search_regex(
92 r'<div\s+data-component\s*=\s*"Details"(.+)</div>', webpage, 'playlist data')
93 playlist_title = self._search_regex(
94 r'"title"\s*:\s*"(.+?)"', playlist_data, 'playlist title')
95 playlist_description = clean_html(self._search_regex(
96 r'"description"\s*:\s*"(.+?)"', playlist_data, 'playlist description',
97 fatal=False)) if extract_description else None
98 api_search = self._search_regex(
99 r'"filter"\s*:\s*"(.+?)"', playlist_data, 'playlist api request')
100 api_data = self._download_json(
101 'https://api-prod.ellentube.com/ellenapi/api/feed/?%s' % api_search,
103 return self.playlist_result(
104 self._extract_videos_from_json(api_data, display_id),
105 display_id, playlist_title, playlist_description)
108 class EllenTubeEpisodeIE(EllenTubePlaylistIE):
109 _VALID_URL = r'https?://(?:www\.)?ellentube\.com/episode/(?P<id>.+)\.html'
112 'url': 'https://www.ellentube.com/episode/dax-shepard-jordan-fisher-haim.html',
114 'id': 'dax-shepard-jordan-fisher-haim',
115 'title': 'Dax Shepard, \'DWTS\' Team Jordan Fisher & Lindsay Arnold, HAIM',
116 'description': 'md5:aed85d42892f6126e71ec5ed2aea2a0d'
121 def _real_extract(self, url):
122 display_id = self._match_id(url)
123 return self._extract_playlist(url, display_id)
126 class EllenTubeStudioIE(EllenTubePlaylistIE):
127 _VALID_URL = r'https?://(?:www\.)?ellentube\.com/studios/(?P<id>.+)\.html'
130 'url': 'https://www.ellentube.com/studios/macey-goes-rving0.html',
132 'id': 'macey-goes-rving0',
133 'title': 'Macey Goes RVing',
135 'playlist_mincount': 3,
138 def _real_extract(self, url):
139 display_id = self._match_id(url)
140 return self._extract_playlist(url, display_id, False)