2 from __future__
import unicode_literals
6 from .turner
import TurnerBaseIE
8 compat_urllib_parse_urlparse
,
18 class TBSIE(TurnerBaseIE
):
19 _VALID_URL
= r
'https?://(?:www\.)?(?P<site>tbs|tntdrama)\.com/(?:movies|shows/[^/]+/(?:clips|season-\d+/episode-\d+))/(?P<id>[^/?#]+)'
21 'url': 'http://www.tntdrama.com/shows/the-alienist/clips/monster',
23 'id': '8d384cde33b89f3a43ce5329de42903ed5099887',
26 '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.',
27 'timestamp': 1508175329,
28 'upload_date': '20171016',
32 'skip_download': True,
35 'url': 'http://www.tbs.com/shows/search-party/season-1/episode-1/explicit-the-mysterious-disappearance-of-the-girl-no-one-knew',
36 'only_matching': True,
38 'url': 'http://www.tntdrama.com/movies/star-wars-a-new-hope',
39 'only_matching': True,
42 def _real_extract(self
, url
):
43 site
, display_id
= re
.match(self
._VALID
_URL
, url
).groups()
44 webpage
= self
._download
_webpage
(url
, display_id
)
45 drupal_settings
= self
._parse
_json
(self
._search
_regex
(
46 r
'<script[^>]+?data-drupal-selector="drupal-settings-json"[^>]*?>({.+?})</script>',
47 webpage
, 'drupal setting'), display_id
)
48 video_data
= drupal_settings
['turner_playlist'][0]
50 media_id
= video_data
['mediaID']
51 title
= video_data
['title']
52 tokenizer_query
= compat_parse_qs(compat_urllib_parse_urlparse(
53 drupal_settings
['ngtv_token_url']).query
)
55 info
= self
._extract
_ngtv
_info
(
56 media_id
, tokenizer_query
, {
58 'site_name': site
[:3].upper(),
59 'auth_required': video_data
.get('authRequired') == '1',
63 for image_id
, image
in video_data
.get('images', {}).items():
64 image_url
= image
.get('url')
65 if not image_url
or image
.get('type') != 'video':
71 mobj
= re
.search(r
'(\d+)x(\d+)', image_url
)
74 'width': int(mobj
.group(1)),
75 'height': int(mobj
.group(2)),
82 'description': strip_or_none(video_data
.get('descriptionNoTags') or video_data
.get('shortDescriptionNoTags')),
83 'duration': float_or_none(video_data
.get('duration')) or info
.get('duration'),
84 'timestamp': int_or_none(video_data
.get('created')),
85 'season_number': int_or_none(video_data
.get('season')),
86 'episode_number': int_or_none(video_data
.get('episode')),
87 'thumbnails': thumbnails
,