From 976e90f0a0ce71ee9c3ecfe5e3c9b53a735db4ae Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 30 Apr 2019 15:32:38 -0500 Subject: [PATCH] Fixed audio methods --- src/sessionmanager/utils.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/sessionmanager/utils.py b/src/sessionmanager/utils.py index c4718ea..8283cab 100644 --- a/src/sessionmanager/utils.py +++ b/src/sessionmanager/utils.py @@ -78,19 +78,16 @@ def transform_audio_url(url): """ Transforms the URL offered by VK to the unencrypted stream so we can still play it. This function will be updated every time VK decides to change something in their Audio API'S. Changelog: - 16/04/2019: Implemented this function. For now it replaces /index.m3u8 by .mp3, also removes the path component before "/audios" if the URL contains the word /audios, or the last path component before the filename if doesn't. - 17/04/2019: Updated function. Now it is not required to strip anything, just replacing /index.m3u8 with .mp3 should be enough. + 30/04/2019: Re-enabled old methods as VK changed everything as how it was working on 16.04.2019. + 17.04.2019: Updated function. Now it is not required to strip anything, just replacing /index.m3u8 with .mp3 should be enough. + 16.04.2019: Implemented this function. For now it replaces /index.m3u8 by .mp3, also removes the path component before "/audios" if the URL contains the word /audios, or the last path component before the filename if doesn't. """ if "vkuseraudio.net" not in url and "index.m3u8" not in url: return url url = url.replace("/index.m3u8", ".mp3") - return url - ### The following code was useful for VK audio methods prior to 17/04/2019. - # I just left this here because they may enable such change any time soon. - ### basically this method was requiring us to strip a part of the full URL. -# parts = url.split("/") -# if "/audio" not in url: -# url = url.replace("/"+parts[-2], "") -# else: -# url = url.replace("/"+parts[-3], "") -# return url \ No newline at end of file + parts = url.split("/") + if "/audios" not in url: + url = url.replace("/"+parts[-2], "") + else: + url = url.replace("/"+parts[-3], "") + return url \ No newline at end of file