2016-10-02 06:39:18 -05:00
|
|
|
|
# coding: utf-8
|
2015-12-20 19:26:37 -06:00
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2015-12-23 15:36:53 -06:00
|
|
|
|
from ..compat import compat_str
|
2015-12-20 19:26:37 -06:00
|
|
|
|
from ..utils import (
|
2015-12-23 15:36:53 -06:00
|
|
|
|
parse_iso8601,
|
|
|
|
|
int_or_none,
|
2015-12-20 19:26:37 -06:00
|
|
|
|
ExtractorError,
|
|
|
|
|
)
|
|
|
|
|
|
2015-12-23 15:36:53 -06:00
|
|
|
|
|
2015-12-20 19:26:37 -06:00
|
|
|
|
class TheInterceptIE(InfoExtractor):
|
2016-09-08 06:29:05 -05:00
|
|
|
|
_VALID_URL = r'https?://theintercept\.com/fieldofvision/(?P<id>[^/?#]+)'
|
2015-12-20 19:26:37 -06:00
|
|
|
|
_TESTS = [{
|
|
|
|
|
'url': 'https://theintercept.com/fieldofvision/thisisacoup-episode-four-surrender-or-die/',
|
2015-12-23 15:36:53 -06:00
|
|
|
|
'md5': '145f28b41d44aab2f87c0a4ac8ec95bd',
|
2015-12-20 19:26:37 -06:00
|
|
|
|
'info_dict': {
|
2015-12-23 15:36:53 -06:00
|
|
|
|
'id': '46214',
|
2015-12-20 19:26:37 -06:00
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': '#ThisIsACoup – Episode Four: Surrender or Die',
|
|
|
|
|
'description': 'md5:74dd27f0e2fbd50817829f97eaa33140',
|
2015-12-23 15:36:53 -06:00
|
|
|
|
'timestamp': 1450429239,
|
|
|
|
|
'upload_date': '20151218',
|
|
|
|
|
'comment_count': int,
|
2015-12-20 19:26:37 -06:00
|
|
|
|
}
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
display_id = self._match_id(url)
|
|
|
|
|
webpage = self._download_webpage(url, display_id)
|
|
|
|
|
|
2015-12-23 15:36:53 -06:00
|
|
|
|
json_data = self._parse_json(self._search_regex(
|
|
|
|
|
r'initialStoreTree\s*=\s*(?P<json_data>{.+})', webpage,
|
|
|
|
|
'initialStoreTree'), display_id)
|
2015-12-20 19:26:37 -06:00
|
|
|
|
|
|
|
|
|
for post in json_data['resources']['posts'].values():
|
|
|
|
|
if post['slug'] == display_id:
|
2015-12-23 15:36:53 -06:00
|
|
|
|
return {
|
|
|
|
|
'_type': 'url_transparent',
|
|
|
|
|
'url': 'jwplatform:%s' % post['fov_videoid'],
|
|
|
|
|
'id': compat_str(post['ID']),
|
|
|
|
|
'display_id': display_id,
|
|
|
|
|
'title': post['title'],
|
|
|
|
|
'description': post.get('excerpt'),
|
|
|
|
|
'timestamp': parse_iso8601(post.get('date')),
|
|
|
|
|
'comment_count': int_or_none(post.get('comments_number')),
|
|
|
|
|
}
|
|
|
|
|
raise ExtractorError('Unable to find the current post')
|