]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/sonyliv.py
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
8 from ..compat
import compat_HTTPError
15 class SonyLIVIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?sonyliv\.com/(?:s(?:how|port)s/[^/]+|movies|clip|trailer|music-videos)/[^/?#&]+-(?P<id>\d+)'
18 'url': 'https://www.sonyliv.com/shows/bachelors-delight-1700000113/achaari-cheese-toast-1000022678?watch=true',
20 'title': 'Achaari Cheese Toast',
23 'upload_date': '20200411',
24 'description': 'md5:3957fa31d9309bf336ceb3f37ad5b7cb',
25 'timestamp': 1586632091,
28 'series': 'Bachelors Delight',
33 'skip_download': True,
36 'url': 'https://www.sonyliv.com/movies/tahalka-1000050121?watch=true',
37 'only_matching': True,
39 'url': 'https://www.sonyliv.com/clip/jigarbaaz-1000098925',
40 'only_matching': True,
42 'url': 'https://www.sonyliv.com/trailer/sandwiched-forever-1000100286?watch=true',
43 'only_matching': True,
45 'url': 'https://www.sonyliv.com/sports/india-tour-of-australia-2020-21-1700000286/cricket-hls-day-3-1st-test-aus-vs-ind-19-dec-2020-1000100959?watch=true',
46 'only_matching': True,
48 'url': 'https://www.sonyliv.com/music-videos/yeh-un-dinon-ki-baat-hai-1000018779',
49 'only_matching': True,
51 _GEO_COUNTRIES
= ['IN']
54 def _call_api(self
, version
, path
, video_id
):
57 headers
['security_token'] = self
._TOKEN
59 return self
._download
_json
(
60 'https://apiv2.sonyliv.com/AGL/%s/A/ENG/WEB/%s' % (version
, path
),
61 video_id
, headers
=headers
)['resultObj']
62 except ExtractorError
as e
:
63 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
64 message
= self
._parse
_json
(
65 e
.cause
.read().decode(), video_id
)['message']
66 if message
== 'Geoblocked Country':
67 self
.raise_geo_restricted(countries
=self
._GEO
_COUNTRIES
)
68 raise ExtractorError(message
)
71 def _real_initialize(self
):
72 self
._TOKEN
= self
._call
_api
('1.4', 'ALL/GETTOKEN', None)
74 def _real_extract(self
, url
):
75 video_id
= self
._match
_id
(url
)
76 content
= self
._call
_api
(
77 '1.5', 'IN/CONTENT/VIDEOURL/VOD/' + video_id
, video_id
)
78 if not self
._downloader
.params
.get('allow_unplayable_formats') and content
.get('isEncrypted'):
79 raise ExtractorError('This video is DRM protected.', expected
=True)
80 dash_url
= content
['videoURL']
82 'x-playback-session-id': '%s-%d' % (uuid
.uuid4().hex, time
.time() * 1000)
84 formats
= self
._extract
_mpd
_formats
(
85 dash_url
, video_id
, mpd_id
='dash', headers
=headers
, fatal
=False)
86 formats
.extend(self
._extract
_m
3u8_formats
(
87 dash_url
.replace('.mpd', '.m3u8').replace('/DASH/', '/HLS/'),
88 video_id
, 'mp4', m3u8_id
='hls', headers
=headers
, fatal
=False))
90 f
.setdefault('http_headers', {}).update(headers
)
91 self
._sort
_formats
(formats
)
93 metadata
= self
._call
_api
(
94 '1.6', 'IN/DETAIL/' + video_id
, video_id
)['containers'][0]['metadata']
95 title
= metadata
['episodeTitle']
101 'thumbnail': content
.get('posterURL'),
102 'description': metadata
.get('longDescription') or metadata
.get('shortDescription'),
103 'timestamp': int_or_none(metadata
.get('creationDate'), 1000),
104 'duration': int_or_none(metadata
.get('duration')),
105 'season_number': int_or_none(metadata
.get('season')),
106 'series': metadata
.get('title'),
107 'episode_number': int_or_none(metadata
.get('episodeNumber')),
108 'release_year': int_or_none(metadata
.get('year')),