[ie/dplay] Fix extractors (#10471)
[yt-dlp3.git] / yt_dlp / extractor / sprout.py
blob444a6c270ff04c6760d1670429afdb02a3e22920
1 from .adobepass import AdobePassIE
2 from ..utils import (
3 int_or_none,
4 smuggle_url,
5 update_url_query,
9 class SproutIE(AdobePassIE):
10 _VALID_URL = r'https?://(?:www\.)?(?:sproutonline|universalkids)\.com/(?:watch|(?:[^/]+/)*videos)/(?P<id>[^/?#]+)'
11 _TESTS = [{
12 'url': 'https://www.universalkids.com/shows/remy-and-boo/season/1/videos/robot-bike-race',
13 'info_dict': {
14 'id': 'bm0foJFaTKqb',
15 'ext': 'mp4',
16 'title': 'Robot Bike Race',
17 'description': 'md5:436b1d97117cc437f54c383f4debc66d',
18 'timestamp': 1606148940,
19 'upload_date': '20201123',
20 'uploader': 'NBCU-MPAT',
22 'params': {
23 'skip_download': True,
25 }, {
26 'url': 'http://www.sproutonline.com/watch/cowboy-adventure',
27 'only_matching': True,
28 }, {
29 'url': 'https://www.universalkids.com/watch/robot-bike-race',
30 'only_matching': True,
32 _GEO_COUNTRIES = ['US']
34 def _real_extract(self, url):
35 display_id = self._match_id(url)
36 mpx_metadata = self._download_json(
37 # http://nbcuunikidsprod.apps.nbcuni.com/networks/universalkids/content/videos/
38 'https://www.universalkids.com/_api/videos/' + display_id,
39 display_id)['mpxMetadata']
40 media_pid = mpx_metadata['mediaPid']
41 theplatform_url = 'https://link.theplatform.com/s/HNK2IC/' + media_pid
42 query = {
43 'mbr': 'true',
44 'manifest': 'm3u',
46 if mpx_metadata.get('entitlement') == 'auth':
47 query['auth'] = self._extract_mvpd_auth(url, media_pid, 'sprout', 'sprout')
48 theplatform_url = smuggle_url(
49 update_url_query(theplatform_url, query), {
50 'force_smil_url': True,
51 'geo_countries': self._GEO_COUNTRIES,
53 return {
54 '_type': 'url_transparent',
55 'id': media_pid,
56 'url': theplatform_url,
57 'series': mpx_metadata.get('seriesName'),
58 'season_number': int_or_none(mpx_metadata.get('seasonNumber')),
59 'episode_number': int_or_none(mpx_metadata.get('episodeNumber')),
60 'ie_key': 'ThePlatform',