Esempio n. 1
0
def get_artist_tracks(username, artist, title):
    if TRACK_SEPARATOR in artist:
        (artist, title) = split_artist_track(artist)

    print("Searching Last.fm library...\r")
    try:
        tracks = lastfm_network.get_user(username).get_artist_tracks(
            artist=artist)
    except Exception as e:
        sys.exit("Exception: " + str(e))

    total = 0

    print("\t\t\t\t\r"),  # clear line
    if title is None:  # print all
        for track in tracks:
            print_track(track)
        total = len(tracks)

    else:  # print matching titles
        find_track = pylast.Track(artist, title, lastfm_network)
        for track in tracks:
            if str(track.track).lower() == str(find_track).lower():
                print_track(track)
                total += 1

    print("Total:", total)
    return total
Esempio n. 2
0
def get_artist_tracks(username, artist, title):
    if TRACK_SEPARATOR in artist:
        (artist, title) = split_artist_track(artist)

    print("Searching Last.fm library...\r",)
    try:
        tracks = lastfm_network.get_user(
            username).get_artist_tracks(artist=artist)
    except Exception as e:
        sys.exit("Exception: " + str(e))

    total = 0

    print("\t\t\t\t\r"),  # clear line
    if title is None:  # print all
        for track in tracks:
            print_track(track)
        total = len(tracks)

    else:  # print matching titles
        find_track = pylast.Track(artist, title, lastfm_network)
        for track in tracks:
            if str(track.track).lower() == str(find_track).lower():
                print_track(track)
                total += 1

    print("Total:", total)
    return total
Esempio n. 3
0
def scrobble_track(artist_track, unix_timestamp):

    (artist, track) = split_artist_track(artist_track)

    # Validate
    if unix_timestamp == 0:
        # Get UNIX timestamp
        unix_timestamp = int(time.mktime(datetime.datetime.now().timetuple()))
    print("Timestamp:\t" + str(unix_timestamp))

    # Scrobble it
    if not testMode:
        lastfm_network.scrobble(artist=artist, title=track, timestamp=unix_timestamp)
Esempio n. 4
0
def scrobble_track(artist_track, unix_timestamp):

    (artist, track) = split_artist_track(artist_track)

    # Validate
    if unix_timestamp == 0:
        # Get UNIX timestamp
        unix_timestamp = int(time.mktime(datetime.datetime.now().timetuple()))
    print("Timestamp:\t" + str(unix_timestamp))

    # Scrobble it
    if not testMode:
        lastfm_network.scrobble(artist=artist,
                                title=track,
                                timestamp=unix_timestamp)