]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/skynewsarabia.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_str
12 class SkyNewsArabiaBaseIE(InfoExtractor
):
13 _IMAGE_BASE_URL
= 'http://www.skynewsarabia.com/web/images'
15 def _call_api(self
, path
, value
):
16 return self
._download
_json
('http://api.skynewsarabia.com/web/rest/v2/%s/%s.json' % (path
, value
), value
)
18 def _get_limelight_media_id(self
, url
):
19 return self
._search
_regex
(r
'/media/[^/]+/([a-z0-9]{32})', url
, 'limelight media id')
21 def _get_image_url(self
, image_path_template
, width
='1600', height
='1200'):
22 return self
._IMAGE
_BASE
_URL
+ image_path_template
.format(width
=width
, height
=height
)
24 def _extract_video_info(self
, video_data
):
25 video_id
= compat_str(video_data
['id'])
26 topic
= video_data
.get('topicTitle')
28 '_type': 'url_transparent',
29 'url': 'limelight:media:%s' % self
._get
_limelight
_media
_id
(video_data
['videoUrl'][0]['url']),
31 'title': video_data
['headline'],
32 'description': video_data
.get('summary'),
33 'thumbnail': self
._get
_image
_url
(video_data
['mediaAsset']['imageUrl']),
34 'timestamp': parse_iso8601(video_data
.get('date')),
35 'duration': parse_duration(video_data
.get('runTime')),
36 'tags': video_data
.get('tags', []),
37 'categories': [topic
] if topic
else [],
38 'webpage_url': 'http://www.skynewsarabia.com/web/video/%s' % video_id
,
39 'ie_key': 'LimelightMedia',
43 class SkyNewsArabiaIE(SkyNewsArabiaBaseIE
):
44 IE_NAME
= 'skynewsarabia:video'
45 _VALID_URL
= r
'https?://(?:www\.)?skynewsarabia\.com/web/video/(?P<id>[0-9]+)'
47 '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',
51 'title': 'نصف مليون مصباح على شجرة كريسماس',
52 'description': 'md5:22f1b27f0850eeb10c7e59b1f16eb7c6',
53 'upload_date': '20151128',
54 'timestamp': 1448697198,
59 'skip_download': True,
63 def _real_extract(self
, url
):
64 video_id
= self
._match
_id
(url
)
65 video_data
= self
._call
_api
('video', video_id
)
66 return self
._extract
_video
_info
(video_data
)
69 class SkyNewsArabiaArticleIE(SkyNewsArabiaBaseIE
):
70 IE_NAME
= 'skynewsarabia:video'
71 _VALID_URL
= r
'https?://(?:www\.)?skynewsarabia\.com/web/article/(?P<id>[0-9]+)'
73 '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',
77 'title': 'بالفيديو.. ألعاب ذكية تحاكي واقع المنطقة',
78 'description': 'md5:0c373d29919a851e080ee4edd0c5d97f',
79 'upload_date': '20151126',
80 'timestamp': 1448559336,
85 'skip_download': True,
88 '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',
91 'title': 'إحباط تهريب أسلحة لميليشيات الحوثي وصالح بجنوب اليمن',
92 'description': 'md5:5c927b8b2e805796e7f693538d96fc7e',
94 'playlist_mincount': 2,
97 def _real_extract(self
, url
):
98 article_id
= self
._match
_id
(url
)
99 article_data
= self
._call
_api
('article', article_id
)
100 media_asset
= article_data
['mediaAsset']
101 if media_asset
['type'] == 'VIDEO':
102 topic
= article_data
.get('topicTitle')
104 '_type': 'url_transparent',
105 'url': 'limelight:media:%s' % self
._get
_limelight
_media
_id
(media_asset
['videoUrl'][0]['url']),
107 'title': article_data
['headline'],
108 'description': article_data
.get('summary'),
109 'thumbnail': self
._get
_image
_url
(media_asset
['imageUrl']),
110 'timestamp': parse_iso8601(article_data
.get('date')),
111 'tags': article_data
.get('tags', []),
112 'categories': [topic
] if topic
else [],
114 'ie_key': 'LimelightMedia',
116 entries
= [self
._extract
_video
_info
(item
) for item
in article_data
.get('inlineItems', []) if item
['type'] == 'VIDEO']
117 return self
.playlist_result(entries
, article_id
, article_data
['headline'], article_data
.get('summary'))