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