Exemplo n.º 1
0
def choose_match(task, config):
    """Given an initial autotagging of items, go through an interactive
    dance with the user to ask for a choice of metadata. Returns an
    (info, items) pair, ASIS, or SKIP.
    """
    # Show what we're tagging.
    print_()
    print_(task.path)

    if config.quiet:
        # No input; just make a decision.
        if task.rec == autotag.RECOMMEND_STRONG:
            dist, items, info = task.candidates[0]
            show_change(task.cur_artist, task.cur_album, items, info, dist,
                        config.color)
            return info, items
        else:
            return _quiet_fall_back(config)

    # Loop until we have a choice.
    candidates, rec = task.candidates, task.rec
    while True:
        # Ask for a choice from the user.
        choice = choose_candidate(candidates, False, rec, config.color, 
                                  config.timid, task.cur_artist,
                                  task.cur_album)
    
        # Choose which tags to use.
        if choice in (importer.action.SKIP, importer.action.ASIS,
                      importer.action.TRACKS):
            # Pass selection to main control flow.
            return choice
        elif choice is importer.action.MANUAL:
            # Try again with manual search terms.
            search_artist, search_album = manual_search(False)
            try:
                _, _, candidates, rec = \
                    autotag.tag_album(task.items, config.timid, search_artist,
                                      search_album)
            except autotag.AutotagError:
                candidates, rec = None, None
        elif choice is importer.action.MANUAL_ID:
            # Try a manually-entered ID.
            search_id = manual_id(False)
            if search_id:
                try:
                    _, _, candidates, rec = \
                        autotag.tag_album(task.items, config.timid,
                                        search_id=search_id)
                except autotag.AutotagError:
                    candidates, rec = None, None
        else:
            # We have a candidate! Finish tagging. Here, choice is
            # an (info, items) pair as desired.
            assert not isinstance(choice, importer.action)
            return choice
Exemplo n.º 2
0
def initial_lookup(config):
    """A coroutine for performing the initial MusicBrainz lookup for an
    album. It accepts lists of Items and yields
    (items, cur_artist, cur_album, candidates, rec) tuples. If no match
    is found, all of the yielded parameters (except items) are None.
    """
    task = None
    while True:
        task = yield task
        if task.sentinel:
            continue

        log.debug('Looking up: %s' % task.path)
        try:
            task.set_match(*autotag.tag_album(task.items, config.timid))
        except autotag.AutotagError:
            task.set_null_match()
Exemplo n.º 3
0
def initial_lookup(config):
    """A coroutine for performing the initial MusicBrainz lookup for an
    album. It accepts lists of Items and yields
    (items, cur_artist, cur_album, candidates, rec) tuples. If no match
    is found, all of the yielded parameters (except items) are None.
    """
    task = None
    while True:
        task = yield task
        if task.sentinel:
            continue

        log.debug('Looking up: %s' % task.path)
        try:
            task.set_match(*autotag.tag_album(task.items, config.timid))
        except autotag.AutotagError:
            task.set_null_match()
Exemplo n.º 4
0
def correctMetadata(albumid, release, downloaded_track_list):
	
	logger.info('Writing metadata')
	items = []
	for downloaded_track in downloaded_track_list:
		items.append(beets.library.Item.from_path(downloaded_track))
	
	cur_artist, cur_album, out_tuples, rec = autotag.tag_album(items, search_artist=release['ArtistName'], search_album=release['AlbumTitle'])
	
	if rec == 'RECOMMEND_NONE':
		logger.warn('No accurate album match found for %s, %s -  not writing metadata' % (release['ArtistName'], release['AlbumTitle']))
		return
	
	distance, items, info = out_tuples[0]
	logger.debug('Beets recommendation: %s' % rec)
	autotag.apply_metadata(items, info)
	
	for item in items:
		item.write()
Exemplo n.º 5
0
def correctMetadata(albumid, release, downloaded_track_list):

    logger.info("Writing metadata")
    items = []
    for downloaded_track in downloaded_track_list:
        items.append(beets.library.Item.from_path(downloaded_track))

    cur_artist, cur_album, out_tuples, rec = autotag.tag_album(
        items, search_artist=release["ArtistName"], search_album=release["AlbumTitle"]
    )

    if rec == "RECOMMEND_NONE":
        logger.warn("No accurate match found  -  not writing metadata")
        return

    distance, items, info = out_tuples[0]
    logger.debug("Beets recommendation: %s" % rec)
    autotag.apply_metadata(items, info)

    for item in items:
        item.write()
