Skip to content

Commit

Permalink
fix unicode issue, closes #95
Browse files Browse the repository at this point in the history
  • Loading branch information
gmdfalk committed Apr 7, 2016
1 parent bd00de4 commit 11cc3f9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions blockify/dbusclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def get_property(self, key):
except dbus.exceptions.DBusException as e:
self.connect_to_spotify_dbus(None)
log.error("Failed to get DBus property: {}".format(e))

return prop

def set_property(self, key, value):
Expand Down Expand Up @@ -142,16 +143,17 @@ def get_art_url(self):
url = ""
try:
metadata = self.get_property("Metadata")
url = metadata["mpris:artUrl"]
url = str(metadata["mpris:artUrl"], "utf-8")
except Exception as e:
log.error("Cannot fetch album cover: {}".format(e))
log.error("Cannot fetch album cover url: {}".format(e))

return url

def get_song_status(self):
"""Get current PlaybackStatus (Paused/Playing...)."""
status = ""
try:
status = self.get_property("PlaybackStatus")
status = str(self.get_property("PlaybackStatus"), "utf-8")
except Exception as e:
log.warn("Cannot get PlaybackStatus: {}".format(e))

Expand Down Expand Up @@ -180,7 +182,7 @@ def get_song_title(self):
title = ""
try:
metadata = self.get_property("Metadata")
title = metadata["xesam:title"]
title = str(metadata["xesam:title"], "utf-8")
except Exception as e:
log.warn("Cannot get song title: {}".format(e))

Expand All @@ -191,7 +193,7 @@ def get_song_album(self):
album = ""
try:
metadata = self.get_property("Metadata")
album = metadata["xesam:album"]
album = str(metadata["xesam:album"], "utf-8")
except Exception as e:
log.warn("Cannot get song album: {}".format(e))

Expand All @@ -202,7 +204,7 @@ def get_song_artist(self):
artist = ""
try:
metadata = self.get_property("Metadata")
artist = metadata["xesam:artist"][0]
artist = str(metadata["xesam:artist"][0], "utf-8")
except Exception as e:
log.warn("Cannot get song artist: {}".format(e))

Expand Down

0 comments on commit 11cc3f9

Please sign in to comment.