]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/paramountplus.py
[test/download] Fallback test to `bv`
[yt-dlp.git] / yt_dlp / extractor / paramountplus.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from .cbs import CBSBaseIE
5 from ..utils import (
6 int_or_none,
7 url_or_none,
8 )
9
10
11 class ParamountPlusIE(CBSBaseIE):
12 _VALID_URL = r'''(?x)
13 (?:
14 paramountplus:|
15 https?://(?:www\.)?(?:
16 paramountplus\.com/(?:shows/[^/]+/video|movies/[^/]+)/
17 )(?P<id>[\w-]+))'''
18
19 # All tests are blocked outside US
20 _TESTS = [{
21 'url': 'https://www.paramountplus.com/shows/catdog/video/Oe44g5_NrlgiZE3aQVONleD6vXc8kP0k/catdog-climb-every-catdog-the-canine-mutiny/',
22 'info_dict': {
23 'id': 'Oe44g5_NrlgiZE3aQVONleD6vXc8kP0k',
24 'ext': 'mp4',
25 'title': 'CatDog - Climb Every CatDog/The Canine Mutiny',
26 'description': 'md5:7ac835000645a69933df226940e3c859',
27 'duration': 1418,
28 'timestamp': 920264400,
29 'upload_date': '19990301',
30 'uploader': 'CBSI-NEW',
31 },
32 'params': {
33 'skip_download': 'm3u8',
34 },
35 }, {
36 'url': 'https://www.paramountplus.com/shows/tooning-out-the-news/video/6hSWYWRrR9EUTz7IEe5fJKBhYvSUfexd/7-23-21-week-in-review-rep-jahana-hayes-howard-fineman-sen-michael-bennet-sheera-frenkel-cecilia-kang-/',
37 'info_dict': {
38 'id': '6hSWYWRrR9EUTz7IEe5fJKBhYvSUfexd',
39 'ext': 'mp4',
40 'title': '7/23/21 WEEK IN REVIEW (Rep. Jahana Hayes/Howard Fineman/Sen. Michael Bennet/Sheera Frenkel & Cecilia Kang)',
41 'description': 'md5:f4adcea3e8b106192022e121f1565bae',
42 'duration': 2506,
43 'timestamp': 1627063200,
44 'upload_date': '20210723',
45 'uploader': 'CBSI-NEW',
46 },
47 'params': {
48 'skip_download': 'm3u8',
49 },
50 }, {
51 'url': 'https://www.paramountplus.com/movies/daddys-home/vM2vm0kE6vsS2U41VhMRKTOVHyQAr6pC',
52 'info_dict': {
53 'id': 'vM2vm0kE6vsS2U41VhMRKTOVHyQAr6pC',
54 'ext': 'mp4',
55 'title': 'Daddy\'s Home',
56 'upload_date': '20151225',
57 'description': 'md5:a0beaf24e8d3b0e81b2ee41d47c06f33',
58 'uploader': 'CBSI-NEW',
59 'timestamp': 1451030400,
60 },
61 'params': {
62 'skip_download': 'm3u8',
63 },
64 'expected_warnings': ['Ignoring subtitle tracks'], # TODO: Investigate this
65 }, {
66 'url': 'https://www.paramountplus.com/movies/sonic-the-hedgehog/5EKDXPOzdVf9voUqW6oRuocyAEeJGbEc',
67 'info_dict': {
68 'id': '5EKDXPOzdVf9voUqW6oRuocyAEeJGbEc',
69 'ext': 'mp4',
70 'uploader': 'CBSI-NEW',
71 'description': 'md5:bc7b6fea84ba631ef77a9bda9f2ff911',
72 'timestamp': 1577865600,
73 'title': 'Sonic the Hedgehog',
74 'upload_date': '20200101',
75 },
76 'params': {
77 'skip_download': 'm3u8',
78 },
79 'expected_warnings': ['Ignoring subtitle tracks'],
80 }, {
81 'url': 'https://www.paramountplus.com/shows/all-rise/video/QmR1WhNkh1a_IrdHZrbcRklm176X_rVc/all-rise-space/',
82 'only_matching': True,
83 }, {
84 'url': 'https://www.paramountplus.com/movies/million-dollar-american-princesses-meghan-and-harry/C0LpgNwXYeB8txxycdWdR9TjxpJOsdCq',
85 'only_matching': True,
86 }]
87
88 def _extract_video_info(self, content_id, mpx_acc=2198311517):
89 items_data = self._download_json(
90 'https://www.paramountplus.com/apps-api/v2.0/androidtv/video/cid/%s.json' % content_id,
91 content_id, query={'locale': 'en-us', 'at': 'ABCqWNNSwhIqINWIIAG+DFzcFUvF8/vcN6cNyXFFfNzWAIvXuoVgX+fK4naOC7V8MLI='}, headers=self.geo_verification_headers())
92
93 asset_types = {
94 item.get('assetType'): {
95 'format': 'SMIL',
96 'formats': 'MPEG4,M3U',
97 } for item in items_data['itemList']
98 }
99 item = items_data['itemList'][-1]
100 return self._extract_common_video_info(content_id, asset_types, mpx_acc, extra_info={
101 'title': item.get('title'),
102 'series': item.get('seriesTitle'),
103 'season_number': int_or_none(item.get('seasonNum')),
104 'episode_number': int_or_none(item.get('episodeNum')),
105 'duration': int_or_none(item.get('duration')),
106 'thumbnail': url_or_none(item.get('thumbnail')),
107 })
108
109
110 class ParamountPlusSeriesIE(InfoExtractor):
111 _VALID_URL = r'https?://(?:www\.)?paramountplus\.com/shows/(?P<id>[a-zA-Z0-9-_]+)/?(?:[#?]|$)'
112 _TESTS = [{
113 'url': 'https://www.paramountplus.com/shows/drake-josh',
114 'playlist_mincount': 50,
115 'info_dict': {
116 'id': 'drake-josh',
117 }
118 }, {
119 'url': 'https://www.paramountplus.com/shows/hawaii_five_0/',
120 'playlist_mincount': 240,
121 'info_dict': {
122 'id': 'hawaii_five_0',
123 }
124 }, {
125 'url': 'https://www.paramountplus.com/shows/spongebob-squarepants/',
126 'playlist_mincount': 248,
127 'info_dict': {
128 'id': 'spongebob-squarepants',
129 }
130 }]
131 _API_URL = 'https://www.paramountplus.com/shows/{}/xhr/episodes/page/0/size/100000/xs/0/season/0/'
132
133 def _entries(self, show_name):
134 show_json = self._download_json(self._API_URL.format(show_name), video_id=show_name)
135 if show_json.get('success'):
136 for episode in show_json['result']['data']:
137 yield self.url_result(
138 'https://www.paramountplus.com%s' % episode['url'],
139 ie=ParamountPlusIE.ie_key(), video_id=episode['content_id'])
140
141 def _real_extract(self, url):
142 show_name = self._match_id(url)
143 return self.playlist_result(self._entries(show_name), playlist_id=show_name)