Skip to content

Commit

Permalink
MerlinMusicPlayer: Fix cover search issues
Browse files Browse the repository at this point in the history
- If hardware decoding was disabled and album field in mp3 tag
 was empty, "n/a" was used for cover search.
- When album field is empty now title is used for cover search.

Signed-off-by: Littlesat <littlesat99@yahoo.com>
  • Loading branch information
betacentauri committed Jan 31, 2014
1 parent 4a1d87d commit 5d94610
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions merlinmusicplayer/src/plugin.py
Expand Up @@ -1106,7 +1106,7 @@ def updateMusicInformationCUE(self):
self.screenSaverScreen.updateDisplayText("%s - %s" % (self.songList[self.currentIndex][0].title,self.songList[self.currentIndex][0].album))
else:
self.screenSaverScreen.updateDisplayText(self.songList[self.currentIndex][0].title)
self.updateCover(self.songList[self.currentIndex][0].artist, self.songList[self.currentIndex][0].album)
self.updateCover(self.songList[self.currentIndex][0].artist, self.songList[self.currentIndex][0].album, self.songList[self.currentIndex][0].title)
self.currentTitle = self.songList[self.currentIndex][0].title
self["nextTitle"].setText(self.getNextTitle())

Expand Down Expand Up @@ -1161,9 +1161,9 @@ def updateMusicInformation(self, artist = "", title = "", album = "", genre = ""
self.screenSaverScreen.updateDisplayText("%s - %s" % (title,album))
else:
self.screenSaverScreen.updateDisplayText(title)
self.updateCover(artist, album)
self.updateCover(artist, album, title)

def updateCover(self, artist, album):
def updateCover(self, artist, album, title):
hasCover = False
audio = None
audiotype = 0
Expand Down Expand Up @@ -1212,7 +1212,7 @@ def updateCover(self, artist, album):
if not hasCover:
if not self["coverArt"].updateCoverArt(self.currentFilename):
if config.plugins.merlinmusicplayer.usegoogleimage.value:
self.getGoogleCover(artist, album)
self.getGoogleCover(artist, album, title)
else:
self["coverArt"].showDefaultCover()
if self.screenSaverScreen:
Expand All @@ -1229,12 +1229,18 @@ def updateSingleMusicInformation(self, name, info, clear):
if self[name].getText() != info:
self[name].setText(info)

def getGoogleCover(self, artist,album):
if artist != "" and album != "":
def getGoogleCover(self, artist, album, title):
if (artist == "" or artist == "n/a"):
self["coverArt"].showDefaultCover()
elif (album == "" or album.startswith("n/a")):
if (title == "" or title == "n/a"):
self["coverArt"].showDefaultCover()
else:
url = "http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=%s+%s" % (quote(artist),quote(title))
sendUrlCommand(url, None,10).addCallback(self.googleImageCallback).addErrback(self.coverDownloadFailed)
else:
url = "http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=%s+%s" % (quote(album),quote(artist))
sendUrlCommand(url, None,10).addCallback(self.googleImageCallback).addErrback(self.coverDownloadFailed)
else:
self["coverArt"].showDefaultCover()

def googleImageCallback(self, result):
foundPos = result.find("unescapedUrl\":\"")
Expand Down

0 comments on commit 5d94610

Please sign in to comment.