mopidy-scrobbler 3.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mopidy_scrobbler-3.0.0/.copier-answers.yml +8 -0
- mopidy_scrobbler-3.0.0/.github/workflows/ci.yml +61 -0
- mopidy_scrobbler-3.0.0/.github/workflows/release.yml +23 -0
- mopidy_scrobbler-3.0.0/.gitignore +9 -0
- mopidy_scrobbler-3.0.0/LICENSE +202 -0
- mopidy_scrobbler-3.0.0/PKG-INFO +154 -0
- mopidy_scrobbler-3.0.0/README.md +134 -0
- mopidy_scrobbler-3.0.0/pyproject.toml +145 -0
- mopidy_scrobbler-3.0.0/setup.cfg +4 -0
- mopidy_scrobbler-3.0.0/src/mopidy_scrobbler/__init__.py +26 -0
- mopidy_scrobbler-3.0.0/src/mopidy_scrobbler/ext.conf +4 -0
- mopidy_scrobbler-3.0.0/src/mopidy_scrobbler/frontend.py +86 -0
- mopidy_scrobbler-3.0.0/src/mopidy_scrobbler.egg-info/PKG-INFO +154 -0
- mopidy_scrobbler-3.0.0/src/mopidy_scrobbler.egg-info/SOURCES.txt +19 -0
- mopidy_scrobbler-3.0.0/src/mopidy_scrobbler.egg-info/dependency_links.txt +1 -0
- mopidy_scrobbler-3.0.0/src/mopidy_scrobbler.egg-info/entry_points.txt +2 -0
- mopidy_scrobbler-3.0.0/src/mopidy_scrobbler.egg-info/requires.txt +3 -0
- mopidy_scrobbler-3.0.0/src/mopidy_scrobbler.egg-info/top_level.txt +1 -0
- mopidy_scrobbler-3.0.0/tests/__init__.py +0 -0
- mopidy_scrobbler-3.0.0/tests/test_extension.py +33 -0
- mopidy_scrobbler-3.0.0/tests/test_frontend.py +177 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
_commit: v2.2.0
|
|
2
|
+
_src_path: gh:mopidy/mopidy-ext-template
|
|
3
|
+
author_email: stein.magnus@jodal.no
|
|
4
|
+
author_full_name: Stein Magnus Jodal
|
|
5
|
+
dist_name: mopidy-scrobbler
|
|
6
|
+
ext_name: scrobbler
|
|
7
|
+
github_username: mopidy
|
|
8
|
+
short_description: Mopidy extension for scrobbling played tracks to Last.fm
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
name: Build
|
|
13
|
+
runs-on: ubuntu-24.04
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v6
|
|
16
|
+
- uses: hynek/build-and-inspect-python-package@v2
|
|
17
|
+
|
|
18
|
+
main:
|
|
19
|
+
strategy:
|
|
20
|
+
fail-fast: false
|
|
21
|
+
matrix:
|
|
22
|
+
include:
|
|
23
|
+
- name: "pytest (3.13)"
|
|
24
|
+
python: "3.13"
|
|
25
|
+
tox: "3.13"
|
|
26
|
+
- name: "pytest (3.14)"
|
|
27
|
+
python: "3.14"
|
|
28
|
+
tox: "3.14"
|
|
29
|
+
coverage: true
|
|
30
|
+
- name: "pyright"
|
|
31
|
+
python: "3.14"
|
|
32
|
+
tox: "pyright"
|
|
33
|
+
- name: "ruff check"
|
|
34
|
+
python: "3.14"
|
|
35
|
+
tox: "ruff-check"
|
|
36
|
+
- name: "ruff format"
|
|
37
|
+
python: "3.14"
|
|
38
|
+
tox: "ruff-format"
|
|
39
|
+
|
|
40
|
+
name: ${{ matrix.name }}
|
|
41
|
+
runs-on: ubuntu-24.04
|
|
42
|
+
container: ghcr.io/mopidy/ci:latest
|
|
43
|
+
|
|
44
|
+
steps:
|
|
45
|
+
- uses: actions/checkout@v6
|
|
46
|
+
- name: Fix home dir permissions to enable pip caching
|
|
47
|
+
run: chown -R root /github/home
|
|
48
|
+
- uses: actions/setup-python@v6
|
|
49
|
+
with:
|
|
50
|
+
python-version: ${{ matrix.python }}
|
|
51
|
+
cache: pip
|
|
52
|
+
allow-prereleases: true
|
|
53
|
+
- run: python -m pip install tox
|
|
54
|
+
- run: python -m tox -e ${{ matrix.tox }}
|
|
55
|
+
if: ${{ ! matrix.coverage }}
|
|
56
|
+
- run: python -m tox -e ${{ matrix.tox }} -- --cov-report=xml
|
|
57
|
+
if: ${{ matrix.coverage }}
|
|
58
|
+
- uses: codecov/codecov-action@v5
|
|
59
|
+
if: ${{ matrix.coverage }}
|
|
60
|
+
with:
|
|
61
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
release:
|
|
9
|
+
runs-on: ubuntu-24.04
|
|
10
|
+
environment:
|
|
11
|
+
name: pypi
|
|
12
|
+
url: https://pypi.org/project/mopidy-scrobbler/
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v6
|
|
17
|
+
- uses: hynek/build-and-inspect-python-package@v2
|
|
18
|
+
id: build
|
|
19
|
+
- uses: actions/download-artifact@v4
|
|
20
|
+
with:
|
|
21
|
+
name: ${{ steps.build.outputs.artifact-name }}
|
|
22
|
+
path: dist
|
|
23
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mopidy-scrobbler
|
|
3
|
+
Version: 3.0.0
|
|
4
|
+
Summary: Mopidy extension for scrobbling played tracks to Last.fm
|
|
5
|
+
Author-email: Stein Magnus Jodal <stein.magnus@jodal.no>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/mopidy/mopidy-scrobbler
|
|
8
|
+
Classifier: Environment :: No Input/Output (Daemon)
|
|
9
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Players
|
|
13
|
+
Requires-Python: >=3.13
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: mopidy>=4.0.0
|
|
17
|
+
Requires-Dist: pykka>=4.1
|
|
18
|
+
Requires-Dist: pylast>=5.3
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# mopidy-scrobbler
|
|
22
|
+
|
|
23
|
+
[](https://pypi.org/p/mopidy-scrobbler)
|
|
24
|
+
[](https://github.com/mopidy/mopidy-scrobbler/actions/workflows/ci.yml)
|
|
25
|
+
[](https://codecov.io/gh/mopidy/mopidy-scrobbler)
|
|
26
|
+
|
|
27
|
+
[Mopidy](https://www.mopidy.com/) extension for scrobbling played tracks to [Last.fm](https://www.last.fm/).
|
|
28
|
+
|
|
29
|
+
This extension requires a free user account at Last.fm.
|
|
30
|
+
|
|
31
|
+
## Maintainer wanted
|
|
32
|
+
|
|
33
|
+
Mopidy-Scrobbler is currently kept on life support by the Mopidy core developers.
|
|
34
|
+
It is in need of a more dedicated maintainer.
|
|
35
|
+
|
|
36
|
+
If you want to be the maintainer of Mopidy-Scrobbler, please:
|
|
37
|
+
|
|
38
|
+
1. Make 2-3 good pull requests improving any part of the project.
|
|
39
|
+
|
|
40
|
+
2. Read and get familiar with all of the project's open issues.
|
|
41
|
+
|
|
42
|
+
3. Send a pull request removing this section and adding yourself as the
|
|
43
|
+
"Current maintainer" in the "Credits" section below. In the pull request
|
|
44
|
+
description, please refer to the previous pull requests and state that
|
|
45
|
+
you've familiarized yourself with the open issues.
|
|
46
|
+
|
|
47
|
+
As a maintainer, you'll be given push access to the repo and the authority
|
|
48
|
+
to make releases to PyPI when you see fit.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
Install by running:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
python3 -m pip install mopidy-scrobbler
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
See https://mopidy.com/ext/scrobbler/ for alternative installation methods.
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
The extension is enabled by default when it is installed. You just need to add
|
|
63
|
+
your Last.fm username and password to your Mopidy configuration file:
|
|
64
|
+
|
|
65
|
+
```ini
|
|
66
|
+
[scrobbler]
|
|
67
|
+
username = alice
|
|
68
|
+
password = secret
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The following configuration values are available:
|
|
72
|
+
|
|
73
|
+
- `scrobbler/enabled`: If the scrobbler extension should be enabled or not.
|
|
74
|
+
Defaults to enabled.
|
|
75
|
+
- `scrobbler/username`: Your Last.fm username.
|
|
76
|
+
- `scrobbler/password`: Your Last.fm password.
|
|
77
|
+
|
|
78
|
+
## Project resources
|
|
79
|
+
|
|
80
|
+
- [Source code](https://github.com/mopidy/mopidy-scrobbler)
|
|
81
|
+
- [Issues](https://github.com/mopidy/mopidy-scrobbler/issues)
|
|
82
|
+
- [Releases](https://github.com/mopidy/mopidy-scrobbler/releases)
|
|
83
|
+
|
|
84
|
+
## Development
|
|
85
|
+
|
|
86
|
+
### Set up development environment
|
|
87
|
+
|
|
88
|
+
Clone the repo using, e.g. using [gh](https://cli.github.com/):
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
gh repo clone mopidy/mopidy-scrobbler
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Enter the directory, and install dependencies using [uv](https://docs.astral.sh/uv/):
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
cd mopidy-scrobbler/
|
|
98
|
+
uv sync
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Running tests
|
|
102
|
+
|
|
103
|
+
To run all tests and linters in isolated environments, use
|
|
104
|
+
[tox](https://tox.wiki/):
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
tox
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
To only run tests, use [pytest](https://pytest.org/):
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
pytest
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
To format the code, use [ruff](https://docs.astral.sh/ruff/):
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
ruff format .
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
To check for lints with ruff, run:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
ruff check .
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
To check for type errors, use [pyright](https://microsoft.github.io/pyright/):
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
pyright .
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Making a release
|
|
135
|
+
|
|
136
|
+
To make a release to PyPI, go to the project's [GitHub releases
|
|
137
|
+
page](https://github.com/mopidy/mopidy-scrobbler/releases)
|
|
138
|
+
and click the "Draft a new release" button.
|
|
139
|
+
|
|
140
|
+
In the "choose a tag" dropdown, select the tag you want to release or create a
|
|
141
|
+
new tag, e.g. `v0.1.0`. Add a title, e.g. `v0.1.0`, and a description of the changes.
|
|
142
|
+
|
|
143
|
+
Decide if the release is a pre-release (alpha, beta, or release candidate) or
|
|
144
|
+
should be marked as the latest release, and click "Publish release".
|
|
145
|
+
|
|
146
|
+
Once the release is created, the `release.yml` GitHub Action will automatically
|
|
147
|
+
build and publish the release to
|
|
148
|
+
[PyPI](https://pypi.org/project/mopidy-scrobbler/).
|
|
149
|
+
|
|
150
|
+
## Credits
|
|
151
|
+
|
|
152
|
+
- Original author: [Stein Magnus Jodal](https://github.com/jodal)
|
|
153
|
+
- Current maintainer: None. Maintainer wanted, see section above.
|
|
154
|
+
- [Contributors](https://github.com/mopidy/mopidy-scrobbler/graphs/contributors)
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# mopidy-scrobbler
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/p/mopidy-scrobbler)
|
|
4
|
+
[](https://github.com/mopidy/mopidy-scrobbler/actions/workflows/ci.yml)
|
|
5
|
+
[](https://codecov.io/gh/mopidy/mopidy-scrobbler)
|
|
6
|
+
|
|
7
|
+
[Mopidy](https://www.mopidy.com/) extension for scrobbling played tracks to [Last.fm](https://www.last.fm/).
|
|
8
|
+
|
|
9
|
+
This extension requires a free user account at Last.fm.
|
|
10
|
+
|
|
11
|
+
## Maintainer wanted
|
|
12
|
+
|
|
13
|
+
Mopidy-Scrobbler is currently kept on life support by the Mopidy core developers.
|
|
14
|
+
It is in need of a more dedicated maintainer.
|
|
15
|
+
|
|
16
|
+
If you want to be the maintainer of Mopidy-Scrobbler, please:
|
|
17
|
+
|
|
18
|
+
1. Make 2-3 good pull requests improving any part of the project.
|
|
19
|
+
|
|
20
|
+
2. Read and get familiar with all of the project's open issues.
|
|
21
|
+
|
|
22
|
+
3. Send a pull request removing this section and adding yourself as the
|
|
23
|
+
"Current maintainer" in the "Credits" section below. In the pull request
|
|
24
|
+
description, please refer to the previous pull requests and state that
|
|
25
|
+
you've familiarized yourself with the open issues.
|
|
26
|
+
|
|
27
|
+
As a maintainer, you'll be given push access to the repo and the authority
|
|
28
|
+
to make releases to PyPI when you see fit.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
Install by running:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
python3 -m pip install mopidy-scrobbler
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
See https://mopidy.com/ext/scrobbler/ for alternative installation methods.
|
|
39
|
+
|
|
40
|
+
## Configuration
|
|
41
|
+
|
|
42
|
+
The extension is enabled by default when it is installed. You just need to add
|
|
43
|
+
your Last.fm username and password to your Mopidy configuration file:
|
|
44
|
+
|
|
45
|
+
```ini
|
|
46
|
+
[scrobbler]
|
|
47
|
+
username = alice
|
|
48
|
+
password = secret
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The following configuration values are available:
|
|
52
|
+
|
|
53
|
+
- `scrobbler/enabled`: If the scrobbler extension should be enabled or not.
|
|
54
|
+
Defaults to enabled.
|
|
55
|
+
- `scrobbler/username`: Your Last.fm username.
|
|
56
|
+
- `scrobbler/password`: Your Last.fm password.
|
|
57
|
+
|
|
58
|
+
## Project resources
|
|
59
|
+
|
|
60
|
+
- [Source code](https://github.com/mopidy/mopidy-scrobbler)
|
|
61
|
+
- [Issues](https://github.com/mopidy/mopidy-scrobbler/issues)
|
|
62
|
+
- [Releases](https://github.com/mopidy/mopidy-scrobbler/releases)
|
|
63
|
+
|
|
64
|
+
## Development
|
|
65
|
+
|
|
66
|
+
### Set up development environment
|
|
67
|
+
|
|
68
|
+
Clone the repo using, e.g. using [gh](https://cli.github.com/):
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
gh repo clone mopidy/mopidy-scrobbler
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Enter the directory, and install dependencies using [uv](https://docs.astral.sh/uv/):
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
cd mopidy-scrobbler/
|
|
78
|
+
uv sync
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Running tests
|
|
82
|
+
|
|
83
|
+
To run all tests and linters in isolated environments, use
|
|
84
|
+
[tox](https://tox.wiki/):
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
tox
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
To only run tests, use [pytest](https://pytest.org/):
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
pytest
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
To format the code, use [ruff](https://docs.astral.sh/ruff/):
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
ruff format .
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
To check for lints with ruff, run:
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
ruff check .
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
To check for type errors, use [pyright](https://microsoft.github.io/pyright/):
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
pyright .
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Making a release
|
|
115
|
+
|
|
116
|
+
To make a release to PyPI, go to the project's [GitHub releases
|
|
117
|
+
page](https://github.com/mopidy/mopidy-scrobbler/releases)
|
|
118
|
+
and click the "Draft a new release" button.
|
|
119
|
+
|
|
120
|
+
In the "choose a tag" dropdown, select the tag you want to release or create a
|
|
121
|
+
new tag, e.g. `v0.1.0`. Add a title, e.g. `v0.1.0`, and a description of the changes.
|
|
122
|
+
|
|
123
|
+
Decide if the release is a pre-release (alpha, beta, or release candidate) or
|
|
124
|
+
should be marked as the latest release, and click "Publish release".
|
|
125
|
+
|
|
126
|
+
Once the release is created, the `release.yml` GitHub Action will automatically
|
|
127
|
+
build and publish the release to
|
|
128
|
+
[PyPI](https://pypi.org/project/mopidy-scrobbler/).
|
|
129
|
+
|
|
130
|
+
## Credits
|
|
131
|
+
|
|
132
|
+
- Original author: [Stein Magnus Jodal](https://github.com/jodal)
|
|
133
|
+
- Current maintainer: None. Maintainer wanted, see section above.
|
|
134
|
+
- [Contributors](https://github.com/mopidy/mopidy-scrobbler/graphs/contributors)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "mopidy-scrobbler"
|
|
3
|
+
description = "Mopidy extension for scrobbling played tracks to Last.fm"
|
|
4
|
+
readme = "README.md"
|
|
5
|
+
requires-python = ">= 3.13"
|
|
6
|
+
license = { text = "Apache-2.0" }
|
|
7
|
+
authors = [{ name = "Stein Magnus Jodal", email = "stein.magnus@jodal.no" }]
|
|
8
|
+
classifiers = [
|
|
9
|
+
"Environment :: No Input/Output (Daemon)",
|
|
10
|
+
"Intended Audience :: End Users/Desktop",
|
|
11
|
+
"License :: OSI Approved :: Apache Software License",
|
|
12
|
+
"Operating System :: OS Independent",
|
|
13
|
+
"Topic :: Multimedia :: Sound/Audio :: Players",
|
|
14
|
+
]
|
|
15
|
+
dynamic = ["version"]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"mopidy >= 4.0.0",
|
|
18
|
+
"pykka >= 4.1",
|
|
19
|
+
"pylast >= 5.3",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://github.com/mopidy/mopidy-scrobbler"
|
|
24
|
+
|
|
25
|
+
[project.entry-points."mopidy.ext"]
|
|
26
|
+
scrobbler = "mopidy_scrobbler:Extension"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
[build-system]
|
|
30
|
+
requires = ["setuptools >= 78", "setuptools-scm >= 8.2"]
|
|
31
|
+
build-backend = "setuptools.build_meta"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
[dependency-groups]
|
|
35
|
+
dev = [
|
|
36
|
+
"tox",
|
|
37
|
+
{ include-group = "ruff" },
|
|
38
|
+
{ include-group = "tests" },
|
|
39
|
+
{ include-group = "typing" },
|
|
40
|
+
]
|
|
41
|
+
ruff = ["ruff"]
|
|
42
|
+
tests = ["pytest", "pytest-cov"]
|
|
43
|
+
typing = ["pyright"]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
[tool.coverage.paths]
|
|
47
|
+
source = ["src/", "*/site-packages/"]
|
|
48
|
+
|
|
49
|
+
[tool.coverage.run]
|
|
50
|
+
source_pkgs = ["mopidy_scrobbler"]
|
|
51
|
+
|
|
52
|
+
[tool.coverage.report]
|
|
53
|
+
show_missing = true
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
[tool.pyright]
|
|
57
|
+
pythonVersion = "3.13"
|
|
58
|
+
typeCheckingMode = "standard"
|
|
59
|
+
# Not all dependencies have type hints:
|
|
60
|
+
reportMissingTypeStubs = false
|
|
61
|
+
# Already covered by ruff's flake8-self checks:
|
|
62
|
+
reportPrivateImportUsage = false
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
[tool.pytest.ini_options]
|
|
66
|
+
filterwarnings = [
|
|
67
|
+
# By default, fail tests on warnings from our own code
|
|
68
|
+
"error:::mopidy_scrobbler",
|
|
69
|
+
#
|
|
70
|
+
# Add any warnings you want to ignore here:
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
[tool.ruff]
|
|
75
|
+
target-version = "py313"
|
|
76
|
+
|
|
77
|
+
[tool.ruff.lint]
|
|
78
|
+
select = ["ALL"]
|
|
79
|
+
ignore = [
|
|
80
|
+
# Add rules you want to ignore here
|
|
81
|
+
"ANN", # flake8-annotations -- TODO
|
|
82
|
+
"D", # pydocstyle
|
|
83
|
+
"D203", # one-blank-line-before-class
|
|
84
|
+
"D213", # multi-line-summary-second-line
|
|
85
|
+
"G004", # logging-f-string
|
|
86
|
+
"PLR2004", # magic-value-comparison -- TODO
|
|
87
|
+
"TD002", # missing-todo-author
|
|
88
|
+
"TD003", # missing-todo-link
|
|
89
|
+
#
|
|
90
|
+
# Conflicting with `ruff format`
|
|
91
|
+
"COM812", # missing-trailing-comma
|
|
92
|
+
"ISC001", # single-line-implicit-string-concatenation
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
[tool.ruff.lint.per-file-ignores]
|
|
96
|
+
"tests/*" = [
|
|
97
|
+
"ARG", # flake8-unused-arguments
|
|
98
|
+
"D", # pydocstyle
|
|
99
|
+
"S101", # assert
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
[tool.setuptools.package-data]
|
|
104
|
+
"*" = ["*.conf"]
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
[tool.setuptools_scm]
|
|
108
|
+
# This section, even if empty, must be present for setuptools_scm to work
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
[tool.tox]
|
|
112
|
+
env_list = [
|
|
113
|
+
"3.13",
|
|
114
|
+
"3.14",
|
|
115
|
+
"pyright",
|
|
116
|
+
"ruff-check",
|
|
117
|
+
"ruff-format",
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
[tool.tox.env_run_base]
|
|
121
|
+
package = "wheel"
|
|
122
|
+
wheel_build_env = ".pkg"
|
|
123
|
+
dependency_groups = ["tests"]
|
|
124
|
+
commands = [
|
|
125
|
+
[
|
|
126
|
+
"pytest",
|
|
127
|
+
"--cov",
|
|
128
|
+
"--basetemp={envtmpdir}",
|
|
129
|
+
{ replace = "posargs", extend = true },
|
|
130
|
+
],
|
|
131
|
+
]
|
|
132
|
+
|
|
133
|
+
[tool.tox.env.pyright]
|
|
134
|
+
dependency_groups = ["typing"]
|
|
135
|
+
commands = [["pyright", "{posargs:src}"]]
|
|
136
|
+
|
|
137
|
+
[tool.tox.env.ruff-check]
|
|
138
|
+
skip_install = true
|
|
139
|
+
dependency_groups = ["ruff"]
|
|
140
|
+
commands = [["ruff", "check", "{posargs:.}"]]
|
|
141
|
+
|
|
142
|
+
[tool.tox.env.ruff-format]
|
|
143
|
+
skip_install = true
|
|
144
|
+
dependency_groups = ["ruff"]
|
|
145
|
+
commands = [["ruff", "format", "--check", "--diff", "{posargs:.}"]]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
from importlib.metadata import version
|
|
3
|
+
|
|
4
|
+
from mopidy import config, ext
|
|
5
|
+
|
|
6
|
+
__version__ = version("mopidy-scrobbler")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Extension(ext.Extension):
|
|
10
|
+
dist_name = "mopidy-scrobbler"
|
|
11
|
+
ext_name = "scrobbler"
|
|
12
|
+
version = __version__
|
|
13
|
+
|
|
14
|
+
def get_default_config(self):
|
|
15
|
+
return config.read(pathlib.Path(__file__).parent / "ext.conf")
|
|
16
|
+
|
|
17
|
+
def get_config_schema(self):
|
|
18
|
+
schema = super().get_config_schema()
|
|
19
|
+
schema["username"] = config.String()
|
|
20
|
+
schema["password"] = config.Secret()
|
|
21
|
+
return schema
|
|
22
|
+
|
|
23
|
+
def setup(self, registry) -> None:
|
|
24
|
+
from .frontend import ScrobblerFrontend # noqa: PLC0415
|
|
25
|
+
|
|
26
|
+
registry.add("frontend", ScrobblerFrontend)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import time
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
import pykka
|
|
8
|
+
import pylast
|
|
9
|
+
from mopidy.core import CoreListener
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from mopidy.models import TlTrack
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
API_KEY = "2236babefa8ebb3d93ea467560d00d04"
|
|
17
|
+
API_SECRET = "94d9a09c0cd5be955c4afaeaffcaefcd" # noqa: S105
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ScrobblerFrontend(pykka.ThreadingActor, CoreListener):
|
|
21
|
+
lastfm: pylast.LastFMNetwork
|
|
22
|
+
last_start_time: int | None
|
|
23
|
+
|
|
24
|
+
def __init__(self, config, core) -> None:
|
|
25
|
+
super().__init__()
|
|
26
|
+
self.config = config
|
|
27
|
+
_ = core
|
|
28
|
+
self.last_start_time = None
|
|
29
|
+
|
|
30
|
+
def on_start(self) -> None:
|
|
31
|
+
try:
|
|
32
|
+
self.lastfm = pylast.LastFMNetwork(
|
|
33
|
+
api_key=API_KEY,
|
|
34
|
+
api_secret=API_SECRET,
|
|
35
|
+
username=self.config["scrobbler"]["username"],
|
|
36
|
+
password_hash=pylast.md5(self.config["scrobbler"]["password"]),
|
|
37
|
+
)
|
|
38
|
+
logger.info("Scrobbler connected to Last.fm")
|
|
39
|
+
except pylast.PyLastError as exc:
|
|
40
|
+
logger.error(f"Error during Last.fm setup: {exc}") # noqa: TRY400
|
|
41
|
+
self.stop()
|
|
42
|
+
|
|
43
|
+
def track_playback_started(self, tl_track: TlTrack) -> None:
|
|
44
|
+
track = tl_track.track
|
|
45
|
+
artists = ", ".join(sorted([a.name for a in track.artists if a.name]))
|
|
46
|
+
duration = (track.length and track.length // 1000) or 0
|
|
47
|
+
self.last_start_time = int(time.time())
|
|
48
|
+
logger.debug(f"Now playing track: {artists} - {track.name}")
|
|
49
|
+
try:
|
|
50
|
+
self.lastfm.update_now_playing(
|
|
51
|
+
artists,
|
|
52
|
+
(track.name or ""),
|
|
53
|
+
album=((track.album and track.album.name) or ""),
|
|
54
|
+
duration=str(duration),
|
|
55
|
+
track_number=str(track.track_no or 0),
|
|
56
|
+
mbid=(str(track.musicbrainz_id) if track.musicbrainz_id else ""),
|
|
57
|
+
)
|
|
58
|
+
except pylast.PyLastError as exc:
|
|
59
|
+
logger.warning(f"Error submitting playing track to Last.fm: {exc}")
|
|
60
|
+
|
|
61
|
+
def track_playback_ended(self, tl_track: TlTrack, time_position: int) -> None:
|
|
62
|
+
track = tl_track.track
|
|
63
|
+
artists = ", ".join(sorted([a.name for a in track.artists if a.name]))
|
|
64
|
+
duration = track.length // 1000 if track.length else None
|
|
65
|
+
time_position = time_position // 1000
|
|
66
|
+
if duration is None or duration < 30:
|
|
67
|
+
logger.debug("Track too short to scrobble. (30s)")
|
|
68
|
+
return
|
|
69
|
+
if time_position < duration // 2 and time_position < 240:
|
|
70
|
+
logger.debug("Track not played long enough to scrobble. (50% or 240s)")
|
|
71
|
+
return
|
|
72
|
+
if self.last_start_time is None:
|
|
73
|
+
self.last_start_time = int(time.time()) - duration
|
|
74
|
+
logger.debug(f"Scrobbling track: {artists} - {track.name}")
|
|
75
|
+
try:
|
|
76
|
+
self.lastfm.scrobble(
|
|
77
|
+
artists,
|
|
78
|
+
(track.name or ""),
|
|
79
|
+
self.last_start_time,
|
|
80
|
+
album=((track.album and track.album.name) or ""),
|
|
81
|
+
track_number=track.track_no,
|
|
82
|
+
duration=duration,
|
|
83
|
+
mbid=(str(track.musicbrainz_id) if track.musicbrainz_id else ""),
|
|
84
|
+
)
|
|
85
|
+
except pylast.PyLastError as exc:
|
|
86
|
+
logger.warning(f"Error submitting played track to Last.fm: {exc}")
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mopidy-scrobbler
|
|
3
|
+
Version: 3.0.0
|
|
4
|
+
Summary: Mopidy extension for scrobbling played tracks to Last.fm
|
|
5
|
+
Author-email: Stein Magnus Jodal <stein.magnus@jodal.no>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/mopidy/mopidy-scrobbler
|
|
8
|
+
Classifier: Environment :: No Input/Output (Daemon)
|
|
9
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Players
|
|
13
|
+
Requires-Python: >=3.13
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: mopidy>=4.0.0
|
|
17
|
+
Requires-Dist: pykka>=4.1
|
|
18
|
+
Requires-Dist: pylast>=5.3
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# mopidy-scrobbler
|
|
22
|
+
|
|
23
|
+
[](https://pypi.org/p/mopidy-scrobbler)
|
|
24
|
+
[](https://github.com/mopidy/mopidy-scrobbler/actions/workflows/ci.yml)
|
|
25
|
+
[](https://codecov.io/gh/mopidy/mopidy-scrobbler)
|
|
26
|
+
|
|
27
|
+
[Mopidy](https://www.mopidy.com/) extension for scrobbling played tracks to [Last.fm](https://www.last.fm/).
|
|
28
|
+
|
|
29
|
+
This extension requires a free user account at Last.fm.
|
|
30
|
+
|
|
31
|
+
## Maintainer wanted
|
|
32
|
+
|
|
33
|
+
Mopidy-Scrobbler is currently kept on life support by the Mopidy core developers.
|
|
34
|
+
It is in need of a more dedicated maintainer.
|
|
35
|
+
|
|
36
|
+
If you want to be the maintainer of Mopidy-Scrobbler, please:
|
|
37
|
+
|
|
38
|
+
1. Make 2-3 good pull requests improving any part of the project.
|
|
39
|
+
|
|
40
|
+
2. Read and get familiar with all of the project's open issues.
|
|
41
|
+
|
|
42
|
+
3. Send a pull request removing this section and adding yourself as the
|
|
43
|
+
"Current maintainer" in the "Credits" section below. In the pull request
|
|
44
|
+
description, please refer to the previous pull requests and state that
|
|
45
|
+
you've familiarized yourself with the open issues.
|
|
46
|
+
|
|
47
|
+
As a maintainer, you'll be given push access to the repo and the authority
|
|
48
|
+
to make releases to PyPI when you see fit.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
Install by running:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
python3 -m pip install mopidy-scrobbler
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
See https://mopidy.com/ext/scrobbler/ for alternative installation methods.
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
The extension is enabled by default when it is installed. You just need to add
|
|
63
|
+
your Last.fm username and password to your Mopidy configuration file:
|
|
64
|
+
|
|
65
|
+
```ini
|
|
66
|
+
[scrobbler]
|
|
67
|
+
username = alice
|
|
68
|
+
password = secret
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The following configuration values are available:
|
|
72
|
+
|
|
73
|
+
- `scrobbler/enabled`: If the scrobbler extension should be enabled or not.
|
|
74
|
+
Defaults to enabled.
|
|
75
|
+
- `scrobbler/username`: Your Last.fm username.
|
|
76
|
+
- `scrobbler/password`: Your Last.fm password.
|
|
77
|
+
|
|
78
|
+
## Project resources
|
|
79
|
+
|
|
80
|
+
- [Source code](https://github.com/mopidy/mopidy-scrobbler)
|
|
81
|
+
- [Issues](https://github.com/mopidy/mopidy-scrobbler/issues)
|
|
82
|
+
- [Releases](https://github.com/mopidy/mopidy-scrobbler/releases)
|
|
83
|
+
|
|
84
|
+
## Development
|
|
85
|
+
|
|
86
|
+
### Set up development environment
|
|
87
|
+
|
|
88
|
+
Clone the repo using, e.g. using [gh](https://cli.github.com/):
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
gh repo clone mopidy/mopidy-scrobbler
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Enter the directory, and install dependencies using [uv](https://docs.astral.sh/uv/):
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
cd mopidy-scrobbler/
|
|
98
|
+
uv sync
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Running tests
|
|
102
|
+
|
|
103
|
+
To run all tests and linters in isolated environments, use
|
|
104
|
+
[tox](https://tox.wiki/):
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
tox
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
To only run tests, use [pytest](https://pytest.org/):
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
pytest
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
To format the code, use [ruff](https://docs.astral.sh/ruff/):
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
ruff format .
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
To check for lints with ruff, run:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
ruff check .
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
To check for type errors, use [pyright](https://microsoft.github.io/pyright/):
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
pyright .
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Making a release
|
|
135
|
+
|
|
136
|
+
To make a release to PyPI, go to the project's [GitHub releases
|
|
137
|
+
page](https://github.com/mopidy/mopidy-scrobbler/releases)
|
|
138
|
+
and click the "Draft a new release" button.
|
|
139
|
+
|
|
140
|
+
In the "choose a tag" dropdown, select the tag you want to release or create a
|
|
141
|
+
new tag, e.g. `v0.1.0`. Add a title, e.g. `v0.1.0`, and a description of the changes.
|
|
142
|
+
|
|
143
|
+
Decide if the release is a pre-release (alpha, beta, or release candidate) or
|
|
144
|
+
should be marked as the latest release, and click "Publish release".
|
|
145
|
+
|
|
146
|
+
Once the release is created, the `release.yml` GitHub Action will automatically
|
|
147
|
+
build and publish the release to
|
|
148
|
+
[PyPI](https://pypi.org/project/mopidy-scrobbler/).
|
|
149
|
+
|
|
150
|
+
## Credits
|
|
151
|
+
|
|
152
|
+
- Original author: [Stein Magnus Jodal](https://github.com/jodal)
|
|
153
|
+
- Current maintainer: None. Maintainer wanted, see section above.
|
|
154
|
+
- [Contributors](https://github.com/mopidy/mopidy-scrobbler/graphs/contributors)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.copier-answers.yml
|
|
2
|
+
.gitignore
|
|
3
|
+
LICENSE
|
|
4
|
+
README.md
|
|
5
|
+
pyproject.toml
|
|
6
|
+
.github/workflows/ci.yml
|
|
7
|
+
.github/workflows/release.yml
|
|
8
|
+
src/mopidy_scrobbler/__init__.py
|
|
9
|
+
src/mopidy_scrobbler/ext.conf
|
|
10
|
+
src/mopidy_scrobbler/frontend.py
|
|
11
|
+
src/mopidy_scrobbler.egg-info/PKG-INFO
|
|
12
|
+
src/mopidy_scrobbler.egg-info/SOURCES.txt
|
|
13
|
+
src/mopidy_scrobbler.egg-info/dependency_links.txt
|
|
14
|
+
src/mopidy_scrobbler.egg-info/entry_points.txt
|
|
15
|
+
src/mopidy_scrobbler.egg-info/requires.txt
|
|
16
|
+
src/mopidy_scrobbler.egg-info/top_level.txt
|
|
17
|
+
tests/__init__.py
|
|
18
|
+
tests/test_extension.py
|
|
19
|
+
tests/test_frontend.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mopidy_scrobbler
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from unittest import mock
|
|
2
|
+
|
|
3
|
+
from mopidy_scrobbler import Extension
|
|
4
|
+
from mopidy_scrobbler import frontend as frontend_lib
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_get_default_config() -> None:
|
|
8
|
+
ext = Extension()
|
|
9
|
+
|
|
10
|
+
config = ext.get_default_config()
|
|
11
|
+
|
|
12
|
+
assert "[scrobbler]" in config
|
|
13
|
+
assert "enabled = true" in config
|
|
14
|
+
assert "username =" in config
|
|
15
|
+
assert "password =" in config
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_get_config_schema() -> None:
|
|
19
|
+
ext = Extension()
|
|
20
|
+
|
|
21
|
+
schema = ext.get_config_schema()
|
|
22
|
+
|
|
23
|
+
assert "username" in schema
|
|
24
|
+
assert "password" in schema
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_setup() -> None:
|
|
28
|
+
ext = Extension()
|
|
29
|
+
registry = mock.Mock()
|
|
30
|
+
|
|
31
|
+
ext.setup(registry)
|
|
32
|
+
|
|
33
|
+
registry.add.assert_called_once_with("frontend", frontend_lib.ScrobblerFrontend)
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
from unittest import mock
|
|
2
|
+
from uuid import UUID
|
|
3
|
+
|
|
4
|
+
import pylast
|
|
5
|
+
import pytest
|
|
6
|
+
from mopidy import models
|
|
7
|
+
from mopidy.types import DurationMs, TracklistId, Uri
|
|
8
|
+
|
|
9
|
+
from mopidy_scrobbler import frontend as frontend_lib
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@pytest.fixture
|
|
13
|
+
def pylast_mock():
|
|
14
|
+
with mock.patch("mopidy_scrobbler.frontend.pylast", spec=pylast) as m:
|
|
15
|
+
m.PyLastError = pylast.PyLastError
|
|
16
|
+
yield m
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@pytest.fixture
|
|
20
|
+
def frontend():
|
|
21
|
+
config = {"scrobbler": {"username": "alice", "password": "secret"}}
|
|
22
|
+
core = mock.sentinel.core
|
|
23
|
+
return frontend_lib.ScrobblerFrontend(config, core)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_on_start_creates_lastfm_network(pylast_mock, frontend) -> None:
|
|
27
|
+
pylast_mock.md5.return_value = mock.sentinel.password_hash
|
|
28
|
+
|
|
29
|
+
frontend.on_start()
|
|
30
|
+
|
|
31
|
+
pylast_mock.LastFMNetwork.assert_called_with(
|
|
32
|
+
api_key=frontend_lib.API_KEY,
|
|
33
|
+
api_secret=frontend_lib.API_SECRET,
|
|
34
|
+
username="alice",
|
|
35
|
+
password_hash=mock.sentinel.password_hash,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_on_start_stops_actor_on_error(pylast_mock, frontend) -> None:
|
|
40
|
+
pylast_mock.NetworkError = pylast.NetworkError
|
|
41
|
+
pylast_mock.LastFMNetwork.side_effect = pylast.NetworkError(None, "foo")
|
|
42
|
+
frontend.stop = mock.Mock()
|
|
43
|
+
|
|
44
|
+
frontend.on_start()
|
|
45
|
+
|
|
46
|
+
frontend.stop.assert_called_with()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_track_playback_started_updates_now_playing(pylast_mock, frontend) -> None:
|
|
50
|
+
frontend.lastfm = mock.Mock(spec=pylast.LastFMNetwork)
|
|
51
|
+
artists = frozenset([models.Artist(name="ABC"), models.Artist(name="XYZ")])
|
|
52
|
+
album = models.Album(name="The Collection")
|
|
53
|
+
track = models.Track(
|
|
54
|
+
uri=Uri("test:123"),
|
|
55
|
+
name="One Two Three",
|
|
56
|
+
artists=artists,
|
|
57
|
+
album=album,
|
|
58
|
+
track_no=3,
|
|
59
|
+
length=DurationMs(180432),
|
|
60
|
+
musicbrainz_id=UUID("59e2b08a-f428-4db6-85aa-a757f026aa2a"),
|
|
61
|
+
)
|
|
62
|
+
tl_track = models.TlTrack(track=track, tlid=17)
|
|
63
|
+
|
|
64
|
+
frontend.track_playback_started(tl_track)
|
|
65
|
+
|
|
66
|
+
frontend.lastfm.update_now_playing.assert_called_with(
|
|
67
|
+
"ABC, XYZ",
|
|
68
|
+
"One Two Three",
|
|
69
|
+
duration="180",
|
|
70
|
+
album="The Collection",
|
|
71
|
+
track_number="3",
|
|
72
|
+
mbid="59e2b08a-f428-4db6-85aa-a757f026aa2a",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_track_playback_started_has_default_values(pylast_mock, frontend) -> None:
|
|
77
|
+
frontend.lastfm = mock.Mock(spec=pylast.LastFMNetwork)
|
|
78
|
+
track = models.Track(uri=Uri("test:foo"))
|
|
79
|
+
tl_track = models.TlTrack(track=track, tlid=TracklistId(17))
|
|
80
|
+
|
|
81
|
+
frontend.track_playback_started(tl_track)
|
|
82
|
+
|
|
83
|
+
frontend.lastfm.update_now_playing.assert_called_with(
|
|
84
|
+
"", "", duration="0", album="", track_number="0", mbid=""
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_track_playback_started_catches_pylast_error(pylast_mock, frontend) -> None:
|
|
89
|
+
frontend.lastfm = mock.Mock(spec=pylast.LastFMNetwork)
|
|
90
|
+
pylast_mock.NetworkError = pylast.NetworkError
|
|
91
|
+
frontend.lastfm.update_now_playing.side_effect = pylast.NetworkError(None, "foo")
|
|
92
|
+
track = models.Track(uri=Uri("test:foo"))
|
|
93
|
+
tl_track = models.TlTrack(track=track, tlid=TracklistId(17))
|
|
94
|
+
|
|
95
|
+
frontend.track_playback_started(tl_track)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def test_track_playback_ended_scrobbles_played_track(pylast_mock, frontend) -> None:
|
|
99
|
+
frontend.last_start_time = 123
|
|
100
|
+
frontend.lastfm = mock.Mock(spec=pylast.LastFMNetwork)
|
|
101
|
+
artists = frozenset([models.Artist(name="ABC"), models.Artist(name="XYZ")])
|
|
102
|
+
album = models.Album(name="The Collection")
|
|
103
|
+
track = models.Track(
|
|
104
|
+
uri=Uri("test:123"),
|
|
105
|
+
name="One Two Three",
|
|
106
|
+
artists=artists,
|
|
107
|
+
album=album,
|
|
108
|
+
track_no=3,
|
|
109
|
+
length=DurationMs(180432),
|
|
110
|
+
musicbrainz_id=UUID("59e2b08a-f428-4db6-85aa-a757f026aa2a"),
|
|
111
|
+
)
|
|
112
|
+
tl_track = models.TlTrack(track=track, tlid=17)
|
|
113
|
+
|
|
114
|
+
frontend.track_playback_ended(tl_track, 150000)
|
|
115
|
+
|
|
116
|
+
frontend.lastfm.scrobble.assert_called_with(
|
|
117
|
+
"ABC, XYZ",
|
|
118
|
+
"One Two Three",
|
|
119
|
+
123,
|
|
120
|
+
duration=180,
|
|
121
|
+
album="The Collection",
|
|
122
|
+
track_number=3,
|
|
123
|
+
mbid="59e2b08a-f428-4db6-85aa-a757f026aa2a",
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def test_track_playback_ended_has_default_values(pylast_mock, frontend) -> None:
|
|
128
|
+
frontend.last_start_time = 123
|
|
129
|
+
frontend.lastfm = mock.Mock(spec=pylast.LastFMNetwork)
|
|
130
|
+
track = models.Track(uri=Uri("test:foo"), length=DurationMs(180432))
|
|
131
|
+
tl_track = models.TlTrack(track=track, tlid=TracklistId(17))
|
|
132
|
+
|
|
133
|
+
frontend.track_playback_ended(tl_track, 150000)
|
|
134
|
+
|
|
135
|
+
frontend.lastfm.scrobble.assert_called_with(
|
|
136
|
+
"", "", 123, duration=180, album="", track_number=None, mbid=""
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def test_does_not_scrobble_tracks_shorter_than_30_sec(pylast_mock, frontend) -> None:
|
|
141
|
+
frontend.lastfm = mock.Mock(spec=pylast.LastFMNetwork)
|
|
142
|
+
track = models.Track(uri=Uri("test:foo"), length=DurationMs(20432))
|
|
143
|
+
tl_track = models.TlTrack(track=track, tlid=TracklistId(17))
|
|
144
|
+
|
|
145
|
+
frontend.track_playback_ended(tl_track, 20432)
|
|
146
|
+
|
|
147
|
+
assert frontend.lastfm.scrobble.call_count == 0
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def test_does_not_scrobble_if_played_less_than_half(pylast_mock, frontend) -> None:
|
|
151
|
+
frontend.lastfm = mock.Mock(spec=pylast.LastFMNetwork)
|
|
152
|
+
track = models.Track(uri=Uri("test:foo"), length=DurationMs(180432))
|
|
153
|
+
tl_track = models.TlTrack(track=track, tlid=TracklistId(17))
|
|
154
|
+
|
|
155
|
+
frontend.track_playback_ended(tl_track, 60432)
|
|
156
|
+
|
|
157
|
+
assert frontend.lastfm.scrobble.call_count == 0
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def test_does_scrobble_if_played_not_half_but_240_sec(pylast_mock, frontend) -> None:
|
|
161
|
+
frontend.lastfm = mock.Mock(spec=pylast.LastFMNetwork)
|
|
162
|
+
track = models.Track(uri=Uri("test:foo"), length=DurationMs(180432))
|
|
163
|
+
tl_track = models.TlTrack(track=track, tlid=TracklistId(17))
|
|
164
|
+
|
|
165
|
+
frontend.track_playback_ended(tl_track, 241432)
|
|
166
|
+
|
|
167
|
+
assert frontend.lastfm.scrobble.call_count == 1
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def test_track_playback_ended_catches_pylast_error(pylast_mock, frontend) -> None:
|
|
171
|
+
frontend.lastfm = mock.Mock(spec=pylast.LastFMNetwork)
|
|
172
|
+
pylast_mock.NetworkError = pylast.NetworkError
|
|
173
|
+
frontend.lastfm.scrobble.side_effect = pylast.NetworkError(None, "foo")
|
|
174
|
+
track = models.Track(uri=Uri("test:foo"), length=DurationMs(180432))
|
|
175
|
+
tl_track = models.TlTrack(track=track, tlid=TracklistId(17))
|
|
176
|
+
|
|
177
|
+
frontend.track_playback_ended(tl_track, 150000)
|