Updated audio methods for changes introduced in 17/04
This commit is contained in:
parent
9373f10d68
commit
f88d2177c3
@ -75,13 +75,22 @@ def clean_text(text):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
def transform_audio_url(url):
|
def transform_audio_url(url):
|
||||||
""" Transforms the URL offered by VK to the unencrypted stream so we can still play it. """
|
""" 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.
|
||||||
|
"""
|
||||||
if "vkuseraudio.net" not in url and "index.m3u8" not in url:
|
if "vkuseraudio.net" not in url and "index.m3u8" not in url:
|
||||||
return url
|
return url
|
||||||
url = url.replace("/index.m3u8", ".mp3")
|
url = url.replace("/index.m3u8", ".mp3")
|
||||||
parts = url.split("/")
|
return url
|
||||||
if "/audio" not in url:
|
### The following code was useful for VK audio methods prior to 17/04/2019.
|
||||||
url = url.replace("/"+parts[-2], "")
|
# I just left this here because they may enable such change any time soon.
|
||||||
else:
|
### basically this method was requiring us to strip a part of the full URL.
|
||||||
url = url.replace("/"+parts[-3], "")
|
# parts = url.split("/")
|
||||||
return url
|
# if "/audio" not in url:
|
||||||
|
# url = url.replace("/"+parts[-2], "")
|
||||||
|
# else:
|
||||||
|
# url = url.replace("/"+parts[-3], "")
|
||||||
|
# return url
|
Loading…
Reference in New Issue
Block a user