]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/skynewsarabia.py
1 from .common
import InfoExtractor
8 class SkyNewsArabiaBaseIE(InfoExtractor
):
9 _IMAGE_BASE_URL
= 'http://www.skynewsarabia.com/web/images'
11 def _call_api(self
, path
, value
):
12 return self
._download
_json
(f
'http://api.skynewsarabia.com/web/rest/v2/{path}/{value}.json', value
)
14 def _get_limelight_media_id(self
, url
):
15 return self
._search
_regex
(r
'/media/[^/]+/([a-z0-9]{32})', url
, 'limelight media id')
17 def _get_image_url(self
, image_path_template
, width
='1600', height
='1200'):
18 return self
._IMAGE
_BASE
_URL
+ image_path_template
.format(width
=width
, height
=height
)
20 def _extract_video_info(self
, video_data
):
21 video_id
= str(video_data
['id'])
22 topic
= video_data
.get('topicTitle')
24 '_type': 'url_transparent',
25 'url': 'limelight:media:{}'.format(self
._get
_limelight
_media
_id
(video_data
['videoUrl'][0]['url'])),
27 'title': video_data
['headline'],
28 'description': video_data
.get('summary'),
29 'thumbnail': self
._get
_image
_url
(video_data
['mediaAsset']['imageUrl']),
30 'timestamp': parse_iso8601(video_data
.get('date')),
31 'duration': parse_duration(video_data
.get('runTime')),
32 'tags': video_data
.get('tags', []),
33 'categories': [topic
] if topic
else [],
34 'webpage_url': f
'http://www.skynewsarabia.com/web/video/{video_id}',
35 'ie_key': 'LimelightMedia',
39 class SkyNewsArabiaIE(SkyNewsArabiaBaseIE
):
41 IE_NAME
= 'skynewsarabia:video'
42 _VALID_URL
= r
'https?://(?:www\.)?skynewsarabia\.com/web/video/(?P<id>[0-9]+)'
44 'url': 'http://www.skynewsarabia.com/web/video/794902/%D9%86%D8%B5%D9%81-%D9%85%D9%84%D9%8A%D9%88%D9%86-%D9%85%D8%B5%D8%A8%D8%A7%D8%AD-%D8%B4%D8%AC%D8%B1%D8%A9-%D9%83%D8%B1%D9%8A%D8%B3%D9%85%D8%A7%D8%B3',
48 'title': 'نصف مليون مصباح على شجرة كريسماس',
49 'description': 'md5:22f1b27f0850eeb10c7e59b1f16eb7c6',
50 'upload_date': '20151128',
51 'timestamp': 1448697198,
56 'skip_download': True,
60 def _real_extract(self
, url
):
61 video_id
= self
._match
_id
(url
)
62 video_data
= self
._call
_api
('video', video_id
)
63 return self
._extract
_video
_info
(video_data
)
66 class SkyNewsArabiaArticleIE(SkyNewsArabiaBaseIE
):
68 IE_NAME
= 'skynewsarabia:article'
69 _VALID_URL
= r
'https?://(?:www\.)?skynewsarabia\.com/web/article/(?P<id>[0-9]+)'
71 'url': 'http://www.skynewsarabia.com/web/article/794549/%D8%A7%D9%94%D8%AD%D8%AF%D8%A7%D8%AB-%D8%A7%D9%84%D8%B4%D8%B1%D9%82-%D8%A7%D9%84%D8%A7%D9%94%D9%88%D8%B3%D8%B7-%D8%AE%D8%B1%D9%8A%D8%B7%D8%A9-%D8%A7%D9%84%D8%A7%D9%94%D9%84%D8%B9%D8%A7%D8%A8-%D8%A7%D9%84%D8%B0%D9%83%D9%8A%D8%A9',
75 'title': 'بالفيديو.. ألعاب ذكية تحاكي واقع المنطقة',
76 'description': 'md5:0c373d29919a851e080ee4edd0c5d97f',
77 'upload_date': '20151126',
78 'timestamp': 1448559336,
83 'skip_download': True,
86 'url': 'http://www.skynewsarabia.com/web/article/794844/%D8%A7%D8%B3%D8%AA%D9%87%D8%AF%D8%A7%D9%81-%D9%82%D9%88%D8%A7%D8%B1%D8%A8-%D8%A7%D9%94%D8%B3%D9%84%D8%AD%D8%A9-%D9%84%D9%85%D9%8A%D9%84%D9%8A%D8%B4%D9%8A%D8%A7%D8%AA-%D8%A7%D9%84%D8%AD%D9%88%D8%AB%D9%8A-%D9%88%D8%B5%D8%A7%D9%84%D8%AD',
89 'title': 'إحباط تهريب أسلحة لميليشيات الحوثي وصالح بجنوب اليمن',
90 'description': 'md5:5c927b8b2e805796e7f693538d96fc7e',
92 'playlist_mincount': 2,
95 def _real_extract(self
, url
):
96 article_id
= self
._match
_id
(url
)
97 article_data
= self
._call
_api
('article', article_id
)
98 media_asset
= article_data
['mediaAsset']
99 if media_asset
['type'] == 'VIDEO':
100 topic
= article_data
.get('topicTitle')
102 '_type': 'url_transparent',
103 'url': 'limelight:media:{}'.format(self
._get
_limelight
_media
_id
(media_asset
['videoUrl'][0]['url'])),
105 'title': article_data
['headline'],
106 'description': article_data
.get('summary'),
107 'thumbnail': self
._get
_image
_url
(media_asset
['imageUrl']),
108 'timestamp': parse_iso8601(article_data
.get('date')),
109 'tags': article_data
.get('tags', []),
110 'categories': [topic
] if topic
else [],
112 'ie_key': 'LimelightMedia',
114 entries
= [self
._extract
_video
_info
(item
) for item
in article_data
.get('inlineItems', []) if item
['type'] == 'VIDEO']
115 return self
.playlist_result(entries
, article_id
, article_data
['headline'], article_data
.get('summary'))