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