]>
Commit | Line | Data |
---|---|---|
b3eaeded RA |
1 | import re |
2 | ||
3 | from .turner import TurnerBaseIE | |
e0d42dd4 RA |
4 | from ..compat import ( |
5 | compat_urllib_parse_urlparse, | |
6 | compat_parse_qs, | |
7 | ) | |
b6f78d76 RA |
8 | from ..utils import ( |
9 | float_or_none, | |
10 | int_or_none, | |
11 | strip_or_none, | |
12 | ) | |
b3eaeded RA |
13 | |
14 | ||
15 | class TBSIE(TurnerBaseIE): | |
01b052b2 | 16 | _VALID_URL = r'https?://(?:www\.)?(?P<site>tbs|tntdrama)\.com(?P<path>/(?:movies|watchtnt|watchtbs|shows/[^/]+/(?:clips|season-\d+/episode-\d+))/(?P<id>[^/?#]+))' |
b3eaeded | 17 | _TESTS = [{ |
b6f78d76 | 18 | 'url': 'http://www.tntdrama.com/shows/the-alienist/clips/monster', |
b3eaeded | 19 | 'info_dict': { |
b6f78d76 | 20 | 'id': '8d384cde33b89f3a43ce5329de42903ed5099887', |
b3eaeded | 21 | 'ext': 'mp4', |
b6f78d76 RA |
22 | 'title': 'Monster', |
23 | 'description': 'Get a first look at the theatrical trailer for TNT’s highly anticipated new psychological thriller The Alienist, which premieres January 22 on TNT.', | |
24 | 'timestamp': 1508175329, | |
25 | 'upload_date': '20171016', | |
85f5a74b | 26 | }, |
b6f78d76 RA |
27 | 'params': { |
28 | # m3u8 download | |
29 | 'skip_download': True, | |
30 | } | |
b3eaeded | 31 | }, { |
b6f78d76 RA |
32 | 'url': 'http://www.tbs.com/shows/search-party/season-1/episode-1/explicit-the-mysterious-disappearance-of-the-girl-no-one-knew', |
33 | 'only_matching': True, | |
34 | }, { | |
35 | 'url': 'http://www.tntdrama.com/movies/star-wars-a-new-hope', | |
36 | 'only_matching': True, | |
b3eaeded RA |
37 | }] |
38 | ||
39 | def _real_extract(self, url): | |
5ad28e7f | 40 | site, path, display_id = self._match_valid_url(url).groups() |
b3eaeded | 41 | webpage = self._download_webpage(url, display_id) |
e0d42dd4 | 42 | drupal_settings = self._parse_json(self._search_regex( |
b6f78d76 | 43 | r'<script[^>]+?data-drupal-selector="drupal-settings-json"[^>]*?>({.+?})</script>', |
e0d42dd4 | 44 | webpage, 'drupal setting'), display_id) |
01b052b2 | 45 | isLive = 'watchtnt' in path or 'watchtbs' in path |
1e79316e | 46 | video_data = next(v for v in drupal_settings['turner_playlist'] if isLive or v.get('url') == path) |
b6f78d76 RA |
47 | |
48 | media_id = video_data['mediaID'] | |
49 | title = video_data['title'] | |
e0d42dd4 RA |
50 | tokenizer_query = compat_parse_qs(compat_urllib_parse_urlparse( |
51 | drupal_settings['ngtv_token_url']).query) | |
b6f78d76 | 52 | |
e0d42dd4 RA |
53 | info = self._extract_ngtv_info( |
54 | media_id, tokenizer_query, { | |
55 | 'url': url, | |
56 | 'site_name': site[:3].upper(), | |
1e79316e L |
57 | 'auth_required': video_data.get('authRequired') == '1' or isLive, |
58 | 'is_live': isLive | |
e0d42dd4 | 59 | }) |
b6f78d76 RA |
60 | |
61 | thumbnails = [] | |
62 | for image_id, image in video_data.get('images', {}).items(): | |
63 | image_url = image.get('url') | |
64 | if not image_url or image.get('type') != 'video': | |
65 | continue | |
66 | i = { | |
67 | 'id': image_id, | |
68 | 'url': image_url, | |
69 | } | |
70 | mobj = re.search(r'(\d+)x(\d+)', image_url) | |
71 | if mobj: | |
72 | i.update({ | |
73 | 'width': int(mobj.group(1)), | |
74 | 'height': int(mobj.group(2)), | |
75 | }) | |
76 | thumbnails.append(i) | |
77 | ||
e0d42dd4 | 78 | info.update({ |
b6f78d76 RA |
79 | 'id': media_id, |
80 | 'title': title, | |
81 | 'description': strip_or_none(video_data.get('descriptionNoTags') or video_data.get('shortDescriptionNoTags')), | |
e0d42dd4 | 82 | 'duration': float_or_none(video_data.get('duration')) or info.get('duration'), |
b6f78d76 RA |
83 | 'timestamp': int_or_none(video_data.get('created')), |
84 | 'season_number': int_or_none(video_data.get('season')), | |
85 | 'episode_number': int_or_none(video_data.get('episode')), | |
b6f78d76 | 86 | 'thumbnails': thumbnails, |
1e79316e | 87 | 'is_live': isLive |
e0d42dd4 RA |
88 | }) |
89 | return info |