• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H30-Nov-2021-348299

src/H30-Nov-2021-3,1482,351

tests/H30-Nov-2021-1,9091,023

.codecov.ymlH A D30-Nov-2021240 86

.editorconfigH A D30-Nov-2021313 1915

.gitignoreH A D30-Nov-2021840 7259

.mergify.ymlH A D30-Nov-2021175 98

.pre-commit-config.yamlH A D30-Nov-20211.3 KiB5848

.scrutinizer.ymlH A D30-Nov-2021164 109

CHANGELOG.mdH A D30-Nov-20214.7 KiB152102

COPYINGH A D30-Nov-20218.9 KiB5228

PKG-INFOH A D30-Nov-20215.7 KiB194149

README.mdH A D30-Nov-20214.5 KiB162120

RELEASING.mdH A D30-Nov-2021820 2315

example_test_pylast.yamlH A D30-Nov-2021138 54

pytest.iniH A D30-Nov-202191 54

setup.cfgH A D30-Nov-20211.4 KiB6355

setup.pyH A D30-Nov-2021247 138

tox.iniH A D30-Nov-2021522 3228

README.md

1pyLast
2======
3
4[![PyPI version](https://img.shields.io/pypi/v/pylast.svg)](https://pypi.org/project/pylast/)
5[![Supported Python versions](https://img.shields.io/pypi/pyversions/pylast.svg)](https://pypi.org/project/pylast/)
6[![PyPI downloads](https://img.shields.io/pypi/dm/pylast.svg)](https://pypistats.org/packages/pylast)
7[![Test](https://github.com/pylast/pylast/workflows/Test/badge.svg)](https://github.com/pylast/pylast/actions)
8[![Coverage (Codecov)](https://codecov.io/gh/pylast/pylast/branch/main/graph/badge.svg)](https://codecov.io/gh/pylast/pylast)
9[![Code style: Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
10[![DOI](https://zenodo.org/badge/7803088.svg)](https://zenodo.org/badge/latestdoi/7803088)
11
12A Python interface to [Last.fm](https://www.last.fm/) and other API-compatible websites
13such as [Libre.fm](https://libre.fm/).
14
15Use the pydoc utility for help on usage or see [tests/](tests/) for examples.
16
17Installation
18------------
19
20Install via pip:
21
22```sh
23python3 -m pip install pylast
24```
25
26Install latest development version:
27
28```sh
29python3 -m pip install -U git+https://github.com/pylast/pylast
30```
31
32Or from requirements.txt:
33
34```txt
35-e git://github.com/pylast/pylast.git#egg=pylast
36```
37
38Note:
39
40* pyLast 4.3+ supports Python 3.6-3.10.
41* pyLast 4.0 - 4.2 supports Python 3.6-3.9.
42* pyLast 3.2 - 3.3 supports Python 3.5-3.8.
43* pyLast 3.0 - 3.1 supports Python 3.5-3.7.
44* pyLast 2.2 - 2.4 supports Python 2.7.10+, 3.4-3.7.
45* pyLast 2.0 - 2.1 supports Python 2.7.10+, 3.4-3.6.
46* pyLast 1.7 - 1.9 supports Python 2.7, 3.3-3.6.
47* pyLast 1.0 - 1.6 supports Python 2.7, 3.3-3.4.
48* pyLast 0.5 supports Python 2, 3.
49* pyLast < 0.5 supports Python 2.
50
51Features
52--------
53
54 * Simple public interface.
55 * Access to all the data exposed by the Last.fm web services.
56 * Scrobbling support.
57 * Full object-oriented design.
58 * Proxy support.
59 * Internal caching support for some web services calls (disabled by default).
60 * Support for other API-compatible networks like Libre.fm.
61
62
63Getting started
64---------------
65
66Here's some simple code example to get you started. In order to create any object from
67pyLast, you need a `Network` object which represents a social music network that is
68Last.fm or any other API-compatible one. You can obtain a pre-configured one for Last.fm
69and use it as follows:
70
71```python
72import pylast
73
74# You have to have your own unique two values for API_KEY and API_SECRET
75# Obtain yours from https://www.last.fm/api/account/create for Last.fm
76API_KEY = "b25b959554ed76058ac220b7b2e0a026"  # this is a sample key
77API_SECRET = "425b55975eed76058ac220b7b4e8a054"
78
79# In order to perform a write operation you need to authenticate yourself
80username = "your_user_name"
81password_hash = pylast.md5("your_password")
82
83network = pylast.LastFMNetwork(
84    api_key=API_KEY,
85    api_secret=API_SECRET,
86    username=username,
87    password_hash=password_hash,
88)
89
90# Now you can use that object everywhere
91track = network.get_track("Iron Maiden", "The Nomad")
92track.love()
93track.add_tags(("awesome", "favorite"))
94
95# Type help(pylast.LastFMNetwork) or help(pylast) in a Python interpreter
96# to get more help about anything and see examples of how it works
97```
98
99More examples in
100<a href="https://github.com/hugovk/lastfm-tools">hugovk/lastfm-tools</a> and
101[tests/](https://github.com/pylast/pylast/tree/main/tests).
102
103Testing
104-------
105
106The [tests/](https://github.com/pylast/pylast/tree/main/tests) directory contains
107integration and unit tests with Last.fm, and plenty of code examples.
108
109For integration tests you need a test account at Last.fm that will become cluttered with
110test data, and an API key and secret. Either copy
111[example_test_pylast.yaml](example_test_pylast.yaml) to test_pylast.yaml and fill out
112the credentials, or set them as environment variables like:
113
114```sh
115export PYLAST_USERNAME=TODO_ENTER_YOURS_HERE
116export PYLAST_PASSWORD_HASH=TODO_ENTER_YOURS_HERE
117export PYLAST_API_KEY=TODO_ENTER_YOURS_HERE
118export PYLAST_API_SECRET=TODO_ENTER_YOURS_HERE
119```
120
121To run all unit and integration tests:
122
123```sh
124python3 -m pip install -e ".[tests]"
125pytest
126```
127
128Or run just one test case:
129
130```sh
131pytest -k test_scrobble
132```
133
134To run with coverage:
135
136```sh
137pytest -v --cov pylast --cov-report term-missing
138coverage report # for command-line report
139coverage html   # for HTML report
140open htmlcov/index.html
141```
142
143Logging
144-------
145
146To enable from your own code:
147
148```python
149import logging
150import pylast
151
152logging.basicConfig(level=logging.DEBUG)
153
154network = pylast.LastFMNetwork(...)
155```
156
157To enable from pytest:
158
159```sh
160pytest --log-cli-level debug -k test_album_search_images
161```
162