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