]>
Commit | Line | Data |
---|---|---|
3cfafc4a AK |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
3cfafc4a AK |
4 | import json |
5 | ||
1d01f26a PH |
6 | from .common import InfoExtractor |
7 | from ..utils import ( | |
8 | ExtractorError, | |
9 | parse_iso8601, | |
10 | ) | |
11 | ||
3cfafc4a AK |
12 | |
13 | class EllenTVIE(InfoExtractor): | |
f4f33952 | 14 | _VALID_URL = r'https?://(?:www\.)?(?:ellentv|ellentube)\.com/videos/(?P<id>[a-z0-9_-]+)' |
6e46c3f1 | 15 | _TESTS = [{ |
3cfafc4a AK |
16 | 'url': 'http://www.ellentv.com/videos/0-7jqrsr18/', |
17 | 'md5': 'e4af06f3bf0d5f471921a18db5764642', | |
18 | 'info_dict': { | |
19 | 'id': '0-7jqrsr18', | |
20 | 'ext': 'mp4', | |
1d01f26a | 21 | 'title': 'What\'s Wrong with These Photos? A Whole Lot', |
baa3c3f0 | 22 | 'description': 'md5:35f152dc66b587cf13e6d2cf4fa467f6', |
1d01f26a PH |
23 | 'timestamp': 1406876400, |
24 | 'upload_date': '20140801', | |
3cfafc4a | 25 | } |
f4f33952 | 26 | }, { |
6e46c3f1 G |
27 | 'url': 'http://ellentube.com/videos/0-dvzmabd5/', |
28 | 'md5': '98238118eaa2bbdf6ad7f708e3e4f4eb', | |
29 | 'info_dict': { | |
30 | 'id': '0-dvzmabd5', | |
31 | 'ext': 'mp4', | |
32 | 'title': '1 year old twin sister makes her brother laugh', | |
baa3c3f0 | 33 | 'description': '1 year old twin sister makes her brother laugh', |
6e46c3f1 G |
34 | 'timestamp': 1419542075, |
35 | 'upload_date': '20141225', | |
36 | } | |
37 | }] | |
3cfafc4a AK |
38 | |
39 | def _real_extract(self, url): | |
f4f33952 | 40 | video_id = self._match_id(url) |
3cfafc4a | 41 | |
1d01f26a | 42 | webpage = self._download_webpage(url, video_id) |
baa3c3f0 S |
43 | video_url = self._html_search_meta('VideoURL', webpage, 'url') |
44 | title = self._og_search_title(webpage, default=None) or self._search_regex( | |
45 | r'pageName\s*=\s*"([^"]+)"', webpage, 'title') | |
46 | description = self._html_search_meta( | |
47 | 'description', webpage, 'description') or self._og_search_description(webpage) | |
1d01f26a PH |
48 | timestamp = parse_iso8601(self._search_regex( |
49 | r'<span class="publish-date"><time datetime="([^"]+)">', | |
50 | webpage, 'timestamp')) | |
3cfafc4a AK |
51 | |
52 | return { | |
1d01f26a | 53 | 'id': video_id, |
baa3c3f0 S |
54 | 'url': video_url, |
55 | 'title': title, | |
56 | 'description': description, | |
1d01f26a | 57 | 'timestamp': timestamp, |
3cfafc4a AK |
58 | } |
59 | ||
1d01f26a | 60 | |
3cfafc4a | 61 | class EllenTVClipsIE(InfoExtractor): |
1d01f26a | 62 | IE_NAME = 'EllenTV:clips' |
3cfafc4a AK |
63 | _VALID_URL = r'https?://(?:www\.)?ellentv\.com/episodes/(?P<id>[a-z0-9_-]+)' |
64 | _TEST = { | |
65 | 'url': 'http://www.ellentv.com/episodes/meryl-streep-vanessa-hudgens/', | |
3cfafc4a | 66 | 'info_dict': { |
1d01f26a PH |
67 | 'id': 'meryl-streep-vanessa-hudgens', |
68 | 'title': 'Meryl Streep, Vanessa Hudgens', | |
69 | }, | |
70 | 'playlist_mincount': 9, | |
3cfafc4a AK |
71 | } |
72 | ||
73 | def _real_extract(self, url): | |
f4f33952 | 74 | playlist_id = self._match_id(url) |
3cfafc4a AK |
75 | |
76 | webpage = self._download_webpage(url, playlist_id) | |
77 | playlist = self._extract_playlist(webpage) | |
78 | ||
79 | return { | |
80 | '_type': 'playlist', | |
81 | 'id': playlist_id, | |
82 | 'title': self._og_search_title(webpage), | |
83 | 'entries': self._extract_entries(playlist) | |
84 | } | |
85 | ||
86 | def _extract_playlist(self, webpage): | |
87 | json_string = self._search_regex(r'playerView.addClips\(\[\{(.*?)\}\]\);', webpage, 'json') | |
88 | try: | |
89 | return json.loads("[{" + json_string + "}]") | |
90 | except ValueError as ve: | |
91 | raise ExtractorError('Failed to download JSON', cause=ve) | |
92 | ||
93 | def _extract_entries(self, playlist): | |
1d01f26a | 94 | return [self.url_result(item['url'], 'EllenTV') for item in playlist] |