]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/israelnationalnews.py
[ie/orf:on] Improve extraction (#9677)
[yt-dlp.git] / yt_dlp / extractor / israelnationalnews.py
CommitLineData
0d887f27
B
1from .common import InfoExtractor
2from ..utils import ExtractorError, traverse_obj
3
4
5class IsraelNationalNewsIE(InfoExtractor):
6 _VALID_URL = r'https?://(?:www\.)?israelnationalnews\.com/news/(?P<id>\d+)'
7 _TESTS = [{
8 'url': 'https://www.israelnationalnews.com/news/354520',
9 'info_dict': {
10 'id': '354520'
11 },
12 'playlist': [{
13 'info_dict': {
14 'id': 'jA84wQhVvg8',
15 'title': 'Even CNN Host Is Shocked by How Bad Biden\'s Approval Ratings Have Gotten | DM CLIPS | Rubin Report',
16 'ext': 'mp4',
17 'description': 'md5:b7325a3d00c7596337dc3ae37e32d35c',
18 'channel': 'The Rubin Report',
19 'channel_follower_count': int,
20 'comment_count': int,
21 'categories': ['News & Politics'],
22 'like_count': int,
23 'uploader_url': 'http://www.youtube.com/user/RubinReport',
24 'uploader_id': 'RubinReport',
25 'availability': 'public',
26 'view_count': int,
27 'duration': 240,
28 'thumbnail': 'https://i.ytimg.com/vi_webp/jA84wQhVvg8/maxresdefault.webp',
29 'live_status': 'not_live',
30 'playable_in_embed': True,
31 'age_limit': 0,
32 'tags': 'count:29',
33 'channel_id': 'UCJdKr0Bgd_5saZYqLCa9mng',
34 'channel_url': 'https://www.youtube.com/channel/UCJdKr0Bgd_5saZYqLCa9mng',
35 'upload_date': '20220606',
36 'uploader': 'The Rubin Report',
37 }
38 }]
39 }]
40
41 def _real_extract(self, url):
42 news_article_id = self._match_id(url)
43 article_json = self._download_json(
44 f'https://www.israelnationalnews.com/Generic/NewAPI/Item?type=0&Item={news_article_id}', news_article_id)
45
46 urls = traverse_obj(article_json, ('Content2', ..., 'content', ..., 'attrs', 'src'))
47 if not urls:
48 raise ExtractorError('This article does not have any videos', expected=True)
49
50 return self.playlist_from_matches(urls, news_article_id, ie='Youtube')