You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.8 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_str
  5. from ..utils import (
  6. parse_iso8601,
  7. int_or_none,
  8. ExtractorError,
  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. def _real_extract(self, url):
  26. display_id = self._match_id(url)
  27. webpage = self._download_webpage(url, display_id)
  28. json_data = self._parse_json(self._search_regex(
  29. r'initialStoreTree\s*=\s*(?P<json_data>{.+})', webpage,
  30. 'initialStoreTree'), display_id)
  31. for post in json_data['resources']['posts'].values():
  32. if post['slug'] == display_id:
  33. return {
  34. '_type': 'url_transparent',
  35. 'url': 'jwplatform:%s' % post['fov_videoid'],
  36. 'id': compat_str(post['ID']),
  37. 'display_id': display_id,
  38. 'title': post['title'],
  39. 'description': post.get('excerpt'),
  40. 'timestamp': parse_iso8601(post.get('date')),
  41. 'comment_count': int_or_none(post.get('comments_number')),
  42. }
  43. raise ExtractorError('Unable to find the current post')