]>
Commit | Line | Data |
---|---|---|
887a2279 YK |
1 | import re |
2 | ||
3 | from .common import InfoExtractor | |
4 | ||
5 | ||
6 | class TrailerAddictIE(InfoExtractor): | |
16484d49 | 7 | _VALID_URL = r'(?:http://)?(?:www\.)?traileraddict\.com/(?:trailer|clip)/(?P<movie>.+?)/(?P<trailer_name>.+)' |
887a2279 YK |
8 | _TEST = { |
9 | u'url': u'http://www.traileraddict.com/trailer/prince-avalanche/trailer', | |
10 | u'file': u'76184.mp4', | |
a052c1d7 | 11 | u'md5': u'57e39dbcf4142ceb8e1f242ff423fd71', |
887a2279 YK |
12 | u'info_dict': { |
13 | u"title": u"Prince Avalanche Trailer", | |
14 | u"description": u"Trailer for Prince Avalanche.Two 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." | |
15 | } | |
16 | } | |
17 | ||
18 | def _real_extract(self, url): | |
19 | mobj = re.match(self._VALID_URL, url) | |
16484d49 JMF |
20 | name = mobj.group('movie') + '/' + mobj.group('trailer_name') |
21 | webpage = self._download_webpage(url, name) | |
b1ca5e3f | 22 | |
887a2279 YK |
23 | title = self._search_regex(r'<title>(.+?)</title>', |
24 | webpage, 'video title').replace(' - Trailer Addict','') | |
25 | view_count = self._search_regex(r'Views: (.+?)<br />', | |
26 | webpage, 'Views Count') | |
46720279 JMF |
27 | video_id = self._og_search_property('video', webpage, 'Video id').split('=')[1] |
28 | ||
b1ca5e3f AVH |
29 | # Presence of (no)watchplus function indicates HD quality is available |
30 | if re.search(r'function (no)?watchplus()', webpage): | |
31 | fvar = "fvarhd" | |
32 | else: | |
33 | fvar = "fvar" | |
34 | ||
35 | info_url = "http://www.traileraddict.com/%s.php?tid=%s" % (fvar, str(video_id)) | |
887a2279 | 36 | info_webpage = self._download_webpage(info_url, video_id , "Downloading the info webpage") |
b1ca5e3f | 37 | |
887a2279 YK |
38 | final_url = self._search_regex(r'&fileurl=(.+)', |
39 | info_webpage, 'Download url').replace('%3F','?') | |
40 | thumbnail_url = self._search_regex(r'&image=(.+?)&', | |
41 | info_webpage, 'thumbnail url') | |
42 | ext = final_url.split('.')[-1].split('?')[0] | |
b1ca5e3f | 43 | |
887a2279 YK |
44 | return [{ |
45 | 'id' : video_id, | |
46 | 'url' : final_url, | |
47 | 'ext' : ext, | |
48 | 'title' : title, | |
49 | 'thumbnail' : thumbnail_url, | |
46720279 | 50 | 'description' : self._og_search_description(webpage), |
887a2279 YK |
51 | 'view_count' : view_count, |
52 | }] |