Example #1
0
def get_recent_tracks(username, number):
    recent_tracks = lastfm_network.get_user(
        username).get_recent_tracks(limit=number)
    for i, track in enumerate(recent_tracks):
        printable = unicode_track_and_timestamp(track)
        print_it(str(i+1) + " " + printable)
    return recent_tracks
Example #2
0
def pick_word(artist_name):
    """Suggest a pronoun for this artist"""
    artist = lastfm_network.get_artist(artist_name)

    members = artist.get_band_members()
    print(members)

    bio = artist.get_bio_summary()
    print_it(bio)

    if members is None:
        members = 0
        print(0, None)
    else:
        print(len(members), ", ".join(members))

    plural, female, male = 0, 0, 0
    band_words = ["the band", "the group", "their", "they"]
    female_words = ["she", "her"]
    male_words = ["he", "his"]

    plural = count_em(band_words, bio)
    female = count_em(female_words, bio)
    male = count_em(male_words, bio)
    print(plural, female, male)

    if members >= 2 and plural > 0 and female == 0 and male == 0:
        choice = "they"
        certainty = "very good"
    elif members == 1 and plural == 0 and female > 0 and male == 0:
        choice = "her"
        certainty = "very good"
    elif members == 1 and plural == 0 and female == 0 and male > 0:
        choice = "he"
        certainty = "very good"
    elif plural > 1 and female == 0 and male == 0:
        choice = "they"
        certainty = "good"
    elif plural == 0 and female > 0 and male == 0:
        choice = "she"
        certainty = "good"
    elif plural == 0 and female == 0 and male > 0:
        choice = "he"
        certainty = "good"
    elif members >= 2:
        choice = "they"
        certainty = "quite good"
    else:
        choice = "they"
        certainty = "default"

    print("Use " + choice.upper() + " (" + certainty + ")")
    return choice, certainty
Example #3
0
def unscrobble(library, scrobble):
    artist = str(scrobble.track.artist)
    title = scrobble.track.title
    timestamp = scrobble.timestamp

    try:
        my_library.remove_scrobble(
            artist=artist, title=title, timestamp=timestamp)
    except AttributeError as e:
        print("Exception: " + str(e))
        sys.exit(
            "Error: pylast 0.5.11 does not support removing scrobbles. "
            "Please install latest pylast: pip install -U pylast")
    except Exception as e:
        sys.exit("Exception: " + str(e))
    print_it("Scrobble removed: " + unicode_track_and_timestamp(scrobble))
Example #4
0
def unscrobble(library, scrobble):
    artist = str(scrobble.track.artist)
    title = scrobble.track.title
    timestamp = scrobble.timestamp

    try:
        my_library.remove_scrobble(artist=artist,
                                   title=title,
                                   timestamp=timestamp)
    except AttributeError as e:
        print("Exception: " + str(e))
        sys.exit("Error: pylast 0.5.11 does not support removing scrobbles. "
                 "Please install latest pylast: pip install -U pylast")
    except Exception as e:
        sys.exit("Exception: " + str(e))
    print_it("Scrobble removed: " + unicode_track_and_timestamp(scrobble))