1 from __future__ import unicode_literals
5 from .common import InfoExtractor
8 class TrailerAddictIE(InfoExtractor):
9 _VALID_URL = r'(?:http://)?(?:www\.)?traileraddict\.com/(?:trailer|clip)/(?P<movie>.+?)/(?P<trailer_name>.+)'
11 'url': 'http://www.traileraddict.com/trailer/prince-avalanche/trailer',
12 'md5': '41365557f3c8c397d091da510e73ceb4',
16 'title': 'Prince Avalanche Trailer',
17 'description': 'Trailer for Prince Avalanche.\n\nTwo highway road workers spend the summer of 1988 away from their city lives. The isolated landscape becomes a place of misadventure as the men find themselves at odds with each other and the women they left behind.',
21 def _real_extract(self, url):
22 mobj = re.match(self._VALID_URL, url)
23 name = mobj.group('movie') + '/' + mobj.group('trailer_name')
24 webpage = self._download_webpage(url, name)
26 title = self._search_regex(r'<title>(.+?)</title>',
27 webpage, 'video title').replace(' - Trailer Addict','')
28 view_count_str = self._search_regex(
29 r'<span class="views_n">([0-9,.]+)</span>',
30 webpage, 'view count', fatal=False)
32 None if view_count_str is None
33 else int(view_count_str.replace(',', '')))
34 video_id = self._search_regex(
35 r'<param\s+name="movie"\s+value="/emb/([0-9]+)"\s*/>',
38 # Presence of (no)watchplus function indicates HD quality is available
39 if re.search(r'function (no)?watchplus()', webpage):
44 info_url = "http://www.traileraddict.com/%s.php?tid=%s" % (fvar, str(video_id))
45 info_webpage = self._download_webpage(info_url, video_id , "Downloading the info webpage")
47 final_url = self._search_regex(r'&fileurl=(.+)',
48 info_webpage, 'Download url').replace('%3F','?')
49 thumbnail_url = self._search_regex(r'&image=(.+?)&',
50 info_webpage, 'thumbnail url')
52 description = self._html_search_regex(
53 r'(?s)<div class="synopsis">.*?<div class="movie_label_info"[^>]*>(.*?)</div>',
54 webpage, 'description', fatal=False)
60 'thumbnail': thumbnail_url,
61 'description': description,
62 'view_count': view_count,