[youtube] Skip unsupported adaptive stream type (#18804)
[youtube-dl] / youtube_dl / extractor / bravotv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .adobepass import AdobePassIE
5 from ..utils import (
6     smuggle_url,
7     update_url_query,
8     int_or_none,
9 )
10
11
12 class BravoTVIE(AdobePassIE):
13     _VALID_URL = r'https?://(?:www\.)?bravotv\.com/(?:[^/]+/)+(?P<id>[^/?#]+)'
14     _TESTS = [{
15         'url': 'http://www.bravotv.com/last-chance-kitchen/season-5/videos/lck-ep-12-fishy-finale',
16         'md5': '9086d0b7ef0ea2aabc4781d75f4e5863',
17         'info_dict': {
18             'id': 'zHyk1_HU_mPy',
19             'ext': 'mp4',
20             'title': 'LCK Ep 12: Fishy Finale',
21             'description': 'S13/E12: Two eliminated chefs have just 12 minutes to cook up a delicious fish dish.',
22             'uploader': 'NBCU-BRAV',
23             'upload_date': '20160302',
24             'timestamp': 1456945320,
25         }
26     }, {
27         'url': 'http://www.bravotv.com/below-deck/season-3/ep-14-reunion-part-1',
28         'only_matching': True,
29     }]
30
31     def _real_extract(self, url):
32         display_id = self._match_id(url)
33         webpage = self._download_webpage(url, display_id)
34         settings = self._parse_json(self._search_regex(
35             r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);', webpage, 'drupal settings'),
36             display_id)
37         info = {}
38         query = {
39             'mbr': 'true',
40         }
41         account_pid, release_pid = [None] * 2
42         tve = settings.get('sharedTVE')
43         if tve:
44             query['manifest'] = 'm3u'
45             account_pid = 'HNK2IC'
46             release_pid = tve['release_pid']
47             if tve.get('entitlement') == 'auth':
48                 adobe_pass = settings.get('adobePass', {})
49                 resource = self._get_mvpd_resource(
50                     adobe_pass.get('adobePassResourceId', 'bravo'),
51                     tve['title'], release_pid, tve.get('rating'))
52                 query['auth'] = self._extract_mvpd_auth(
53                     url, release_pid, adobe_pass.get('adobePassRequestorId', 'bravo'), resource)
54         else:
55             shared_playlist = settings['shared_playlist']
56             account_pid = shared_playlist['account_pid']
57             metadata = shared_playlist['video_metadata'][shared_playlist['default_clip']]
58             release_pid = metadata['release_pid']
59             info.update({
60                 'title': metadata['title'],
61                 'description': metadata.get('description'),
62                 'season_number': int_or_none(metadata.get('season_num')),
63                 'episode_number': int_or_none(metadata.get('episode_num')),
64             })
65             query['switch'] = 'progressive'
66         info.update({
67             '_type': 'url_transparent',
68             'id': release_pid,
69             'url': smuggle_url(update_url_query(
70                 'http://link.theplatform.com/s/%s/%s' % (account_pid, release_pid),
71                 query), {'force_smil_url': True}),
72             'ie_key': 'ThePlatform',
73         })
74         return info