Fixed all audio methods due to latest VK changes
This commit is contained in:
parent
5f224a077c
commit
4f3bb6ac93
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|
||||||
|
* Updated method for accessing audio files due to the latest changes on VK apps.
|
||||||
* When changing volume of the playing audio, it will decrease or increase the volume by 2% instead of 5%.
|
* When changing volume of the playing audio, it will decrease or increase the volume by 2% instead of 5%.
|
||||||
* Read confirmations will be sent to VK as soon as you read the message. Before, read confirmations were being sent every 3 minutes to the social network.
|
* Read confirmations will be sent to VK as soon as you read the message. Before, read confirmations were being sent every 3 minutes to the social network.
|
||||||
|
|
||||||
|
@ -324,6 +324,7 @@ class Controller(object):
|
|||||||
@ filename: the current path to where the file will be saved.
|
@ filename: the current path to where the file will be saved.
|
||||||
The dowwload progress will be displayed in the status bar on the window.
|
The dowwload progress will be displayed in the status bar on the window.
|
||||||
"""
|
"""
|
||||||
|
url = utils.transform_audio_url(url)
|
||||||
log.debug("downloading %s URL to %s filename" % (url, filename,))
|
log.debug("downloading %s URL to %s filename" % (url, filename,))
|
||||||
call_threaded(utils.download_file, url, filename, self.window)
|
call_threaded(utils.download_file, url, filename, self.window)
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ from sound_lib.main import BassError
|
|||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
from mysc.repeating_timer import RepeatingTimer
|
from mysc.repeating_timer import RepeatingTimer
|
||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
|
from sessionmanager import utils
|
||||||
|
|
||||||
player = None
|
player = None
|
||||||
log = logging.getLogger("player")
|
log = logging.getLogger("player")
|
||||||
@ -76,10 +77,11 @@ class audioPlayer(object):
|
|||||||
if self.is_working == False:
|
if self.is_working == False:
|
||||||
self.is_working = True
|
self.is_working = True
|
||||||
# Let's encode the URL as bytes if on Python 3
|
# Let's encode the URL as bytes if on Python 3
|
||||||
url_ = bytes(object["url"], "utf-8")
|
url_ = utils.transform_audio_url(object["url"])
|
||||||
|
url_ = bytes(url_, "utf-8")
|
||||||
try:
|
try:
|
||||||
self.stream = URLStream(url=url_)
|
self.stream = URLStream(url=url_)
|
||||||
except IndexError:
|
except:
|
||||||
log.error("Unable to play URL %s" % (url_))
|
log.error("Unable to play URL %s" % (url_))
|
||||||
return
|
return
|
||||||
# Translators: {0} will be replaced with a song's title and {1} with the artist.
|
# Translators: {0} will be replaced with a song's title and {1} with the artist.
|
||||||
@ -186,5 +188,4 @@ class audioPlayer(object):
|
|||||||
if self.stream != None and self.stream.is_playing == False:
|
if self.stream != None and self.stream.is_playing == False:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
@ -72,4 +72,16 @@ def clean_text(text):
|
|||||||
""" Clean text, removing all unneeded HTMl and converting HTML represented characters in their unicode counterparts."""
|
""" Clean text, removing all unneeded HTMl and converting HTML represented characters in their unicode counterparts."""
|
||||||
text = detect_users(text)
|
text = detect_users(text)
|
||||||
text = html.unescape(text)
|
text = html.unescape(text)
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
def transform_audio_url(url):
|
||||||
|
""" Transforms the URL offered by VK to the unencrypted stream so we can still play it. """
|
||||||
|
if "vkuseraudio.net" not in url and "index.m3u8" not in url:
|
||||||
|
return url
|
||||||
|
url = url.replace("/index.m3u8", ".mp3")
|
||||||
|
parts = url.split("/")
|
||||||
|
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