def __init__(self, user_name, count=25, offset=0, time_range='all_time'):
     super().__init__()
     self.client = pylistenbrainz.ListenBrainz()
     self.user_name = user_name
     self.count = count
     self.offset = offset
     self.time_range = time_range
 def __init__(self, user_name, artist_type, count=25, offset=0):
     super().__init__()
     self.client = pylistenbrainz.ListenBrainz()
     self.user_name = user_name
     self.count = count
     self.offset = offset
     self.artist_type = artist_type
     self._last_updated = None
Beispiel #3
0
 def __init__(self, user_name, artist_type, count=25, offset=0):
     """
         The offset parameter does not work yet.
     """
     Element.__init__(self)
     self.client = pylistenbrainz.ListenBrainz()
     self.user_name = user_name
     self.count = count
     self.offset = offset
     self.artist_type = artist_type
import pylistenbrainz
import time

auth_token = input('Please enter your auth token: ')

listen = pylistenbrainz.Listen(
    track_name="Fade",
    artist_name="Kanye West",
    release_name="The Life of Pablo",
    listened_at=int(time.time()),
)

client = pylistenbrainz.ListenBrainz()
client.set_auth_token(auth_token)
response = client.submit_single_listen(listen)
assert response['status'] == 'ok'

listen_2 = pylistenbrainz.Listen(
    track_name="Contact",
    artist_name="Daft Punk",
    release_name="Random Access Memories",
    listened_at=int(time.time()),
)

listen_3 = pylistenbrainz.Listen(
    track_name="Get Lucky",
    artist_name="Daft Punk",
    release_name="Random Access Memories",
    listened_at=int(time.time()),
)
import xml.etree.ElementTree as ET

import pylistenbrainz
import requests
from dotenv import load_dotenv

load_dotenv()

URL_TEMPLATE = (
    "https://libre.fm/2.0/?method=user.getrecenttracks&api_key="
    "Max-----------------------------&user={}&page={}&limit=200"
)
LIBRE_FM_USERNAME = os.getenv("LIBRE_FM_USERNAME")

# Authenticate with Listenbrainz
listenbrainz = pylistenbrainz.ListenBrainz()
listenbrainz.set_auth_token(os.getenv("LISTENBRAINZ_AUTH_TOKEN"))


def process_page(page: int) -> None:
    """
    Takes a page number, gets the XML from libre.fm, parses it and sends to Listenbrainz
    """
    request = requests.get(URL_TEMPLATE.format(LIBRE_FM_USERNAME, page))

    xml_page = ET.fromstring(request.text)
    all_listens = xml_page.getiterator("track")  # pylint: disable=deprecated-method

    listens = []
    for listen in all_listens:
        # Iterate each listen and extract required fields
Beispiel #6
0
 def setUp(self):
     self.client = pylistenbrainz.ListenBrainz()