]>
Commit | Line | Data |
---|---|---|
63f41d38 | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
81d989c2 RA |
4 | import re |
5 | ||
fb009b7f RA |
6 | from .adobepass import AdobePassIE |
7 | from ..utils import ( | |
8 | smuggle_url, | |
9 | update_url_query, | |
10 | int_or_none, | |
11 | ) | |
63f41d38 | 12 | |
13 | ||
fb009b7f | 14 | class BravoTVIE(AdobePassIE): |
2181983a | 15 | _VALID_URL = r'https?://(?:www\.)?(?P<req_id>bravotv|oxygen)\.com/(?:[^/]+/)+(?P<id>[^/?#]+)' |
fb009b7f | 16 | _TESTS = [{ |
81d989c2 RA |
17 | 'url': 'https://www.bravotv.com/top-chef/season-16/episode-15/videos/the-top-chef-season-16-winner-is', |
18 | 'md5': 'e34684cfea2a96cd2ee1ef3a60909de9', | |
63f41d38 | 19 | 'info_dict': { |
81d989c2 | 20 | 'id': 'epL0pmK1kQlT', |
63f41d38 | 21 | 'ext': 'mp4', |
81d989c2 RA |
22 | 'title': 'The Top Chef Season 16 Winner Is...', |
23 | 'description': 'Find out who takes the title of Top Chef!', | |
79ba9140 | 24 | 'uploader': 'NBCU-BRAV', |
81d989c2 RA |
25 | 'upload_date': '20190314', |
26 | 'timestamp': 1552591860, | |
63f41d38 | 27 | } |
fb009b7f RA |
28 | }, { |
29 | 'url': 'http://www.bravotv.com/below-deck/season-3/ep-14-reunion-part-1', | |
30 | 'only_matching': True, | |
2181983a | 31 | }, { |
32 | 'url': 'https://www.oxygen.com/in-ice-cold-blood/season-2/episode-16/videos/handling-the-horwitz-house-after-the-murder-season-2', | |
33 | 'only_matching': True, | |
fb009b7f | 34 | }] |
63f41d38 | 35 | |
36 | def _real_extract(self, url): | |
2181983a | 37 | site, display_id = re.match(self._VALID_URL, url).groups() |
fb009b7f RA |
38 | webpage = self._download_webpage(url, display_id) |
39 | settings = self._parse_json(self._search_regex( | |
81d989c2 | 40 | r'<script[^>]+data-drupal-selector="drupal-settings-json"[^>]*>({.+?})</script>', webpage, 'drupal settings'), |
fb009b7f RA |
41 | display_id) |
42 | info = {} | |
43 | query = { | |
44 | 'mbr': 'true', | |
45 | } | |
46 | account_pid, release_pid = [None] * 2 | |
81d989c2 | 47 | tve = settings.get('ls_tve') |
fb009b7f RA |
48 | if tve: |
49 | query['manifest'] = 'm3u' | |
81d989c2 RA |
50 | mobj = re.search(r'<[^>]+id="pdk-player"[^>]+data-url=["\']?(?:https?:)?//player\.theplatform\.com/p/([^/]+)/(?:[^/]+/)*select/([^?#&"\']+)', webpage) |
51 | if mobj: | |
52 | account_pid, tp_path = mobj.groups() | |
53 | release_pid = tp_path.strip('/').split('/')[-1] | |
54 | else: | |
55 | account_pid = 'HNK2IC' | |
56 | tp_path = release_pid = tve['release_pid'] | |
fb009b7f | 57 | if tve.get('entitlement') == 'auth': |
81d989c2 | 58 | adobe_pass = settings.get('tve_adobe_auth', {}) |
2181983a | 59 | if site == 'bravotv': |
60 | site = 'bravo' | |
fb009b7f | 61 | resource = self._get_mvpd_resource( |
2181983a | 62 | adobe_pass.get('adobePassResourceId') or site, |
fb009b7f RA |
63 | tve['title'], release_pid, tve.get('rating')) |
64 | query['auth'] = self._extract_mvpd_auth( | |
2181983a | 65 | url, release_pid, |
66 | adobe_pass.get('adobePassRequestorId') or site, resource) | |
fb009b7f | 67 | else: |
81d989c2 | 68 | shared_playlist = settings['ls_playlist'] |
fb009b7f RA |
69 | account_pid = shared_playlist['account_pid'] |
70 | metadata = shared_playlist['video_metadata'][shared_playlist['default_clip']] | |
81d989c2 RA |
71 | tp_path = release_pid = metadata.get('release_pid') |
72 | if not release_pid: | |
73 | release_pid = metadata['guid'] | |
74 | tp_path = 'media/guid/2140479951/' + release_pid | |
fb009b7f RA |
75 | info.update({ |
76 | 'title': metadata['title'], | |
77 | 'description': metadata.get('description'), | |
78 | 'season_number': int_or_none(metadata.get('season_num')), | |
79 | 'episode_number': int_or_none(metadata.get('episode_num')), | |
80 | }) | |
81 | query['switch'] = 'progressive' | |
82 | info.update({ | |
83 | '_type': 'url_transparent', | |
84 | 'id': release_pid, | |
85 | 'url': smuggle_url(update_url_query( | |
81d989c2 | 86 | 'http://link.theplatform.com/s/%s/%s' % (account_pid, tp_path), |
fb009b7f RA |
87 | query), {'force_smil_url': True}), |
88 | 'ie_key': 'ThePlatform', | |
89 | }) | |
90 | return info |