mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-22 02:15:12 +00:00
[ie/AmazonMiniTV] Fix extractor (#8103)
Closes #7817 Authored by: Aniruddh-J
This commit is contained in:
parent
5336bf57a7
commit
9d376c4dae
1 changed files with 9 additions and 54 deletions
|
@ -37,7 +37,7 @@ def _call_api(self, asin, data=None, note=None):
|
||||||
return resp['data'][data['operationName']]
|
return resp['data'][data['operationName']]
|
||||||
|
|
||||||
|
|
||||||
class AmazonMiniTVIE(AmazonMiniTVBaseIE):
|
class AmazonMiniTVIE(InfoExtractor):
|
||||||
_VALID_URL = r'(?:https?://(?:www\.)?amazon\.in/minitv/tp/|amazonminitv:(?:amzn1\.dv\.gti\.)?)(?P<id>[a-f0-9-]+)'
|
_VALID_URL = r'(?:https?://(?:www\.)?amazon\.in/minitv/tp/|amazonminitv:(?:amzn1\.dv\.gti\.)?)(?P<id>[a-f0-9-]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://www.amazon.in/minitv/tp/75fe3a75-b8fe-4499-8100-5c9424344840?referrer=https%3A%2F%2Fwww.amazon.in%2Fminitv',
|
'url': 'https://www.amazon.in/minitv/tp/75fe3a75-b8fe-4499-8100-5c9424344840?referrer=https%3A%2F%2Fwww.amazon.in%2Fminitv',
|
||||||
|
@ -86,56 +86,14 @@ class AmazonMiniTVIE(AmazonMiniTVBaseIE):
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
_GRAPHQL_QUERY_CONTENT = '''
|
|
||||||
query content($sessionIdToken: String!, $deviceLocale: String, $contentId: ID!, $contentType: ContentType!, $clientId: String) {
|
|
||||||
content(
|
|
||||||
applicationContextInput: {deviceLocale: $deviceLocale, sessionIdToken: $sessionIdToken, clientId: $clientId}
|
|
||||||
contentId: $contentId
|
|
||||||
contentType: $contentType
|
|
||||||
) {
|
|
||||||
contentId
|
|
||||||
name
|
|
||||||
... on Episode {
|
|
||||||
contentId
|
|
||||||
vodType
|
|
||||||
name
|
|
||||||
images
|
|
||||||
description {
|
|
||||||
synopsis
|
|
||||||
contentLengthInSeconds
|
|
||||||
}
|
|
||||||
publicReleaseDateUTC
|
|
||||||
audioTracks
|
|
||||||
seasonId
|
|
||||||
seriesId
|
|
||||||
seriesName
|
|
||||||
seasonNumber
|
|
||||||
episodeNumber
|
|
||||||
timecode {
|
|
||||||
endCreditsTime
|
|
||||||
}
|
|
||||||
}
|
|
||||||
... on MovieContent {
|
|
||||||
contentId
|
|
||||||
vodType
|
|
||||||
name
|
|
||||||
description {
|
|
||||||
synopsis
|
|
||||||
contentLengthInSeconds
|
|
||||||
}
|
|
||||||
images
|
|
||||||
publicReleaseDateUTC
|
|
||||||
audioTracks
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}'''
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
asin = f'amzn1.dv.gti.{self._match_id(url)}'
|
video_uuid = self._match_id(url)
|
||||||
prs = self._call_api(asin, note='Downloading playback info')
|
asin = f'amzn1.dv.gti.{video_uuid}'
|
||||||
|
webpage = self._download_webpage(f'https://www.amazon.in/minitv/tp/{video_uuid}', asin)
|
||||||
|
data = self._search_nextjs_data(webpage, asin)['props']['pageProps']['ssrProps']
|
||||||
|
|
||||||
formats, subtitles = [], {}
|
formats, subtitles = [], {}
|
||||||
for type_, asset in prs['playbackAssets'].items():
|
for type_, asset in traverse_obj(data, ('playbackData', 'playbackAssets', {dict.items}, ...)):
|
||||||
if not traverse_obj(asset, 'manifestUrl'):
|
if not traverse_obj(asset, 'manifestUrl'):
|
||||||
continue
|
continue
|
||||||
if type_ == 'hls':
|
if type_ == 'hls':
|
||||||
|
@ -152,12 +110,7 @@ def _real_extract(self, url):
|
||||||
else:
|
else:
|
||||||
self.report_warning(f'Unknown asset type: {type_}')
|
self.report_warning(f'Unknown asset type: {type_}')
|
||||||
|
|
||||||
title_info = self._call_api(
|
title_info = traverse_obj(data, ('contentData', {dict})) or {}
|
||||||
asin, note='Downloading title info', data={
|
|
||||||
'operationName': 'content',
|
|
||||||
'variables': {'contentId': asin},
|
|
||||||
'query': self._GRAPHQL_QUERY_CONTENT,
|
|
||||||
})
|
|
||||||
credits_time = try_get(title_info, lambda x: x['timecode']['endCreditsTime'] / 1000)
|
credits_time = try_get(title_info, lambda x: x['timecode']['endCreditsTime'] / 1000)
|
||||||
is_episode = title_info.get('vodType') == 'EPISODE'
|
is_episode = title_info.get('vodType') == 'EPISODE'
|
||||||
|
|
||||||
|
@ -192,6 +145,7 @@ class AmazonMiniTVSeasonIE(AmazonMiniTVBaseIE):
|
||||||
IE_NAME = 'amazonminitv:season'
|
IE_NAME = 'amazonminitv:season'
|
||||||
_VALID_URL = r'amazonminitv:season:(?:amzn1\.dv\.gti\.)?(?P<id>[a-f0-9-]+)'
|
_VALID_URL = r'amazonminitv:season:(?:amzn1\.dv\.gti\.)?(?P<id>[a-f0-9-]+)'
|
||||||
IE_DESC = 'Amazon MiniTV Season, "minitv:season:" prefix'
|
IE_DESC = 'Amazon MiniTV Season, "minitv:season:" prefix'
|
||||||
|
_WORKING = False
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'amazonminitv:season:amzn1.dv.gti.0aa996eb-6a1b-4886-a342-387fbd2f1db0',
|
'url': 'amazonminitv:season:amzn1.dv.gti.0aa996eb-6a1b-4886-a342-387fbd2f1db0',
|
||||||
'playlist_mincount': 6,
|
'playlist_mincount': 6,
|
||||||
|
@ -251,6 +205,7 @@ class AmazonMiniTVSeriesIE(AmazonMiniTVBaseIE):
|
||||||
IE_NAME = 'amazonminitv:series'
|
IE_NAME = 'amazonminitv:series'
|
||||||
_VALID_URL = r'amazonminitv:series:(?:amzn1\.dv\.gti\.)?(?P<id>[a-f0-9-]+)'
|
_VALID_URL = r'amazonminitv:series:(?:amzn1\.dv\.gti\.)?(?P<id>[a-f0-9-]+)'
|
||||||
IE_DESC = 'Amazon MiniTV Series, "minitv:series:" prefix'
|
IE_DESC = 'Amazon MiniTV Series, "minitv:series:" prefix'
|
||||||
|
_WORKING = False
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'amazonminitv:series:amzn1.dv.gti.56521d46-b040-4fd5-872e-3e70476a04b0',
|
'url': 'amazonminitv:series:amzn1.dv.gti.56521d46-b040-4fd5-872e-3e70476a04b0',
|
||||||
'playlist_mincount': 3,
|
'playlist_mincount': 3,
|
||||||
|
|
Loading…
Reference in a new issue