]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/skynewsarabia.py
1 from .common
import InfoExtractor
2 from ..compat
import compat_str
9 class SkyNewsArabiaBaseIE(InfoExtractor
):
10 _IMAGE_BASE_URL
= 'http://www.skynewsarabia.com/web/images'
12 def _call_api(self
, path
, value
):
13 return self
._download
_json
('http://api.skynewsarabia.com/web/rest/v2/%s/%s.json' % (path
, value
), value
)
15 def _get_limelight_media_id(self
, url
):
16 return self
._search
_regex
(r
'/media/[^/]+/([a-z0-9]{32})', url
, 'limelight media id')
18 def _get_image_url(self
, image_path_template
, width
='1600', height
='1200'):
19 return self
._IMAGE
_BASE
_URL
+ image_path_template
.format(width
=width
, height
=height
)
21 def _extract_video_info(self
, video_data
):
22 video_id
= compat_str(video_data
['id'])
23 topic
= video_data
.get('topicTitle')
25 '_type': 'url_transparent',
26 'url': 'limelight:media:%s' % self
._get
_limelight
_media
_id
(video_data
['videoUrl'][0]['url']),
28 'title': video_data
['headline'],
29 'description': video_data
.get('summary'),
30 'thumbnail': self
._get
_image
_url
(video_data
['mediaAsset']['imageUrl']),
31 'timestamp': parse_iso8601(video_data
.get('date')),
32 'duration': parse_duration(video_data
.get('runTime')),
33 'tags': video_data
.get('tags', []),
34 'categories': [topic
] if topic
else [],
35 'webpage_url': 'http://www.skynewsarabia.com/web/video/%s' % video_id
,
36 'ie_key': 'LimelightMedia',
40 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
):
67 IE_NAME
= 'skynewsarabia:article'
68 _VALID_URL
= r
'https?://(?:www\.)?skynewsarabia\.com/web/article/(?P<id>[0-9]+)'
70 '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',
74 'title': 'بالفيديو.. ألعاب ذكية تحاكي واقع المنطقة',
75 'description': 'md5:0c373d29919a851e080ee4edd0c5d97f',
76 'upload_date': '20151126',
77 'timestamp': 1448559336,
82 'skip_download': True,
85 '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',
88 'title': 'إحباط تهريب أسلحة لميليشيات الحوثي وصالح بجنوب اليمن',
89 'description': 'md5:5c927b8b2e805796e7f693538d96fc7e',
91 'playlist_mincount': 2,
94 def _real_extract(self
, url
):
95 article_id
= self
._match
_id
(url
)
96 article_data
= self
._call
_api
('article', article_id
)
97 media_asset
= article_data
['mediaAsset']
98 if media_asset
['type'] == 'VIDEO':
99 topic
= article_data
.get('topicTitle')
101 '_type': 'url_transparent',
102 'url': 'limelight:media:%s' % self
._get
_limelight
_media
_id
(media_asset
['videoUrl'][0]['url']),
104 'title': article_data
['headline'],
105 'description': article_data
.get('summary'),
106 'thumbnail': self
._get
_image
_url
(media_asset
['imageUrl']),
107 'timestamp': parse_iso8601(article_data
.get('date')),
108 'tags': article_data
.get('tags', []),
109 'categories': [topic
] if topic
else [],
111 'ie_key': 'LimelightMedia',
113 entries
= [self
._extract
_video
_info
(item
) for item
in article_data
.get('inlineItems', []) if item
['type'] == 'VIDEO']
114 return self
.playlist_result(entries
, article_id
, article_data
['headline'], article_data
.get('summary'))