1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
12 class ImdbIE(InfoExtractor
):
14 IE_DESC
= 'Internet Movie Database trailers'
15 _VALID_URL
= r
'http://(?:www|m)\.imdb\.com/video/imdb/vi(?P<id>\d+)'
18 'url': 'http://www.imdb.com/video/imdb/vi2524815897',
19 'md5': '9f34fa777ade3a6e57a054fdbcb3a068',
23 'title': 'Ice Age: Continental Drift Trailer (No. 2) - IMDb',
24 'description': 'md5:9061c2219254e5d14e03c25c98e96a81',
28 def _real_extract(self
, url
):
29 video_id
= self
._match
_id
(url
)
30 webpage
= self
._download
_webpage
('http://www.imdb.com/video/imdb/vi%s' % video_id
, video_id
)
31 descr
= self
._html
_search
_regex
(
32 r
'(?s)<span itemprop="description">(.*?)</span>',
33 webpage
, 'description', fatal
=False)
34 available_formats
= re
.findall(
35 r
'case \'(?P
<f_id
>.*?
)\' :$\s
+url
= \'(?P
<path
>.*?
)\'', webpage,
38 for f_id, f_path in available_formats:
39 f_path = f_path.strip()
40 format_page = self._download_webpage(
41 compat_urlparse.urljoin(url, f_path),
42 'Downloading info
for %s format
' % f_id)
43 json_data = self._search_regex(
44 r'<script
[^
>]+class="imdb-player-data"[^
>]*?
>(.*?
)</script
>',
45 format_page, 'json data
', flags=re.DOTALL)
46 info = json.loads(json_data)
47 format_info = info['videoPlayerObject
']['video
']
50 'url
': format_info['url
'],
55 'title
': self._og_search_title(webpage),
58 'thumbnail
': format_info['slate
'],
62 class ImdbListIE(InfoExtractor):
64 IE_DESC = 'Internet Movie Database lists
'
65 _VALID_URL = r'http
://www\
.imdb\
.com
/list/(?P
<id>[\da
-zA
-Z_
-]{11}
)'
67 'url
': 'http
://www
.imdb
.com
/list/JFs9NWw6XI0
',
70 'title
': 'March
23, 2012 Releases
',
75 def _real_extract(self, url):
76 list_id = self._match_id(url)
77 webpage = self._download_webpage(url, list_id)
79 self.url_result('http
://www
.imdb
.com
' + m, 'Imdb
')
80 for m in re.findall(r'href
="(/video/imdb/vi[^"]+)"\s+data-type="playlist
"', webpage)]
82 list_title = self._html_search_regex(
83 r'<h1 class="header
">(.*?)</h1>', webpage, 'list title')
85 return self.playlist_result(entries, list_id, list_title)