예제 #1
0
def item_candidates(item, artist, title):
    """Search for item matches. ``item`` is the Item to be matched.
    ``artist`` and ``title`` are strings and either reflect the item or
    are specified by the user.
    """
    # Plugin candidates.
    for candidate in plugins.item_candidates(item, artist, title):
        yield candidate
예제 #2
0
def item_candidates(item, artist, title):
    """Search for item matches. ``item`` is the Item to be matched.
    ``artist`` and ``title`` are strings and either reflect the item or
    are specified by the user.
    """

    # MusicBrainz candidates.
    if config["musicbrainz"]["enabled"] and artist and title:
        yield from invoke_mb(mb.match_track, artist, title)

    # Plugin candidates.
    yield from plugins.item_candidates(item, artist, title)
예제 #3
0
파일: __init__.py 프로젝트: navinpai/beets
def tag_item(item, timid=False, search_artist=None, search_title=None,
             search_id=None):
    """Attempts to find metadata for a single track. Returns a
    `(candidates, recommendation)` pair where `candidates` is a list
    of `(distance, track_info)` pairs. `search_artist` and 
    `search_title` may be used to override the current metadata for
    the purposes of the MusicBrainz title; likewise `search_id`.
    """
    candidates = []

    # First, try matching by MusicBrainz ID.
    trackid = search_id or item.mb_trackid
    if trackid:
        log.debug('Searching for track ID: ' + trackid)
        track_info = mb.track_for_id(trackid)
        if track_info:
            dist = track_distance(item, track_info, incl_artist=True)
            candidates.append((dist, track_info))
            # If this is a good match, then don't keep searching.
            rec = recommendation(candidates)
            if rec == RECOMMEND_STRONG and not timid:
                log.debug('Track ID match.')
                return candidates, rec

    # If we're searching by ID, don't proceed.
    if search_id is not None:
        if candidates:
            return candidates, rec
        else:
            return [], RECOMMEND_NONE
    
    # Search terms.
    if not (search_artist and search_title):
        search_artist, search_title = item.artist, item.title
    log.debug(u'Item search terms: %s - %s' % (search_artist, search_title))

    # Candidate metadata from search.
    for track_info in mb.match_track(search_artist, search_title):
        dist = track_distance(item, track_info, incl_artist=True)
        candidates.append((dist, track_info))

    # Add candidates from plugins.
    for track_info in plugins.item_candidates(item):
        dist = track_distance(item, track_info, incl_artist=True)
        candidates.append((dist, track_info))

    # Sort by distance and return with recommendation.
    log.debug('Found %i candidates.' % len(candidates))
    candidates.sort()
    rec = recommendation(candidates)
    return candidates, rec
예제 #4
0
파일: hooks.py 프로젝트: MechanisM/beets
def _item_candidates(item, artist, title):
    """Search for item matches. ``item`` is the Item to be matched.
    ``artist`` and ``title`` are strings and either reflect the item or
    are specified by the user.
    """
    out = []

    # MusicBrainz candidates.
    if artist and title:
        out.extend(mb.match_track(artist, title))

    # Plugin candidates.
    out.extend(plugins.item_candidates(item))

    return out
예제 #5
0
def _item_candidates(item, artist, title):
    """Search for item matches. ``item`` is the Item to be matched.
    ``artist`` and ``title`` are strings and either reflect the item or
    are specified by the user.
    """
    out = []

    # MusicBrainz candidates.
    if artist and title:
        out.extend(mb.match_track(artist, title))

    # Plugin candidates.
    out.extend(plugins.item_candidates(item))

    return out
예제 #6
0
파일: hooks.py 프로젝트: adamjakab/Beets
def item_candidates(item, artist, title):
    """Search for item matches. ``item`` is the Item to be matched.
    ``artist`` and ``title`` are strings and either reflect the item or
    are specified by the user.
    """

    # MusicBrainz candidates.
    if artist and title:
        try:
            yield from mb.match_track(artist, title)
        except mb.MusicBrainzAPIError as exc:
            exc.log(log)

    # Plugin candidates.
    yield from plugins.item_candidates(item, artist, title)
예제 #7
0
파일: hooks.py 프로젝트: SerhatG/nzbToMedia
def item_candidates(item, artist, title):
    """Search for item matches. ``item`` is the Item to be matched.
    ``artist`` and ``title`` are strings and either reflect the item or
    are specified by the user.
    """

    # MusicBrainz candidates.
    if artist and title:
        try:
            for candidate in mb.match_track(artist, title):
                yield candidate
        except mb.MusicBrainzAPIError as exc:
            exc.log(log)

    # Plugin candidates.
    for candidate in plugins.item_candidates(item, artist, title):
        yield candidate
예제 #8
0
파일: __init__.py 프로젝트: mdecker/beets
def tag_item(item, search_artist=None, search_title=None):
    """Attempts to find metadata for a single track. Returns a
    `(candidates, recommendation)` pair where `candidates` is a list
    of `(distance, track_info)` pairs. `search_artist` and 
    `search_title` may be used to override the current metadata for
    the purposes of the MusicBrainz category.
    """
    candidates = []

    # First, try matching by MusicBrainz ID.
    trackid = item.mb_trackid
    if trackid:
        track_info = mb.track_by_id(item.mb_trackid)
        if track_info:
            dist = track_distance(item, track_info, incl_artist=True)
            candidates.append((dist, track_info))
            # If this is a good match, then don't keep searching.
            rec = recommendation(candidates)
            if rec == RECOMMEND_STRONG:
                log.debug('Track ID match.')
                return candidates, rec

    # Search terms.
    if not (search_artist and search_title):
        search_artist, search_title = item.artist, item.title
    log.debug(u'Item search terms: %s - %s' % (search_artist, search_title))

    # Candidate metadata from search.
    for track_info in mb.match_track(search_artist, search_title):
        dist = track_distance(item, track_info, incl_artist=True)
        candidates.append((dist, track_info))

    # Add candidates from plugins.
    for track_info in plugins.item_candidates(item):
        dist = track_distance(item, track_info, incl_artist=True)
        candidates.append((dist, track_info))

    # Sort by distance and return with recommendation.
    log.debug('Found %i candidates.' % len(candidates))
    candidates.sort()
    rec = recommendation(candidates)
    return candidates, rec
예제 #9
0
def item_candidates(item, artist, title):
    """Search for item matches. ``item`` is the Item to be matched.
    ``artist`` and ``title`` are strings and either reflect the item or
    are specified by the user.
    """
    out = []

    # MusicBrainz candidates.
    if artist and title:
        try:
            out.extend(mb.match_track(artist, title))
        except mb.MusicBrainzAPIError as exc:
            exc.log(log)

    # Plugin candidates.
    out.extend(plugins.item_candidates(item, artist, title))

    # Notify subscribed plugins about fetched track info
    for i in out:
        plugins.send('trackinfo_received', info=i)

    return out
예제 #10
0
def item_candidates(item, artist, title):
    """Search for item matches. ``item`` is the Item to be matched.
    ``artist`` and ``title`` are strings and either reflect the item or
    are specified by the user.
    """

    # MusicBrainz candidates.
    if artist and title:
        try:
            for candidate in mb.match_track(artist, title):
                yield TrackAlbumTuple(candidate, None)
        except mb.MusicBrainzAPIError as exc:
            exc.log(log)

    # Plugin candidates.
    for candidate in plugins.item_candidates(item, artist, title):
        # allow (track_info, album_info) tuples
        plugins.send(u'trackinfo_received', info=candidate)
        if isinstance(candidate, TrackAlbumTuple):
            yield candidate
        else:

            yield TrackAlbumTuple(candidate, None)