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