1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-07-08 21:04:38 +02:00
yt-dlp/yt_dlp/extractor/theintercept.py
Simon Sawicki e897bd8292
[misc] Add hatch, ruff, pre-commit and improve dev docs (#7409)
Authored by: bashonly, seproDev, Grub4K

Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
2024-05-26 21:27:21 +02:00

47 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
ExtractorError,
int_or_none,
parse_iso8601,
)
class TheInterceptIE(InfoExtractor):
_VALID_URL = r'https?://theintercept\.com/fieldofvision/(?P<id>[^/?#]+)'
_TESTS = [{
'url': 'https://theintercept.com/fieldofvision/thisisacoup-episode-four-surrender-or-die/',
'md5': '145f28b41d44aab2f87c0a4ac8ec95bd',
'info_dict': {
'id': '46214',
'ext': 'mp4',
'title': '#ThisIsACoup Episode Four: Surrender or Die',
'description': 'md5:74dd27f0e2fbd50817829f97eaa33140',
'timestamp': 1450429239,
'upload_date': '20151218',
'comment_count': int,
}
}]
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
json_data = self._parse_json(self._search_regex(
r'initialStoreTree\s*=\s*(?P<json_data>{.+})', webpage,
'initialStoreTree'), display_id)
for post in json_data['resources']['posts'].values():
if post['slug'] == display_id:
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')