def onRefresh(self, event): discMeta = None self.amazonStore = self.amazonASIN = self.coverjpg = None self._setInfoLabel(self.button_amazon, "") self._ripping = False (toc, numFound, info, releases) = searchMbForDisc(self._device) if numFound == 1: cdid = info[0] numTracks = info[1] discMeta = createDiscMetadata(releases[0], cdid, numTracks, toc) elif numFound > 1: list = getDiscNames(releases) pickDialog = wx.SingleChoiceDialog(self, "Pick one", "Multiple discs found", list) pickDialog.ShowModal() chosen = pickDialog.GetSelection() cdid = info[0] numTracks = info[1] discMeta = createDiscMetadata(releases[chosen], cdid, numTracks, toc) else: logging.info("CD Not Found") button = wx.MessageDialog( self, "Add CD to MusicBrainz?", "CD Not Found", wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION).ShowModal() if button == wx.ID_YES: url = info[0] if url: print "opening web browser to '%s'..." % url webbrowser.open_new(url) else: self._eject() if discMeta: discMeta.genre = getArtistTopTag(discMeta.artist, discMeta.mbArtistId) wx.CallAfter(self.updateDisplay, discMeta)
def onRefresh(self, event): discMeta = None self.amazonStore = self.amazonASIN = self.coverjpg = None self._setInfoLabel(self.button_amazon, "") self._ripping = False (toc, numFound, info, releases) = searchMbForDisc(self._device) if numFound == 1: cdid = info[0] numTracks = info[1] discMeta = createDiscMetadata(releases[0], cdid, numTracks, toc) elif numFound > 1: list = getDiscNames(releases) pickDialog = wx.SingleChoiceDialog(self, "Pick one", "Multiple discs found", list) pickDialog.ShowModal() chosen = pickDialog.GetSelection() cdid = info[0] numTracks = info[1] discMeta = createDiscMetadata(releases[chosen], cdid, numTracks, toc) else: logging.info("CD Not Found") button = wx.MessageDialog(self, "Add CD to MusicBrainz?", "CD Not Found", wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION).ShowModal() if button == wx.ID_YES: url = info[0] if url: print "opening web browser to '%s'..." % url webbrowser.open_new(url) else: self._eject() if discMeta: discMeta.genre = getArtistTopTag(discMeta.artist, discMeta.mbArtistId) wx.CallAfter(self.updateDisplay, discMeta)
f = open(discmetafile, "r") xml = f.read() #print xml discmeta = gnosis.xml.pickle.loads(xml) f.close() print "\n---------------------" print ("%s - %s" % (discmeta.artist, discmeta.title)).encode("ascii", "ignore") if hasattr(discmeta, "genre") and discmeta.genre: print u"Already have genre" else: genre = artistTags.get(discmeta.artist, None) if not genre: print "Fetching from Scrobbler..." genre = getArtistTopTag(discmeta.artist, discmeta.mbArtistId) if genre: artistTags[discmeta.artist] = genre else: print "Scrobbler gave me nuffink" if genre: print "got genre: %s" % genre discmeta.genre = genre os.renames(discmetafile, discmetafile+".bak") print "saving %s" % discmetafile f = open(discmetafile, "w") xml = gnosis.xml.pickle.dumps(discmeta) f.write(xml)
xml = f.read() #print xml discmeta = gnosis.xml.pickle.loads(xml) f.close() print "\n---------------------" print("%s - %s" % (discmeta.artist, discmeta.title)).encode( "ascii", "ignore") if hasattr(discmeta, "genre") and discmeta.genre: print u"Already have genre" else: genre = artistTags.get(discmeta.artist, None) if not genre: print "Fetching from Scrobbler..." genre = getArtistTopTag(discmeta.artist, discmeta.mbArtistId) if genre: artistTags[discmeta.artist] = genre else: print "Scrobbler gave me nuffink" if genre: print "got genre: %s" % genre discmeta.genre = genre os.renames(discmetafile, discmetafile + ".bak") print "saving %s" % discmetafile f = open(discmetafile, "w") xml = gnosis.xml.pickle.dumps(discmeta) f.write(xml)