]>
Commit | Line | Data |
---|---|---|
56b6faf9 PH |
1 | from __future__ import unicode_literals |
2 | ||
887a2279 YK |
3 | import re |
4 | ||
5 | from .common import InfoExtractor | |
6 | ||
7 | ||
8 | class TrailerAddictIE(InfoExtractor): | |
58d915df | 9 | _WORKING = False |
5886b38d | 10 | _VALID_URL = r'(?:https?://)?(?:www\.)?traileraddict\.com/(?:trailer|clip)/(?P<movie>.+?)/(?P<trailer_name>.+)' |
887a2279 | 11 | _TEST = { |
56b6faf9 PH |
12 | 'url': 'http://www.traileraddict.com/trailer/prince-avalanche/trailer', |
13 | 'md5': '41365557f3c8c397d091da510e73ceb4', | |
14 | 'info_dict': { | |
15 | 'id': '76184', | |
16 | 'ext': 'mp4', | |
17 | 'title': 'Prince Avalanche Trailer', | |
18 | '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.', | |
887a2279 YK |
19 | } |
20 | } | |
21 | ||
22 | def _real_extract(self, url): | |
5ad28e7f | 23 | mobj = self._match_valid_url(url) |
16484d49 JMF |
24 | name = mobj.group('movie') + '/' + mobj.group('trailer_name') |
25 | webpage = self._download_webpage(url, name) | |
b1ca5e3f | 26 | |
887a2279 | 27 | title = self._search_regex(r'<title>(.+?)</title>', |
9e1a5b84 | 28 | webpage, 'video title').replace(' - Trailer Addict', '') |
56b6faf9 PH |
29 | view_count_str = self._search_regex( |
30 | r'<span class="views_n">([0-9,.]+)</span>', | |
31 | webpage, 'view count', fatal=False) | |
32 | view_count = ( | |
33 | None if view_count_str is None | |
34 | else int(view_count_str.replace(',', ''))) | |
35 | video_id = self._search_regex( | |
36 | r'<param\s+name="movie"\s+value="/emb/([0-9]+)"\s*/>', | |
37 | webpage, 'video id') | |
46720279 | 38 | |
b1ca5e3f AVH |
39 | # Presence of (no)watchplus function indicates HD quality is available |
40 | if re.search(r'function (no)?watchplus()', webpage): | |
611c1dd9 | 41 | fvar = 'fvarhd' |
b1ca5e3f | 42 | else: |
611c1dd9 | 43 | fvar = 'fvar' |
b1ca5e3f | 44 | |
611c1dd9 S |
45 | info_url = 'http://www.traileraddict.com/%s.php?tid=%s' % (fvar, str(video_id)) |
46 | info_webpage = self._download_webpage(info_url, video_id, 'Downloading the info webpage') | |
b1ca5e3f | 47 | |
887a2279 | 48 | final_url = self._search_regex(r'&fileurl=(.+)', |
9e1a5b84 | 49 | info_webpage, 'Download url').replace('%3F', '?') |
887a2279 | 50 | thumbnail_url = self._search_regex(r'&image=(.+?)&', |
9e1a5b84 | 51 | info_webpage, 'thumbnail url') |
56b6faf9 PH |
52 | |
53 | description = self._html_search_regex( | |
54 | r'(?s)<div class="synopsis">.*?<div class="movie_label_info"[^>]*>(.*?)</div>', | |
55 | webpage, 'description', fatal=False) | |
56 | ||
57 | return { | |
58 | 'id': video_id, | |
59 | 'url': final_url, | |
60 | 'title': title, | |
61 | 'thumbnail': thumbnail_url, | |
62 | 'description': description, | |
63 | 'view_count': view_count, | |
64 | } |