Skip to content

Commit

Permalink
[merlinmusicplayer] py3 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
WanWizard committed Sep 12, 2023
1 parent 94c673d commit 83c6a61
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions merlinmusicplayer/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ class myHTTPClientFactory(HTTPClientFactory):
def __init__(self, url, method='GET', postdata=None, headers=None,
agent="SHOUTcast", timeout=0, cookies=None,
followRedirect=1, lastModified=None, etag=None):
if type(url) is str:
url = bytes(url, 'utf-8')
if type(method) is str:
method = bytes(method, 'utf-8')
HTTPClientFactory.__init__(self, url, method=method, postdata=postdata,
headers=headers, agent=agent, timeout=timeout, cookies=cookies, followRedirect=followRedirect)

Expand Down Expand Up @@ -1548,8 +1552,10 @@ def startRun(self):
audio = ID3(self.currentSong.filename)
except:
audio = None
text = getEncodedString(self.getLyricsFromID3Tag(audio)).replace("\r\n", "\n")
text = text.replace("\r", "\n")
text = getEncodedString(self.getLyricsFromID3Tag(audio))
if type(text) is bytes:
text = text.decode('utf-8')
text = text.replace("\r\n", "\n").replace("\r", "\n")
self["lyric_text"].setText(text)

def getLyricsFromID3Tag(self, tag):
Expand All @@ -1569,10 +1575,10 @@ def urlError(self, error=None):
def gotLyrics(self, xmlstring):
root = cet_fromstring(xmlstring)
lyrictext = ""
lyrictext = root.findtext("{http://api.chartlyrics.com/}Lyric").encode("utf-8", 'ignore')
lyrictext = root.findtext("{http://api.chartlyrics.com/}Lyric")
self["lyric_text"].setText(lyrictext)
title = root.findtext("{http://api.chartlyrics.com/}LyricSong").encode("utf-8", 'ignore')
artist = root.findtext("{http://api.chartlyrics.com/}LyricArtist").encode("utf-8", 'ignore')
title = root.findtext("{http://api.chartlyrics.com/}LyricSong")
artist = root.findtext("{http://api.chartlyrics.com/}LyricArtist")
result = _("Response -> lyrics for: %s (%s)") % (title, artist)
self["resulttext"].setText(result)
if not lyrictext:
Expand Down

0 comments on commit 83c6a61

Please sign in to comment.