]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..compat import compat_str | |
3 | from ..utils import ( | |
4 | parse_iso8601, | |
5 | int_or_none, | |
6 | ExtractorError, | |
7 | ) | |
8 | ||
9 | ||
10 | class TheInterceptIE(InfoExtractor): | |
11 | _VALID_URL = r'https?://theintercept\.com/fieldofvision/(?P<id>[^/?#]+)' | |
12 | _TESTS = [{ | |
13 | 'url': 'https://theintercept.com/fieldofvision/thisisacoup-episode-four-surrender-or-die/', | |
14 | 'md5': '145f28b41d44aab2f87c0a4ac8ec95bd', | |
15 | 'info_dict': { | |
16 | 'id': '46214', | |
17 | 'ext': 'mp4', | |
18 | 'title': '#ThisIsACoup – Episode Four: Surrender or Die', | |
19 | 'description': 'md5:74dd27f0e2fbd50817829f97eaa33140', | |
20 | 'timestamp': 1450429239, | |
21 | 'upload_date': '20151218', | |
22 | 'comment_count': int, | |
23 | } | |
24 | }] | |
25 | ||
26 | def _real_extract(self, url): | |
27 | display_id = self._match_id(url) | |
28 | webpage = self._download_webpage(url, display_id) | |
29 | ||
30 | json_data = self._parse_json(self._search_regex( | |
31 | r'initialStoreTree\s*=\s*(?P<json_data>{.+})', webpage, | |
32 | 'initialStoreTree'), display_id) | |
33 | ||
34 | for post in json_data['resources']['posts'].values(): | |
35 | if post['slug'] == display_id: | |
36 | return { | |
37 | '_type': 'url_transparent', | |
38 | 'url': 'jwplatform:%s' % post['fov_videoid'], | |
39 | 'id': compat_str(post['ID']), | |
40 | 'display_id': display_id, | |
41 | 'title': post['title'], | |
42 | 'description': post.get('excerpt'), | |
43 | 'timestamp': parse_iso8601(post.get('date')), | |
44 | 'comment_count': int_or_none(post.get('comments_number')), | |
45 | } | |
46 | raise ExtractorError('Unable to find the current post') |