1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-10 13:12:45 +01:00

[SonyLIV] Add SonyLIVSeriesIE (#331)

Authored by: Ashish0804
This commit is contained in:
Ashish 2021-05-22 17:53:06 +05:30 committed by GitHub
parent 13a49340ed
commit 135e6b93f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 2 deletions

View File

@ -1184,7 +1184,10 @@
from .slutload import SlutloadIE from .slutload import SlutloadIE
from .snotr import SnotrIE from .snotr import SnotrIE
from .sohu import SohuIE from .sohu import SohuIE
from .sonyliv import SonyLIVIE from .sonyliv import (
SonyLIVIE,
SonyLIVSeriesIE,
)
from .soundcloud import ( from .soundcloud import (
SoundcloudEmbedIE, SoundcloudEmbedIE,
SoundcloudIE, SoundcloudIE,

View File

@ -9,11 +9,18 @@
from ..utils import ( from ..utils import (
ExtractorError, ExtractorError,
int_or_none, int_or_none,
try_get,
) )
class SonyLIVIE(InfoExtractor): class SonyLIVIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?sonyliv\.com/(?:s(?:how|port)s/[^/]+|movies|clip|trailer|music-videos)/[^/?#&]+-(?P<id>\d+)' _VALID_URL = r'''(?x)
(?:
sonyliv:|
https?://(?:www\.)?sonyliv\.com/(?:s(?:how|port)s/[^/]+|movies|clip|trailer|music-videos)/[^/?#&]+-
)
(?P<id>\d+)
'''
_TESTS = [{ _TESTS = [{
'url': 'https://www.sonyliv.com/shows/bachelors-delight-1700000113/achaari-cheese-toast-1000022678?watch=true', 'url': 'https://www.sonyliv.com/shows/bachelors-delight-1700000113/achaari-cheese-toast-1000022678?watch=true',
'info_dict': { 'info_dict': {
@ -107,3 +114,41 @@ def _real_extract(self, url):
'episode_number': int_or_none(metadata.get('episodeNumber')), 'episode_number': int_or_none(metadata.get('episodeNumber')),
'release_year': int_or_none(metadata.get('year')), 'release_year': int_or_none(metadata.get('year')),
} }
class SonyLIVSeriesIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?sonyliv\.com/shows/[^/?#&]+-(?P<id>\d{10})$'
_TESTS = [{
'url': 'https://www.sonyliv.com/shows/adaalat-1700000091',
'playlist_mincount': 456,
'info_dict': {
'id': '1700000091',
},
}]
_API_SHOW_URL = "https://apiv2.sonyliv.com/AGL/1.9/R/ENG/WEB/IN/DL/DETAIL/{}?kids_safe=false&from=0&to=49"
_API_EPISODES_URL = "https://apiv2.sonyliv.com/AGL/1.4/R/ENG/WEB/IN/CONTENT/DETAIL/BUNDLE/{}?from=0&to=1000&orderBy=episodeNumber&sortOrder=asc"
_API_SECURITY_URL = 'https://apiv2.sonyliv.com/AGL/1.4/A/ENG/WEB/ALL/GETTOKEN'
def _entries(self, show_id):
headers = {
'Accept': 'application/json, text/plain, */*',
'Referer': 'https://www.sonyliv.com',
}
headers['security_token'] = self._download_json(
self._API_SECURITY_URL, video_id=show_id, headers=headers,
note='Downloading security token')['resultObj']
seasons = try_get(
self._download_json(self._API_SHOW_URL.format(show_id), video_id=show_id, headers=headers),
lambda x: x['resultObj']['containers'][0]['containers'], list)
for season in seasons or []:
season_id = season['id']
episodes = try_get(
self._download_json(self._API_EPISODES_URL.format(season_id), video_id=season_id, headers=headers),
lambda x: x['resultObj']['containers'][0]['containers'], list)
for episode in episodes or []:
video_id = episode.get('id')
yield self.url_result('sonyliv:%s' % video_id, ie=SonyLIVIE.ie_key(), video_id=video_id)
def _real_extract(self, url):
show_id = self._match_id(url)
return self.playlist_result(self._entries(show_id), playlist_id=show_id)