]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/aparat.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
13 class AparatIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?aparat\.com/(?:v/|video/video/embed/videohash/)(?P<id>[a-zA-Z0-9]+)'
17 'url': 'http://www.aparat.com/v/wP8On',
18 'md5': '131aca2e14fe7c4dcb3c4877ba300c89',
22 'title': 'تیم گلکسی 11 - زومیت',
23 'description': 'md5:096bdabcdcc4569f2b8a5e903a3b3028',
25 'timestamp': 1387394859,
26 'upload_date': '20131218',
31 'url': 'https://www.aparat.com/v/8dflw/',
32 'only_matching': True,
35 def _real_extract(self
, url
):
36 video_id
= self
._match
_id
(url
)
38 # Provides more metadata
39 webpage
= self
._download
_webpage
(url
, video_id
, fatal
=False)
42 # Note: There is an easier-to-parse configuration at
43 # http://www.aparat.com/video/video/config/videohash/%video_id
44 # but the URL in there does not work
45 webpage
= self
._download
_webpage
(
46 'http://www.aparat.com/video/video/embed/vt/frame/showvideo/yes/videohash/' + video_id
,
49 options
= self
._parse
_json
(
51 r
'options\s*=\s*JSON\.parse\(\s*(["\'])(?P
<value
>(?
:(?
!\
1).)+)\
1\s
*\
)',
52 webpage, 'options
', group='value
'),
55 player = options['plugins
']['sabaPlayerPlugin
']
58 for sources in player['multiSRC
']:
60 if not isinstance(item, dict):
62 file_url = url_or_none(item.get('src
'))
65 item_type = item.get('type')
66 if item_type == 'application
/vnd
.apple
.mpegurl
':
67 formats.extend(self._extract_m3u8_formats(
68 file_url, video_id, 'mp4
',
69 entry_protocol='m3u8_native
', m3u8_id='hls
',
72 ext = mimetype2ext(item.get('type'))
73 label = item.get('label
')
77 'format_id
': 'http
-%s' % (label or ext),
78 'height
': int_or_none(self._search_regex(
79 r'(\d
+)[pP
]', label or '', 'height
',
83 formats, field_preference=('height
', 'width
', 'tbr
', 'format_id
'))
85 info = self._search_json_ld(webpage, video_id, default={})
87 if not info.get('title
'):
88 info['title
'] = player['title
']
90 return merge_dicts(info, {
92 'thumbnail
': url_or_none(options.get('poster
')),
93 'duration
': int_or_none(player.get('duration
')),