mirror of
https://github.com/glomatico/gamdl.git
synced 2025-01-22 11:18:39 +00:00
refactor to use webplayback api to get the stream url instead of itunes page
This commit is contained in:
parent
acd5fefb76
commit
fcbe596a80
@ -609,9 +609,9 @@ def main(
|
|||||||
itunes_page = itunes_api.get_itunes_page(
|
itunes_page = itunes_api.get_itunes_page(
|
||||||
"music-video", music_video_id_alt
|
"music-video", music_video_id_alt
|
||||||
)
|
)
|
||||||
stream_url_master = downloader_music_video.get_stream_url_master(
|
logger.debug("Getting webplayback")
|
||||||
itunes_page
|
webplayback = apple_music_api.get_webplayback(track_metadata["id"])
|
||||||
)
|
stream_url_master = webplayback["hls-playlist-url"]
|
||||||
logger.debug("Getting M3U8 data")
|
logger.debug("Getting M3U8 data")
|
||||||
m3u8_master_data = downloader_music_video.get_m3u8_master_data(
|
m3u8_master_data = downloader_music_video.get_m3u8_master_data(
|
||||||
stream_url_master
|
stream_url_master
|
||||||
|
@ -25,17 +25,11 @@ class DownloaderMusicVideo:
|
|||||||
self.downloader = downloader
|
self.downloader = downloader
|
||||||
self.codec = codec
|
self.codec = codec
|
||||||
|
|
||||||
def get_stream_url_master(self, itunes_page: dict) -> str:
|
def get_stream_url_master(self, webplayback: dict) -> str:
|
||||||
return itunes_page["offers"][0]["assets"][0]["hlsUrl"]
|
return webplayback["hls-playlist-url"]
|
||||||
|
|
||||||
def get_m3u8_master_data(self, stream_url_master: str) -> dict:
|
def get_m3u8_master_data(self, stream_url_master: str) -> dict:
|
||||||
url_parts = urllib.parse.urlparse(stream_url_master)
|
return m3u8.load(stream_url_master).data
|
||||||
query = urllib.parse.parse_qs(url_parts.query, keep_blank_values=True)
|
|
||||||
query.update({"aec": "HD", "dsid": "1"})
|
|
||||||
stream_url_master_new = url_parts._replace(
|
|
||||||
query=urllib.parse.urlencode(query, doseq=True)
|
|
||||||
).geturl()
|
|
||||||
return m3u8.load(stream_url_master_new).data
|
|
||||||
|
|
||||||
def get_playlist_video(
|
def get_playlist_video(
|
||||||
self,
|
self,
|
||||||
|
Loading…
Reference in New Issue
Block a user