From 3d461850f7c536f59951405581c86ec735aac096 Mon Sep 17 00:00:00 2001 From: 7x11x13 Date: Fri, 7 Jan 2022 05:45:59 -0500 Subject: [PATCH] Fix downloading --- scdl/scdl.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/scdl/scdl.py b/scdl/scdl.py index 9a2c346..205e9b4 100755 --- a/scdl/scdl.py +++ b/scdl/scdl.py @@ -574,17 +574,25 @@ def download_hls(client: SoundCloud, track: BasicTrack, title: str, playlist_inf logger.debug(f"Trancodings: {track.media.transcodings}") - transcodings = {t.preset: t for t in track.media.transcodings if t.format.protocol == "hls"} - transcoding = None + aac_transcoding = None + mp3_transcoding = None + + for t in track.media.transcodings: + if t.format.protocol == "hls" and "aac" in t.preset: + aac_transcoding = t + elif t.format.protocol == "hls" and "mp3" in t.preset: + mp3_transcoding = t + aac = False - if not kwargs.get("onlymp3") and "aac_hq" in transcodings: - transcoding = transcodings["aac_hq"] + transcoding = None + if not kwargs.get("onlymp3") and aac_transcoding: + transcoding = aac_transcoding aac = True - elif "mp3_0_0" in transcodings: - transcoding = transcodings["mp3_0_0"] + elif mp3_transcoding: + transcoding = mp3_transcoding if not transcoding: - raise SoundCloudException(f"Could not find mp3_0_0 or aac_hq transcoding. Available transcodings: {list(transcodings)}") + raise SoundCloudException(f"Could not find mp3 or aac transcoding. Available transcodings: {[t.preset for t in track.media.transcodings if t.format.protocol == 'hls']}") filename = get_filename(track, None, aac, playlist_info, **kwargs) logger.debug(f"filename : {filename}")