]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/aparat.py
2 from __future__
import unicode_literals
6 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': '6714e0af7e0d875c5a39c4dc4ab46ad1',
22 'title': 'تیم گلکسی 11 - زومیت',
25 # 'skip': 'Extremely unreliable',
28 def _real_extract(self
, url
):
29 video_id
= self
._match
_id
(url
)
31 # Note: There is an easier-to-parse configuration at
32 # http://www.aparat.com/video/video/config/videohash/%video_id
33 # but the URL in there does not work
34 embed_url
= ('http://www.aparat.com/video/video/embed/videohash/' +
35 video_id
+ '/vt/frame')
36 webpage
= self
._download
_webpage
(embed_url
, video_id
)
38 video_urls
= [video_url
.replace('\\/', '/') for video_url
in re
.findall(
39 r
'(?:fileList\[[0-9]+\]\s*=|"file"\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
='Testing video URL %d' % i
, errnote
=False)
47 raise ExtractorError('No working video URLs found')
49 title
= self
._search
_regex
(r
'\s+title:\s*"([^"]+)"', webpage
, 'title')
50 thumbnail
= self
._search
_regex
(
51 r
'image:\s*"([^"]+)"', webpage
, 'thumbnail', fatal
=False)
58 'thumbnail': thumbnail
,
59 'age_limit': self
._family
_friendly
_search
(webpage
),