Merge pull request #360 from pylast/updates

This commit is contained in:
Hugo van Kemenade 2021-01-04 20:25:12 +02:00 committed by GitHub
commit b7700b58c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 64 additions and 27 deletions

View file

@ -12,8 +12,11 @@
Please include **code** that reproduces the issue. Please include **code** that reproduces the issue.
The [best reproductions](https://stackoverflow.com/help/minimal-reproducible-example) are [self-contained scripts](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/) with minimal dependencies. The [best reproductions](https://stackoverflow.com/help/minimal-reproducible-example)
are
[self-contained scripts](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/)
with minimal dependencies.
```python ```python
code goes here # code goes here
``` ```

8
.github/labels.yml vendored
View file

@ -97,12 +97,18 @@
- color: 0366d6 - color: 0366d6
description: "For dependencies" description: "For dependencies"
name: dependencies name: dependencies
- color: 0052cc
description: "Documentation"
name: docs
- color: f4660e - color: f4660e
description: "" description: ""
name: Hacktoberfest name: Hacktoberfest
- color: f4660e - color: f4660e
description: "To credit accepted Hacktoberfest PRs" description: "To credit accepted Hacktoberfest PRs"
name: hacktoberfest-accepted name: hacktoberfest-accepted
- color: d65e88
description: "Deploy and release"
name: release
- color: fef2c0 - color: fef2c0
description: "" description: "Unit tests, linting, CI, etc."
name: test name: test

View file

@ -23,7 +23,6 @@ exclude-labels:
- "changelog: skip" - "changelog: skip"
template: | template: |
## Changes
$CHANGES $CHANGES

View file

@ -3,7 +3,7 @@ name: Lint
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
build: lint:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:

View file

@ -47,7 +47,6 @@ jobs:
python -m pip install -U tox python -m pip install -U tox
- name: Tox tests - name: Tox tests
shell: bash
run: | run: |
tox -e py tox -e py
env: env:

View file

@ -14,6 +14,13 @@ repos:
files: \.pyi?$ files: \.pyi?$
types: [] types: []
- repo: https://github.com/asottile/blacken-docs
rev: v1.9.1
hooks:
- id: blacken-docs
args: ["--target-version", "py36"]
additional_dependencies: [black==20.8b1]
- repo: https://github.com/PyCQA/isort - repo: https://github.com/PyCQA/isort
rev: 5.7.0 rev: 5.7.0
hooks: hooks:

View file

@ -9,7 +9,8 @@ pyLast
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![DOI](https://zenodo.org/badge/7803088.svg)](https://zenodo.org/badge/latestdoi/7803088) [![DOI](https://zenodo.org/badge/7803088.svg)](https://zenodo.org/badge/latestdoi/7803088)
A Python interface to [Last.fm](https://www.last.fm/) and other API-compatible websites such as [Libre.fm](https://libre.fm/). A Python interface to [Last.fm](https://www.last.fm/) and other API-compatible websites
such as [Libre.fm](https://libre.fm/).
Use the pydoc utility for help on usage or see [tests/](tests/) for examples. Use the pydoc utility for help on usage or see [tests/](tests/) for examples.
@ -18,25 +19,31 @@ Installation
Install via pip: Install via pip:
pip install pylast ```sh
python3 -m pip install pylast
```
Install latest development version: Install latest development version:
pip install -U git+https://github.com/pylast/pylast ```sh
python3 -m pip install -U git+https://github.com/pylast/pylast
```
Or from requirements.txt: Or from requirements.txt:
-e git://github.com/pylast/pylast.git#egg=pylast ```txt
-e git://github.com/pylast/pylast.git#egg=pylast
```
Note: Note:
* pyLast 4.0.0+ supports Python 3.6-3.9. * pyLast 4.0+ supports Python 3.6-3.9.
* pyLast 3.2.0 - 3.3.0 supports Python 3.5-3.8. * pyLast 3.2 - 3.3 supports Python 3.5-3.8.
* pyLast 3.0.0 - 3.1.0 supports Python 3.5-3.7. * pyLast 3.0 - 3.1 supports Python 3.5-3.7.
* pyLast 2.2.0 - 2.4.0 supports Python 2.7.10+, 3.4-3.7. * pyLast 2.2 - 2.4 supports Python 2.7.10+, 3.4-3.7.
* pyLast 2.0.0 - 2.1.0 supports Python 2.7.10+, 3.4-3.6. * pyLast 2.0 - 2.1 supports Python 2.7.10+, 3.4-3.6.
* pyLast 1.7.0 - 1.9.0 supports Python 2.7, 3.3-3.6. * pyLast 1.7 - 1.9 supports Python 2.7, 3.3-3.6.
* pyLast 1.0.0 - 1.6.0 supports Python 2.7, 3.3-3.4. * pyLast 1.0 - 1.6 supports Python 2.7, 3.3-3.4.
* pyLast 0.5 supports Python 2, 3. * pyLast 0.5 supports Python 2, 3.
* pyLast < 0.5 supports Python 2. * pyLast < 0.5 supports Python 2.
@ -55,7 +62,10 @@ Features
Getting started Getting started
--------------- ---------------
Here's some simple code example to get you started. In order to create any object from pyLast, you need a `Network` object which represents a social music network that is Last.fm or any other API-compatible one. You can obtain a pre-configured one for Last.fm and use it as follows: Here's some simple code example to get you started. In order to create any object from
pyLast, you need a `Network` object which represents a social music network that is
Last.fm or any other API-compatible one. You can obtain a pre-configured one for Last.fm
and use it as follows:
```python ```python
import pylast import pylast
@ -69,8 +79,12 @@ API_SECRET = "425b55975eed76058ac220b7b4e8a054"
username = "your_user_name" username = "your_user_name"
password_hash = pylast.md5("your_password") password_hash = pylast.md5("your_password")
network = pylast.LastFMNetwork(api_key=API_KEY, api_secret=API_SECRET, network = pylast.LastFMNetwork(
username=username, password_hash=password_hash) api_key=API_KEY,
api_secret=API_SECRET,
username=username,
password_hash=password_hash,
)
# Now you can use that object everywhere # Now you can use that object everywhere
artist = network.get_artist("System of a Down") artist = network.get_artist("System of a Down")
@ -85,14 +99,20 @@ track.add_tags(("awesome", "favorite"))
# to get more help about anything and see examples of how it works # to get more help about anything and see examples of how it works
``` ```
More examples in <a href="https://github.com/hugovk/lastfm-tools">hugovk/lastfm-tools</a> and [tests/](tests/). More examples in
<a href="https://github.com/hugovk/lastfm-tools">hugovk/lastfm-tools</a> and
[tests/](https://github.com/pylast/pylast/tree/master/tests).
Testing Testing
------- -------
The [tests/](tests/) directory contains integration and unit tests with Last.fm, and plenty of code examples. The [tests/](https://github.com/pylast/pylast/tree/master/tests) directory contains
integration and unit tests with Last.fm, and plenty of code examples.
For integration tests you need a test account at Last.fm that will become cluttered with test data, and an API key and secret. Either copy [example_test_pylast.yaml](example_test_pylast.yaml) to test_pylast.yaml and fill out the credentials, or set them as environment variables like: For integration tests you need a test account at Last.fm that will become cluttered with
test data, and an API key and secret. Either copy
[example_test_pylast.yaml](example_test_pylast.yaml) to test_pylast.yaml and fill out
the credentials, or set them as environment variables like:
```sh ```sh
export PYLAST_USERNAME=TODO_ENTER_YOURS_HERE export PYLAST_USERNAME=TODO_ENTER_YOURS_HERE
@ -102,17 +122,20 @@ export PYLAST_API_SECRET=TODO_ENTER_YOURS_HERE
``` ```
To run all unit and integration tests: To run all unit and integration tests:
```sh ```sh
pip install -e ".[tests]" python3 -m pip install -e ".[tests]"
pytest pytest
``` ```
Or run just one test case: Or run just one test case:
```sh ```sh
pytest -k test_scrobble pytest -k test_scrobble
``` ```
To run with coverage: To run with coverage:
```sh ```sh
pytest -v --cov pylast --cov-report term-missing pytest -v --cov pylast --cov-report term-missing
coverage report # for command-line report coverage report # for command-line report

View file

@ -3,7 +3,7 @@
# A Python interface to Last.fm and Libre.fm # A Python interface to Last.fm and Libre.fm
# #
# Copyright 2008-2010 Amr Hassan # Copyright 2008-2010 Amr Hassan
# Copyright 2013-2020 hugovk # Copyright 2013-2021 hugovk
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -35,7 +35,7 @@ from xml.dom import Node, minidom
import pkg_resources import pkg_resources
__author__ = "Amr Hassan, hugovk, Mice Pápai" __author__ = "Amr Hassan, hugovk, Mice Pápai"
__copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2020 hugovk, 2017 Mice Pápai" __copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2021 hugovk, 2017 Mice Pápai"
__license__ = "apache2" __license__ = "apache2"
__email__ = "amr.hassan@gmail.com" __email__ = "amr.hassan@gmail.com"
__version__ = pkg_resources.get_distribution(__name__).version __version__ = pkg_resources.get_distribution(__name__).version

View file

@ -11,7 +11,7 @@ from flaky import flaky
import pylast import pylast
WRITE_TEST = sys.version_info[:2] == (3, 8) WRITE_TEST = sys.version_info[:2] == (3, 9)
def load_secrets(): # pragma: no cover def load_secrets(): # pragma: no cover