]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/bravotv.py
[udemy] Extract asset captions
[yt-dlp.git] / youtube_dl / extractor / bravotv.py
CommitLineData
63f41d38 1# coding: utf-8
2from __future__ import unicode_literals
3
fb009b7f
RA
4from .adobepass import AdobePassIE
5from ..utils import (
6 smuggle_url,
7 update_url_query,
8 int_or_none,
9)
63f41d38 10
11
fb009b7f
RA
12class BravoTVIE(AdobePassIE):
13 _VALID_URL = r'https?://(?:www\.)?bravotv\.com/(?:[^/]+/)+(?P<id>[^/?#]+)'
14 _TESTS = [{
63f41d38 15 'url': 'http://www.bravotv.com/last-chance-kitchen/season-5/videos/lck-ep-12-fishy-finale',
fb009b7f 16 'md5': '9086d0b7ef0ea2aabc4781d75f4e5863',
63f41d38 17 'info_dict': {
fb009b7f 18 'id': 'zHyk1_HU_mPy',
63f41d38 19 'ext': 'mp4',
fb009b7f
RA
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.',
79ba9140 22 'uploader': 'NBCU-BRAV',
fb009b7f
RA
23 'upload_date': '20160302',
24 'timestamp': 1456945320,
63f41d38 25 }
fb009b7f
RA
26 }, {
27 'url': 'http://www.bravotv.com/below-deck/season-3/ep-14-reunion-part-1',
28 'only_matching': True,
29 }]
63f41d38 30
31 def _real_extract(self, url):
fb009b7f
RA
32 display_id = self._match_id(url)
33 webpage = self._download_webpage(url, display_id)
34 settings = self._parse_json(self._search_regex(
ccb6570e 35 r'jQuery\.extend\(Drupal\.settings\s*,\s*({.+?})\);', webpage, 'drupal settings'),
fb009b7f
RA
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