Ejemplo n.º 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
Ejemplo 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
Ejemplo n.º 3
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
Ejemplo n.º 4
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 = track_and_timestamp(track)
        print(str(i + 1) + " " + printable)
    return recent_tracks
Ejemplo n.º 5
0
import pylast

from mylast import lastfm_network, lastfm_username

# Loves whatever track is now playing on Last.fm,
# then prints confirmation of last loved track.
# Optional parameter: love "artist - title" instead.
# Prerequisites: mylast.py, pyLast

if len(sys.argv) > 1:
    (artist, title) = sys.argv[1].split("-")
    artist = artist.strip()
    title = title.strip()
    track = pylast.Track(artist, title, lastfm_network)
else:
    track = lastfm_network.get_user(lastfm_username).get_now_playing()

last_loved_track = str(
    lastfm_network.get_user(lastfm_username).get_loved_tracks(limit=1)[0][0])
print("Last:\t" + str(last_loved_track))

print("Loving:\t" + str(track))
if track is None:
    sys.exit("Didn't get the track now playing from Last.fm")

track.love()

# Confirm the track has been loved
if track.get_userloved():
    print("Loved it!")
else:
Ejemplo n.º 6
0
    parser = argparse.ArgumentParser(
        description="Show my now playing song, or that of a given username",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    )
    parser.add_argument(
        "username",
        nargs="?",
        default=lastfm_username,
        help="Show now playing of this username",
    )
    parser.add_argument("--loop", action="store_true", help="Loop until Ctrl-C")
    parser.add_argument("--say", action="store_true", help="Announcertron 4000")
    args = parser.parse_args()

    if not args.loop:
        now_playing = lastfm_network.get_user(args.username).get_now_playing()
        print(now_playing)
        if args.say:
            say(now_playing)
    else:
        last_played = None
        while True:
            now_playing = lastfm_network.get_user(args.username).get_now_playing()
            # print("last:", last_played)
            # print("now: ", now_playing)
            if now_playing != last_played:
                last_played = now_playing
                if now_playing:
                    print(now_playing)
                    if args.say:
                        say(now_playing)
Ejemplo n.º 7
0
#!/usr/bin/env python
from __future__ import print_function
import sys
from mylast import lastfm_network, lastfm_username

# Show my now playing song, or that of a given username
# Prerequisites: mylast.py, pyLast

if len(sys.argv) > 1:
    username = sys.argv[1]
else:
    username = lastfm_username

print(lastfm_network.get_user(username).get_now_playing())
Ejemplo n.º 8
0
    parser.add_argument(
        "username",
        nargs="?",
        default=lastfm_username,
        help="Show now playing of this username",
    )
    parser.add_argument("--loop",
                        action="store_true",
                        help="Loop until Ctrl-C")
    parser.add_argument("--say",
                        action="store_true",
                        help="Announcertron 4000")
    args = parser.parse_args()

    if not args.loop:
        now_playing = lastfm_network.get_user(args.username).get_now_playing()
        print(now_playing)
        if args.say:
            say(now_playing)
    else:
        last_played = None
        while True:
            now_playing = lastfm_network.get_user(
                args.username).get_now_playing()
            # print("last:", last_played)
            # print("now: ", now_playing)
            if now_playing != last_played:
                last_played = now_playing
                if now_playing:
                    print(now_playing)
                    if args.say:
Ejemplo n.º 9
0
#!/usr/bin/python
from __future__ import print_function
import sys
from mylast import lastfm_network, lastfm_username

# Prints a list of you last loved tracks on Last.fm.
# Optional parameter: number of tracks
# Prerequisites: mylast.py, pyLast


if len(sys.argv) > 1:
    number = int(sys.argv[1])
else:
    number = 20

last_loved_tracks = lastfm_network.get_user(
    lastfm_username).get_loved_tracks(limit=number)

for i, track in enumerate(last_loved_tracks):
    print(str(i+1) + ")\t" + str(track[0]))

# End of file
Ejemplo n.º 10
0
from mylast import lastfm_network, lastfm_username

# Loves whatever track is now playing on Last.fm,
# then prints confirmation of last loved track.
# Optional parameter: love "artist - title" instead.
# Prerequisites: mylast.py, pyLast


if len(sys.argv) > 1:
    (artist, title) = sys.argv[1].split("-")
    artist = artist.strip()
    title = title.strip()
    track = pylast.Track(artist, title, lastfm_network)
else:
    track = lastfm_network.get_user(lastfm_username).get_now_playing()

last_loved_track = str(
    lastfm_network.get_user(lastfm_username).get_loved_tracks(limit=1)[0][0]
)
print("Last:\t" + str(last_loved_track))

print("Loving:\t" + str(track))
if track is None:
    sys.exit("Didn't get the track now playing from Last.fm")

track.love()


# Confirm the track has been loved
if track.get_userloved():
Ejemplo n.º 11
0
#!/usr/bin/python
from __future__ import print_function
import sys
from mylast import lastfm_network, lastfm_username

# Prints a list of you last loved tracks on Last.fm.
# Optional parameter: number of tracks
# Prerequisites: mylast.py, pyLast

if len(sys.argv) > 1:
    number = int(sys.argv[1])
else:
    number = 20

last_loved_tracks = lastfm_network.get_user(lastfm_username).get_loved_tracks(
    limit=number)

for i, track in enumerate(last_loved_tracks):
    print(str(i + 1) + ")\t" + str(track[0]))

# End of file
Ejemplo n.º 12
0
def get_recent_tracks(username, number):
    recent_tracks = lastfm_network.get_user(username).get_recent_tracks(
        limit=number)
    for track in recent_tracks:
        print_track(track)
    return recent_tracks
Ejemplo n.º 13
0
def lastfm_now_playing(station):
    recent_tracks = lastfm_network.get_user(station).get_recent_tracks(limit=2)
    last = recent_tracks[0]
    return last