mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-07 05:48:31 +00:00
Apply suggestions
This commit is contained in:
parent
abd475ecaa
commit
04d3745186
@ -1,12 +1,11 @@
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
|
||||||
float_or_none,
|
float_or_none,
|
||||||
parse_resolution,
|
parse_resolution,
|
||||||
qualities,
|
qualities,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
)
|
)
|
||||||
from ..utils.traversal import traverse_obj
|
from ..utils.traversal import require, traverse_obj
|
||||||
|
|
||||||
|
|
||||||
class AppleConnectIE(InfoExtractor):
|
class AppleConnectIE(InfoExtractor):
|
||||||
@ -54,15 +53,15 @@ def _real_extract(self, url):
|
|||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
if not (videos := traverse_obj(self._download_json(
|
videos = self._download_json(
|
||||||
'https://amp-api.music.apple.com/v1/catalog/us/uploaded-videos',
|
'https://amp-api.music.apple.com/v1/catalog/us/uploaded-videos',
|
||||||
video_id, headers=self._HEADERS, query={'ids': video_id, 'l': 'en-US'},
|
video_id, headers=self._HEADERS, query={'ids': video_id, 'l': 'en-US'})
|
||||||
), ('data', ..., 'attributes', any), default={})):
|
attributes = traverse_obj(videos, (
|
||||||
raise ExtractorError('Failed to fetch video information')
|
'data', ..., 'attributes', any, {require('video information')}))
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
quality = qualities(list(self._QUALITIES.keys()))
|
quality = qualities(list(self._QUALITIES.keys()))
|
||||||
for format_id, src_url in traverse_obj(videos, (
|
for format_id, src_url in traverse_obj(attributes, (
|
||||||
'assetTokens', {dict.items}, lambda _, v: url_or_none(v[1]),
|
'assetTokens', {dict.items}, lambda _, v: url_or_none(v[1]),
|
||||||
)):
|
)):
|
||||||
formats.append({
|
formats.append({
|
||||||
@ -82,7 +81,7 @@ def _real_extract(self, url):
|
|||||||
'formats': formats,
|
'formats': formats,
|
||||||
'thumbnail': self._html_search_meta(
|
'thumbnail': self._html_search_meta(
|
||||||
('og:image', 'og:image:secure_url', 'twitter:image'), webpage),
|
('og:image', 'og:image:secure_url', 'twitter:image'), webpage),
|
||||||
**traverse_obj(videos, {
|
**traverse_obj(attributes, {
|
||||||
'title': ('name', {str}),
|
'title': ('name', {str}),
|
||||||
'duration': ('durationInMilliseconds', {float_or_none(scale=1000)}),
|
'duration': ('durationInMilliseconds', {float_or_none(scale=1000)}),
|
||||||
'upload_date': ('uploadDate', {str}, {lambda x: x.replace('-', '')}),
|
'upload_date': ('uploadDate', {str}, {lambda x: x.replace('-', '')}),
|
||||||
|
Loading…
Reference in New Issue
Block a user