def getMusicBrainz(self, ittoc, mbdiscid, release=None, country=None, prompt=False): """ @type ittoc: L{morituri.image.table.Table} """ # look up disc on musicbrainz self._stdout.write( 'Disc duration: %s, %d audio tracks\n' % (common.formatTime( ittoc.duration() / 1000.0), ittoc.getAudioTracks())) self.debug('MusicBrainz submit url: %r', ittoc.getMusicBrainzSubmitURL()) ret = None metadatas = None e = None for _ in range(0, 4): try: metadatas = mbngs.musicbrainz(mbdiscid, country=country, record=self._record) except mbngs.NotFoundException, e: break except musicbrainz.NetworkError, e: self._stdout.write("Warning: network error: %r\n" % (e, )) break
def getMusicBrainz(self, ittoc, mbdiscid, release=None, country=None, prompt=False): """ @type ittoc: L{morituri.image.table.Table} """ # look up disc on musicbrainz self._stdout.write('Disc duration: %s, %d audio tracks\n' % ( common.formatTime(ittoc.duration() / 1000.0), ittoc.getAudioTracks())) logger.debug('MusicBrainz submit url: %r', ittoc.getMusicBrainzSubmitURL()) ret = None metadatas = None e = None for _ in range(0, 4): try: metadatas = mbngs.musicbrainz(mbdiscid, country=country, record=self._record) except mbngs.NotFoundException, e: break except musicbrainzngs.NetworkError, e: self._stdout.write("Warning: network error: %r\n" % (e, )) break
def getMusicBrainz(self, ittoc, mbdiscid, release=None): """ @type ittoc: L{morituri.image.table.Table} """ # look up disc on musicbrainz self._stdout.write('Disc duration: %s, %d audio tracks\n' % ( common.formatTime(ittoc.duration() / 1000.0), ittoc.getAudioTracks())) self.debug('MusicBrainz submit url: %r', ittoc.getMusicBrainzSubmitURL()) ret = None metadatas = None e = None for _ in range(0, 4): try: metadatas = mbngs.musicbrainz(mbdiscid, record=self._record) except mbngs.NotFoundException, e: break except mbngs.MusicBrainzException, e: self._stdout.write("Warning: %r\n" % (e, )) time.sleep(5) continue
def getMusicBrainz(self, ittoc, mbdiscid, release=None): # look up disc on musicbrainz self._stdout.write('Disc duration: %s\n' % common.formatTime( ittoc.duration() / 1000.0)) self.debug('MusicBrainz submit url: %r', ittoc.getMusicBrainzSubmitURL()) ret = None metadatas = None e = None for _ in range(0, 4): try: metadatas = musicbrainzngs.musicbrainz(mbdiscid, record=self._record) except musicbrainzngs.NotFoundException, e: break except musicbrainzngs.MusicBrainzException, e: self._stdout.write("Warning: %r\n" % (e, )) time.sleep(5) continue
def getMusicBrainz(self, ittoc, mbdiscid, release=None): # look up disc on musicbrainz print 'Disc duration: %s' % common.formatTime( ittoc.duration() / 1000.0) self.debug('MusicBrainz submit url: %r', ittoc.getMusicBrainzSubmitURL()) ret = None metadatas = None e = None for _ in range(0, 4): try: metadatas = musicbrainzngs.musicbrainz(mbdiscid, record=self._record) except musicbrainzngs.NotFoundException, e: break except musicbrainzngs.MusicBrainzException, e: print "Warning:", e time.sleep(5) continue
def testFormatTime(self): self.assertEquals(common.formatTime(7202), '02:00:02.000')
self._stdout.write("Error: %r\n" % (e, )) self._stdout.write('Continuing without metadata\n') if metadatas: deltas = {} self._stdout.write('\nMatching releases:\n') for metadata in metadatas: self._stdout.write('\n') self._stdout.write('Artist : %s\n' % metadata.artist.encode('utf-8')) self._stdout.write('Title : %s\n' % metadata.title.encode('utf-8')) self._stdout.write('Duration: %s\n' % common.formatTime(metadata.duration / 1000.0)) self._stdout.write('URL : %s\n' % metadata.url) self._stdout.write('Release : %s\n' % metadata.mbid) self._stdout.write('Type : %s\n' % metadata.releaseType) delta = abs(metadata.duration - ittoc.duration()) if not delta in deltas: deltas[delta] = [] deltas[delta].append(metadata) if release: metadatas = [m for m in metadatas if m.url.endswith(release)] self.debug('Asked for release %r, only kept %r', release, metadatas) if len(metadatas) == 1: self._stdout.write('\n')
self._stdout.write('Continuing without metadata\n') if metadatas: deltas = {} self._stdout.write('\nMatching releases:\n') for metadata in metadatas: self._stdout.write('\n') self._stdout.write('Artist : %s\n' % metadata.artist.encode('utf-8')) self._stdout.write('Title : %s\n' % metadata.title.encode('utf-8')) self._stdout.write( 'Duration: %s\n' % common.formatTime(metadata.duration / 1000.0)) self._stdout.write('URL : %s\n' % metadata.url) self._stdout.write('Release : %s\n' % metadata.mbid) self._stdout.write('Type : %s\n' % metadata.releaseType) if metadata.barcode: self._stdout.write("Barcode : %s\n" % metadata.barcode) if metadata.catalogNumber: self._stdout.write("Cat no : %s\n" % metadata.catalogNumber) delta = abs(metadata.duration - ittoc.duration()) if not delta in deltas: deltas[delta] = [] deltas[delta].append(metadata) lowest = None
if not metadatas: if e: self._stdout.write("Error: %r\n" % (e,)) self._stdout.write("Continuing without metadata\n") if metadatas: deltas = {} self._stdout.write("\nMatching releases:\n") for metadata in metadatas: self._stdout.write("\n") self._stdout.write("Artist : %s\n" % metadata.artist.encode("utf-8")) self._stdout.write("Title : %s\n" % metadata.title.encode("utf-8")) self._stdout.write("Duration: %s\n" % common.formatTime(metadata.duration / 1000.0)) self._stdout.write("URL : %s\n" % metadata.url) self._stdout.write("Release : %s\n" % metadata.mbid) self._stdout.write("Type : %s\n" % metadata.releaseType) if metadata.barcode: self._stdout.write("Barcode : %s\n" % metadata.barcode) if metadata.catalogNumber: self._stdout.write("Cat no : %s\n" % metadata.catalogNumber) delta = abs(metadata.duration - ittoc.duration()) if not delta in deltas: deltas[delta] = [] deltas[delta].append(metadata) lowest = None
continue if not metadatas: if e: print "Error:", e print 'Continuing without metadata' if metadatas: print print 'Matching releases:' deltas = {} for metadata in metadatas: print 'Artist : %s' % metadata.artist.encode('utf-8') print 'Title : %s' % metadata.title.encode('utf-8') print 'Duration: %s' % common.formatTime( metadata.duration / 1000.0) print 'URL : %s' % metadata.url delta = abs(metadata.duration - ittoc.duration()) if not delta in deltas: deltas[delta] = [] deltas[delta].append(metadata) if release: metadatas = [m for m in metadatas if m.url.endswith(release)] self.debug('Asked for release %r, only kept %r', release, metadatas) if len(metadatas) == 1: print print 'Picked requested release id %s' % release print 'Artist : %s' % metadatas[0].artist.encode('utf-8')