Exemplo n.º 6
0
	
	return destination_path
		
def correctMetadata(albumid, release, downloaded_track_list):
	
	logger.info('Writing metadata')
	items = []
	for downloaded_track in downloaded_track_list:

		try:
			items.append(beets.library.Item.from_path(downloaded_track))
		except Exception, e:
			logger.error("Beets couldn't create an Item from: " + downloaded_track + " - not a media file?" + str(e))
	
	try:
		cur_artist, cur_album, out_tuples, rec = autotag.tag_album(items, search_artist=helpers.latinToAscii(release['ArtistName']), search_album=helpers.latinToAscii(release['AlbumTitle']))
	except Exception, e:
		logger.error('Error getting recommendation: %s. Not writing metadata' % e)
		return
	if rec == 'RECOMMEND_NONE':
		logger.warn('No accurate album match found for %s, %s -  not writing metadata' % (release['ArtistName'], release['AlbumTitle']))
		return
	
	distance, items, info = out_tuples[0]
	logger.debug('Beets recommendation: %s' % rec)
	autotag.apply_metadata(items, info)
	
	if len(items) != len(downloaded_track_list):
		logger.warn("Mismatch between number of tracks downloaded and the metadata items, but I'll try to write it anyway")
	
	i = 1
Exemplo n.º 7
0
                    " because it is not a mutagen friendly file format")
        except Exception, e:

            logger.error(
                "Beets couldn't create an Item from: " +
                downloaded_track.decode(headphones.SYS_ENCODING, 'replace') +
                " - not a media file?" + str(e))

    for items in [lossy_items, lossless_items]:

        if not items:
            continue

        try:
            cur_artist, cur_album, candidates, rec = autotag.tag_album(
                items,
                search_artist=helpers.latinToAscii(release['ArtistName']),
                search_album=helpers.latinToAscii(release['AlbumTitle']))
        except Exception, e:
            logger.error(
                'Error getting recommendation: %s. Not writing metadata' % e)
            return
        if rec == 'RECOMMEND_NONE':
            logger.warn(
                'No accurate album match found for %s, %s -  not writing metadata'
                % (release['ArtistName'], release['AlbumTitle']))
            return

        if candidates:
            dist, info, mapping, extra_items, extra_tracks = candidates[0]
        else:
            logger.warn(
Exemplo n.º 8
0
	except Exception, e:
		logger.error('Could not remove directory: %s. %s' % (albumpath, e))
	
	return destination_path
		
def correctMetadata(albumid, release, downloaded_track_list):
	
	logger.info('Writing metadata')
	items = []
	for downloaded_track in downloaded_track_list:
		try:
			items.append(beets.library.Item.from_path(downloaded_track))
		except Exception, e:
			logger.error("Beets couldn't create an Item from: " + downloaded_track + " - not a media file?" + str(e))
	
	cur_artist, cur_album, out_tuples, rec = autotag.tag_album(items, search_artist=release['ArtistName'], search_album=release['AlbumTitle'])
	
	if rec == 'RECOMMEND_NONE':
		logger.warn('No accurate album match found for %s, %s -  not writing metadata' % (release['ArtistName'], release['AlbumTitle']))
		return
	
	distance, items, info = out_tuples[0]
	logger.debug('Beets recommendation: %s' % rec)
	autotag.apply_metadata(items, info)
	
	for item in items:
		item.write()

def renameFiles(albumpath, downloaded_track_list, release):
	logger.info('Renaming files')
	try:
Exemplo n.º 9
0
            logger.error(
                "Beets couldn't create an Item from: "
                + downloaded_track.decode(headphones.SYS_ENCODING, "replace")
                + " - not a media file?"
                + str(e)
            )

    for items in [lossy_items, lossless_items]:

        if not items:
            continue

        try:
            cur_artist, cur_album, candidates, rec = autotag.tag_album(
                items,
                search_artist=helpers.latinToAscii(release["ArtistName"]),
                search_album=helpers.latinToAscii(release["AlbumTitle"]),
            )
        except Exception, e:
            logger.error("Error getting recommendation: %s. Not writing metadata" % e)
            return
        if rec == "RECOMMEND_NONE":
            logger.warn(
                "No accurate album match found for %s, %s -  not writing metadata"
                % (release["ArtistName"], release["AlbumTitle"])
            )
            return

        if candidates:
            dist, info, mapping, extra_items, extra_tracks = candidates[0]
        else: