示例#1
0
def find_new_tracks(args, label='music', weight=1.5):
    """Finds new tracks by known artists, downloads and adds them."""
    tracks = get_new_tracks(args, label=label, weight=weight)

    if is_verbose():
        print 'New tracks: %u.' % len(tracks)

    added = 0
    artist_names = []
    for track in tracks:
        if is_verbose():
            print "Track:", track
        logging.info((u'[%u/%u] fetching "%s" by %s' % (added + 1, len(tracks), track['title'], track['artist'])).encode("utf-8"))
        try:
            if track['artist'] not in artist_names:
                artist_names.append(track['artist'])
            filename = ardj.util.fetch(str(track['url']), suffix=track.get('suffix'))
            if not is_dry_run():
                add_file(str(filename), add_labels=track.get('tags', ['tagme', 'music']),
                    artist=track["artist"], title=track["title"], dlink=track['url'])
            added += 1
        except KeyboardInterrupt:
            raise
        except Exception, e:
            logging.error((u"Could not download \"%s\" by %s: %s" % (track['title'], track['artist'], e)).encode("utf-8"))
示例#2
0
def get_new_tracks(artist_names=None, label='music', weight=1.5):
    if not artist_names:
        artist_names = ardj.database.Open().get_artist_names(label, weight)

    tracklist = ardj.jamendo.find_new_tracks(artist_names)
    tracklist += ardj.podcast.find_new_tracks(artist_names)

    cli = ardj.scrobbler.LastFM().authorize()
    if cli is not None:
        for artist_name in artist_names:
            tracklist += cli.get_tracks_by_artist(artist_name)

    if is_verbose():
        print 'Total tracks: %u.' % len(tracklist)

    return get_missing_tracks(tracklist, limit=ardj.settings.get('fresh_music/tracks_per_artist', 2))