]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/aparat.py
3 from __future__
import unicode_literals
7 from .common
import InfoExtractor
14 class AparatIE(InfoExtractor
):
15 _VALID_URL
= r
'^https?://(?:www\.)?aparat\.com/(?:v/|video/video/embed/videohash/)(?P<id>[a-zA-Z0-9]+)'
18 'url': 'http://www.aparat.com/v/wP8On',
19 'md5': '6714e0af7e0d875c5a39c4dc4ab46ad1',
23 'title': 'تیم گلکسی 11 - زومیت',
25 # 'skip': 'Extremely unreliable',
28 def _real_extract(self
, url
):
29 m
= re
.match(self
._VALID
_URL
, url
)
30 video_id
= m
.group('id')
32 # Note: There is an easier-to-parse configuration at
33 # http://www.aparat.com/video/video/config/videohash/%video_id
34 # but the URL in there does not work
35 embed_url
= ('http://www.aparat.com/video/video/embed/videohash/' +
36 video_id
+ '/vt/frame')
37 webpage
= self
._download
_webpage
(embed_url
, video_id
)
39 video_urls
= re
.findall(r
'fileList\[[0-9]+\]\s*=\s*"([^"]+)"', webpage
)
40 for i
, video_url
in enumerate(video_urls
):
41 req
= HEADRequest(video_url
)
42 res
= self
._request
_webpage
(
43 req
, video_id
, note
=u
'Testing video URL %d' % i
, errnote
=False)
47 raise ExtractorError(u
'No working video URLs found')
49 title
= self
._search
_regex
(r
'\s+title:\s*"([^"]+)"', webpage
, u
'title')
50 thumbnail
= self
._search
_regex
(
51 r
'\s+image:\s*"([^"]+)"', webpage
, u
'thumbnail', fatal
=False)
58 'thumbnail': thumbnail
,