]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/imdb.py
d8e9712a7acd39db97c8a55b2551137ca0e56a41
4 from .common
import InfoExtractor
7 get_element_by_attribute
,
11 class ImdbIE(InfoExtractor
):
13 IE_DESC
= u
'Internet Movie Database trailers'
14 _VALID_URL
= r
'http://www\.imdb\.com/video/imdb/vi(?P<id>\d+)'
17 u
'url': u
'http://www.imdb.com/video/imdb/vi2524815897',
18 u
'md5': u
'9f34fa777ade3a6e57a054fdbcb3a068',
22 u
'title': u
'Ice Age: Continental Drift Trailer (No. 2) - IMDb',
23 u
'description': u
'md5:9061c2219254e5d14e03c25c98e96a81',
28 def _real_extract(self
, url
):
29 mobj
= re
.match(self
._VALID
_URL
, url
)
30 video_id
= mobj
.group('id')
31 webpage
= self
._download
_webpage
(url
,video_id
)
32 descr
= get_element_by_attribute('itemprop', 'description', webpage
)
33 available_formats
= re
.findall(
34 r
'case \'(?P
<f_id
>.*?
)\' :$\s
+url
= \'(?P
<path
>.*?
)\'', webpage,
37 for f_id, f_path in available_formats:
38 format_page = self._download_webpage(
39 compat_urlparse.urljoin(url, f_path),
40 u'Downloading info
for %s format
' % f_id)
41 json_data = self._search_regex(
42 r'<script
[^
>]+class="imdb-player-data"[^
>]*?
>(.*?
)</script
>',
43 format_page, u'json data
', flags=re.DOTALL)
44 info = json.loads(json_data)
45 format_info = info['videoPlayerObject
']['video
']
48 'url
': format_info['url
'],
49 'height
': int(info['titleObject
']['encoding
']['selected
'][:-1]),
54 'title
': self._og_search_title(webpage),
57 'thumbnail
': format_info['slate
'],
58 'duration
': int(info['titleObject
']['title
']['duration_seconds
']),