From 8dcee29952e69e1e484066471d4a8f6c473d0683 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 1 Jan 2019 20:04:30 -0600 Subject: [PATCH] Fixed an issue when playing a song in Python 2 --- src/controller/player.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/controller/player.py b/src/controller/player.py index ea5fed6..151771c 100644 --- a/src/controller/player.py +++ b/src/controller/player.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +import sys import random import output import sound_lib @@ -43,8 +44,13 @@ class audioPlayer(object): # Make sure that there are no other sounds trying to be played. if self.is_working == False: self.is_working = True + # Let's encode the URL as bytes if on Python 3 + if sys.version[0] == "3": + url_ = bytes(url["url"], "utf-8") + else: + url_ = url["url"] try: - self.stream = URLStream(url=bytes(url["url"], "utf-8")) + self.stream = URLStream(url=url_) except BassError: log.debug("Error when playing the file %r") % (url,) return