How to use pylast - 10 common examples

To help you get started, we’ve selected a few pylast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mopidy / mopidy / mopidy / frontends / lastfm.py View on Github external
def track_playback_started(self, tl_track):
        track = tl_track.track
        artists = ', '.join([a.name for a in track.artists])
        duration = track.length and track.length // 1000 or 0
        self.last_start_time = int(time.time())
        logger.debug('Now playing track: %s - %s', artists, track.name)
        try:
            self.lastfm.update_now_playing(
                artists,
                (track.name or ''),
                album=(track.album and track.album.name or ''),
                duration=str(duration),
                track_number=str(track.track_no),
                mbid=(track.musicbrainz_id or ''))
        except (pylast.ScrobblingError, pylast.NetworkError,
                pylast.MalformedResponseError, pylast.WSError) as e:
            logger.warning('Error submitting playing track to Last.fm: %s', e)
github pylast / pylast / tests / test_network.py View on Github external
def test_network_get_top_tags_with_limit(self):
        # Arrange
        # Act
        tags = self.network.get_top_tags(limit=1)

        # Assert
        self.helper_only_one_thing_in_top_list(tags, pylast.Tag)
github ioggstream / iposonic / test / test_scrobble.py View on Github external
def test_get_album_1():
    network = pylast.LastFMNetwork(api_key=API_KEY, api_secret=
                                   API_SECRET, username=lastfm_user.get('username'), password_hash=pylast.md5(lastfm_user.get('password')))

    top_albums = [(x.item.title, x.item.artist.name)
                  for x in u.get_top_albums()]
    top_albums = [(x.item.title, x.item.artist.name)
                  for x in u.get_top_albums()]
github ioggstream / iposonic / test / test_scrobble.py View on Github external
# scrobble playground (for now)
#
from __future__ import unicode_literals
from nose import *
import time
import pylast
from test_iposonic import harn_setup

API_KEY = "b725246f2c3e1738153c656928483570"
API_SECRET = "e08b9a80defa4ccd9fda4d4e89d5eb19"

username = "ioggstream"
password = "secret"
password_hash = pylast.md5(password)

network = pylast.LastFMNetwork(api_key=API_KEY, api_secret=
                               API_SECRET, username=username, password_hash=password_hash)


def test_get_user():
    u = network.get_user('ioggstream')
    u.get_library()
    u.get_country()
    u.get_neighbours()
    u.get_loved_tracks()
    u.get_top_artists()
    u.get_url()
    u.get_top_tags()
    u.get_top_albums()
    u.get_friends()
    u.get_name()
    u.get_playlists()
github pylast / pylast / tests / test_track.py View on Github external
def test_track_wiki_summary(self):
        # Arrange
        track = pylast.Track("Test Artist", "test title", self.network)

        # Act
        wiki = track.get_wiki_summary()

        # Assert
        assert wiki is not None
        assert len(wiki) >= 1
github pylast / pylast / tests / test_track.py View on Github external
def test_tracks_notequal(self):
        # Arrange
        track1 = pylast.Track("Test Artist", "test title", self.network)
        track2 = pylast.Track("Test Artist", "Test Track", self.network)

        # Act
        # Assert
        assert track1 != track2
github pylast / pylast / tests / test_track.py View on Github external
def test_track_with_no_mbid(self):
        # Arrange
        track = pylast.Track("Static-X", "Set It Off", self.network)

        # Act
        mbid = track.get_mbid()

        # Assert
        assert mbid is None
github pylast / pylast / tests / test_user.py View on Github external
def helper_get_assert_charts(self, thing, date):
        # Arrange
        album_chart, track_chart = None, None
        (from_date, to_date) = date

        # Act
        artist_chart = thing.get_weekly_artist_charts(from_date, to_date)
        if type(thing) is not pylast.Tag:
            album_chart = thing.get_weekly_album_charts(from_date, to_date)
            track_chart = thing.get_weekly_track_charts(from_date, to_date)

        # Assert
        self.helper_assert_chart(artist_chart, pylast.Artist)
        if type(thing) is not pylast.Tag:
            self.helper_assert_chart(album_chart, pylast.Album)
            self.helper_assert_chart(track_chart, pylast.Track)
github pylast / pylast / tests / test_track.py View on Github external
def test_tracks_notequal(self):
        # Arrange
        track1 = pylast.Track("Test Artist", "test title", self.network)
        track2 = pylast.Track("Test Artist", "Test Track", self.network)

        # Act
        # Assert
        assert track1 != track2
github pylast / pylast / tests / test_network.py View on Github external
def test_country_network_top_tracks(self):
        # Arrange
        # Act
        things = self.network.get_geo_top_tracks("Croatia", limit=2)

        # Assert
        self.helper_two_different_things_in_top_list(things, pylast.Track)