def add_new_track(release, possible_releases, fileid, track, trackinfo, impossible_releases): releaseid = release.id found_tracknumber = lookups.track_number(release.tracks, track) if releaseid in possible_releases: assert found_tracknumber not in possible_releases[releaseid] assert fileid not in possible_releases[releaseid].values(), ( fileid, possible_releases[releaseid]) possible_releases[releaseid][found_tracknumber] = fileid print "Found track", found_tracknumber, "(", release.tracks[ found_tracknumber - 1].title, ")", "of", release.title, ":", os.path.basename( fileid), "(tracks found: %s)\x1b[K" % (util.output_list( possible_releases[releaseid].keys())) return else: possible_releases[releaseid] = {found_tracknumber: fileid} util.update_progress( "Considering new %s - %s (found track %d)" % (release.artist.name, release.title, found_tracknumber)) # Right, lets see if we can find some other tracks quick smart for trackind in range(len(release.tracks)): # Don't waste time on things we've already found if (trackind + 1) in possible_releases[releaseid]: continue track = lookups.get_track_by_id(release.tracks[trackind].id) for fileid in trackinfo: if fileid in possible_releases[releaseid].values(): continue if trackinfo[fileid].getPUID() in track.puids: # yay, found one. if verify_track(release, possible_releases, impossible_releases, trackinfo, fileid, track): possible_releases[releaseid][trackind + 1] = fileid util.update_progress( " Also found track %02d: %s" % (trackind + 1, release.tracks[trackind].title)) break print " Found tracks: %s" % (util.output_list( possible_releases[releaseid].keys())), if util.list_difference(range(1, len(release.tracks) + 1), possible_releases[releaseid].keys()): print " Missing tracks: %s" % (util.output_list( util.list_difference(range(1, len(release.tracks) + 1), possible_releases[releaseid].keys()))) else: print
def giving_up(removed_releases,fileid): if not removed_releases: util.report("No possible releases left") return util.report("Possible releases:") for releaseid in removed_releases: # If this release only has one track that we found, # and we have other possible releases, ignore this one. # # TODO: Actually, we should just display the top 2 # releases, by number of tracks found on it. if len(removed_releases[releaseid])<2 \ and len(removed_releases)>1: continue release = lookups.get_release_by_releaseid(releaseid) util.report("%s - %s (%s.html)" % ( release.artist.name, release.title, releaseid)) for trackind in range(len(release.tracks)): if (trackind+1) in removed_releases[releaseid]: continue util.report(" #%02d %s.html %s" % ( trackind+1, release.tracks[trackind].id, release.tracks[trackind].title)) util.report(" %s" % ( util.output_list(removed_releases[releaseid].keys()) ))
def end_of_track(possible_releases, impossible_releases, track_generator, trackinfo, fileid): # If there are no more tracks for this # skip it and try more. del track_generator[fileid] util.report("All possibilities for file %s exhausted" % fileid) util.report("filename: %s" % trackinfo[fileid].getFilename()) util.report("Metadata Title: %s" % (trackinfo[fileid].getMDTrackTitle())) util.report("puid: %s" % trackinfo[fileid].getPUID()) removed_releases = {} util.report("Current possible releases:") for i in possible_releases.keys(): # Ignore any release that doesn't have this # track, since we can no longer find it. if fileid not in possible_releases[i].values(): removed_releases[i] = possible_releases[i] del possible_releases[i] impossible_releases.append(i) if possible_releases == {}: giving_up(removed_releases, fileid) return for i in possible_releases: util.report(" %s (tracks found: %s)" % (lookups.get_release_by_releaseid(i).title, util.output_list(possible_releases[i].keys())))
def giving_up(removed_releases, fileid): if not removed_releases: util.report("No possible releases left") return util.report("Possible releases:") for releaseid in removed_releases: # If this release only has one track that we found, # and we have other possible releases, ignore this one. # # TODO: Actually, we should just display the top 2 # releases, by number of tracks found on it. if len(removed_releases[releaseid])<2 \ and len(removed_releases)>1: continue release = lookups.get_release_by_releaseid(releaseid) util.report("%s - %s (%s.html)" % (release.artist.name, release.title, releaseid)) for trackind in range(len(release.tracks)): if (trackind + 1) in removed_releases[releaseid]: continue util.report(" #%02d %s.html %s" % (trackind + 1, release.tracks[trackind].id, release.tracks[trackind].title)) util.report(" %s" % (util.output_list(removed_releases[releaseid].keys())))
def add_new_track(release, possible_releases, fileid, track, trackinfo, impossible_releases): releaseid = release.id found_tracknumber=lookups.track_number(release.tracks, track) if releaseid in possible_releases: assert found_tracknumber not in possible_releases[releaseid] assert fileid not in possible_releases[releaseid].values(),(fileid,possible_releases[releaseid]) possible_releases[releaseid][found_tracknumber]=fileid print "Found track",found_tracknumber,"(",release.tracks[found_tracknumber-1].title,")","of",release.title,":",os.path.basename(fileid),"(tracks found: %s)\x1b[K" % (util.output_list(possible_releases[releaseid].keys())) return else: possible_releases[releaseid]={found_tracknumber:fileid} util.update_progress("Considering new %s - %s (found track %d)" % ( release.artist.name, release.title, found_tracknumber)) # Right, lets see if we can find some other tracks quick smart for trackind in range(len(release.tracks)): # Don't waste time on things we've already found if (trackind+1) in possible_releases[releaseid]: continue track = lookups.get_track_by_id(release.tracks[trackind].id) for fileid in trackinfo: if fileid in possible_releases[releaseid].values(): continue if trackinfo[fileid].getPUID() in track.puids: # yay, found one. if verify_track(release, possible_releases, impossible_releases, trackinfo, fileid, track): possible_releases[releaseid][trackind+1]=fileid util.update_progress(" Also found track %02d: %s" % (trackind+1,release.tracks[trackind].title)) break print " Found tracks: %s" % ( util.output_list(possible_releases[releaseid].keys())), if util.list_difference(range(1,len(release.tracks)+1), possible_releases[releaseid].keys()): print " Missing tracks: %s"% ( util.output_list( util.list_difference(range(1,len(release.tracks)+1), possible_releases[releaseid].keys()))) else: print
def end_of_track(possible_releases,impossible_releases,track_generator,trackinfo,fileid): # If there are no more tracks for this # skip it and try more. del track_generator[fileid] util.report("All possibilities for file %s exhausted" % fileid) util.report("filename: %s" % trackinfo[fileid].getFilename()) util.report("Metadata Title: %s" % (trackinfo[fileid].getMDTrackTitle())) util.report("puid: %s" % trackinfo[fileid].getPUID()) removed_releases={} util.report("Current possible releases:") for i in possible_releases.keys(): # Ignore any release that doesn't have this # track, since we can no longer find it. if fileid not in possible_releases[i].values(): removed_releases[i]=possible_releases[i] del possible_releases[i] impossible_releases.append(i) if possible_releases=={}: giving_up(removed_releases, fileid) return for i in possible_releases: util.report(" %s (tracks found: %s)" % (lookups.get_release_by_releaseid(i).title,util.output_list(possible_releases[i].keys())))
def end_of_track(possible_releases,impossible_releases,track_generator,trackinfo,fileid): # If there are no more tracks for this # skip it and try more. del track_generator[fileid] print "All possibilities for file",fileid,"exhausted\x1b[K" print "filename",trackinfo[fileid].getFilename() print "Metadata Title:",trackinfo[fileid].getMDTrackTitle() print "puid:",trackinfo[fileid].getPUID() removed_releases={} print "Current possible releases:" for i in possible_releases.keys(): # Ignore any release that doesn't have this # track, since we can no longer find it. if fileid not in possible_releases[i].values(): removed_releases[i]=possible_releases[i] del possible_releases[i] impossible_releases.append(i) if possible_releases=={}: giving_up(removed_releases, fileid) return for i in possible_releases: print "",lookups.get_release_by_releaseid(i).title,"(tracks found: %s)" % (util.output_list(possible_releases[i].keys()))