Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7ba6360e5 | ||
|
|
8a4880d5ec | ||
|
|
b388e7112d | ||
|
|
b878523d51 | ||
|
|
016fc707d1 | ||
|
|
9243fe4d3f | ||
|
|
c55a6596d0 | ||
|
|
81e0b0cf42 | ||
|
|
6649cbbcae | ||
|
|
65ee13fa65 | ||
|
|
9e4218f11b | ||
|
|
aadb1c6def | ||
|
|
2c4c42a42b | ||
|
|
ad383b602e | ||
|
|
65cd610468 | ||
|
|
735556bf21 | ||
|
|
524b78a075 | ||
|
|
9c84a64d4e | ||
|
|
bee83cb9f3 | ||
|
|
87edaafe19 | ||
|
|
a887865f05 | ||
|
|
d0b8e1ed22 | ||
|
|
48fba1e0e2 | ||
|
|
6cd17d7586 | ||
|
|
83b27d7ba1 | ||
|
|
79193fbc8e | ||
|
|
2b984cca6e | ||
|
|
44abd70caa | ||
|
|
f106d68921 | ||
|
|
dfd2ef868b | ||
|
|
5bdeeddb0b | ||
|
|
7b169ea807 | ||
|
|
457e051828 | ||
|
|
25a7ac7a20 | ||
|
|
ae24c4a00e | ||
|
|
86bf9fd302 | ||
|
|
bef41fc2cc | ||
|
|
e1704b0b54 | ||
|
|
88b53df909 | ||
|
|
d2f457a84d | ||
|
|
50e2360d14 | ||
|
|
b307b11440 | ||
|
|
dfdb5285da | ||
|
|
df8a114a0c |
No files matched your search
@@ -10,12 +10,32 @@ CORS_ORIGINS=http://localhost:8080
|
|||||||
# Where Last.fm clients are redirected to approve desktop auth tokens.
|
# Where Last.fm clients are redirected to approve desktop auth tokens.
|
||||||
UI_BASE_URL=http://localhost:8080
|
UI_BASE_URL=http://localhost:8080
|
||||||
|
|
||||||
|
# Logging: level (DEBUG, INFO, WARNING, ERROR) and format ("text", or "json" for log aggregators).
|
||||||
|
LOG_LEVEL=INFO
|
||||||
|
LOG_FORMAT=text
|
||||||
|
|
||||||
# Prometheus metrics are served on a separate port.
|
# Prometheus metrics are served on a separate port.
|
||||||
METRICS_PORT=9100
|
METRICS_PORT=9100
|
||||||
|
|
||||||
# Set to allow importing history straight from Last.fm (https://www.last.fm/api/account/create).
|
# Set to allow importing history straight from Last.fm (https://www.last.fm/api/account/create).
|
||||||
LASTFM_API_KEY=
|
LASTFM_API_KEY=
|
||||||
|
|
||||||
|
# Album art (MusicBrainz + Cover Art Archive, both free and keyless — no setup required).
|
||||||
|
# MusicBrainz asks for a contact URL/email in requests; falls back to UI_BASE_URL if unset.
|
||||||
|
MUSICBRAINZ_CONTACT=
|
||||||
|
# Where downloaded art is stored. docker compose points this at a shared volume; the
|
||||||
|
# default below is for running the api/worker directly (not in Docker).
|
||||||
|
ART_STORAGE_DIR=var/album-art
|
||||||
|
# Largest image a user may upload as their own album art (bytes). Uploaded art is
|
||||||
|
# stored in ART_STORAGE_DIR too, so back that directory up.
|
||||||
|
ART_UPLOAD_MAX_BYTES=5242880
|
||||||
|
# Largest profile image a user may upload (bytes). Stored in an "avatars" folder inside
|
||||||
|
# ART_STORAGE_DIR, so the same backups cover it.
|
||||||
|
AVATAR_UPLOAD_MAX_BYTES=2097152
|
||||||
|
# Let users use their Gravatar as their profile image. The server fetches it, sending
|
||||||
|
# Gravatar a hash of the user's email address, so it's off unless you turn it on.
|
||||||
|
AVATAR_GRAVATAR_ENABLED=false
|
||||||
|
|
||||||
# docker compose host ports (defaults shown)
|
# docker compose host ports (defaults shown)
|
||||||
API_PORT=5050
|
API_PORT=5050
|
||||||
UI_PORT=8080
|
UI_PORT=8080
|
||||||
|
|||||||
@@ -78,20 +78,19 @@ jobs:
|
|||||||
run: for f in deploy/grafana/dashboards/*.json; do python3 -m json.tool "$f" > /dev/null; done
|
run: for f in deploy/grafana/dashboards/*.json; do python3 -m json.tool "$f" > /dev/null; done
|
||||||
|
|
||||||
federation-interop:
|
federation-interop:
|
||||||
# A real GoToSocial server follows a Scrobbler user (see scripts/interop/run.sh).
|
# A real GoToSocial server follows a Scrobbled user (see scripts/interop/run.sh).
|
||||||
# Not for pull requests from forks: it runs containers on the runner's Docker.
|
# Not for pull requests from forks: it runs containers on the runner's Docker.
|
||||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Scrobbler <-> GoToSocial
|
- name: Scrobbled <-> GoToSocial
|
||||||
env:
|
env:
|
||||||
|
# Own compose project, network and image tags, so concurrent runs can't collide
|
||||||
INTEROP_PROJECT: interop-${{ github.run_id }}
|
INTEROP_PROJECT: interop-${{ github.run_id }}
|
||||||
run: |
|
SCROBBLER_IMAGE_TAG: interop-${{ github.run_id }}
|
||||||
# A subnet of its own, so concurrent runs can't collide
|
run: scripts/interop/run.sh
|
||||||
export INTEROP_SUBNET="172.30.$(( ${{ github.run_number }} % 200 + 20 )).0/24"
|
|
||||||
scripts/interop/run.sh
|
|
||||||
|
|
||||||
# ---- Publishing (main and v* tags only) -------------------------------------
|
# ---- Publishing (main and v* tags only) -------------------------------------
|
||||||
|
|
||||||
@@ -101,6 +100,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
tags: ${{ steps.version.outputs.image_tags }}
|
tags: ${{ steps.version.outputs.image_tags }}
|
||||||
|
version: ${{ steps.version.outputs.version }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: https://github.com/astral-sh/setup-uv@v6
|
- uses: https://github.com/astral-sh/setup-uv@v6
|
||||||
@@ -179,8 +179,24 @@ jobs:
|
|||||||
--publish-url "https://${{ vars.PKGS_HOST }}/pypi/${{ vars.PKGS_PYPI_FEED }}/legacy"
|
--publish-url "https://${{ vars.PKGS_HOST }}/pypi/${{ vars.PKGS_PYPI_FEED }}/legacy"
|
||||||
--username api --password "${{ secrets.PKGS_API_KEY }}"
|
--username api --password "${{ secrets.PKGS_API_KEY }}"
|
||||||
|
|
||||||
|
trigger-deploy:
|
||||||
|
needs: [images]
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Trigger ScrobbledDeploy
|
||||||
|
env:
|
||||||
|
VERSION: ${{ needs.images.outputs.version }}
|
||||||
|
TOKEN: ${{ secrets.SCROBBLEDDEPLOY_DISPATCH_TOKEN }}
|
||||||
|
run: |
|
||||||
|
curl -fsS -X POST \
|
||||||
|
-H "Authorization: token ${TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"ref\":\"main\",\"inputs\":{\"image_tag\":\"${VERSION}\"}}" \
|
||||||
|
"https://git.daubney.dev/api/v1/repos/matt/ScrobbledDeploy/actions/workflows/deploy.yml/dispatches"
|
||||||
|
|
||||||
notify:
|
notify:
|
||||||
needs: [lint, test, validate-monitoring, federation-interop, images, assets, python-package]
|
needs: [lint, test, validate-monitoring, federation-interop, images, assets, python-package, trigger-deploy]
|
||||||
if: always()
|
if: always()
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ htmlcov/
|
|||||||
|
|
||||||
# Runtime
|
# Runtime
|
||||||
prometheus_multiproc/
|
prometheus_multiproc/
|
||||||
|
var/album-art/
|
||||||
|
|
||||||
# IDEs
|
# IDEs
|
||||||
.idea/
|
.idea/
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Artwork licence
|
||||||
|
|
||||||
|
Copyright (c) 2026 Matthew Daubney. All rights reserved.
|
||||||
|
|
||||||
|
This applies to the Scrobbled logo and everything derived from it: the record and
|
||||||
|
tonearm mark, the wordmark and the icon files. In this repository that is
|
||||||
|
`frontend/img/`, `frontend/favicon.*`, `frontend/apple-touch-icon.png`,
|
||||||
|
`frontend/icon-*.png` and the mark drawn by `.brand-mark` in the web UI. The rest
|
||||||
|
of the repository is under [LICENSE](LICENSE).
|
||||||
|
|
||||||
|
## Permitted use
|
||||||
|
|
||||||
|
You may use the Scrobbled name and logo, unmodified, to refer to the Scrobbled
|
||||||
|
product. For example, in an article, review, tutorial, integration listing or
|
||||||
|
"works with Scrobbled" mention.
|
||||||
|
|
||||||
|
When you do:
|
||||||
|
|
||||||
|
- Use the files as supplied. Scaling is fine. Don't recolour, redraw, crop,
|
||||||
|
distort, animate or combine them with other marks.
|
||||||
|
- Don't use the logo in a way that suggests Scrobbled made, endorsed or
|
||||||
|
sponsors your product, service or organisation.
|
||||||
|
- Don't use the logo, or anything confusingly similar, as the name or logo of
|
||||||
|
your own product, app or business.
|
||||||
|
|
||||||
|
## Everything else
|
||||||
|
|
||||||
|
Any other use needs written permission first. That includes modifying the
|
||||||
|
artwork, selling it or merchandise bearing it, and using it as part of another
|
||||||
|
brand. To ask, contact Matthew Daubney.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Scrobbler
|
# Scrobbled
|
||||||
|
|
||||||
A self-hosted music scrobbling service. It speaks the **Last.fm (Audioscrobbler 2.0) API**,
|
A self-hosted music scrobbling service. It speaks the **Last.fm (Audioscrobbler 2.0) API**,
|
||||||
so players and scrobblers that let you set a custom Last.fm server can use it unchanged.
|
so players and scrobblers that let you set a custom Last.fm server can use it unchanged.
|
||||||
@@ -15,12 +15,12 @@ Prometheus ◄── API :9100/metrics, postgres-exporter ──► Grafana
|
|||||||
|
|
||||||
## Docs
|
## Docs
|
||||||
|
|
||||||
- **[Deploy](docs/deploy.md)** — running a real instance: images, configuration, TLS,
|
- **[Admin guide](docs/admin-guide.md)** — running a real instance: images,
|
||||||
monitoring, backups, releases.
|
configuration, TLS, monitoring, backups, upgrades, troubleshooting.
|
||||||
|
- **[User guide](docs/user-guide.md)** — accounts and apps, connecting a player,
|
||||||
|
importing history, sharing on the fediverse.
|
||||||
- **[Set up](docs/setup.md)** — working on the code: local dev environment, migrations,
|
- **[Set up](docs/setup.md)** — working on the code: local dev environment, migrations,
|
||||||
tests, CI/CD.
|
tests, CI/CD.
|
||||||
- **[Use](docs/usage.md)** — accounts and apps, connecting a player, importing history,
|
|
||||||
sharing on the fediverse.
|
|
||||||
- **API reference**: `/api/openapi.json`, Swagger UI at `/api/docs`, ReDoc at
|
- **API reference**: `/api/openapi.json`, Swagger UI at `/api/docs`, ReDoc at
|
||||||
`/api/redoc` (a copy is committed at `docs/openapi.json`).
|
`/api/redoc` (a copy is committed at `docs/openapi.json`).
|
||||||
- **Federation internals**: `src/scrobbler/federation/README.md`. Design docs for how it
|
- **Federation internals**: `src/scrobbler/federation/README.md`. Design docs for how it
|
||||||
@@ -34,10 +34,11 @@ docker compose up -d # db, api (:5050), worker, ui (:8080)
|
|||||||
```
|
```
|
||||||
|
|
||||||
Open http://localhost:8080, create an account, then go to **Apps** and create an app for
|
Open http://localhost:8080, create an account, then go to **Apps** and create an app for
|
||||||
a player. See [docs/deploy.md](docs/deploy.md) for the published images, full
|
a player. See [docs/admin-guide.md](docs/admin-guide.md) for the published images, full
|
||||||
configuration reference and production notes.
|
configuration reference and production notes.
|
||||||
|
|
||||||
## Licence
|
## Licence
|
||||||
|
|
||||||
BSD 3-Clause; see [LICENSE](LICENSE). The fonts vendored in `frontend/fonts/` are under
|
BSD 3-Clause; see [LICENSE](LICENSE). The fonts vendored in `frontend/fonts/` are under
|
||||||
the SIL Open Font License 1.1.
|
the SIL Open Font License 1.1. The Scrobbled logo, wordmark and icons are not BSD-licensed:
|
||||||
|
they are all rights reserved, see [LICENSE-ARTWORK.md](LICENSE-ARTWORK.md).
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"uid": "scrobbler-api-overview",
|
"uid": "scrobbler-api-overview",
|
||||||
"title": "Scrobbler: API overview",
|
"title": "Scrobbled: API overview",
|
||||||
"description": "Rate, errors and duration for every endpoint of the Scrobbler API.",
|
"description": "Rate, errors and duration for every endpoint of the Scrobbled API.",
|
||||||
"tags": [
|
"tags": [
|
||||||
"scrobbler"
|
"scrobbler"
|
||||||
],
|
],
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
"scrobbler"
|
"scrobbler"
|
||||||
],
|
],
|
||||||
"asDropdown": true,
|
"asDropdown": true,
|
||||||
"title": "Scrobbler",
|
"title": "Scrobbled",
|
||||||
"includeVars": false
|
"includeVars": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"uid": "scrobbler-database",
|
"uid": "scrobbler-database",
|
||||||
"title": "Scrobbler: Database",
|
"title": "Scrobbled: Database",
|
||||||
"description": "Query latency and pool use from the app's side; Postgres health from postgres-exporter.",
|
"description": "Query latency and pool use from the app's side; Postgres health from postgres-exporter.",
|
||||||
"tags": [
|
"tags": [
|
||||||
"scrobbler"
|
"scrobbler"
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
"scrobbler"
|
"scrobbler"
|
||||||
],
|
],
|
||||||
"asDropdown": true,
|
"asDropdown": true,
|
||||||
"title": "Scrobbler",
|
"title": "Scrobbled",
|
||||||
"includeVars": false
|
"includeVars": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"uid": "scrobbler-federation",
|
"uid": "scrobbler-federation",
|
||||||
"title": "Scrobbler: Federation",
|
"title": "Scrobbled: Federation",
|
||||||
"description": "ActivityPub: how the fediverse finds and talks to users sharing their listening. Empty unless FEDERATION_ENABLED is on.",
|
"description": "ActivityPub: how the fediverse finds and talks to users sharing their listening. Empty unless FEDERATION_ENABLED is on.",
|
||||||
"tags": [
|
"tags": [
|
||||||
"scrobbler"
|
"scrobbler"
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
"scrobbler"
|
"scrobbler"
|
||||||
],
|
],
|
||||||
"asDropdown": true,
|
"asDropdown": true,
|
||||||
"title": "Scrobbler",
|
"title": "Scrobbled",
|
||||||
"includeVars": false
|
"includeVars": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"uid": "scrobbler-lastfm",
|
"uid": "scrobbler-lastfm",
|
||||||
"title": "Scrobbler: Last.fm API",
|
"title": "Scrobbled: Last.fm API",
|
||||||
"description": "The Last.fm-compatible /2.0/ API: which methods clients call, what fails, and what happens to scrobbles.",
|
"description": "The Last.fm-compatible /2.0/ API: which methods clients call, what fails, and what happens to scrobbles.",
|
||||||
"tags": [
|
"tags": [
|
||||||
"scrobbler"
|
"scrobbler"
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
"scrobbler"
|
"scrobbler"
|
||||||
],
|
],
|
||||||
"asDropdown": true,
|
"asDropdown": true,
|
||||||
"title": "Scrobbler",
|
"title": "Scrobbled",
|
||||||
"includeVars": false
|
"includeVars": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"uid": "scrobbler-usage",
|
"uid": "scrobbler-usage",
|
||||||
"title": "Scrobbler: Usage",
|
"title": "Scrobbled: Usage",
|
||||||
"description": "Who is using the service and how much they're listening.",
|
"description": "Who is using the service and how much they're listening.",
|
||||||
"tags": [
|
"tags": [
|
||||||
"scrobbler"
|
"scrobbler"
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
"scrobbler"
|
"scrobbler"
|
||||||
],
|
],
|
||||||
"asDropdown": true,
|
"asDropdown": true,
|
||||||
"title": "Scrobbler",
|
"title": "Scrobbled",
|
||||||
"includeVars": false
|
"includeVars": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -989,6 +989,131 @@
|
|||||||
"w": 12,
|
"w": 12,
|
||||||
"h": 8
|
"h": 8
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "row",
|
||||||
|
"title": "Album art",
|
||||||
|
"id": 21,
|
||||||
|
"collapsed": false,
|
||||||
|
"gridPos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 54,
|
||||||
|
"w": 24,
|
||||||
|
"h": 1
|
||||||
|
},
|
||||||
|
"panels": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stat",
|
||||||
|
"title": "Albums needing manual art",
|
||||||
|
"description": "Not found or errored in the shared cache, and not fixed by any user. See the Album Art dashboard.",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "max(scrobbler_art_unresolved_albums)",
|
||||||
|
"legendFormat": "__auto",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "short",
|
||||||
|
"decimals": 0,
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "text",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "area",
|
||||||
|
"textMode": "auto",
|
||||||
|
"justifyMode": "auto"
|
||||||
|
},
|
||||||
|
"id": 22,
|
||||||
|
"gridPos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 55,
|
||||||
|
"w": 6,
|
||||||
|
"h": 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stat",
|
||||||
|
"title": "Pending art corrections",
|
||||||
|
"description": "",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "max(scrobbler_art_overrides{kind=\"correction\",status=\"pending\"})",
|
||||||
|
"legendFormat": "__auto",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "short",
|
||||||
|
"decimals": 0,
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "text",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"reduceOptions": {
|
||||||
|
"calcs": [
|
||||||
|
"lastNotNull"
|
||||||
|
],
|
||||||
|
"fields": "",
|
||||||
|
"values": false
|
||||||
|
},
|
||||||
|
"colorMode": "value",
|
||||||
|
"graphMode": "area",
|
||||||
|
"textMode": "auto",
|
||||||
|
"justifyMode": "auto"
|
||||||
|
},
|
||||||
|
"id": 23,
|
||||||
|
"gridPos": {
|
||||||
|
"x": 6,
|
||||||
|
"y": 55,
|
||||||
|
"w": 6,
|
||||||
|
"h": 5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
apiVersion: 1
|
apiVersion: 1
|
||||||
providers:
|
providers:
|
||||||
- name: scrobbler
|
- name: scrobbler
|
||||||
folder: Scrobbler
|
folder: Scrobbled
|
||||||
type: file
|
type: file
|
||||||
allowUiUpdates: true
|
allowUiUpdates: true
|
||||||
options:
|
options:
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# Federation interop test: Scrobbler and a real GoToSocial server on one private network.
|
# Federation interop test: Scrobbled and a real GoToSocial server on one private network.
|
||||||
#
|
#
|
||||||
# docker compose -f docker-compose.yml -f deploy/interop/docker-compose.interop.yml up -d --build
|
# docker compose -f docker-compose.yml -f deploy/interop/docker-compose.interop.yml up -d --build
|
||||||
# ...create the GoToSocial user (see scripts/interop/run.sh), then run the driver.
|
# ...create the GoToSocial user (see scripts/interop/run.sh), then run the driver.
|
||||||
#
|
#
|
||||||
# TEST ONLY: GoToSocial runs over plain HTTP and skips TLS verification; Scrobbler is
|
# TEST ONLY: GoToSocial runs over plain HTTP and skips TLS verification; Scrobbled is
|
||||||
# served over HTTPS by a Caddy proxy with a throwaway certificate, and its "insecure
|
# served over HTTPS by a Caddy proxy with a throwaway certificate, and its "insecure
|
||||||
# testing" switch lets it reach GoToSocial over HTTP on this private network. All on the
|
# testing" switch lets it reach GoToSocial over HTTP on this private network. All on the
|
||||||
# reserved .test domain. Never use these settings anywhere else.
|
# reserved .test domain. Never use these settings anywhere else.
|
||||||
@@ -18,11 +18,10 @@ x-federation: &federation
|
|||||||
FEDERATION_INSECURE_TESTING: "1"
|
FEDERATION_INSECURE_TESTING: "1"
|
||||||
UI_BASE_URL: https://scrobble.test
|
UI_BASE_URL: https://scrobble.test
|
||||||
|
|
||||||
|
# Docker picks the network's subnet, so concurrent runs can't collide on one. GoToSocial
|
||||||
|
# is therefore told to trust any private range rather than one specific /24.
|
||||||
networks:
|
networks:
|
||||||
fedi:
|
fedi:
|
||||||
ipam:
|
|
||||||
config:
|
|
||||||
- subnet: ${INTEROP_SUBNET:-172.30.0.0/24}
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
@@ -63,9 +62,9 @@ services:
|
|||||||
GTS_PORT: "80"
|
GTS_PORT: "80"
|
||||||
GTS_DB_TYPE: sqlite
|
GTS_DB_TYPE: sqlite
|
||||||
GTS_DB_ADDRESS: /gotosocial/storage/sqlite.db
|
GTS_DB_ADDRESS: /gotosocial/storage/sqlite.db
|
||||||
GTS_HTTP_CLIENT_ALLOW_IPS: ${INTEROP_SUBNET:-172.30.0.0/24} # let it reach Scrobbler on this network
|
GTS_HTTP_CLIENT_ALLOW_IPS: ${INTEROP_PRIVATE_RANGES:-10.0.0.0/8,172.16.0.0/12,192.168.0.0/16} # let it reach Scrobbled on this network
|
||||||
GTS_HTTP_CLIENT_TLS_INSECURE_SKIP_VERIFY: "true" # Caddy's throwaway certificate
|
GTS_HTTP_CLIENT_TLS_INSECURE_SKIP_VERIFY: "true" # Caddy's throwaway certificate
|
||||||
GTS_TRUSTED_PROXIES: ${INTEROP_SUBNET:-172.30.0.0/24}
|
GTS_TRUSTED_PROXIES: ${INTEROP_PRIVATE_RANGES:-10.0.0.0/8,172.16.0.0/12,192.168.0.0/16}
|
||||||
GTS_ACCOUNTS_REGISTRATION_OPEN: "false"
|
GTS_ACCOUNTS_REGISTRATION_OPEN: "false"
|
||||||
GTS_LOG_LEVEL: ${GTS_LOG_LEVEL:-info}
|
GTS_LOG_LEVEL: ${GTS_LOG_LEVEL:-info}
|
||||||
sysctls:
|
sysctls:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ server {
|
|||||||
try_files $uri $uri/ =404;
|
try_files $uri $uri/ =404;
|
||||||
# Files aren't fingerprinted, so always revalidate.
|
# Files aren't fingerprinted, so always revalidate.
|
||||||
add_header Cache-Control "no-cache";
|
add_header Cache-Control "no-cache";
|
||||||
add_header Content-Security-Policy "default-src 'self'; connect-src 'self' ${API_BASE_URL}; img-src 'self' data:; style-src 'self'; font-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'" always;
|
add_header Content-Security-Policy "default-src 'self'; connect-src 'self' ${API_BASE_URL}; img-src 'self' data: blob:; style-src 'self'; font-src 'self'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'" always;
|
||||||
add_header X-Content-Type-Options nosniff always;
|
add_header X-Content-Type-Options nosniff always;
|
||||||
add_header Referrer-Policy same-origin always;
|
add_header Referrer-Policy same-origin always;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ groups:
|
|||||||
for: 2m
|
for: 2m
|
||||||
labels: {severity: critical}
|
labels: {severity: critical}
|
||||||
annotations:
|
annotations:
|
||||||
summary: Scrobbler API metrics endpoint is down
|
summary: Scrobbled API metrics endpoint is down
|
||||||
description: Prometheus hasn't been able to scrape {{ $labels.instance }} for 2 minutes.
|
description: Prometheus hasn't been able to scrape {{ $labels.instance }} for 2 minutes.
|
||||||
|
|
||||||
- alert: HighErrorRate
|
- alert: HighErrorRate
|
||||||
@@ -107,6 +107,43 @@ groups:
|
|||||||
summary: More than 20% of incoming fediverse signatures are failing
|
summary: More than 20% of incoming fediverse signatures are failing
|
||||||
description: Check the Federation dashboard for the reason (e.g. a clock problem shows as 'expired').
|
description: Check the Federation dashboard for the reason (e.g. a clock problem shows as 'expired').
|
||||||
|
|
||||||
|
- alert: AlbumArtBacklog
|
||||||
|
expr: max(scrobbler_art_oldest_pending_seconds) > 900
|
||||||
|
for: 10m
|
||||||
|
labels: {severity: warning}
|
||||||
|
annotations:
|
||||||
|
summary: Album art requests have been waiting over 15 minutes
|
||||||
|
description: The worker is probably stopped, or MusicBrainz / Cover Art Archive is failing.
|
||||||
|
|
||||||
|
- alert: AlbumArtUpstreamErrors
|
||||||
|
expr: |
|
||||||
|
sum by (service) (rate(scrobbler_art_upstream_errors_total[15m]))
|
||||||
|
/ sum by (service) (rate(scrobbler_art_upstream_seconds_count[15m])) > 0.5
|
||||||
|
for: 15m
|
||||||
|
labels: {severity: warning}
|
||||||
|
annotations:
|
||||||
|
summary: Over half of {{ $labels.service }} album art calls are failing
|
||||||
|
description: Failed lookups are cached as errors and retried later; check the upstream's status.
|
||||||
|
|
||||||
|
- alert: AlbumArtCorrectionBacklog
|
||||||
|
expr: max(scrobbler_art_override_oldest_pending_seconds) > 900
|
||||||
|
for: 10m
|
||||||
|
labels: {severity: warning}
|
||||||
|
annotations:
|
||||||
|
summary: A manual album art correction has been waiting over 15 minutes
|
||||||
|
description: The worker is probably stopped, or MusicBrainz / Cover Art Archive is failing.
|
||||||
|
|
||||||
|
- alert: AlbumArtUploadRejections
|
||||||
|
expr: |
|
||||||
|
sum(rate(scrobbler_art_uploads_total{result!="ok"}[30m]))
|
||||||
|
/ sum(rate(scrobbler_art_uploads_total[30m])) > 0.5
|
||||||
|
and sum(rate(scrobbler_art_uploads_total[30m])) > 0.002
|
||||||
|
for: 30m
|
||||||
|
labels: {severity: warning}
|
||||||
|
annotations:
|
||||||
|
summary: Most album art uploads are being rejected
|
||||||
|
description: Check the Album Art dashboard for the reason (too_large suggests ART_UPLOAD_MAX_BYTES or a proxy limit; bad_type a client sending the wrong format).
|
||||||
|
|
||||||
- alert: PostgresDown
|
- alert: PostgresDown
|
||||||
expr: pg_up == 0
|
expr: pg_up == 0
|
||||||
for: 2m
|
for: 2m
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ services:
|
|||||||
UI_BASE_URL: ${UI_BASE_URL:-http://localhost:8080}
|
UI_BASE_URL: ${UI_BASE_URL:-http://localhost:8080}
|
||||||
WEB_CONCURRENCY: ${WEB_CONCURRENCY:-2}
|
WEB_CONCURRENCY: ${WEB_CONCURRENCY:-2}
|
||||||
FORWARDED_ALLOW_IPS: "*"
|
FORWARDED_ALLOW_IPS: "*"
|
||||||
|
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
||||||
|
LOG_FORMAT: ${LOG_FORMAT:-text}
|
||||||
LASTFM_API_KEY: ${LASTFM_API_KEY:-}
|
LASTFM_API_KEY: ${LASTFM_API_KEY:-}
|
||||||
|
MUSICBRAINZ_CONTACT: ${MUSICBRAINZ_CONTACT:-}
|
||||||
|
ART_STORAGE_DIR: ${ART_STORAGE_DIR:-/data/album-art}
|
||||||
FEDERATION_ENABLED: ${FEDERATION_ENABLED:-0}
|
FEDERATION_ENABLED: ${FEDERATION_ENABLED:-0}
|
||||||
FEDERATION_DOMAIN: ${FEDERATION_DOMAIN:-}
|
FEDERATION_DOMAIN: ${FEDERATION_DOMAIN:-}
|
||||||
FEDERATION_BASE_URL: ${FEDERATION_BASE_URL:-}
|
FEDERATION_BASE_URL: ${FEDERATION_BASE_URL:-}
|
||||||
@@ -42,6 +46,8 @@ services:
|
|||||||
- "${API_PORT:-5050}:8000"
|
- "${API_PORT:-5050}:8000"
|
||||||
expose:
|
expose:
|
||||||
- "9100" # metrics: internal network only
|
- "9100" # metrics: internal network only
|
||||||
|
volumes:
|
||||||
|
- album-art-data:/data/album-art
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -57,13 +63,19 @@ services:
|
|||||||
DATABASE_URL: postgresql+psycopg://scrobbler:${POSTGRES_PASSWORD:-scrobbler}@db:5432/scrobbler
|
DATABASE_URL: postgresql+psycopg://scrobbler:${POSTGRES_PASSWORD:-scrobbler}@db:5432/scrobbler
|
||||||
SECRET_KEY: ${SECRET_KEY:-change-me}
|
SECRET_KEY: ${SECRET_KEY:-change-me}
|
||||||
LASTFM_API_KEY: ${LASTFM_API_KEY:-}
|
LASTFM_API_KEY: ${LASTFM_API_KEY:-}
|
||||||
|
MUSICBRAINZ_CONTACT: ${MUSICBRAINZ_CONTACT:-}
|
||||||
|
ART_STORAGE_DIR: ${ART_STORAGE_DIR:-/data/album-art}
|
||||||
FEDERATION_ENABLED: ${FEDERATION_ENABLED:-0}
|
FEDERATION_ENABLED: ${FEDERATION_ENABLED:-0}
|
||||||
FEDERATION_DOMAIN: ${FEDERATION_DOMAIN:-}
|
FEDERATION_DOMAIN: ${FEDERATION_DOMAIN:-}
|
||||||
FEDERATION_BASE_URL: ${FEDERATION_BASE_URL:-}
|
FEDERATION_BASE_URL: ${FEDERATION_BASE_URL:-}
|
||||||
FEDERATION_KEY_SECRET: ${FEDERATION_KEY_SECRET:-}
|
FEDERATION_KEY_SECRET: ${FEDERATION_KEY_SECRET:-}
|
||||||
RUN_MIGRATIONS: "0" # the api service applies them
|
RUN_MIGRATIONS: "0" # the api service applies them
|
||||||
|
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
||||||
|
LOG_FORMAT: ${LOG_FORMAT:-text}
|
||||||
expose:
|
expose:
|
||||||
- "9101" # metrics: internal network only
|
- "9101" # metrics: internal network only
|
||||||
|
volumes:
|
||||||
|
- album-art-data:/data/album-art
|
||||||
healthcheck:
|
healthcheck:
|
||||||
disable: true
|
disable: true
|
||||||
depends_on:
|
depends_on:
|
||||||
@@ -123,5 +135,6 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
db-data:
|
db-data:
|
||||||
|
album-art-data:
|
||||||
prometheus-data:
|
prometheus-data:
|
||||||
grafana-data:
|
grafana-data:
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Scrobbler API: gunicorn serving the Flask app, metrics on :9100.
|
# Scrobbled API: gunicorn serving the Flask app, metrics on :9100.
|
||||||
FROM ghcr.io/astral-sh/uv:0.7.21 AS uv
|
FROM ghcr.io/astral-sh/uv:0.7.21 AS uv
|
||||||
|
|
||||||
FROM python:3.13-slim AS build
|
FROM python:3.13-slim AS build
|
||||||
@@ -13,6 +13,8 @@ RUN uv sync --locked --no-dev --no-editable
|
|||||||
FROM python:3.13-slim
|
FROM python:3.13-slim
|
||||||
LABEL org.opencontainers.image.licenses="BSD-3-Clause"
|
LABEL org.opencontainers.image.licenses="BSD-3-Clause"
|
||||||
RUN useradd --system --uid 10001 --no-create-home scrobbler
|
RUN useradd --system --uid 10001 --no-create-home scrobbler
|
||||||
|
# Downloaded album art lives here, on a volume shared with the worker (which writes it).
|
||||||
|
RUN mkdir -p /data/album-art && chown scrobbler:scrobbler /data/album-art
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app/.venv /app/.venv
|
COPY --from=build /app/.venv /app/.venv
|
||||||
COPY gunicorn.conf.py docker/api-entrypoint.sh ./
|
COPY gunicorn.conf.py docker/api-entrypoint.sh ./
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Scrobbler web UI: static files served by nginx.
|
# Scrobbled web UI: static files served by nginx.
|
||||||
FROM nginx:1.29-alpine
|
FROM nginx:1.29-alpine
|
||||||
LABEL org.opencontainers.image.licenses="BSD-3-Clause"
|
LABEL org.opencontainers.image.licenses="BSD-3-Clause"
|
||||||
ENV API_BASE_URL=http://localhost:5050
|
ENV API_BASE_URL=http://localhost:5050
|
||||||
|
|||||||
@@ -0,0 +1,285 @@
|
|||||||
|
# Admin guide
|
||||||
|
|
||||||
|
Running a real Scrobbled instance: architecture, installation, configuration, TLS,
|
||||||
|
fediverse sharing, monitoring, backups, upgrades and troubleshooting. If you're using an
|
||||||
|
instance someone else runs, see the [user guide](user-guide.md) instead. If you're
|
||||||
|
working on Scrobbled's own code, see [setup.md](setup.md).
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
```
|
||||||
|
players / scrobblers ──► API /2.0/ Last.fm-compatible
|
||||||
|
web UI (static files) ──► API /api/v1/ JSON API for the UI
|
||||||
|
API ──► PostgreSQL
|
||||||
|
Prometheus ◄── API :9100/metrics, postgres-exporter ──► Grafana
|
||||||
|
```
|
||||||
|
|
||||||
|
- **`api`**: Flask under gunicorn. API-only; it serves no HTML pages.
|
||||||
|
- **`ui`**: nginx serving the static frontend (`frontend/`, no build step).
|
||||||
|
- **`worker`**: `flask worker` — history imports, resolving and downloading album art
|
||||||
|
(MusicBrainz + Cover Art Archive), and background tasks for optional modules
|
||||||
|
(federation's deliveries, scheduled posts, and so on). This is the only service that
|
||||||
|
makes outbound calls to third-party APIs (Last.fm, MusicBrainz, Cover Art Archive, and
|
||||||
|
remote fediverse servers with federation on) — worth knowing if you're restricting
|
||||||
|
egress.
|
||||||
|
- **`db`**: PostgreSQL.
|
||||||
|
- With the `monitoring` profile: `prometheus`, `grafana`, `postgres-exporter`.
|
||||||
|
|
||||||
|
Everything Scrobbled needs to run is in these five services plus optional monitoring —
|
||||||
|
there's no separate cache, queue or search service to operate.
|
||||||
|
|
||||||
|
## Installing
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cp .env.example .env # then set SECRET_KEY and POSTGRES_PASSWORD
|
||||||
|
SCROBBLER_IMAGE_TAG=main docker compose up -d --no-build # or drop --no-build to build locally
|
||||||
|
```
|
||||||
|
|
||||||
|
Open `http://localhost:8080`, create an account, then go to **Apps** and create an app
|
||||||
|
for each player. Add `--profile monitoring` for Prometheus and Grafana.
|
||||||
|
|
||||||
|
Published images: `pkgs.daubney.dev/scrobbler/scrobbler-api` and
|
||||||
|
`pkgs.daubney.dev/scrobbler/scrobbler-ui`, tagged `main` (latest push to `main`),
|
||||||
|
`sha-<commit>`, and `<version>`/`latest` for tagged releases.
|
||||||
|
|
||||||
|
This is enough for evaluating Scrobbled. Before putting it in front of real users, also
|
||||||
|
read **Putting it behind TLS** below — the quick start above serves plain HTTP only.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
| Variable | Used by | Default | Purpose |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `DATABASE_URL` | api | local Postgres | SQLAlchemy URL (`postgresql+psycopg://…`) |
|
||||||
|
| `SECRET_KEY` | api | `dev-insecure-secret` | Flask secret — set a real one |
|
||||||
|
| `CORS_ORIGINS` | api | `http://localhost:8080` | Comma-separated origins allowed to call `/api/v1`: wherever browsers actually load the UI from |
|
||||||
|
| `UI_BASE_URL` | api | `http://localhost:8080` | Where `/api/auth/` sends users to approve desktop sign-ins, and (with federation on) the public identity users are found under |
|
||||||
|
| `OPENAPI_DOCS_ENABLED` | api | `1` | Set to `0` to hide `/api/docs` and `/api/redoc` |
|
||||||
|
| `LOG_LEVEL` | api, worker | `INFO` | `DEBUG`, `INFO`, `WARNING` or `ERROR`. The worker logs each task pass that did work at `INFO` (with its duration); idle polls show at `DEBUG` |
|
||||||
|
| `LOG_FORMAT` | api, worker | `text` | `json` writes one JSON object per line (with `task` and `duration_ms` fields for worker tasks), for log aggregators |
|
||||||
|
| `METRICS_PORT` | api | `9100` | Prometheus metrics port — keep it off the public network |
|
||||||
|
| `WEB_CONCURRENCY` | api | `2` | gunicorn workers |
|
||||||
|
| `RUN_MIGRATIONS` | api image | `1` | Apply database migrations on start |
|
||||||
|
| `LASTFM_API_KEY` | api, worker | *(unset)* | Enables importing straight from Last.fm ([get a key](https://www.last.fm/api/account/create)) |
|
||||||
|
| `MUSICBRAINZ_CONTACT` | api, worker | `UI_BASE_URL` | Contact URL/email sent to MusicBrainz for album art lookups (no key needed, but they ask for one) |
|
||||||
|
| `ART_STORAGE_DIR` | api, worker | `var/album-art` | Where downloaded album art is stored; the worker writes it, the api serves it — both need access to the same directory (`docker compose` mounts a shared volume there) |
|
||||||
|
| `AVATAR_UPLOAD_MAX_BYTES` | api | 2 MB | Largest profile image a user may upload (a reverse proxy needs a body limit at least this large too). Images are stored in `avatars/` inside `ART_STORAGE_DIR` |
|
||||||
|
| `AVATAR_GRAVATAR_ENABLED` | api | off | Lets users use their Gravatar as their profile image. The api then calls gravatar.com (outbound HTTPS needed), sending it a SHA-256 hash of the user's email address; browsers never contact Gravatar |
|
||||||
|
| `ART_UPLOAD_MAX_BYTES` | api | 5 MB | Largest image a user may upload as their own album art. A reverse proxy in front of the api needs a body limit at least this large |
|
||||||
|
| `IMPORT_MAX_BYTES` | api | 200 MB | Largest export file accepted |
|
||||||
|
| `WORKER_METRICS_PORT` | worker | `9101` | The worker's Prometheus metrics port |
|
||||||
|
| `API_BASE_URL` | ui image | `http://localhost:5050` | Where the browser reaches the API — written into `config.js` and the CSP |
|
||||||
|
|
||||||
|
In `docker compose`, host ports are set with `DB_PORT`, `API_PORT`, `UI_PORT`,
|
||||||
|
`PROMETHEUS_PORT` and `GRAFANA_PORT`.
|
||||||
|
|
||||||
|
`CORS_ORIGINS` and `UI_BASE_URL` answer different questions and can differ: the first is
|
||||||
|
*which browser origins may call the JSON API*, the second is *where the public identity
|
||||||
|
and sign-in redirects point*. Don't assume setting one sets the other —
|
||||||
|
`docker-compose.yml` passes them through independently, and forgetting to set
|
||||||
|
`CORS_ORIGINS` to your real public origin is the single most common cause of "the UI
|
||||||
|
can't reach the API" once you're off `localhost` (see Troubleshooting).
|
||||||
|
|
||||||
|
### Fediverse sharing (optional)
|
||||||
|
|
||||||
|
Off unless the server enables it, and then off for each user until they turn it on:
|
||||||
|
|
||||||
|
1. Set on the **api** and **worker**:
|
||||||
|
- `FEDERATION_ENABLED=1`
|
||||||
|
- `FEDERATION_DOMAIN`: the UI's host, e.g. `scrobble.example`
|
||||||
|
- `FEDERATION_BASE_URL`: the UI's origin, e.g. `https://scrobble.example`
|
||||||
|
- `FEDERATION_KEY_SECRET`: 32+ random characters
|
||||||
|
2. Give the **ui** container `API_INTERNAL_URL` (compose sets `http://api:8000`). It
|
||||||
|
forwards these paths to the API: `/.well-known/webfinger`, `/.well-known/nodeinfo`,
|
||||||
|
`/.well-known/host-meta`, `/nodeinfo/`, `/users/`, `/inbox` and `/actor`.
|
||||||
|
3. Serve the UI over **real HTTPS** on that domain — other fediverse servers only talk to
|
||||||
|
HTTPS, and won't accept a self-signed certificate.
|
||||||
|
|
||||||
|
Handles and actor URLs **can't change once anyone follows a user**, so choose the domain
|
||||||
|
carefully before enabling this in production.
|
||||||
|
|
||||||
|
`FEDERATION_KEY_SECRET` encrypts every user's signing key. **Back it up, and never
|
||||||
|
change it**: losing it means users' keys can't be read, and followers would have to
|
||||||
|
follow again.
|
||||||
|
|
||||||
|
Optional: `FEDERATION_BLOCKED_DOMAINS` (comma-separated, subdomains included),
|
||||||
|
`FEDERATION_DELIVERY_CONCURRENCY` (default 4), `FEDERATION_SIGNATURE_SCHEMES` (default
|
||||||
|
`draft-cavage,rfc9421`). The `worker` service must be running — it delivers outgoing
|
||||||
|
activities and processes incoming ones.
|
||||||
|
|
||||||
|
Once it's on, tell your users: they still need to opt in themselves under **Sharing** in
|
||||||
|
the web UI — see the [user guide](user-guide.md#sharing-on-the-fediverse).
|
||||||
|
|
||||||
|
## Putting it behind TLS
|
||||||
|
|
||||||
|
Scrobbled itself only speaks plain HTTP; something in front of it needs to terminate
|
||||||
|
TLS. Any reverse proxy works — nginx, Caddy, or a tunnel like Cloudflare Tunnel for
|
||||||
|
testing without a public IP (see `docs/design/activitypub-phase4.md` for how the
|
||||||
|
project's own manual federation test used one).
|
||||||
|
|
||||||
|
Caddy, proxying everything to the `ui` container (which itself forwards the fediverse
|
||||||
|
paths to `api`), gets you a certificate automatically with no extra steps:
|
||||||
|
|
||||||
|
```
|
||||||
|
scrobble.example {
|
||||||
|
reverse_proxy localhost:8080
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
nginx with certbot, doing the same job:
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name scrobble.example;
|
||||||
|
location / { return 301 https://$host$request_uri; }
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name scrobble.example;
|
||||||
|
ssl_certificate /etc/letsencrypt/live/scrobble.example/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/scrobble.example/privkey.pem;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:8080;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Proto https;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
certbot --nginx -d scrobble.example
|
||||||
|
```
|
||||||
|
|
||||||
|
Point `UI_BASE_URL`/`FEDERATION_BASE_URL`/`FEDERATION_DOMAIN` at that same public
|
||||||
|
`https://scrobble.example` origin. The API (`API_PORT`, default 5050) doesn't need its
|
||||||
|
own public hostname unless you want browsers to reach it directly instead of through the
|
||||||
|
UI's proxy — set `API_BASE_URL` accordingly either way, since the browser calls it
|
||||||
|
directly for `/api/v1`, and make sure `CORS_ORIGINS` includes `https://scrobble.example`
|
||||||
|
regardless of which layout you pick.
|
||||||
|
|
||||||
|
## Monitoring
|
||||||
|
|
||||||
|
The API serves Prometheus metrics on `METRICS_PORT`, summed across gunicorn workers. All
|
||||||
|
series are prefixed `scrobbler_`: HTTP request rate/errors/latency, Last.fm calls and
|
||||||
|
auth failures, scrobble outcomes, database query latency and pool use, and gauges for
|
||||||
|
registered/active/currently-listening users. Labels never contain usernames, API keys or
|
||||||
|
track names.
|
||||||
|
|
||||||
|
With `--profile monitoring`, Grafana (`GRAFANA_ADMIN_PASSWORD`) provisions a
|
||||||
|
**Scrobbled** folder with dashboards for API overview, Last.fm API, usage, database and
|
||||||
|
(with federation on) federation. Alert rules live in `deploy/prometheus/alerts.yml` —
|
||||||
|
evaluated by Prometheus and visible in Grafana, but nothing routes them anywhere without
|
||||||
|
Alertmanager.
|
||||||
|
|
||||||
|
## Backups and restore
|
||||||
|
|
||||||
|
Back up, at minimum:
|
||||||
|
|
||||||
|
- The Postgres database (all scrobble history, accounts, federation state).
|
||||||
|
- `FEDERATION_KEY_SECRET`, if federation is on — it's the only thing that can decrypt
|
||||||
|
stored signing keys, and it's never derivable from the database alone.
|
||||||
|
- Your `.env` (or equivalent secrets store), so `SECRET_KEY` and the rest survive a
|
||||||
|
rebuild without inventing new ones.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker compose exec db pg_dump -U scrobbler scrobbler | gzip > backup-$(date +%F).sql.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
To restore onto a fresh `db` volume:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
gunzip -c backup-2026-01-01.sql.gz | docker compose exec -T db psql -U scrobbler scrobbler
|
||||||
|
```
|
||||||
|
|
||||||
|
Restoring an older dump with federation on will leave followers pointed at posts that no
|
||||||
|
longer exist and profile data that's gone stale — expected after any point-in-time
|
||||||
|
restore, not a sign anything's broken.
|
||||||
|
|
||||||
|
The `album-art-data` volume holds two kinds of file. Cover art the worker downloaded is a
|
||||||
|
disposable cache — it's simply re-downloaded the next time it's requested. Images users
|
||||||
|
**upload** (and the art from their manual corrections) live under `user/` in the same
|
||||||
|
volume and can't be re-created, so include the volume in your backups. The database rows
|
||||||
|
that point at them are in `user_album_art`; restore the two together.
|
||||||
|
|
||||||
|
Profile images (uploads, and copies of users' Gravatars) are in `avatars/` in that volume,
|
||||||
|
one file per user id, and likewise belong in your backups. The `users` table records
|
||||||
|
which users have one (`avatar_source`); a missing file just shows as no image. Gravatar
|
||||||
|
copies can be re-fetched by their users, but uploads can't be re-created.
|
||||||
|
|
||||||
|
## Upgrades
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker compose pull # or set SCROBBLER_IMAGE_TAG to a specific version
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Migrations run automatically on API container start (`RUN_MIGRATIONS=1`, the default).
|
||||||
|
Take a database backup first for anything beyond a patch version — check
|
||||||
|
`docs/design/` and the Gitea release notes for the version you're jumping to if it spans
|
||||||
|
a major version.
|
||||||
|
|
||||||
|
## Releases
|
||||||
|
|
||||||
|
Gitea Actions (`.gitea/workflows/ci.yml`) builds and publishes on every push to `main`
|
||||||
|
and on `v*` tags, once lint, tests and the Prometheus config checks all pass:
|
||||||
|
|
||||||
|
- Both images push to the ProGet `scrobbler` Docker feed.
|
||||||
|
- The OpenAPI spec, dashboards and Prometheus config upload to the `scrobbler-assets`
|
||||||
|
feed.
|
||||||
|
- `v*` tags also publish the wheel/sdist to the `scrobbler-python` PyPI feed (as
|
||||||
|
`scrobby`; `scrobbler` on public PyPI is an unrelated project).
|
||||||
|
|
||||||
|
To release: tag `vX.Y.Z` on `main` and push the tag. That tag sets both the package and
|
||||||
|
image version. See [setup.md](setup.md) for the secrets/variables the workflow needs and
|
||||||
|
how to run it locally before tagging.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
**The web UI loads but can't reach the API ("Can't reach the Scrobbled API at …" or
|
||||||
|
requests failing silently).** Almost always `CORS_ORIGINS` on the `api` service not
|
||||||
|
listing the exact origin the browser loads the UI from (scheme and host both have to
|
||||||
|
match — `https://scrobble.example` is not the same origin as `http://scrobble.example`
|
||||||
|
or `www.scrobble.example`). Check with:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -i -X OPTIONS https://scrobble.example/api/v1/auth/me \
|
||||||
|
-H "Origin: https://scrobble.example" -H "Access-Control-Request-Method: GET"
|
||||||
|
```
|
||||||
|
|
||||||
|
A missing `access-control-allow-origin` header in the response confirms it. This is
|
||||||
|
separate from `UI_BASE_URL` — setting one does not set the other.
|
||||||
|
|
||||||
|
**Federation looks enabled but the "Sharing" page/nav link doesn't appear for a user.**
|
||||||
|
First confirm federation is actually on server-side, independent of what any log line
|
||||||
|
says (gunicorn drops `log.info` by default unless something configures logging):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -o /dev/null -w '%{http_code}\n' https://scrobble.example/actor # 200 = federation is on
|
||||||
|
```
|
||||||
|
|
||||||
|
If that's `200`, the server is fine and the problem is client-side: the web UI caches
|
||||||
|
whether federation is available in the browser's `sessionStorage` for the tab, and
|
||||||
|
caches static JS in the ordinary browser cache. Ask the user to hard-refresh
|
||||||
|
(Ctrl/Cmd+Shift+R) or try a private window — if it works there, it's a stale cache, not
|
||||||
|
a server problem.
|
||||||
|
|
||||||
|
**A fediverse profile 404s from a specific remote server (e.g. mastodon.social) right
|
||||||
|
after you enable sharing, even though WebFinger looks correct from curl.** Large
|
||||||
|
instances cache a *negative* WebFinger lookup for a while. Confirm the server's own
|
||||||
|
response is correct first:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -H 'Accept: application/jrd+json' \
|
||||||
|
'https://scrobble.example/.well-known/webfinger?resource=acct:name@scrobble.example'
|
||||||
|
```
|
||||||
|
|
||||||
|
If that's correct, the fix is time (or trying a smaller/different instance to confirm
|
||||||
|
it's not a Scrobbled-side problem) — there's nothing to change on the server.
|
||||||
|
|
||||||
|
**A legacy scrobbler client (e.g. VLC's built-in scrobbler) fails to connect at all.**
|
||||||
|
Scrobbled implements the Last.fm 2.0 API only, not the legacy 1.2 Audioscrobbler
|
||||||
|
handshake (`hs=true&p=1.2&...`). Clients that only speak 1.2 can't be pointed at
|
||||||
|
Scrobbled regardless of configuration — point users at a client with 2.0 support
|
||||||
|
instead.
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
# Deploying Scrobbler
|
|
||||||
|
|
||||||
This covers running a real instance: the published images, configuration, putting it
|
|
||||||
behind TLS, monitoring, backups and releases. For running the code locally to work on
|
|
||||||
it, see [setup.md](setup.md). For what the service does once it's running, see
|
|
||||||
[usage.md](usage.md).
|
|
||||||
|
|
||||||
## Services
|
|
||||||
|
|
||||||
```
|
|
||||||
players / scrobblers ──► API /2.0/ Last.fm-compatible
|
|
||||||
web UI (static files) ──► API /api/v1/ JSON API for the UI
|
|
||||||
API ──► PostgreSQL
|
|
||||||
Prometheus ◄── API :9100/metrics, postgres-exporter ──► Grafana
|
|
||||||
```
|
|
||||||
|
|
||||||
- **`api`**: Flask under gunicorn. API-only; it serves no HTML pages.
|
|
||||||
- **`ui`**: nginx serving the static frontend (`frontend/`, no build step).
|
|
||||||
- **`worker`**: `flask worker` — history imports and background tasks for optional
|
|
||||||
modules (federation's deliveries, scheduled posts, and so on).
|
|
||||||
- **`db`**: PostgreSQL.
|
|
||||||
- With the `monitoring` profile: `prometheus`, `grafana`, `postgres-exporter`.
|
|
||||||
|
|
||||||
## Quick start
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cp .env.example .env # then set SECRET_KEY and POSTGRES_PASSWORD
|
|
||||||
SCROBBLER_IMAGE_TAG=main docker compose up -d --no-build # or drop --no-build to build locally
|
|
||||||
```
|
|
||||||
|
|
||||||
Open `http://localhost:8080`, create an account, then go to **Apps** and create an app
|
|
||||||
for each player. Add `--profile monitoring` for Prometheus and Grafana.
|
|
||||||
|
|
||||||
Published images: `pkgs.daubney.dev/scrobbler/scrobbler-api` and
|
|
||||||
`pkgs.daubney.dev/scrobbler/scrobbler-ui`, tagged `main` (latest push to `main`),
|
|
||||||
`sha-<commit>`, and `<version>`/`latest` for tagged releases.
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
| Variable | Used by | Default | Purpose |
|
|
||||||
|---|---|---|---|
|
|
||||||
| `DATABASE_URL` | api | local Postgres | SQLAlchemy URL (`postgresql+psycopg://…`) |
|
|
||||||
| `SECRET_KEY` | api | `dev-insecure-secret` | Flask secret — set a real one |
|
|
||||||
| `CORS_ORIGINS` | api | `http://localhost:8080` | Comma-separated origins allowed to call `/api/v1`: wherever browsers actually load the UI from |
|
|
||||||
| `UI_BASE_URL` | api | `http://localhost:8080` | Where `/api/auth/` sends users to approve desktop sign-ins, and (with federation on) the public identity users are found under |
|
|
||||||
| `OPENAPI_DOCS_ENABLED` | api | `1` | Set to `0` to hide `/api/docs` and `/api/redoc` |
|
|
||||||
| `METRICS_PORT` | api | `9100` | Prometheus metrics port — keep it off the public network |
|
|
||||||
| `WEB_CONCURRENCY` | api | `2` | gunicorn workers |
|
|
||||||
| `RUN_MIGRATIONS` | api image | `1` | Apply database migrations on start |
|
|
||||||
| `LASTFM_API_KEY` | api, worker | *(unset)* | Enables importing straight from Last.fm ([get a key](https://www.last.fm/api/account/create)) |
|
|
||||||
| `IMPORT_MAX_BYTES` | api | 200 MB | Largest export file accepted |
|
|
||||||
| `WORKER_METRICS_PORT` | worker | `9101` | The worker's Prometheus metrics port |
|
|
||||||
| `API_BASE_URL` | ui image | `http://localhost:5050` | Where the browser reaches the API — written into `config.js` and the CSP |
|
|
||||||
|
|
||||||
In `docker compose`, host ports are set with `DB_PORT`, `API_PORT`, `UI_PORT`,
|
|
||||||
`PROMETHEUS_PORT` and `GRAFANA_PORT`.
|
|
||||||
|
|
||||||
`CORS_ORIGINS` and `UI_BASE_URL` answer different questions and can differ: the first is
|
|
||||||
*which browser origins may call the JSON API*, the second is *where the public identity
|
|
||||||
and sign-in redirects point*. Don't assume setting one sets the other — `docker-compose.yml`
|
|
||||||
passes them through independently.
|
|
||||||
|
|
||||||
### Fediverse sharing (optional)
|
|
||||||
|
|
||||||
Off unless the server enables it, and then off for each user until they turn it on:
|
|
||||||
|
|
||||||
1. Set on the **api** and **worker**:
|
|
||||||
- `FEDERATION_ENABLED=1`
|
|
||||||
- `FEDERATION_DOMAIN`: the UI's host, e.g. `scrobble.example`
|
|
||||||
- `FEDERATION_BASE_URL`: the UI's origin, e.g. `https://scrobble.example`
|
|
||||||
- `FEDERATION_KEY_SECRET`: 32+ random characters
|
|
||||||
2. Give the **ui** container `API_INTERNAL_URL` (compose sets `http://api:8000`). It
|
|
||||||
forwards these paths to the API: `/.well-known/webfinger`, `/.well-known/nodeinfo`,
|
|
||||||
`/.well-known/host-meta`, `/nodeinfo/`, `/users/`, `/inbox` and `/actor`.
|
|
||||||
3. Serve the UI over **real HTTPS** on that domain — other fediverse servers only talk to
|
|
||||||
HTTPS, and won't accept a self-signed certificate.
|
|
||||||
|
|
||||||
Handles and actor URLs **can't change once anyone follows a user**, so choose the domain
|
|
||||||
carefully before enabling this in production.
|
|
||||||
|
|
||||||
`FEDERATION_KEY_SECRET` encrypts every user's signing key. **Back it up, and never
|
|
||||||
change it**: losing it means users' keys can't be read, and followers would have to
|
|
||||||
follow again.
|
|
||||||
|
|
||||||
Optional: `FEDERATION_BLOCKED_DOMAINS` (comma-separated, subdomains included),
|
|
||||||
`FEDERATION_DELIVERY_CONCURRENCY` (default 4), `FEDERATION_SIGNATURE_SCHEMES` (default
|
|
||||||
`draft-cavage,rfc9421`). The `worker` service must be running — it delivers outgoing
|
|
||||||
activities and processes incoming ones.
|
|
||||||
|
|
||||||
## Putting it behind TLS
|
|
||||||
|
|
||||||
Scrobbler itself only speaks plain HTTP; something in front of it needs to terminate
|
|
||||||
TLS. Any reverse proxy works — nginx, Caddy, or a tunnel like Cloudflare Tunnel for
|
|
||||||
testing without a public IP (see `docs/design/activitypub-phase4.md` for how the
|
|
||||||
project's own manual federation test used one). A minimal Caddy example, proxying
|
|
||||||
everything to the `ui` container (which itself forwards the fediverse paths to `api`):
|
|
||||||
|
|
||||||
```
|
|
||||||
scrobble.example {
|
|
||||||
reverse_proxy localhost:8080
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Point `UI_BASE_URL`/`FEDERATION_BASE_URL`/`FEDERATION_DOMAIN` at that same public
|
|
||||||
`https://scrobble.example` origin. The API (`API_PORT`, default 5050) doesn't need its
|
|
||||||
own public hostname unless you want browsers to reach it directly instead of through the
|
|
||||||
UI's proxy — set `API_BASE_URL` accordingly either way, since the browser calls it
|
|
||||||
directly for `/api/v1`.
|
|
||||||
|
|
||||||
## Monitoring
|
|
||||||
|
|
||||||
The API serves Prometheus metrics on `METRICS_PORT`, summed across gunicorn workers. All
|
|
||||||
series are prefixed `scrobbler_`: HTTP request rate/errors/latency, Last.fm calls and
|
|
||||||
auth failures, scrobble outcomes, database query latency and pool use, and gauges for
|
|
||||||
registered/active/currently-listening users. Labels never contain usernames, API keys or
|
|
||||||
track names.
|
|
||||||
|
|
||||||
With `--profile monitoring`, Grafana (`GRAFANA_ADMIN_PASSWORD`) provisions a
|
|
||||||
**Scrobbler** folder with dashboards for API overview, Last.fm API, usage, database and
|
|
||||||
(with federation on) federation. Alert rules live in `deploy/prometheus/alerts.yml` —
|
|
||||||
evaluated by Prometheus and visible in Grafana, but nothing routes them anywhere without
|
|
||||||
Alertmanager.
|
|
||||||
|
|
||||||
## Backups
|
|
||||||
|
|
||||||
Back up, at minimum:
|
|
||||||
|
|
||||||
- The Postgres database (all scrobble history, accounts, federation state).
|
|
||||||
- `FEDERATION_KEY_SECRET`, if federation is on — it's the only thing that can decrypt
|
|
||||||
stored signing keys, and it's never derivable from the database alone.
|
|
||||||
|
|
||||||
## Releases
|
|
||||||
|
|
||||||
Gitea Actions (`.gitea/workflows/ci.yml`) builds and publishes on every push to `main`
|
|
||||||
and on `v*` tags, once lint, tests and the Prometheus config checks all pass:
|
|
||||||
|
|
||||||
- Both images push to the ProGet `scrobbler` Docker feed.
|
|
||||||
- The OpenAPI spec, dashboards and Prometheus config upload to the `scrobbler-assets`
|
|
||||||
feed.
|
|
||||||
- `v*` tags also publish the wheel/sdist to the `scrobbler-python` PyPI feed (as
|
|
||||||
`scrobby`; `scrobbler` on public PyPI is an unrelated project).
|
|
||||||
|
|
||||||
To release: tag `vX.Y.Z` on `main` and push the tag. That tag sets both the package and
|
|
||||||
image version. See [setup.md](setup.md) for the secrets/variables the workflow needs and
|
|
||||||
how to run it locally before tagging.
|
|
||||||
@@ -5,12 +5,12 @@
|
|||||||
Where this differed from the plan:
|
Where this differed from the plan:
|
||||||
|
|
||||||
- **httpcore instead of httpx.** httpcore is the transport layer underneath httpx, and it publicly supports the custom network backend that connecting to a pre-checked address needs.
|
- **httpcore instead of httpx.** httpcore is the transport layer underneath httpx, and it publicly supports the custom network backend that connecting to a pre-checked address needs.
|
||||||
- **No in-process test with two Scrobbler instances.** Scrobbler can't initiate follows yet, so one instance has nothing to send the other. Scripted remote accounts over real HTTP cover the same paths, and GoToSocial is the real second server.
|
- **No in-process test with two Scrobbled instances.** Scrobbled can't initiate follows yet, so one instance has nothing to send the other. Scripted remote accounts over real HTTP cover the same paths, and GoToSocial is the real second server.
|
||||||
- **Undo of a Block.** Unblocking needed it: GoToSocial otherwise keeps the block.
|
- **Undo of a Block.** Unblocking needed it: GoToSocial otherwise keeps the block.
|
||||||
|
|
||||||
This implements phase 2 of [activitypub.md](activitypub.md), building on [phase 1](activitypub-phase1.md).
|
This implements phase 2 of [activitypub.md](activitypub.md), building on [phase 1](activitypub-phase1.md).
|
||||||
|
|
||||||
**Outcome:** people on Mastodon, GoToSocial and similar servers can follow a user who shares. Follows are accepted automatically, or wait for the user's approval if they've turned it on. The user sees their followers and can approve, decline, remove or block them. Scrobbler signs everything it sends and checks the signature on everything it receives. Posts come in phase 3; this phase makes the relationship work end to end.
|
**Outcome:** people on Mastodon, GoToSocial and similar servers can follow a user who shares. Follows are accepted automatically, or wait for the user's approval if they've turned it on. The user sees their followers and can approve, decline, remove or block them. Scrobbled signs everything it sends and checks the signature on everything it receives. Posts come in phase 3; this phase makes the relationship work end to end.
|
||||||
|
|
||||||
Everything below is inside `scrobbler.federation`, and the boundary tests keep holding. Federation off still means nothing is registered.
|
Everything below is inside `scrobbler.federation`, and the boundary tests keep holding. Federation off still means nothing is registered.
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ Everything below is inside `scrobbler.federation`, and the boundary tests keep h
|
|||||||
- At most 3 redirects, each checked the same way.
|
- At most 3 redirects, each checked the same way.
|
||||||
- Response bodies are capped at 1 MB.
|
- Response bodies are capped at 1 MB.
|
||||||
- Timeouts: 10s to connect and 20s to read.
|
- Timeouts: 10s to connect and 20s to read.
|
||||||
- A `User-Agent` of `Scrobbler/<version> (+<base url>)`.
|
- A `User-Agent` of `Scrobbled/<version> (+<base url>)`.
|
||||||
- `signed_get(url, as_actor)`, which signs with the instance actor by default so "authorized fetch" servers answer; and `signed_post(inbox, activity, as_user)`.
|
- `signed_get(url, as_actor)`, which signs with the instance actor by default so "authorized fetch" servers answer; and `signed_post(inbox, activity, as_user)`.
|
||||||
- **`FEDERATION_INSECURE_TESTING=1`** is **for automated tests only**. It allows `http://` and private addresses. It's refused unless the domain ends in `.test` (a reserved top-level domain) and logs a warning every minute while on. It exists so CI can federate with GoToSocial on a private Docker network.
|
- **`FEDERATION_INSECURE_TESTING=1`** is **for automated tests only**. It allows `http://` and private addresses. It's refused unless the domain ends in `.test` (a reserved top-level domain) and logs a warning every minute while on. It exists so CI can federate with GoToSocial on a private Docker network.
|
||||||
- **`remote.py`**: the remote-actor cache.
|
- **`remote.py`**: the remote-actor cache.
|
||||||
@@ -178,12 +178,12 @@ Everything below is inside `scrobbler.federation`, and the boundary tests keep h
|
|||||||
- bad signatures rejected with the right reason
|
- bad signatures rejected with the right reason
|
||||||
- a blocked domain
|
- a blocked domain
|
||||||
- turning sharing off
|
- turning sharing off
|
||||||
- **A real peer in CI**: a new `federation-interop` job runs Scrobbler (API, worker and UI) and a GoToSocial container on one Docker network. The hosts are `scrobble.test` and `gts.test`, over HTTP, with each side's test-only settings. A script:
|
- **A real peer in CI**: a new `federation-interop` job runs Scrobbled (API, worker and UI) and a GoToSocial container on one Docker network. The hosts are `scrobble.test` and `gts.test`, over HTTP, with each side's test-only settings. A script:
|
||||||
1. creates a GoToSocial user with its admin CLI,
|
1. creates a GoToSocial user with its admin CLI,
|
||||||
2. gets a user token by driving GoToSocial's sign-in and OAuth screens with plain HTTP (this part gets a short spike first, since GoToSocial has no password grant),
|
2. gets a user token by driving GoToSocial's sign-in and OAuth screens with plain HTTP (this part gets a short spike first, since GoToSocial has no password grant),
|
||||||
3. follows `@alice@scrobble.test`, and checks it's accepted,
|
3. follows `@alice@scrobble.test`, and checks it's accepted,
|
||||||
4. unfollows, and checks it's gone,
|
4. unfollows, and checks it's gone,
|
||||||
5. with manual approval on, checks the request waits until approved through Scrobbler's API.
|
5. with manual approval on, checks the request waits until approved through Scrobbled's API.
|
||||||
|
|
||||||
The job posts to ntfy like every other job. It doesn't run on pull requests from forks.
|
The job posts to ntfy like every other job. It doesn't run on pull requests from forks.
|
||||||
- **Manual pass before merging**: follow and unfollow from a real Mastodon account through a tunnel.
|
- **Manual pass before merging**: follow and unfollow from a real Mastodon account through a tunnel.
|
||||||
@@ -210,5 +210,5 @@ Everything below is inside `scrobbler.federation`, and the boundary tests keep h
|
|||||||
|
|
||||||
- **Licences**:
|
- **Licences**:
|
||||||
- `httpx` is BSD-3-Clause and `cryptography` is Apache-2.0/BSD.
|
- `httpx` is BSD-3-Clause and `cryptography` is Apache-2.0/BSD.
|
||||||
- GoToSocial is AGPL, but it runs only as a separate container in CI to test against. Nothing of it is linked into, or shipped with, Scrobbler, so it has no effect on Scrobbler's licence.
|
- GoToSocial is AGPL, but it runs only as a separate container in CI to test against. Nothing of it is linked into, or shipped with, Scrobbled, so it has no effect on Scrobbled's licence.
|
||||||
- **Scale**: this is the biggest phase, and signatures plus safe outbound HTTP are where the risk lies. They come first and have the most thorough tests.
|
- **Scale**: this is the biggest phase, and signatures plus safe outbound HTTP are where the risk lies. They come first and have the most thorough tests.
|
||||||
@@ -46,7 +46,7 @@ Everything is in `scrobbler.federation` except one small addition to the core st
|
|||||||
- `id`, `attributedTo`, `content` (HTML) plus `contentMap` (`{"en": …}`)
|
- `id`, `attributedTo`, `content` (HTML) plus `contentMap` (`{"en": …}`)
|
||||||
- `published`, `url` (the UI post page)
|
- `published`, `url` (the UI post page)
|
||||||
- `to` and `cc` from the visibility setting
|
- `to` and `cc` from the visibility setting
|
||||||
- `tag` (`Hashtag` objects: `#Scrobbler`, and `#NowPlaying` in phase 4)
|
- `tag` (`Hashtag` objects: `#Scrobbled`, and `#NowPlaying` in phase 4)
|
||||||
- `sensitive: false`
|
- `sensitive: false`
|
||||||
- **`create(...)`**: `Create` wrapping the Note, with the same addressing.
|
- **`create(...)`**: `Create` wrapping the Note, with the same addressing.
|
||||||
- **`delete(...)`**: `Delete` whose object is a `Tombstone` of the Note (the same shape Mastodon sends).
|
- **`delete(...)`**: `Delete` whose object is a `Tombstone` of the Note (the same shape Mastodon sends).
|
||||||
@@ -85,7 +85,7 @@ Everything is in `scrobbler.federation` except one small addition to the core st
|
|||||||
> **My week in music: 312 plays**
|
> **My week in music: 312 plays**
|
||||||
> Top artists: 1. Radiohead (48) 2. Björk (31) 3. Portishead (22)
|
> Top artists: 1. Radiohead (48) 2. Björk (31) 3. Portishead (22)
|
||||||
> Most played: *Reckoner* by Radiohead (12 plays)
|
> Most played: *Reckoner* by Radiohead (12 plays)
|
||||||
> #Scrobbler
|
> #Scrobbled
|
||||||
|
|
||||||
**Milestones** (`publishing/milestones.py`, worker task `federation.milestones`):
|
**Milestones** (`publishing/milestones.py`, worker task `federation.milestones`):
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ Everything is in `scrobbler.federation` except one small addition to the core st
|
|||||||
- **No retroactive posts:**
|
- **No retroactive posts:**
|
||||||
- When a user **turns sharing on**, every threshold they've already passed is marked `posted=false`.
|
- When a user **turns sharing on**, every threshold they've already passed is marked `posted=false`.
|
||||||
- When an **import finishes** (`import_finished`), the same happens: imported history moves the baseline silently. Imported plays therefore never trigger milestone posts, even if a live scrobble crosses a line soon after.
|
- When an **import finishes** (`import_finished`), the same happens: imported history moves the baseline silently. Imported plays therefore never trigger milestone posts, even if a live scrobble crosses a line soon after.
|
||||||
- Example: *"10,000 plays on Scrobbler 🎉"* or *"Björk just joined my all-time top 10 (at #7)"*.
|
- Example: *"10,000 plays on Scrobbled 🎉"* or *"Björk just joined my all-time top 10 (at #7)"*.
|
||||||
|
|
||||||
## 6. Endpoints (served on the UI domain, documented in OpenAPI)
|
## 6. Endpoints (served on the UI domain, documented in OpenAPI)
|
||||||
|
|
||||||
@@ -188,5 +188,5 @@ Everything is in `scrobbler.federation` except one small addition to the core st
|
|||||||
| Milestone thresholds | Plays: 1k, 5k, 10k, then every 25k. An artist's plays: 100, 500, 1k. New artist in the all-time top 10 |
|
| Milestone thresholds | Plays: 1k, 5k, 10k, then every 25k. An artist's plays: 100, 500, 1k. New artist in the all-time top 10 |
|
||||||
| Posts per milestone check | At most one (the most notable) |
|
| Posts per milestone check | At most one (the most notable) |
|
||||||
| Post language | English only for now (`contentMap.en`) |
|
| Post language | English only for now (`contentMap.en`) |
|
||||||
| Hashtag | `#Scrobbler` on every post |
|
| Hashtag | `#Scrobbled` on every post |
|
||||||
| Deleting individual posts | Allowed, from the web UI |
|
| Deleting individual posts | Allowed, from the web UI |
|
||||||
@@ -26,7 +26,7 @@ Everything is in `scrobbler.federation`, using the core's existing `services.scr
|
|||||||
## 1. Settings and data (migration on the `federation` branch)
|
## 1. Settings and data (migration on the `federation` branch)
|
||||||
|
|
||||||
- **`federation_settings` gains `now_playing_mode`**: `off` (default), `profile`, or `posts`. Validated the same way `visibility` is.
|
- **`federation_settings` gains `now_playing_mode`**: `off` (default), `profile`, or `posts`. Validated the same way `visibility` is.
|
||||||
- **`federation_now_playing`**, one row per user, the state of what Scrobbler has last told the fediverse (as opposed to `now_playing` in core, which is what's actually playing):
|
- **`federation_now_playing`**, one row per user, the state of what Scrobbled has last told the fediverse (as opposed to `now_playing` in core, which is what's actually playing):
|
||||||
- `profile_key` (nullable) and `profile_updated_at` (nullable): what the last `Update(Person)` said, and when it was sent
|
- `profile_key` (nullable) and `profile_updated_at` (nullable): what the last `Update(Person)` said, and when it was sent
|
||||||
- `post_key` (nullable) and `post_posted_at` (nullable): the key of the last now-playing post, and when
|
- `post_key` (nullable) and `post_posted_at` (nullable): the key of the last now-playing post, and when
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ Everything is in `scrobbler.federation`, using the core's existing `services.scr
|
|||||||
|
|
||||||
- **`update(activity_id, actor_id, actor_object)`**: wraps a document as an `Update`, addressed the same way `undo()` already does (mirrors its shape).
|
- **`update(activity_id, actor_id, actor_object)`**: wraps a document as an `Update`, addressed the same way `undo()` already does (mirrors its shape).
|
||||||
- **`person(...)` already takes `fields`** (phase 1): a "Now playing" field is just one more `(name, value)` pair, `"Track by Artist"`.
|
- **`person(...)` already takes `fields`** (phase 1): a "Now playing" field is just one more `(name, value)` pair, `"Track by Artist"`.
|
||||||
- Now-playing posts reuse the existing `note()`/`create()` builders from phase 3, tagged `#NowPlaying` in addition to `#Scrobbler` (already anticipated in the phase 3 plan's vocabulary notes).
|
- Now-playing posts reuse the existing `note()`/`create()` builders from phase 3, tagged `#NowPlaying` in addition to `#Scrobbled` (already anticipated in the phase 3 plan's vocabulary notes).
|
||||||
|
|
||||||
## 3. Live actor vs. pushed updates
|
## 3. Live actor vs. pushed updates
|
||||||
|
|
||||||
@@ -114,4 +114,4 @@ No event receiver, no pending-checks queue: unlike milestones, now playing doesn
|
|||||||
| Minimum played before a post | 30 seconds |
|
| Minimum played before a post | 30 seconds |
|
||||||
| Deleting the previous now-playing post | Always, when a new one goes out |
|
| Deleting the previous now-playing post | Always, when a new one goes out |
|
||||||
| Worker poll interval | 30 seconds |
|
| Worker poll interval | 30 seconds |
|
||||||
| Hashtags | `#Scrobbler` and `#NowPlaying` |
|
| Hashtags | `#Scrobbled` and `#NowPlaying` |
|
||||||
@@ -4,17 +4,17 @@ Status: **proposal, for review.** Nothing here is built yet. The decisions still
|
|||||||
|
|
||||||
## Summary
|
## Summary
|
||||||
|
|
||||||
Let a user turn their Scrobbler account into a fediverse account, for example `@alice@scrobble.example`, that people on Mastodon, GoToSocial, Misskey and similar servers can follow. Followers see three kinds of post:
|
Let a user turn their Scrobbled account into a fediverse account, for example `@alice@scrobble.example`, that people on Mastodon, GoToSocial, Misskey and similar servers can follow. Followers see three kinds of post:
|
||||||
|
|
||||||
- a **weekly listening summary**
|
- a **weekly listening summary**
|
||||||
- **milestones** (for example "10,000th scrobble")
|
- **milestones** (for example "10,000th scrobble")
|
||||||
- **what the user is playing now**
|
- **what the user is playing now**
|
||||||
|
|
||||||
The first version is **outbound only**: Scrobbler publishes, and it accepts and manages followers. Following other people and showing their listening in the UI is a possible later phase (see [Later](#later-following-and-listen-activities)). The data model is designed so it can be added without rework.
|
The first version is **outbound only**: Scrobbled publishes, and it accepts and manages followers. Following other people and showing their listening in the UI is a possible later phase (see [Later](#later-following-and-listen-activities)). The data model is designed so it can be added without rework.
|
||||||
|
|
||||||
Federation is **off for everyone until they turn it on**. Until then a user can't be found by WebFinger and nothing about them is published.
|
Federation is **off for everyone until they turn it on**. Until then a user can't be found by WebFinger and nothing about them is published.
|
||||||
|
|
||||||
**Decided:** we write the protocol layer ourselves, on `cryptography` plus the Flask, SQLAlchemy and worker setup we already have (about 1,500 lines, in the four phases below). Scrobbler is BSD-licensed, and the ready-made Python library is AGPL (see [Build or buy](#build-or-buy)).
|
**Decided:** we write the protocol layer ourselves, on `cryptography` plus the Flask, SQLAlchemy and worker setup we already have (about 1,500 lines, in the four phases below). Scrobbled is BSD-licensed, and the ready-made Python library is AGPL (see [Build or buy](#build-or-buy)).
|
||||||
|
|
||||||
All of it lives in **one self-contained package, `scrobbler.federation`**, behind a narrow interface. It can then be changed, replaced or switched off without touching the rest of the app, and changes to the specs (signature schemes, vocabulary, FEPs) stay inside it. See [Module structure](#module-structure).
|
All of it lives in **one self-contained package, `scrobbler.federation`**, behind a narrow interface. It can then be changed, replaced or switched off without touching the rest of the app, and changes to the specs (signature schemes, vocabulary, FEPs) stay inside it. See [Module structure](#module-structure).
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ All of it lives in **one self-contained package, `scrobbler.federation`**, behin
|
|||||||
## How it fits the current system
|
## How it fits the current system
|
||||||
|
|
||||||
```
|
```
|
||||||
Mastodon, GoToSocial, … Scrobbler
|
Mastodon, GoToSocial, … Scrobbled
|
||||||
────────────────────────────────────────────────────────────────────────────
|
────────────────────────────────────────────────────────────────────────────
|
||||||
GET /.well-known/webfinger?resource=acct:… ─► API (only for opted-in users)
|
GET /.well-known/webfinger?resource=acct:… ─► API (only for opted-in users)
|
||||||
GET /users/alice (Accept: activity+json) ─► API actor document
|
GET /users/alice (Accept: activity+json) ─► API actor document
|
||||||
@@ -53,7 +53,7 @@ POST /users/alice/inbox or /inbox ─► API verify signature, reco
|
|||||||
|
|
||||||
## Module structure
|
## Module structure
|
||||||
|
|
||||||
Everything to do with ActivityPub lives in `src/scrobbler/federation/`. The rest of Scrobbler knows only two things about it: how to switch it on, and a handful of domain events. Replacing the implementation (with another library, or a rewrite when the specs move on) means replacing this package; nothing else changes.
|
Everything to do with ActivityPub lives in `src/scrobbler/federation/`. The rest of Scrobbled knows only two things about it: how to switch it on, and a handful of domain events. Replacing the implementation (with another library, or a rewrite when the specs move on) means replacing this package; nothing else changes.
|
||||||
|
|
||||||
```
|
```
|
||||||
src/scrobbler/
|
src/scrobbler/
|
||||||
@@ -222,7 +222,7 @@ Serve `/.well-known/nodeinfo` and `/nodeinfo/2.1`, giving the software name `scr
|
|||||||
|
|
||||||
## What gets posted
|
## What gets posted
|
||||||
|
|
||||||
Posts are `Note` objects inside `Create` activities: Mastodon shows `Note` as a normal status, while other types are squashed into a title and link. The HTML uses only tags Mastodon keeps (`p`, `a`, `br`, `strong`, `em`, `ul`, `ol`, `li`), and all track and artist text is escaped. Each post also gets hashtags (`#NowPlaying`, `#Scrobbler`) as `Hashtag` tags. Visibility follows the user's setting, which defaults to **followers only**:
|
Posts are `Note` objects inside `Create` activities: Mastodon shows `Note` as a normal status, while other types are squashed into a title and link. The HTML uses only tags Mastodon keeps (`p`, `a`, `br`, `strong`, `em`, `ul`, `ol`, `li`), and all track and artist text is escaped. Each post also gets hashtags (`#NowPlaying`, `#Scrobbled`) as `Hashtag` tags. Visibility follows the user's setting, which defaults to **followers only**:
|
||||||
|
|
||||||
| Setting | `to` | `cc` |
|
| Setting | `to` | `cc` |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
@@ -248,7 +248,7 @@ Example:
|
|||||||
> **This week: 312 scrobbles**
|
> **This week: 312 scrobbles**
|
||||||
> Top artists: 1. Radiohead (48) 2. Björk (31) 3. Portishead (22)
|
> Top artists: 1. Radiohead (48) 2. Björk (31) 3. Portishead (22)
|
||||||
> Top track: *Reckoner* by Radiohead (12 plays)
|
> Top track: *Reckoner* by Radiohead (12 plays)
|
||||||
> #Scrobbler
|
> #Scrobbled
|
||||||
|
|
||||||
### Milestones
|
### Milestones
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ A new post for every track would flood followers' timelines. There are two optio
|
|||||||
| Maturity | New code, but the scope is narrow | Active, but young (0.3.x, one maintainer) | The most complete framework |
|
| Maturity | New code, but the scope is narrow | Active, but young (0.3.x, one maintainer) | The most complete framework |
|
||||||
| Effort | About 1,500 lines, mostly signatures, inbox and delivery | Less code, but we'd adapt its storage and flow to ours | A new service to run and monitor |
|
| Effort | About 1,500 lines, mostly signatures, inbox and delivery | Less code, but we'd adapt its storage and flow to ours | A new service to run and monitor |
|
||||||
|
|
||||||
**Decided: write it ourselves.** Scrobbler is BSD-3-Clause licensed. Using Pubby inside the app would make the running program subject to the AGPL, which defeats the point of a permissive licence. Fedify is excellent, but it would split the backend across two languages. The protocol surface we need is small (four activity types in and three out), so writing it ourselves is the least total cost. It also keeps ActivityPub on the same metrics, dashboards and tests as everything else, and it can all live in the one replaceable module described above.
|
**Decided: write it ourselves.** Scrobbled is BSD-3-Clause licensed. Using Pubby inside the app would make the running program subject to the AGPL, which defeats the point of a permissive licence. Fedify is excellent, but it would split the backend across two languages. The protocol surface we need is small (four activity types in and three out), so writing it ourselves is the least total cost. It also keeps ActivityPub on the same metrics, dashboards and tests as everything else, and it can all live in the one replaceable module described above.
|
||||||
|
|
||||||
New dependency: `cryptography` (Apache-2.0 or BSD), for keys and signatures.
|
New dependency: `cryptography` (Apache-2.0 or BSD), for keys and signatures.
|
||||||
|
|
||||||
@@ -335,8 +335,8 @@ Everything goes on the existing Prometheus and Grafana setup:
|
|||||||
- inbox state transitions
|
- inbox state transitions
|
||||||
- delivery retry schedule
|
- delivery retry schedule
|
||||||
- visibility addressing
|
- visibility addressing
|
||||||
- **In-process federation**: two Scrobbler instances in one test process following each other.
|
- **In-process federation**: two Scrobbled instances in one test process following each other.
|
||||||
- **A real peer in CI**: a [GoToSocial](https://gotosocial.org) container, which is a single binary with SQLite. It follows a Scrobbler user and we assert that it receives the `Accept` and the posts. That's much lighter than running Mastodon in CI.
|
- **A real peer in CI**: a [GoToSocial](https://gotosocial.org) container, which is a single binary with SQLite. It follows a Scrobbled user and we assert that it receives the `Accept` and the posts. That's much lighter than running Mastodon in CI.
|
||||||
- **Manual pass before release** (done, over a `cloudflared` tunnel - see [phase 4](activitypub-phase4.md)):
|
- **Manual pass before release** (done, over a `cloudflared` tunnel - see [phase 4](activitypub-phase4.md)):
|
||||||
- follow from a real Mastodon account
|
- follow from a real Mastodon account
|
||||||
- check the profile, posts, profile-field updates and unfollowing
|
- check the profile, posts, profile-field updates and unfollowing
|
||||||
@@ -363,8 +363,8 @@ Each phase can be released on its own, with its migration, docs, OpenAPI updates
|
|||||||
|
|
||||||
This is the "profiles plus friends' listening" option, deliberately left out of v1:
|
This is the "profiles plus friends' listening" option, deliberately left out of v1:
|
||||||
|
|
||||||
- Users follow other Scrobbler users, or any actor that publishes listens, and see a friends feed in the UI.
|
- Users follow other Scrobbled users, or any actor that publishes listens, and see a friends feed in the UI.
|
||||||
- **Wire format**: ActivityStreams has a `Listen` activity type. Funkwhale already federates `Listen` activities whose object is a `Track`. We'd send the same thing to followers on Scrobbler and Funkwhale servers only. Mastodon ignores activity types it doesn't know, and a stream of `Listen`s isn't something people want in their timelines anyway.
|
- **Wire format**: ActivityStreams has a `Listen` activity type. Funkwhale already federates `Listen` activities whose object is a `Track`. We'd send the same thing to followers on Scrobbled and Funkwhale servers only. Mastodon ignores activity types it doesn't know, and a stream of `Listen`s isn't something people want in their timelines anyway.
|
||||||
- **Changes needed**: an outbound `Follow` flow, storing received listens, a feed UI, and moderation of incoming content.
|
- **Changes needed**: an outbound `Follow` flow, storing received listens, a feed UI, and moderation of incoming content.
|
||||||
- **Account migration** (`Move` and `alsoKnownAs`) would come with this, so users can change handle or domain without losing followers.
|
- **Account migration** (`Move` and `alsoKnownAs`) would come with this, so users can change handle or domain without losing followers.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
# Working on Scrobbler
|
# Working on Scrobbled
|
||||||
|
|
||||||
Setting up a local development environment. For running a real instance, see
|
Setting up a local development environment. For running a real instance, see the
|
||||||
[deploy.md](deploy.md). For what the service does, see [usage.md](usage.md).
|
[admin guide](admin-guide.md). For what the service does, see the
|
||||||
|
[user guide](user-guide.md).
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ route is missing its bearer-auth declaration.
|
|||||||
|
|
||||||
- `uv run python scripts/generate_traffic.py --minutes 5` — sends a realistic mix of
|
- `uv run python scripts/generate_traffic.py --minutes 5` — sends a realistic mix of
|
||||||
scrobbles and errors, so the Grafana dashboards have something to show.
|
scrobbles and errors, so the Grafana dashboards have something to show.
|
||||||
- `scripts/interop/run.sh` — runs Scrobbler against a real GoToSocial server on a private
|
- `scripts/interop/run.sh` — runs Scrobbled against a real GoToSocial server on a private
|
||||||
network and checks the whole federation follow/post/now-playing life cycle end to end.
|
network and checks the whole federation follow/post/now-playing life cycle end to end.
|
||||||
CI runs this on every push; run it locally the same way before changing anything in
|
CI runs this on every push; run it locally the same way before changing anything in
|
||||||
`scrobbler.federation`.
|
`scrobbler.federation`.
|
||||||
@@ -88,7 +89,7 @@ Everything runs from `.gitea/workflows/ci.yml`:
|
|||||||
- **Every push and PR**: lint, the migrations-vs-models check, tests against Postgres,
|
- **Every push and PR**: lint, the migrations-vs-models check, tests against Postgres,
|
||||||
and `promtool` checks of the Prometheus config and alert rules.
|
and `promtool` checks of the Prometheus config and alert rules.
|
||||||
- **Pushes to `main` and tags**, once those all pass: images and assets publish (see
|
- **Pushes to `main` and tags**, once those all pass: images and assets publish (see
|
||||||
[deploy.md](deploy.md#releases)).
|
[admin guide](admin-guide.md#releases)).
|
||||||
- **Every run** posts to the `ScrobblingService` topic on notify.daubney.dev.
|
- **Every run** posts to the `ScrobblingService` topic on notify.daubney.dev.
|
||||||
|
|
||||||
Repository secrets: `PKGS_USER`, `PKGS_PASSWORD`, `PKGS_API_KEY`, `NTFY_USER`,
|
Repository secrets: `PKGS_USER`, `PKGS_PASSWORD`, `PKGS_API_KEY`, `NTFY_USER`,
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
# Using Scrobbler
|
|
||||||
|
|
||||||
What the service does, once it's running. For getting an instance running, see
|
|
||||||
[deploy.md](deploy.md); for working on the code, see [setup.md](setup.md).
|
|
||||||
|
|
||||||
## Account and apps
|
|
||||||
|
|
||||||
Register in the web UI, then go to **Apps** and create one app per player or scrobbler
|
|
||||||
client you use — each gets its own API key and shared secret, and can be revoked on its
|
|
||||||
own from the **Sessions** page without affecting the others.
|
|
||||||
|
|
||||||
## Connecting a player
|
|
||||||
|
|
||||||
In the player's scrobbling settings, choose a custom or self-hosted Last.fm server:
|
|
||||||
|
|
||||||
- **API URL**: `https://your-host/2.0/`
|
|
||||||
- **API key and shared secret**: from an app on the **Apps** page
|
|
||||||
- **Username and password**: your Scrobbler account
|
|
||||||
|
|
||||||
Two sign-in flows are supported:
|
|
||||||
|
|
||||||
- **Mobile**: `auth.getMobileSession` with a username and password, sent as a POST body
|
|
||||||
over HTTPS.
|
|
||||||
- **Desktop**: `auth.getToken`, then the user approves at `/api/auth/` (redirects to the
|
|
||||||
web UI), then `auth.getSession`.
|
|
||||||
|
|
||||||
The legacy `authToken = md5(username + md5(password))` form isn't supported — checking
|
|
||||||
it would mean storing unsalted password hashes. pylast's `password_hash` option uses
|
|
||||||
that form; use `SessionKeyGenerator` (the desktop flow) instead.
|
|
||||||
|
|
||||||
Supported methods: `auth.getMobileSession`, `auth.getToken`, `auth.getSession`,
|
|
||||||
`track.scrobble` (up to 50 per request), `track.updateNowPlaying`, `user.getInfo`,
|
|
||||||
`user.getRecentTracks`, `user.getTopArtists`, `user.getTopAlbums`, `user.getTopTracks`.
|
|
||||||
`/api/docs` has the full parameters, rules and example responses for each.
|
|
||||||
|
|
||||||
A scrobble is ignored (not rejected) if the artist or track is empty, or the timestamp
|
|
||||||
is more than 14 days old or more than 5 minutes in the future. Resending the same
|
|
||||||
scrobble is accepted and stored once, so client retries are safe.
|
|
||||||
|
|
||||||
## Importing history
|
|
||||||
|
|
||||||
Open **Import** in the web UI:
|
|
||||||
|
|
||||||
- **An export file**:
|
|
||||||
- CSV from [lastfm-to-csv](https://benjaminbenben.com/lastfm-to-csv/), no header row,
|
|
||||||
artist/album/track/date columns.
|
|
||||||
- Any CSV or TSV with a header row naming artist, track and a date or Unix-time
|
|
||||||
column. Comma, semicolon and tab delimiters all work.
|
|
||||||
- A JSON export of `user.getRecentTracks` pages (such as lastfm.ghan.nl's), a single
|
|
||||||
`recenttracks` response, or a flat list of tracks.
|
|
||||||
- Files can be gzipped.
|
|
||||||
- **Last.fm directly**: enter a Last.fm username and the worker pages through that
|
|
||||||
account's public history. Only appears when the server has `LASTFM_API_KEY` set.
|
|
||||||
|
|
||||||
Imports run in the background; the page shows progress and can cancel one in flight.
|
|
||||||
Unlike live scrobbles, imports keep plays of any age (still skipping rows with no artist
|
|
||||||
or track, or plays dated in the future). Plays already in your history are skipped, so
|
|
||||||
importing the same export again is safe.
|
|
||||||
|
|
||||||
## Sharing on the fediverse
|
|
||||||
|
|
||||||
Only available when the server has federation enabled (ask whoever runs it, or see
|
|
||||||
[deploy.md](deploy.md#fediverse-sharing-optional) if that's you). Turn it on under
|
|
||||||
**Sharing**, and you're findable as `@name@<the server's host>` from Mastodon and other
|
|
||||||
fediverse apps:
|
|
||||||
|
|
||||||
- Follows are accepted automatically, or wait for your approval if you turn that on.
|
|
||||||
- **Followers** lists requests, followers and blocked accounts, with approve, decline,
|
|
||||||
remove, block and unblock.
|
|
||||||
|
|
||||||
Once someone follows, **Sharing**'s **What to post** section controls what they see:
|
|
||||||
|
|
||||||
- **Weekly summary**: play count and top artist(s), posted once a week (Monday 09:00 in
|
|
||||||
your own time zone, for the week that just ended). A live preview shows what it would
|
|
||||||
say so far.
|
|
||||||
- **Milestones**: total scrobbles, an artist's plays, and a new entry into your all-time
|
|
||||||
top 10 — each posted once, the first time it's reached. History already on file when
|
|
||||||
you turn sharing on, or added by an import, is never posted about retroactively.
|
|
||||||
|
|
||||||
Both are on by default and can be switched off independently. Posts use the same
|
|
||||||
visibility as your profile (followers only by default, or unlisted/public); **Posts**
|
|
||||||
lists your own posts with delete (sends a `Delete` to whoever received it).
|
|
||||||
|
|
||||||
**Now playing** is a separate, three-way choice:
|
|
||||||
|
|
||||||
- **Off** (default): nothing shown or posted.
|
|
||||||
- **Show on my profile**: a "Now playing: *Track* by Artist" field, refreshed at most
|
|
||||||
every 5 minutes while something's playing and cleared a few minutes after it stops.
|
|
||||||
- **Show on my profile and post**: the profile field, plus a post for each track played
|
|
||||||
30 seconds or more, at most one every 30 minutes, with the previous now-playing post
|
|
||||||
deleted once the new one is confirmed published.
|
|
||||||
|
|
||||||
Handles and actor URLs **can't change once anyone follows you**, so if you're the one
|
|
||||||
who gets to choose the server's domain, choose it carefully.
|
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
# User guide
|
||||||
|
|
||||||
|
What Scrobbled does once you're signed in: connecting a player, importing your old
|
||||||
|
history, and sharing your listening on the fediverse. If you're setting up or running an
|
||||||
|
instance rather than using one, see the [admin guide](admin-guide.md) instead.
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
|
||||||
|
Register in the web UI, then go to **Apps** and create one app per player or scrobbler
|
||||||
|
client you use — each gets its own API key and shared secret, and can be revoked on its
|
||||||
|
own from the **Sessions** page without affecting the others. If a friend runs your
|
||||||
|
instance, ask them for its address; that's the only thing you need from them to get
|
||||||
|
going.
|
||||||
|
|
||||||
|
## Connecting a player
|
||||||
|
|
||||||
|
In the player's scrobbling settings, choose a custom or self-hosted Last.fm server:
|
||||||
|
|
||||||
|
- **API URL**: `https://your-host/2.0/`
|
||||||
|
- **API key and shared secret**: from an app on the **Apps** page
|
||||||
|
- **Username and password**: your Scrobbled account
|
||||||
|
|
||||||
|
Two sign-in flows are supported, and most players use one or the other automatically:
|
||||||
|
|
||||||
|
- **Mobile**: you enter your username and password directly in the player.
|
||||||
|
- **Desktop**: the player opens a browser page for you to approve, then signs itself in
|
||||||
|
— no password ever passed to the player.
|
||||||
|
|
||||||
|
A sign-in method that hashes your password before sending it (sometimes offered as a
|
||||||
|
"stored password" or "password hash" option, e.g. pylast's `password_hash`) isn't
|
||||||
|
supported — use the plain username/password or desktop-approval flow instead.
|
||||||
|
|
||||||
|
Supported methods, if your player lets you check: `auth.getMobileSession`,
|
||||||
|
`auth.getToken`, `auth.getSession`, `track.scrobble` (up to 50 per request),
|
||||||
|
`track.updateNowPlaying`, `user.getInfo`, `user.getRecentTracks`, `user.getTopArtists`,
|
||||||
|
`user.getTopAlbums`, `user.getTopTracks`. `/api/docs` on your instance has the full
|
||||||
|
parameters and example responses for each, if you're curious or debugging a client.
|
||||||
|
|
||||||
|
A play is silently skipped (not rejected as an error) if the artist or track name is
|
||||||
|
empty, or its timestamp is more than 14 days old or more than 5 minutes in the future.
|
||||||
|
Sending the same play twice — a common side effect of a player retrying after a network
|
||||||
|
blip — is accepted both times but only stored once, so retries are always safe.
|
||||||
|
|
||||||
|
**A legacy scrobbler that speaks the old 1.2 "handshake" protocol (rather than 2.0) won't
|
||||||
|
work here** — this is a client limitation, not a setting to fix. VLC's built-in
|
||||||
|
scrobbler is one example; look for a plugin or a different player with 2.0 support.
|
||||||
|
|
||||||
|
## Importing history
|
||||||
|
|
||||||
|
Open **Import** in the web UI:
|
||||||
|
|
||||||
|
- **An export file**:
|
||||||
|
- CSV from [lastfm-to-csv](https://benjaminbenben.com/lastfm-to-csv/), no header row,
|
||||||
|
artist/album/track/date columns.
|
||||||
|
- Any CSV or TSV with a header row naming artist, track and a date or Unix-time
|
||||||
|
column. Comma, semicolon and tab delimiters all work.
|
||||||
|
- A JSON export of `user.getRecentTracks` pages (such as lastfm.ghan.nl's), a single
|
||||||
|
`recenttracks` response, or a flat list of tracks.
|
||||||
|
- Files can be gzipped.
|
||||||
|
- **Last.fm directly**: enter a Last.fm username and the import runs against that
|
||||||
|
account's public history. Only appears if your instance's admin has set this up.
|
||||||
|
|
||||||
|
Imports run in the background — the page shows progress and you can cancel one in
|
||||||
|
flight. Unlike live scrobbles, imports keep plays of any age (still skipping rows with no
|
||||||
|
artist or track, or plays dated in the future). Plays already in your history are
|
||||||
|
skipped, so importing the same export again, or importing overlapping exports, is safe.
|
||||||
|
|
||||||
|
## Your profile image
|
||||||
|
|
||||||
|
Click your name in the page header to open **Profile**, where you can give yourself a
|
||||||
|
picture, shown next to your name. Upload a JPEG, PNG or WebP image, or remove it again.
|
||||||
|
|
||||||
|
If your instance's admin has allowed it, you can also **use your Gravatar**. The server
|
||||||
|
asks Gravatar for the picture linked to your account email, sending it a hash of that
|
||||||
|
address (never the address itself), and keeps a copy; your browser doesn't contact
|
||||||
|
Gravatar. **Refresh Gravatar** fetches it again after you change it there. Choosing an
|
||||||
|
upload replaces a Gravatar and vice versa.
|
||||||
|
|
||||||
|
Your image is private by default. If your instance shares on the fediverse, **Sharing**
|
||||||
|
has a **Share my profile image** switch that shows it on your public profile page and
|
||||||
|
sends it to other servers as your picture. They keep their own copies, so a change or
|
||||||
|
removal can take a while to show up everywhere.
|
||||||
|
|
||||||
|
## Sharing on the fediverse
|
||||||
|
|
||||||
|
Only available if your instance's admin has turned this on — ask them, or check whether
|
||||||
|
**Sharing** appears in the navigation. Turn it on there, and you're findable as
|
||||||
|
`@name@<your instance's host>` from Mastodon and other fediverse apps.
|
||||||
|
|
||||||
|
- Follows are accepted automatically, or wait for your approval if you turn that on
|
||||||
|
under **Followers and discovery**.
|
||||||
|
- **Followers** lists requests, followers and blocked accounts, with approve, decline,
|
||||||
|
remove, block and unblock.
|
||||||
|
|
||||||
|
Once someone follows you, **Sharing**'s **What to post** section controls what they see:
|
||||||
|
|
||||||
|
- **Weekly summary**: your play count and top artist(s), posted once a week (Monday
|
||||||
|
09:00 in your own time zone, for the week that just ended). A live preview shows what
|
||||||
|
it would say so far.
|
||||||
|
- **Milestones**: total scrobbles, an artist's plays, and a new entry into your all-time
|
||||||
|
top 10 — each posted once, the first time you reach it. History already on file when
|
||||||
|
you turn sharing on, or added by an import, is never posted about retroactively.
|
||||||
|
|
||||||
|
Both are on by default and can be switched off independently. Posts use the same
|
||||||
|
visibility as your profile (followers only by default, or unlisted/public); **Posts**
|
||||||
|
lists your own posts, each with a delete button.
|
||||||
|
|
||||||
|
**Now playing** is a separate, three-way choice:
|
||||||
|
|
||||||
|
- **Off** (default): nothing shown or posted.
|
||||||
|
- **Show on my profile**: a "Now playing: *Track* by Artist" field on your profile,
|
||||||
|
refreshed at most every 5 minutes while something's playing and cleared a few minutes
|
||||||
|
after it stops.
|
||||||
|
- **Show on my profile and post**: the profile field, plus a post for each track played
|
||||||
|
30 seconds or more, at most one every 30 minutes, with the previous now-playing post
|
||||||
|
deleted once the new one is confirmed published.
|
||||||
|
|
||||||
|
**Your handle can't change once anyone follows you** — if you get to choose the
|
||||||
|
instance's domain yourself, or you're choosing which instance to join, bear that in mind
|
||||||
|
before you start sharing.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
**I turned Sharing on but can't see it in the menu.** Try a hard refresh
|
||||||
|
(Ctrl/Cmd+Shift+R) or a private/incognito window. The menu remembers whether sharing is
|
||||||
|
available for the length of a browser tab, so it can lag behind a setting your admin just
|
||||||
|
changed.
|
||||||
|
|
||||||
|
**My profile 404s on a big instance like mastodon.social right after I start sharing.**
|
||||||
|
Some servers cache a "not found" for a little while after they first look you up. Give it
|
||||||
|
an hour, or try searching from a smaller instance to confirm your handle really works.
|
||||||
|
|
||||||
|
**A change I made under Sharing doesn't seem to have taken effect.** Make sure you
|
||||||
|
clicked **Save sharing settings** at the bottom of the page — ticking a box alone doesn't
|
||||||
|
save it.
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Profile · Scrobbled</title>
|
||||||
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
|
<link rel="stylesheet" href="css/style.css">
|
||||||
|
<script src="config.js"></script>
|
||||||
|
<script type="module" src="js/account.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="site-header" id="site-header"></header>
|
||||||
|
<main id="main">
|
||||||
|
<h1 class="page-title">Profile</h1>
|
||||||
|
<p class="lede">Your profile image, shown next to your name.</p>
|
||||||
|
<div id="messages" aria-live="polite"></div>
|
||||||
|
<section id="avatar-panel"></section>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
After Width: | Height: | Size: 16 KiB |
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Allow access · Scrobbler</title>
|
<title>Allow access · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/approve.js"></script>
|
<script type="module" src="js/approve.js"></script>
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Apps · Scrobbler</title>
|
<title>Apps · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/apps.js"></script>
|
<script type="module" src="js/apps.js"></script>
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Album art · Scrobbled</title>
|
||||||
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
|
<link rel="stylesheet" href="css/style.css">
|
||||||
|
<script src="config.js"></script>
|
||||||
|
<script type="module" src="js/art-failures.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="site-header" id="site-header"></header>
|
||||||
|
<main id="main">
|
||||||
|
<h1 class="page-title">Album art</h1>
|
||||||
|
<p class="lede" id="art-summary">Albums you've scrobbled that have no cover art.</p>
|
||||||
|
<div id="messages" aria-live="polite"></div>
|
||||||
|
<ul class="rows art-rows" id="albums"></ul>
|
||||||
|
<nav class="pager" aria-label="Pages" id="pager"></nav>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Where the Scrobbler API lives. The UI container rewrites this file from the
|
// Where the Scrobbled API lives. The UI container rewrites this file from the
|
||||||
// API_BASE_URL environment variable at start-up; edit it by hand otherwise.
|
// API_BASE_URL environment variable at start-up; edit it by hand otherwise.
|
||||||
window.SCROBBLER_CONFIG = {
|
window.SCROBBLER_CONFIG = {
|
||||||
apiBaseUrl: "http://localhost:5050",
|
apiBaseUrl: "http://localhost:5050",
|
||||||
|
|||||||
@@ -152,18 +152,32 @@ code {
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.6rem;
|
gap: 0.6rem;
|
||||||
font-weight: 700;
|
|
||||||
font-size: var(--step-1);
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A small round "power" lamp */
|
/* The Scrobbled mark: a record with the tonearm resting on it */
|
||||||
.brand-mark {
|
.brand-mark {
|
||||||
width: 0.7rem;
|
width: 2rem;
|
||||||
height: 0.7rem;
|
height: 2rem;
|
||||||
border-radius: 50%;
|
background: url("../img/scrobbled-mark-simple.svg") center / contain no-repeat;
|
||||||
background: var(--glow);
|
}
|
||||||
box-shadow: 0 0 0 3px var(--panel), 0 0 10px 1px color-mix(in srgb, var(--glow) 60%, transparent);
|
|
||||||
|
/* The outlined wordmark; the name is in the link's visually-hidden text. The "b" is
|
||||||
|
lime on dark and violet on light, so there is one file per theme. */
|
||||||
|
.brand-word {
|
||||||
|
width: 5.3rem;
|
||||||
|
height: 1.4rem;
|
||||||
|
background: url("../img/scrobbled-wordmark-on-light.svg") center / contain no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root:not([data-theme="light"]) .brand-word {
|
||||||
|
background-image: url("../img/scrobbled-wordmark-on-dark.svg");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[data-theme="dark"] .brand-word {
|
||||||
|
background-image: url("../img/scrobbled-wordmark-on-dark.svg");
|
||||||
}
|
}
|
||||||
|
|
||||||
.site-header nav ul {
|
.site-header nav ul {
|
||||||
@@ -195,10 +209,76 @@ code {
|
|||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
align-items: baseline;
|
align-items: center;
|
||||||
color: var(--ink-soft);
|
color: var(--ink-soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.account-link {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
align-items: center;
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-link:hover .account-name {
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-avatar {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A profile image: round, with the placeholder ring while there's none */
|
||||||
|
.avatar {
|
||||||
|
display: block;
|
||||||
|
flex: none;
|
||||||
|
border-radius: 50%;
|
||||||
|
object-fit: cover;
|
||||||
|
background: var(--paper-raised);
|
||||||
|
border: 1px solid var(--rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-sm {
|
||||||
|
width: 1.75rem;
|
||||||
|
height: 1.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-lg {
|
||||||
|
width: 7rem;
|
||||||
|
height: 7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-empty {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-empty::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
inset: 32%;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 2px solid var(--bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 1.5rem;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-body {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.75rem;
|
||||||
|
max-width: 40rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-xl {
|
||||||
|
width: 6rem;
|
||||||
|
height: 6rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
max-width: 1120px;
|
max-width: 1120px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
@@ -582,6 +662,16 @@ input {
|
|||||||
background: var(--slate);
|
background: var(--slate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ranking a.name {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ranking a.name:hover,
|
||||||
|
.ranking a.name:focus-visible {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
/* ---- Listening log -------------------------------------------------------- */
|
/* ---- Listening log -------------------------------------------------------- */
|
||||||
.log {
|
.log {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
@@ -615,6 +705,22 @@ input {
|
|||||||
color: var(--ink-soft);
|
color: var(--ink-soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Stack the track above a muted artist line and make the cell a link, like .ranking rows */
|
||||||
|
.log-stacked .by {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-stacked li a {
|
||||||
|
display: block;
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-stacked li a:hover,
|
||||||
|
.log-stacked li a:focus-visible {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
.log-day {
|
.log-day {
|
||||||
margin: 2rem 0 0.25rem;
|
margin: 2rem 0 0.25rem;
|
||||||
font-size: var(--step-0);
|
font-size: var(--step-0);
|
||||||
@@ -977,3 +1083,170 @@ input {
|
|||||||
.confirm-off .button-row {
|
.confirm-off .button-row {
|
||||||
margin-top: 0.75rem;
|
margin-top: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---- Song lookup ------------------------------------------------------------ */
|
||||||
|
.song-search {
|
||||||
|
position: relative;
|
||||||
|
max-width: 28rem;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-search .field {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-results {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 10;
|
||||||
|
inset-inline: 0;
|
||||||
|
top: 100%;
|
||||||
|
margin: 0.25rem 0 0;
|
||||||
|
padding: 0.35rem;
|
||||||
|
list-style: none;
|
||||||
|
background: var(--paper-raised);
|
||||||
|
border: 1px solid var(--rule);
|
||||||
|
border-radius: var(--radius-control);
|
||||||
|
box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
|
||||||
|
max-height: 18rem;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-results li {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-results a {
|
||||||
|
display: block;
|
||||||
|
padding: 0.5rem 0.6rem;
|
||||||
|
border-radius: var(--radius-control);
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-results a:hover,
|
||||||
|
.search-results a:focus-visible {
|
||||||
|
background: var(--panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-results .by {
|
||||||
|
display: block;
|
||||||
|
color: var(--ink-soft);
|
||||||
|
font-size: var(--step--1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-results .empty {
|
||||||
|
padding: 0.5rem 0.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-meta {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
|
||||||
|
gap: 1rem 2rem;
|
||||||
|
margin: 1.25rem 0 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-meta div {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-meta dt {
|
||||||
|
font-size: var(--step--1);
|
||||||
|
color: var(--ink-soft);
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-meta dd {
|
||||||
|
margin: 0;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The song page's glowing display gets an art thumbnail alongside its text, when there's one */
|
||||||
|
.display-with-art {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.display-with-art .display-body {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.display-art {
|
||||||
|
width: 4.5rem;
|
||||||
|
height: 4.5rem;
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- Album art ---------------------------------------------------------------- */
|
||||||
|
.art-thumb {
|
||||||
|
display: block;
|
||||||
|
border-radius: var(--radius-control);
|
||||||
|
object-fit: cover;
|
||||||
|
background: var(--paper-raised);
|
||||||
|
border: 1px solid var(--rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
.art-thumb-empty {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No artwork: a plain ring, echoing the record in .brand-mark */
|
||||||
|
.art-thumb-empty::after {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
inset: 32%;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 2px solid var(--bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Most played > Albums: a thumbnail column ahead of the rank */
|
||||||
|
.ranking-art li {
|
||||||
|
grid-template-columns: 2.25rem 2rem minmax(0, 1fr) auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ranking-art .art-thumb {
|
||||||
|
width: 2.25rem;
|
||||||
|
height: 2.25rem;
|
||||||
|
align-self: center; /* .ranking li aligns its other cells to baseline, which suits text, not art */
|
||||||
|
}
|
||||||
|
|
||||||
|
.ranking-art .meter {
|
||||||
|
left: 5.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Recently played / History: a thumbnail column ahead of the time */
|
||||||
|
.log-art li {
|
||||||
|
grid-template-columns: 2.25rem 8rem minmax(0, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-art.log-clock li {
|
||||||
|
grid-template-columns: 2.25rem 3.5rem minmax(0, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-art .art-thumb {
|
||||||
|
width: 2.25rem;
|
||||||
|
height: 2.25rem;
|
||||||
|
align-self: center; /* .log li items default to stretch/start, which suits text, not art */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- Album art: fixing missing art ---------------------------------------------- */
|
||||||
|
.art-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 4rem minmax(0, 1fr);
|
||||||
|
gap: 1rem;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.art-thumb-lg {
|
||||||
|
width: 4rem;
|
||||||
|
height: 4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.art-row-body .muted {
|
||||||
|
margin: 0.35rem 0 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.art-correction {
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 4.7 KiB |
@@ -0,0 +1,7 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-6 8 196 196" width="512" height="512"><circle cx="88" cy="112" r="76" fill="#15131A" stroke="#F4F1EA" stroke-width="9"/>
|
||||||
|
<circle cx="88" cy="112" r="28" fill="#8B6CFF"/>
|
||||||
|
<path d="M168 32 L144 78" fill="none" stroke="#000000" stroke-width="14" stroke-linecap="round"/>
|
||||||
|
<circle cx="168" cy="32" r="14" fill="#F4F1EA" stroke="#000000" stroke-width="2.4"/>
|
||||||
|
<path d="M168 32 L144 78" fill="none" stroke="#F4F1EA" stroke-width="10" stroke-linecap="round"/>
|
||||||
|
<path d="M144 78 L126 108 L114 96" fill="none" stroke="#C8F560" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 639 B |
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Followers · Scrobbler</title>
|
<title>Followers · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/followers.js"></script>
|
<script type="module" src="js/followers.js"></script>
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>History · Scrobbler</title>
|
<title>History · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/history.js"></script>
|
<script type="module" src="js/history.js"></script>
|
||||||
|
|||||||
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 35 KiB |
@@ -0,0 +1,7 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-6 8 196 196" width="512" height="512"><circle cx="88" cy="112" r="76" fill="#15131A" stroke="#F4F1EA" stroke-width="9"/>
|
||||||
|
<circle cx="88" cy="112" r="28" fill="#8B6CFF"/>
|
||||||
|
<path d="M168 32 L144 78" fill="none" stroke="#000000" stroke-width="14" stroke-linecap="round"/>
|
||||||
|
<circle cx="168" cy="32" r="14" fill="#F4F1EA" stroke="#000000" stroke-width="2.4"/>
|
||||||
|
<path d="M168 32 L144 78" fill="none" stroke="#F4F1EA" stroke-width="10" stroke-linecap="round"/>
|
||||||
|
<path d="M144 78 L126 108 L114 96" fill="none" stroke="#C8F560" stroke-width="15" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 639 B |
@@ -0,0 +1,10 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-6 8 196 196" width="512" height="512"><circle cx="88" cy="112" r="78" fill="#15131A" stroke="#F4F1EA" stroke-width="5"/>
|
||||||
|
<circle cx="88" cy="112" r="60" fill="none" stroke="#F4F1EA" stroke-width="2" stroke-opacity="0.4"/>
|
||||||
|
<circle cx="88" cy="112" r="46" fill="none" stroke="#F4F1EA" stroke-width="2" stroke-opacity="0.28"/>
|
||||||
|
<circle cx="88" cy="112" r="24" fill="#8B6CFF"/>
|
||||||
|
<circle cx="88" cy="112" r="4" fill="#15131A"/>
|
||||||
|
<path d="M168 32 L144 78" fill="none" stroke="#000000" stroke-width="9" stroke-linecap="round"/>
|
||||||
|
<circle cx="168" cy="32" r="12" fill="#F4F1EA" stroke="#000000" stroke-width="1.6"/>
|
||||||
|
<path d="M168 32 L144 78" fill="none" stroke="#F4F1EA" stroke-width="7" stroke-linecap="round"/>
|
||||||
|
<path d="M144 78 L128 108 L119 99" fill="none" stroke="#C8F560" stroke-width="11" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 888 B |
@@ -0,0 +1,11 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-35.0 -111.0 554.7 146.0" width="555" height="146" role="img" aria-label="scrobbled">
|
||||||
|
<path d="M27.8 1.4Q22.5 1.4 18.2 0.45Q13.9 -0.5 10.7 -2.3Q7.5 -4.1 5.45 -6.65Q3.4 -9.2 2.6 -12.3L14.6 -17.6Q15.3 -15.9 17.05 -14.15Q18.8 -12.4 21.75 -11.3Q24.7 -10.2 28.9 -10.2Q32.9 -10.2 35.15 -11.35Q37.4 -12.5 37.4 -14.7Q37.4 -16.3 36.15 -17.25Q34.9 -18.2 32.4 -18.95Q29.9 -19.7 26.2 -20.4Q22.4 -21.2 18.5 -22.25Q14.6 -23.3 11.2 -25.15Q7.8 -27 5.75 -30.05Q3.7 -33.1 3.7 -37.8Q3.7 -42.7 6.3 -46.35Q8.9 -50 14.05 -52.1Q19.2 -54.2 26.6 -54.2Q33.2 -54.2 38.2 -52.5Q43.2 -50.8 46.55 -47.65Q49.9 -44.5 51.2 -40.1L38.3 -35.5Q37.8 -37.7 36.25 -39.3Q34.7 -40.9 32.35 -41.75Q30 -42.6 26.8 -42.6Q22.9 -42.6 20.75 -41.4Q18.6 -40.2 18.6 -38.2Q18.6 -36.6 20.05 -35.55Q21.5 -34.5 24.2 -33.8Q26.9 -33.1 30.6 -32.3Q34.5 -31.5 38.35 -30.45Q42.2 -29.4 45.35 -27.65Q48.5 -25.9 50.35 -23.05Q52.2 -20.2 52.2 -15.7Q52.2 -10.4 49.4 -6.55Q46.6 -2.7 41.15 -0.65Q35.7 1.4 27.8 1.4Z" fill="#F4F1EA"/>
|
||||||
|
<path d="M84.6 1.4Q77.8 1.4 72.6 -0.5Q67.4 -2.4 63.9 -5.95Q60.4 -9.5 58.55 -14.5Q56.7 -19.5 56.7 -25.7Q56.7 -32.1 58.55 -37.3Q60.4 -42.5 63.9 -46.3Q67.4 -50.1 72.5 -52.15Q77.6 -54.2 84.2 -54.2Q90.8 -54.2 95.6 -52.1Q100.4 -50 103.45 -46.2Q106.5 -42.4 107.6 -37.4L92.7 -32.4Q92.4 -35.7 91.1 -37.8Q89.8 -39.9 87.75 -40.85Q85.7 -41.8 83.3 -41.8Q80.8 -41.8 78.9 -40.8Q77 -39.8 75.7 -37.8Q74.4 -35.8 73.7 -32.95Q73 -30.1 73 -26.4Q73 -21.1 74.35 -17.55Q75.7 -14 78.35 -12.2Q81 -10.4 84.8 -10.4Q88.7 -10.4 90.9 -12Q93.1 -13.6 94.1 -15.95Q95.1 -18.3 95.3 -20.6L109.3 -17.5Q108.9 -13.8 107.35 -10.35Q105.8 -6.9 102.8 -4.25Q99.8 -1.6 95.35 -0.1Q90.9 1.4 84.6 1.4Z" fill="#F4F1EA"/>
|
||||||
|
<path d="M114.8 0V-24.5V-52.8H128L128.3 -34.9H130.3Q131 -41.9 132.95 -46.05Q134.9 -50.2 138.55 -52.1Q142.2 -54 147.6 -54Q148.4 -54 149.4 -53.95Q150.4 -53.9 151.7 -53.7L151.1 -36.5Q149.5 -37.3 147.65 -37.55Q145.8 -37.8 144.4 -37.8Q140.5 -37.8 137.65 -36.3Q134.8 -34.8 133.15 -31.7Q131.5 -28.6 131 -23.9V0Z" fill="#F4F1EA"/>
|
||||||
|
<path d="M181.7 1.4Q173.7 1.4 167.55 -1.7Q161.4 -4.8 157.9 -11Q154.4 -17.2 154.4 -26.5Q154.4 -35.8 157.9 -41.95Q161.4 -48.1 167.6 -51.15Q173.8 -54.2 181.8 -54.2Q189.8 -54.2 196 -51.1Q202.2 -48 205.7 -41.85Q209.2 -35.7 209.2 -26.4Q209.2 -16.9 205.6 -10.7Q202 -4.5 195.75 -1.55Q189.5 1.4 181.7 1.4ZM182.2 -10.3Q185.8 -10.3 188.2 -11.95Q190.6 -13.6 191.8 -17Q193 -20.4 193 -25.4Q193 -30.7 191.7 -34.35Q190.4 -38 187.85 -39.95Q185.3 -41.9 181.3 -41.9Q177.9 -41.9 175.45 -40.25Q173 -38.6 171.8 -35.2Q170.6 -31.8 170.6 -26.7Q170.6 -18.5 173.65 -14.4Q176.7 -10.3 182.2 -10.3Z" fill="#F4F1EA"/>
|
||||||
|
<path d="M250 1.4Q245 1.4 241.25 -0.5Q237.5 -2.4 235.15 -6.2Q232.8 -10 232 -15.6H230.1L229.8 0H216.6V-25.9V-72H232.7V-54.5Q232.7 -52.1 232.35 -49.45Q232 -46.8 231.45 -43.9Q230.9 -41 230.3 -37.7H232.6Q234 -43.1 236.3 -46.7Q238.6 -50.3 242.05 -52.15Q245.5 -54 250.2 -54Q256.8 -54 261.65 -50.6Q266.5 -47.2 269.2 -40.95Q271.9 -34.7 271.9 -26Q271.9 -17.6 269.25 -11.45Q266.6 -5.3 261.7 -1.95Q256.8 1.4 250 1.4ZM244 -11.6Q247.3 -11.6 249.8 -13.45Q252.3 -15.3 253.65 -18.65Q255 -22 255 -26.5Q255 -31.1 253.7 -34.35Q252.4 -37.6 250.05 -39.4Q247.7 -41.2 244.4 -41.2Q242.2 -41.2 240.35 -40.4Q238.5 -39.6 237.1 -38.2Q235.7 -36.8 234.7 -35.05Q233.7 -33.3 233.2 -31.35Q232.7 -29.4 232.7 -27.5V-25.4Q232.7 -23.3 233.3 -20.9Q233.9 -18.5 235.25 -16.4Q236.6 -14.3 238.75 -12.95Q240.9 -11.6 244 -11.6Z" fill="#C8F560"/>
|
||||||
|
<path d="M312.8 1.4Q307.8 1.4 304.05 -0.5Q300.3 -2.4 297.95 -6.2Q295.6 -10 294.8 -15.6H292.9L292.6 0H279.4V-25.9V-72H295.5V-54.5Q295.5 -52.1 295.15 -49.45Q294.8 -46.8 294.25 -43.9Q293.7 -41 293.1 -37.7H295.4Q296.8 -43.1 299.1 -46.7Q301.4 -50.3 304.85 -52.15Q308.3 -54 313 -54Q319.6 -54 324.45 -50.6Q329.3 -47.2 332 -40.95Q334.7 -34.7 334.7 -26Q334.7 -17.6 332.05 -11.45Q329.4 -5.3 324.5 -1.95Q319.6 1.4 312.8 1.4ZM306.8 -11.6Q310.1 -11.6 312.6 -13.45Q315.1 -15.3 316.45 -18.65Q317.8 -22 317.8 -26.5Q317.8 -31.1 316.5 -34.35Q315.2 -37.6 312.85 -39.4Q310.5 -41.2 307.2 -41.2Q305 -41.2 303.15 -40.4Q301.3 -39.6 299.9 -38.2Q298.5 -36.8 297.5 -35.05Q296.5 -33.3 296 -31.35Q295.5 -29.4 295.5 -27.5V-25.4Q295.5 -23.3 296.1 -20.9Q296.7 -18.5 298.05 -16.4Q299.4 -14.3 301.55 -12.95Q303.7 -11.6 306.8 -11.6Z" fill="#F4F1EA"/>
|
||||||
|
<path d="M342.2 0V-72H358V0Z" fill="#F4F1EA"/>
|
||||||
|
<path d="M393.6 1.4Q387 1.4 381.8 -0.35Q376.6 -2.1 372.95 -5.5Q369.3 -8.9 367.4 -13.9Q365.5 -18.9 365.5 -25.4Q365.5 -31.7 367.35 -37Q369.2 -42.3 372.65 -46.15Q376.1 -50 381.15 -52.1Q386.2 -54.2 392.5 -54.2Q398.9 -54.2 403.75 -52.15Q408.6 -50.1 411.75 -46.1Q414.9 -42.1 416.4 -36.35Q417.9 -30.6 417.4 -23.2L376.1 -22.9V-31.3L408.2 -31.6L402.5 -27.7Q403.2 -32.7 401.9 -35.85Q400.6 -39 398.1 -40.45Q395.6 -41.9 392.7 -41.9Q389.2 -41.9 386.55 -40Q383.9 -38.1 382.4 -34.5Q380.9 -30.9 380.9 -25.7Q380.9 -17.5 384.45 -13.8Q388 -10.1 393.5 -10.1Q396.2 -10.1 398 -10.85Q399.8 -11.6 400.95 -12.75Q402.1 -13.9 402.75 -15.3Q403.4 -16.7 403.8 -18L417.8 -15Q417 -11.3 415.25 -8.3Q413.5 -5.3 410.55 -3.1Q407.6 -0.9 403.45 0.25Q399.3 1.4 393.6 1.4Z" fill="#F4F1EA"/>
|
||||||
|
<path d="M445.3 1.4Q438.7 1.4 433.75 -1.95Q428.8 -5.3 426 -11.55Q423.2 -17.8 423.2 -26.5Q423.2 -34.5 425.6 -40.7Q428 -46.9 432.75 -50.45Q437.5 -54 444.5 -54Q449.5 -54 452.95 -52.2Q456.4 -50.4 458.7 -46.8Q461 -43.2 462.4 -37.7H464.9Q464.2 -41.1 463.6 -44.15Q463 -47.2 462.65 -49.85Q462.3 -52.5 462.3 -54.5V-72H478.5V-25.8V0H465.3L465.1 -15.6H462.9Q461.8 -9.6 459.45 -5.85Q457.1 -2.1 453.55 -0.35Q450 1.4 445.3 1.4ZM451.1 -11.6Q454.2 -11.6 456.35 -12.95Q458.5 -14.3 459.8 -16.4Q461.1 -18.5 461.7 -20.9Q462.3 -23.3 462.3 -25.4V-27.5Q462.3 -29.4 461.8 -31.3Q461.3 -33.2 460.35 -35Q459.4 -36.8 458 -38.2Q456.6 -39.6 454.75 -40.4Q452.9 -41.2 450.7 -41.2Q447.4 -41.2 445.05 -39.4Q442.7 -37.6 441.45 -34.3Q440.2 -31 440.2 -26.5Q440.2 -22 441.5 -18.65Q442.8 -15.3 445.3 -13.45Q447.8 -11.6 451.1 -11.6Z" fill="#F4F1EA"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 5.7 KiB |
@@ -0,0 +1,11 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-35.0 -111.0 554.7 146.0" width="555" height="146" role="img" aria-label="scrobbled">
|
||||||
|
<path d="M27.8 1.4Q22.5 1.4 18.2 0.45Q13.9 -0.5 10.7 -2.3Q7.5 -4.1 5.45 -6.65Q3.4 -9.2 2.6 -12.3L14.6 -17.6Q15.3 -15.9 17.05 -14.15Q18.8 -12.4 21.75 -11.3Q24.7 -10.2 28.9 -10.2Q32.9 -10.2 35.15 -11.35Q37.4 -12.5 37.4 -14.7Q37.4 -16.3 36.15 -17.25Q34.9 -18.2 32.4 -18.95Q29.9 -19.7 26.2 -20.4Q22.4 -21.2 18.5 -22.25Q14.6 -23.3 11.2 -25.15Q7.8 -27 5.75 -30.05Q3.7 -33.1 3.7 -37.8Q3.7 -42.7 6.3 -46.35Q8.9 -50 14.05 -52.1Q19.2 -54.2 26.6 -54.2Q33.2 -54.2 38.2 -52.5Q43.2 -50.8 46.55 -47.65Q49.9 -44.5 51.2 -40.1L38.3 -35.5Q37.8 -37.7 36.25 -39.3Q34.7 -40.9 32.35 -41.75Q30 -42.6 26.8 -42.6Q22.9 -42.6 20.75 -41.4Q18.6 -40.2 18.6 -38.2Q18.6 -36.6 20.05 -35.55Q21.5 -34.5 24.2 -33.8Q26.9 -33.1 30.6 -32.3Q34.5 -31.5 38.35 -30.45Q42.2 -29.4 45.35 -27.65Q48.5 -25.9 50.35 -23.05Q52.2 -20.2 52.2 -15.7Q52.2 -10.4 49.4 -6.55Q46.6 -2.7 41.15 -0.65Q35.7 1.4 27.8 1.4Z" fill="#15131A"/>
|
||||||
|
<path d="M84.6 1.4Q77.8 1.4 72.6 -0.5Q67.4 -2.4 63.9 -5.95Q60.4 -9.5 58.55 -14.5Q56.7 -19.5 56.7 -25.7Q56.7 -32.1 58.55 -37.3Q60.4 -42.5 63.9 -46.3Q67.4 -50.1 72.5 -52.15Q77.6 -54.2 84.2 -54.2Q90.8 -54.2 95.6 -52.1Q100.4 -50 103.45 -46.2Q106.5 -42.4 107.6 -37.4L92.7 -32.4Q92.4 -35.7 91.1 -37.8Q89.8 -39.9 87.75 -40.85Q85.7 -41.8 83.3 -41.8Q80.8 -41.8 78.9 -40.8Q77 -39.8 75.7 -37.8Q74.4 -35.8 73.7 -32.95Q73 -30.1 73 -26.4Q73 -21.1 74.35 -17.55Q75.7 -14 78.35 -12.2Q81 -10.4 84.8 -10.4Q88.7 -10.4 90.9 -12Q93.1 -13.6 94.1 -15.95Q95.1 -18.3 95.3 -20.6L109.3 -17.5Q108.9 -13.8 107.35 -10.35Q105.8 -6.9 102.8 -4.25Q99.8 -1.6 95.35 -0.1Q90.9 1.4 84.6 1.4Z" fill="#15131A"/>
|
||||||
|
<path d="M114.8 0V-24.5V-52.8H128L128.3 -34.9H130.3Q131 -41.9 132.95 -46.05Q134.9 -50.2 138.55 -52.1Q142.2 -54 147.6 -54Q148.4 -54 149.4 -53.95Q150.4 -53.9 151.7 -53.7L151.1 -36.5Q149.5 -37.3 147.65 -37.55Q145.8 -37.8 144.4 -37.8Q140.5 -37.8 137.65 -36.3Q134.8 -34.8 133.15 -31.7Q131.5 -28.6 131 -23.9V0Z" fill="#15131A"/>
|
||||||
|
<path d="M181.7 1.4Q173.7 1.4 167.55 -1.7Q161.4 -4.8 157.9 -11Q154.4 -17.2 154.4 -26.5Q154.4 -35.8 157.9 -41.95Q161.4 -48.1 167.6 -51.15Q173.8 -54.2 181.8 -54.2Q189.8 -54.2 196 -51.1Q202.2 -48 205.7 -41.85Q209.2 -35.7 209.2 -26.4Q209.2 -16.9 205.6 -10.7Q202 -4.5 195.75 -1.55Q189.5 1.4 181.7 1.4ZM182.2 -10.3Q185.8 -10.3 188.2 -11.95Q190.6 -13.6 191.8 -17Q193 -20.4 193 -25.4Q193 -30.7 191.7 -34.35Q190.4 -38 187.85 -39.95Q185.3 -41.9 181.3 -41.9Q177.9 -41.9 175.45 -40.25Q173 -38.6 171.8 -35.2Q170.6 -31.8 170.6 -26.7Q170.6 -18.5 173.65 -14.4Q176.7 -10.3 182.2 -10.3Z" fill="#15131A"/>
|
||||||
|
<path d="M250 1.4Q245 1.4 241.25 -0.5Q237.5 -2.4 235.15 -6.2Q232.8 -10 232 -15.6H230.1L229.8 0H216.6V-25.9V-72H232.7V-54.5Q232.7 -52.1 232.35 -49.45Q232 -46.8 231.45 -43.9Q230.9 -41 230.3 -37.7H232.6Q234 -43.1 236.3 -46.7Q238.6 -50.3 242.05 -52.15Q245.5 -54 250.2 -54Q256.8 -54 261.65 -50.6Q266.5 -47.2 269.2 -40.95Q271.9 -34.7 271.9 -26Q271.9 -17.6 269.25 -11.45Q266.6 -5.3 261.7 -1.95Q256.8 1.4 250 1.4ZM244 -11.6Q247.3 -11.6 249.8 -13.45Q252.3 -15.3 253.65 -18.65Q255 -22 255 -26.5Q255 -31.1 253.7 -34.35Q252.4 -37.6 250.05 -39.4Q247.7 -41.2 244.4 -41.2Q242.2 -41.2 240.35 -40.4Q238.5 -39.6 237.1 -38.2Q235.7 -36.8 234.7 -35.05Q233.7 -33.3 233.2 -31.35Q232.7 -29.4 232.7 -27.5V-25.4Q232.7 -23.3 233.3 -20.9Q233.9 -18.5 235.25 -16.4Q236.6 -14.3 238.75 -12.95Q240.9 -11.6 244 -11.6Z" fill="#8B6CFF"/>
|
||||||
|
<path d="M312.8 1.4Q307.8 1.4 304.05 -0.5Q300.3 -2.4 297.95 -6.2Q295.6 -10 294.8 -15.6H292.9L292.6 0H279.4V-25.9V-72H295.5V-54.5Q295.5 -52.1 295.15 -49.45Q294.8 -46.8 294.25 -43.9Q293.7 -41 293.1 -37.7H295.4Q296.8 -43.1 299.1 -46.7Q301.4 -50.3 304.85 -52.15Q308.3 -54 313 -54Q319.6 -54 324.45 -50.6Q329.3 -47.2 332 -40.95Q334.7 -34.7 334.7 -26Q334.7 -17.6 332.05 -11.45Q329.4 -5.3 324.5 -1.95Q319.6 1.4 312.8 1.4ZM306.8 -11.6Q310.1 -11.6 312.6 -13.45Q315.1 -15.3 316.45 -18.65Q317.8 -22 317.8 -26.5Q317.8 -31.1 316.5 -34.35Q315.2 -37.6 312.85 -39.4Q310.5 -41.2 307.2 -41.2Q305 -41.2 303.15 -40.4Q301.3 -39.6 299.9 -38.2Q298.5 -36.8 297.5 -35.05Q296.5 -33.3 296 -31.35Q295.5 -29.4 295.5 -27.5V-25.4Q295.5 -23.3 296.1 -20.9Q296.7 -18.5 298.05 -16.4Q299.4 -14.3 301.55 -12.95Q303.7 -11.6 306.8 -11.6Z" fill="#15131A"/>
|
||||||
|
<path d="M342.2 0V-72H358V0Z" fill="#15131A"/>
|
||||||
|
<path d="M393.6 1.4Q387 1.4 381.8 -0.35Q376.6 -2.1 372.95 -5.5Q369.3 -8.9 367.4 -13.9Q365.5 -18.9 365.5 -25.4Q365.5 -31.7 367.35 -37Q369.2 -42.3 372.65 -46.15Q376.1 -50 381.15 -52.1Q386.2 -54.2 392.5 -54.2Q398.9 -54.2 403.75 -52.15Q408.6 -50.1 411.75 -46.1Q414.9 -42.1 416.4 -36.35Q417.9 -30.6 417.4 -23.2L376.1 -22.9V-31.3L408.2 -31.6L402.5 -27.7Q403.2 -32.7 401.9 -35.85Q400.6 -39 398.1 -40.45Q395.6 -41.9 392.7 -41.9Q389.2 -41.9 386.55 -40Q383.9 -38.1 382.4 -34.5Q380.9 -30.9 380.9 -25.7Q380.9 -17.5 384.45 -13.8Q388 -10.1 393.5 -10.1Q396.2 -10.1 398 -10.85Q399.8 -11.6 400.95 -12.75Q402.1 -13.9 402.75 -15.3Q403.4 -16.7 403.8 -18L417.8 -15Q417 -11.3 415.25 -8.3Q413.5 -5.3 410.55 -3.1Q407.6 -0.9 403.45 0.25Q399.3 1.4 393.6 1.4Z" fill="#15131A"/>
|
||||||
|
<path d="M445.3 1.4Q438.7 1.4 433.75 -1.95Q428.8 -5.3 426 -11.55Q423.2 -17.8 423.2 -26.5Q423.2 -34.5 425.6 -40.7Q428 -46.9 432.75 -50.45Q437.5 -54 444.5 -54Q449.5 -54 452.95 -52.2Q456.4 -50.4 458.7 -46.8Q461 -43.2 462.4 -37.7H464.9Q464.2 -41.1 463.6 -44.15Q463 -47.2 462.65 -49.85Q462.3 -52.5 462.3 -54.5V-72H478.5V-25.8V0H465.3L465.1 -15.6H462.9Q461.8 -9.6 459.45 -5.85Q457.1 -2.1 453.55 -0.35Q450 1.4 445.3 1.4ZM451.1 -11.6Q454.2 -11.6 456.35 -12.95Q458.5 -14.3 459.8 -16.4Q461.1 -18.5 461.7 -20.9Q462.3 -23.3 462.3 -25.4V-27.5Q462.3 -29.4 461.8 -31.3Q461.3 -33.2 460.35 -35Q459.4 -36.8 458 -38.2Q456.6 -39.6 454.75 -40.4Q452.9 -41.2 450.7 -41.2Q447.4 -41.2 445.05 -39.4Q442.7 -37.6 441.45 -34.3Q440.2 -31 440.2 -26.5Q440.2 -22 441.5 -18.65Q442.8 -15.3 445.3 -13.45Q447.8 -11.6 451.1 -11.6Z" fill="#15131A"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 5.7 KiB |
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Import · Scrobbler</title>
|
<title>Import · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/import.js"></script>
|
<script type="module" src="js/import.js"></script>
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Overview · Scrobbler</title>
|
<title>Overview · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/dashboard.js"></script>
|
<script type="module" src="js/dashboard.js"></script>
|
||||||
@@ -14,6 +18,14 @@
|
|||||||
<main id="main">
|
<main id="main">
|
||||||
<h1 class="visually-hidden">Overview</h1>
|
<h1 class="visually-hidden">Overview</h1>
|
||||||
<div id="panel" class="panel" aria-live="polite"></div>
|
<div id="panel" class="panel" aria-live="polite"></div>
|
||||||
|
<section aria-labelledby="song-search-title" class="song-search">
|
||||||
|
<h2 id="song-search-title" class="visually-hidden">Find a song</h2>
|
||||||
|
<div class="field">
|
||||||
|
<label for="song-search">Find a song</label>
|
||||||
|
<input id="song-search" type="search" autocomplete="off" placeholder="Search your scrobbles…">
|
||||||
|
</div>
|
||||||
|
<ul class="search-results" id="song-search-results" hidden></ul>
|
||||||
|
</section>
|
||||||
<section aria-labelledby="charts-title">
|
<section aria-labelledby="charts-title">
|
||||||
<div class="section-head">
|
<div class="section-head">
|
||||||
<h2 id="charts-title">Most played</h2>
|
<h2 id="charts-title">Most played</h2>
|
||||||
@@ -23,6 +35,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="charts">
|
<div class="charts">
|
||||||
<div><h3 class="muted">Artists</h3><ol class="ranking" id="top-artists"></ol></div>
|
<div><h3 class="muted">Artists</h3><ol class="ranking" id="top-artists"></ol></div>
|
||||||
|
<div><h3 class="muted">Albums</h3><ol class="ranking ranking-art" id="top-albums"></ol></div>
|
||||||
<div><h3 class="muted">Tracks</h3><ol class="ranking" id="top-tracks"></ol></div>
|
<div><h3 class="muted">Tracks</h3><ol class="ranking" id="top-tracks"></ol></div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -31,7 +44,7 @@
|
|||||||
<h2 id="recent-title">Recently played</h2>
|
<h2 id="recent-title">Recently played</h2>
|
||||||
<a href="history.html">Full history</a>
|
<a href="history.html">Full history</a>
|
||||||
</div>
|
</div>
|
||||||
<ol class="log" id="recent"></ol>
|
<ol class="log log-stacked log-art" id="recent"></ol>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import { api, describeError, upload } from "./api.js";
|
||||||
|
import { avatarImage } from "./avatar.js";
|
||||||
|
import { errorBox, h, replace } from "./dom.js";
|
||||||
|
import { signedInPage } from "./layout.js";
|
||||||
|
|
||||||
|
const root = document.getElementById("avatar-panel");
|
||||||
|
const messages = document.getElementById("messages");
|
||||||
|
|
||||||
|
const SOURCES = {
|
||||||
|
upload: "An image you uploaded.",
|
||||||
|
gravatar: "Your Gravatar, copied to this server.",
|
||||||
|
none: "You haven't set a profile image yet.",
|
||||||
|
};
|
||||||
|
|
||||||
|
let user = await signedInPage("account.html");
|
||||||
|
render();
|
||||||
|
|
||||||
|
function say(notice) {
|
||||||
|
replace(messages, notice);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runs a change, adopts the user it returns (or refetches), and redraws everything that
|
||||||
|
// shows the image - this panel and the one in the page header.
|
||||||
|
async function change(action, done) {
|
||||||
|
const buttons = root.querySelectorAll("button");
|
||||||
|
buttons.forEach((button) => (button.disabled = true));
|
||||||
|
try {
|
||||||
|
user = (await action()) ?? (await api("/auth/me"));
|
||||||
|
say(h("p", { class: "notice notice-ok" }, done));
|
||||||
|
} catch (error) {
|
||||||
|
say(errorBox(describeError(error)));
|
||||||
|
}
|
||||||
|
render();
|
||||||
|
const slot = document.querySelector(".account-avatar");
|
||||||
|
if (slot) replace(slot, avatarImage(user, "avatar-sm"));
|
||||||
|
}
|
||||||
|
|
||||||
|
function render() {
|
||||||
|
const file = h("input", { type: "file", accept: "image/jpeg,image/png,image/webp", hidden: true });
|
||||||
|
file.addEventListener("change", () => {
|
||||||
|
if (!file.files[0]) return;
|
||||||
|
const data = new FormData();
|
||||||
|
data.append("file", file.files[0]);
|
||||||
|
change(() => upload("/me/avatar", data, undefined, "PUT"), "Profile image updated.");
|
||||||
|
});
|
||||||
|
|
||||||
|
const buttons = [
|
||||||
|
h("button", { type: "button", class: "button", onclick: () => file.click() }, "Upload image"),
|
||||||
|
user.gravatar_enabled
|
||||||
|
? h(
|
||||||
|
"button",
|
||||||
|
{
|
||||||
|
type: "button",
|
||||||
|
class: "button button-quiet",
|
||||||
|
onclick: () => change(() => api("/me/avatar/gravatar", { method: "POST" }), "Now using your Gravatar."),
|
||||||
|
},
|
||||||
|
user.avatar_source === "gravatar" ? "Refresh Gravatar" : "Use my Gravatar",
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
user.has_avatar
|
||||||
|
? h(
|
||||||
|
"button",
|
||||||
|
{
|
||||||
|
type: "button",
|
||||||
|
class: "button button-quiet",
|
||||||
|
onclick: () => change(() => api("/me/avatar", { method: "DELETE" }), "Profile image removed."),
|
||||||
|
},
|
||||||
|
"Remove",
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
];
|
||||||
|
|
||||||
|
replace(
|
||||||
|
root,
|
||||||
|
h(
|
||||||
|
"div",
|
||||||
|
{ class: "avatar-row" },
|
||||||
|
avatarImage(user, "avatar-lg"),
|
||||||
|
h(
|
||||||
|
"div",
|
||||||
|
{ class: "avatar-body" },
|
||||||
|
h("p", {}, SOURCES[user.avatar_source] ?? SOURCES.none),
|
||||||
|
h("p", { class: "muted" }, "JPEG, PNG or WebP. Only you see it, unless you choose to share it on your fediverse profile."),
|
||||||
|
h("div", { class: "button-row" }, buttons, file),
|
||||||
|
user.gravatar_enabled
|
||||||
|
? h(
|
||||||
|
"p",
|
||||||
|
{ class: "muted" },
|
||||||
|
"Using Gravatar makes this server ask Gravatar for the picture linked to your email address, sending it a hash of that address (not the address itself). Your browser never contacts Gravatar.",
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Thin client for the Scrobbler /api/v1 JSON API.
|
// Thin client for the Scrobbled /api/v1 JSON API.
|
||||||
|
|
||||||
const TOKEN_KEY = "scrobbler.token";
|
const TOKEN_KEY = "scrobbler.token";
|
||||||
|
|
||||||
@@ -40,6 +40,29 @@ export function redirectToLogin() {
|
|||||||
location.href = `login.html?next=${encodeURIComponent(safeNext(here + location.search))}`;
|
location.href = `login.html?next=${encodeURIComponent(safeNext(here + location.search))}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetches a binary resource (e.g. album art) with the same bearer-auth transport as api(),
|
||||||
|
// returning a blob: object URL, or null on any failure (including a 404 "no art" response) -
|
||||||
|
// the caller treats "missing" and "couldn't fetch" the same way: show a placeholder.
|
||||||
|
export async function fetchImage(path) {
|
||||||
|
const headers = {};
|
||||||
|
const token = getToken();
|
||||||
|
if (token) headers.Authorization = `Bearer ${token}`;
|
||||||
|
|
||||||
|
let response;
|
||||||
|
try {
|
||||||
|
response = await fetch(`${apiBase}/api/v1${path}`, { headers });
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (response.status === 401) {
|
||||||
|
setToken(null);
|
||||||
|
redirectToLogin();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!response.ok) return null;
|
||||||
|
return URL.createObjectURL(await response.blob());
|
||||||
|
}
|
||||||
|
|
||||||
export async function api(path, { method = "GET", body, auth = true } = {}) {
|
export async function api(path, { method = "GET", body, auth = true } = {}) {
|
||||||
const headers = {};
|
const headers = {};
|
||||||
if (body !== undefined) headers["Content-Type"] = "application/json";
|
if (body !== undefined) headers["Content-Type"] = "application/json";
|
||||||
@@ -54,7 +77,7 @@ export async function api(path, { method = "GET", body, auth = true } = {}) {
|
|||||||
body: body === undefined ? undefined : JSON.stringify(body),
|
body: body === undefined ? undefined : JSON.stringify(body),
|
||||||
});
|
});
|
||||||
} catch {
|
} catch {
|
||||||
throw new ApiError(0, "network", `Can't reach the Scrobbler API at ${apiBase}. Check that it's running.`);
|
throw new ApiError(0, "network", `Can't reach the Scrobbled API at ${apiBase}. Check that it's running.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.status === 401 && auth) {
|
if (response.status === 401 && auth) {
|
||||||
@@ -79,7 +102,7 @@ export async function api(path, { method = "GET", body, auth = true } = {}) {
|
|||||||
|
|
||||||
// Turn webargs validation details into a single readable sentence.
|
// Turn webargs validation details into a single readable sentence.
|
||||||
export function describeError(error) {
|
export function describeError(error) {
|
||||||
const fields = error.details?.json ?? error.details?.query;
|
const fields = error.details?.json ?? error.details?.query ?? error.details?.files;
|
||||||
if (fields) {
|
if (fields) {
|
||||||
return Object.entries(fields)
|
return Object.entries(fields)
|
||||||
.map(([field, messages]) => `${field}: ${[].concat(messages).join(" ")}`)
|
.map(([field, messages]) => `${field}: ${[].concat(messages).join(" ")}`)
|
||||||
@@ -89,17 +112,17 @@ export function describeError(error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Multipart upload with progress (fetch can't report upload progress).
|
// Multipart upload with progress (fetch can't report upload progress).
|
||||||
export function upload(path, formData, onProgress) {
|
export function upload(path, formData, onProgress, method = "POST") {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.open("POST", `${apiBase}/api/v1${path}`);
|
xhr.open(method, `${apiBase}/api/v1${path}`);
|
||||||
const token = getToken();
|
const token = getToken();
|
||||||
if (token) xhr.setRequestHeader("Authorization", `Bearer ${token}`);
|
if (token) xhr.setRequestHeader("Authorization", `Bearer ${token}`);
|
||||||
xhr.upload.addEventListener("progress", (event) => {
|
xhr.upload.addEventListener("progress", (event) => {
|
||||||
if (event.lengthComputable) onProgress?.(event.loaded / event.total);
|
if (event.lengthComputable) onProgress?.(event.loaded / event.total);
|
||||||
});
|
});
|
||||||
xhr.addEventListener("error", () =>
|
xhr.addEventListener("error", () =>
|
||||||
reject(new ApiError(0, "network", `Can't reach the Scrobbler API at ${apiBase}. Check that it's running.`)),
|
reject(new ApiError(0, "network", `Can't reach the Scrobbled API at ${apiBase}. Check that it's running.`)),
|
||||||
);
|
);
|
||||||
xhr.addEventListener("load", () => {
|
xhr.addEventListener("load", () => {
|
||||||
let data = null;
|
let data = null;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ function renderSetup() {
|
|||||||
h("dt", {}, "Username"),
|
h("dt", {}, "Username"),
|
||||||
h("dd", {}, h("code", {}, user.username)),
|
h("dd", {}, h("code", {}, user.username)),
|
||||||
h("dt", {}, "Password"),
|
h("dt", {}, "Password"),
|
||||||
h("dd", {}, "Your Scrobbler password"),
|
h("dd", {}, "Your Scrobbled password"),
|
||||||
h("dt", {}, "Key and secret"),
|
h("dt", {}, "Key and secret"),
|
||||||
h("dd", {}, "From one of the apps above"),
|
h("dd", {}, "From one of the apps above"),
|
||||||
h("dt", {}, "API reference"),
|
h("dt", {}, "API reference"),
|
||||||
|
|||||||
@@ -0,0 +1,178 @@
|
|||||||
|
import { api, describeError, upload } from "./api.js";
|
||||||
|
import { artThumb, forgetArt } from "./art.js";
|
||||||
|
import { errorBox, h, num, replace } from "./dom.js";
|
||||||
|
import { signedInPage } from "./layout.js";
|
||||||
|
|
||||||
|
const PER_PAGE = 25;
|
||||||
|
const list = document.getElementById("albums");
|
||||||
|
const messages = document.getElementById("messages");
|
||||||
|
const pager = document.getElementById("pager");
|
||||||
|
const page = Math.max(1, Number.parseInt(new URLSearchParams(location.search).get("page"), 10) || 1);
|
||||||
|
|
||||||
|
await signedInPage("art.html");
|
||||||
|
await refresh();
|
||||||
|
|
||||||
|
async function refresh() {
|
||||||
|
try {
|
||||||
|
render(await api(`/art/failures?page=${page}&limit=${PER_PAGE}`));
|
||||||
|
} catch (error) {
|
||||||
|
replace(list, h("li", {}, errorBox(error.message)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function render(result) {
|
||||||
|
document.getElementById("art-summary").textContent = result.total
|
||||||
|
? `${num(result.total)} of your albums have no cover art, most-played first. Upload a picture, retry the lookup, or correct what it searches for.`
|
||||||
|
: "Every album you've scrobbled has cover art, or is still being looked up.";
|
||||||
|
if (!result.items.length) {
|
||||||
|
replace(list);
|
||||||
|
} else {
|
||||||
|
replace(list, result.items.map(albumRow));
|
||||||
|
}
|
||||||
|
replace(
|
||||||
|
pager,
|
||||||
|
result.page > 1 ? h("a", { class: "button button-quiet", href: `?page=${result.page - 1}` }, "Previous") : h("span"),
|
||||||
|
result.page < result.total_pages
|
||||||
|
? h("a", { class: "button button-quiet", href: `?page=${result.page + 1}` }, "Next")
|
||||||
|
: h("span"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function statusText(item) {
|
||||||
|
const own = item.override;
|
||||||
|
if (own?.status === "pending") return "Your correction is waiting to be looked up.";
|
||||||
|
if (own?.status === "error") {
|
||||||
|
return own.error_code === "NotFound"
|
||||||
|
? "Your correction didn't find any art."
|
||||||
|
: `Your correction failed (${own.error_code ?? "unknown error"}).`;
|
||||||
|
}
|
||||||
|
if (item.status === "error") return `The lookup failed (${item.error_code ?? "unknown error"}). It will be tried again.`;
|
||||||
|
if (item.status === "not_found") return "No cover art was found for this album.";
|
||||||
|
return "Waiting to be looked up.";
|
||||||
|
}
|
||||||
|
|
||||||
|
function say(notice) {
|
||||||
|
replace(messages, notice);
|
||||||
|
}
|
||||||
|
|
||||||
|
function albumRow(item) {
|
||||||
|
const { artist, album } = item;
|
||||||
|
const query = `artist=${encodeURIComponent(artist)}&album=${encodeURIComponent(album)}`;
|
||||||
|
const fileInput = h("input", { type: "file", accept: "image/jpeg,image/png,image/webp", hidden: true });
|
||||||
|
const correction = correctionForm(item, query);
|
||||||
|
const buttons = h("div", { class: "button-row" });
|
||||||
|
const busy = (on) => buttons.querySelectorAll("button").forEach((b) => (b.disabled = on));
|
||||||
|
|
||||||
|
async function act(work, done) {
|
||||||
|
busy(true);
|
||||||
|
replace(messages);
|
||||||
|
try {
|
||||||
|
await work();
|
||||||
|
say(h("p", { class: "notice notice-ok", role: "status" }, done));
|
||||||
|
forgetArt(artist, album);
|
||||||
|
await refresh();
|
||||||
|
} catch (error) {
|
||||||
|
say(errorBox(describeError(error)));
|
||||||
|
} finally {
|
||||||
|
busy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fileInput.addEventListener("change", () => {
|
||||||
|
const file = fileInput.files[0];
|
||||||
|
if (!file) return;
|
||||||
|
const data = new FormData();
|
||||||
|
data.append("file", file);
|
||||||
|
act(() => upload(`/art/album?${query}`, data), `Uploaded art for ${album}.`);
|
||||||
|
fileInput.value = "";
|
||||||
|
});
|
||||||
|
|
||||||
|
replace(
|
||||||
|
buttons,
|
||||||
|
h("button", { type: "button", class: "button", onclick: () => fileInput.click() }, "Upload art"),
|
||||||
|
h(
|
||||||
|
"button",
|
||||||
|
{
|
||||||
|
type: "button",
|
||||||
|
class: "button button-quiet",
|
||||||
|
onclick: () => act(() => api(`/art/album/retry?${query}`, { method: "POST" }), `Looking up ${album} again.`),
|
||||||
|
},
|
||||||
|
"Retry lookup",
|
||||||
|
),
|
||||||
|
h(
|
||||||
|
"button",
|
||||||
|
{ type: "button", class: "button button-quiet", onclick: () => (correction.hidden = !correction.hidden) },
|
||||||
|
"Correct search",
|
||||||
|
),
|
||||||
|
item.override
|
||||||
|
? h(
|
||||||
|
"button",
|
||||||
|
{
|
||||||
|
type: "button",
|
||||||
|
class: "button button-quiet",
|
||||||
|
onclick: () => act(() => api(`/art/album?${query}`, { method: "DELETE" }), `Removed your correction for ${album}.`),
|
||||||
|
},
|
||||||
|
"Remove mine",
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
correction.addEventListener("submit", (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
const body = { artist, album };
|
||||||
|
const { search_artist, search_album, release_group_mbid, release_mbid } = correction.elements;
|
||||||
|
if (search_artist.value.trim()) body.search_artist = search_artist.value.trim();
|
||||||
|
if (search_album.value.trim()) body.search_album = search_album.value.trim();
|
||||||
|
if (release_group_mbid.value.trim()) body.release_group_mbid = release_group_mbid.value.trim();
|
||||||
|
if (release_mbid.value.trim()) body.release_mbid = release_mbid.value.trim();
|
||||||
|
act(() => api("/art/album/correction", { method: "PUT", body }), `Queued a corrected lookup for ${album}.`);
|
||||||
|
});
|
||||||
|
|
||||||
|
return h(
|
||||||
|
"li",
|
||||||
|
{ class: "art-row" },
|
||||||
|
artThumb(artist, album, "art-thumb-lg"),
|
||||||
|
h(
|
||||||
|
"div",
|
||||||
|
{ class: "art-row-body" },
|
||||||
|
h("span", { class: "row-title" }, album),
|
||||||
|
h("span", { class: "by" }, ` by ${artist}`),
|
||||||
|
h("p", { class: "muted" }, `${num(item.scrobbles)} ${item.scrobbles === 1 ? "scrobble" : "scrobbles"} · ${statusText(item)}`),
|
||||||
|
buttons,
|
||||||
|
fileInput,
|
||||||
|
correction,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function correctionForm(item, query) {
|
||||||
|
const own = item.override ?? {};
|
||||||
|
const field = (name, label, value, hint, extra = {}) =>
|
||||||
|
h(
|
||||||
|
"div",
|
||||||
|
{ class: "field" },
|
||||||
|
h("label", { for: `${name}-${query}` }, label),
|
||||||
|
h("input", { id: `${name}-${query}`, name, type: "text", value: value ?? "", autocomplete: "off", ...extra }),
|
||||||
|
hint ? h("p", { class: "hint" }, hint) : null,
|
||||||
|
);
|
||||||
|
return h(
|
||||||
|
"form",
|
||||||
|
{ class: "stacked-form art-correction", hidden: true },
|
||||||
|
field("search_artist", "Search for artist", own.search_artist ?? item.artist),
|
||||||
|
field("search_album", "Search for album", own.search_album ?? item.album),
|
||||||
|
field(
|
||||||
|
"release_group_mbid",
|
||||||
|
"MusicBrainz release-group ID (optional)",
|
||||||
|
own.release_group_mbid,
|
||||||
|
"If you know it, paste the ID from the album's MusicBrainz page. It skips the search.",
|
||||||
|
{ placeholder: "00000000-0000-0000-0000-000000000000", pattern: "[0-9a-fA-F-]{36}" },
|
||||||
|
),
|
||||||
|
field(
|
||||||
|
"release_mbid",
|
||||||
|
"MusicBrainz release ID (optional)",
|
||||||
|
own.release_mbid,
|
||||||
|
"Or a specific release's ID, if that's the one you have. Use either this or the release-group ID.",
|
||||||
|
{ placeholder: "00000000-0000-0000-0000-000000000000", pattern: "[0-9a-fA-F-]{36}" },
|
||||||
|
),
|
||||||
|
h("button", { type: "submit", class: "button" }, "Look it up"),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
// A small thumbnail that starts as a placeholder and swaps itself for the real album art
|
||||||
|
// once (if) it resolves. Shared by every list/page that shows art.
|
||||||
|
|
||||||
|
import { fetchImage } from "./api.js";
|
||||||
|
import { h } from "./dom.js";
|
||||||
|
|
||||||
|
const cache = new Map(); // dedupes repeat/concurrent lookups for the same album within a page
|
||||||
|
|
||||||
|
const keyFor = (artist, album) => `${artist.toLowerCase()}␟${album.toLowerCase()}`;
|
||||||
|
|
||||||
|
// Forget a looked-up album (after the user uploads or corrects its art) so the next
|
||||||
|
// artThumb() for it asks the server again instead of reusing the stale answer.
|
||||||
|
export function forgetArt(artist, album) {
|
||||||
|
cache.delete(keyFor(artist, album));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function artThumb(artist, album, extraClass) {
|
||||||
|
const classes = extraClass ? `art-thumb ${extraClass}` : "art-thumb";
|
||||||
|
const el = h("div", { class: `${classes} art-thumb-empty` });
|
||||||
|
if (!album) return el; // nothing to look up
|
||||||
|
|
||||||
|
const key = keyFor(artist, album);
|
||||||
|
if (!cache.has(key)) {
|
||||||
|
cache.set(
|
||||||
|
key,
|
||||||
|
fetchImage(`/art/album?artist=${encodeURIComponent(artist)}&album=${encodeURIComponent(album)}`),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
cache.get(key).then((url) => {
|
||||||
|
if (!url) return; // miss or failed fetch: leave the placeholder
|
||||||
|
// Not revoked: the same URL is shared by every thumbnail for this album on the page
|
||||||
|
// (see `cache` above), and this is a full-page-reload site, so the browser releases it
|
||||||
|
// on navigation anyway.
|
||||||
|
const img = h("img", { class: classes, alt: "", loading: "lazy" });
|
||||||
|
img.src = url;
|
||||||
|
el.replaceWith(img);
|
||||||
|
});
|
||||||
|
return el;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// A round profile image that starts as a placeholder ring and swaps itself for the real
|
||||||
|
// picture once (if) it loads. `source` is either a signed-in user (their own image,
|
||||||
|
// fetched with their token) or { path } for another public image URL.
|
||||||
|
|
||||||
|
import { fetchImage } from "./api.js";
|
||||||
|
import { h } from "./dom.js";
|
||||||
|
|
||||||
|
export function avatarImage(user, extraClass, path = "/me/avatar") {
|
||||||
|
const classes = extraClass ? `avatar ${extraClass}` : "avatar";
|
||||||
|
const el = h("span", { class: `${classes} avatar-empty`, "aria-hidden": "true" });
|
||||||
|
if (!user?.has_avatar) return el;
|
||||||
|
fetchImage(path).then((url) => {
|
||||||
|
if (!url) return; // miss or failed fetch: leave the placeholder
|
||||||
|
const img = h("img", { class: classes, alt: "" });
|
||||||
|
img.src = url;
|
||||||
|
el.replaceWith(img);
|
||||||
|
});
|
||||||
|
return el;
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import { api } from "./api.js";
|
import { api } from "./api.js";
|
||||||
import { errorBox, formatDate, formatDuration, h, num, replace, timeAgo } from "./dom.js";
|
import { artThumb } from "./art.js";
|
||||||
|
import { errorBox, formatDuration, h, num, replace, timeAgo } from "./dom.js";
|
||||||
import { signedInPage } from "./layout.js";
|
import { signedInPage } from "./layout.js";
|
||||||
|
import { spectrum } from "./spectrum.js";
|
||||||
|
|
||||||
const PERIODS = [
|
const PERIODS = [
|
||||||
["7day", "7 days"],
|
["7day", "7 days"],
|
||||||
@@ -9,7 +11,6 @@ const PERIODS = [
|
|||||||
["overall", "All time"],
|
["overall", "All time"],
|
||||||
];
|
];
|
||||||
const PERIOD_KEY = "scrobbler.period";
|
const PERIOD_KEY = "scrobbler.period";
|
||||||
const SEGMENTS = 10; // lit segments per spectrum column at the busiest day
|
|
||||||
const NOW_PLAYING_POLL_MS = 30_000;
|
const NOW_PLAYING_POLL_MS = 30_000;
|
||||||
|
|
||||||
const panel = document.getElementById("panel");
|
const panel = document.getElementById("panel");
|
||||||
@@ -19,6 +20,7 @@ let progressTimer;
|
|||||||
|
|
||||||
await signedInPage("index.html");
|
await signedInPage("index.html");
|
||||||
renderPeriodSelector();
|
renderPeriodSelector();
|
||||||
|
initSongSearch();
|
||||||
await Promise.all([loadPanel(), loadTop(currentPeriod()), loadRecent()]).catch(showError);
|
await Promise.all([loadPanel(), loadTop(currentPeriod()), loadRecent()]).catch(showError);
|
||||||
setInterval(() => refreshDisplay().catch(() => {}), NOW_PLAYING_POLL_MS);
|
setInterval(() => refreshDisplay().catch(() => {}), NOW_PLAYING_POLL_MS);
|
||||||
|
|
||||||
@@ -117,55 +119,6 @@ function readouts(summary) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Daily plays for the last 30 days, drawn as a segmented level meter.
|
|
||||||
function spectrum(counts) {
|
|
||||||
const NS = "http://www.w3.org/2000/svg";
|
|
||||||
const width = 1000;
|
|
||||||
const height = 96;
|
|
||||||
const gap = 4;
|
|
||||||
const max = Math.max(1, ...counts.map((c) => c.count));
|
|
||||||
const columnWidth = width / counts.length;
|
|
||||||
const segmentHeight = height / SEGMENTS;
|
|
||||||
const total = counts.reduce((sum, c) => sum + c.count, 0);
|
|
||||||
|
|
||||||
const svg = document.createElementNS(NS, "svg");
|
|
||||||
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
||||||
svg.setAttribute("preserveAspectRatio", "none");
|
|
||||||
svg.setAttribute("role", "img");
|
|
||||||
svg.setAttribute("aria-label", `Plays per day over the last ${counts.length} days: ${num(total)} in total`);
|
|
||||||
|
|
||||||
counts.forEach((day, i) => {
|
|
||||||
const lit = day.count ? Math.max(1, Math.round((day.count / max) * SEGMENTS)) : 0;
|
|
||||||
const group = document.createElementNS(NS, "g");
|
|
||||||
const title = document.createElementNS(NS, "title");
|
|
||||||
title.textContent = `${formatDate(day.start)}: ${num(day.count)} ${day.count === 1 ? "play" : "plays"}`;
|
|
||||||
group.append(title);
|
|
||||||
for (let s = 0; s < SEGMENTS; s++) {
|
|
||||||
const rect = document.createElementNS(NS, "rect");
|
|
||||||
rect.setAttribute("x", i * columnWidth + gap / 2);
|
|
||||||
rect.setAttribute("y", height - (s + 1) * segmentHeight + 1.5);
|
|
||||||
rect.setAttribute("width", columnWidth - gap);
|
|
||||||
rect.setAttribute("height", segmentHeight - 3);
|
|
||||||
rect.setAttribute("class", s < lit ? "seg-on" : "seg-off");
|
|
||||||
group.append(rect);
|
|
||||||
}
|
|
||||||
svg.append(group);
|
|
||||||
});
|
|
||||||
|
|
||||||
return h(
|
|
||||||
"div",
|
|
||||||
{ class: "spectrum" },
|
|
||||||
svg,
|
|
||||||
h(
|
|
||||||
"div",
|
|
||||||
{ class: "spectrum-axis" },
|
|
||||||
h("span", {}, formatDate(counts[0].start)),
|
|
||||||
h("span", {}, `${num(total)} plays in 30 days`),
|
|
||||||
h("span", {}, "Today"),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- Most played ------------------------------------------------------------
|
// ---- Most played ------------------------------------------------------------
|
||||||
|
|
||||||
function currentPeriod() {
|
function currentPeriod() {
|
||||||
@@ -199,39 +152,103 @@ function renderPeriodSelector() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadTop(period) {
|
async function loadTop(period) {
|
||||||
const [artists, tracks] = await Promise.all([
|
const [artists, albums, tracks] = await Promise.all([
|
||||||
api(`/me/top/artists?period=${period}&limit=10`),
|
api(`/me/top/artists?period=${period}&limit=10`),
|
||||||
|
api(`/me/top/albums?period=${period}&limit=10`),
|
||||||
api(`/me/top/tracks?period=${period}&limit=10`),
|
api(`/me/top/tracks?period=${period}&limit=10`),
|
||||||
]);
|
]);
|
||||||
renderRanking(document.getElementById("top-artists"), artists.items, false);
|
renderRanking(document.getElementById("top-artists"), artists.items, false);
|
||||||
renderRanking(document.getElementById("top-tracks"), tracks.items, true);
|
renderRanking(document.getElementById("top-albums"), albums.items, true, false, true);
|
||||||
|
renderRanking(document.getElementById("top-tracks"), tracks.items, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderRanking(list, items, withArtist) {
|
function renderRanking(list, items, withArtist, linkToSong = false, withArt = false) {
|
||||||
if (!items.length) {
|
if (!items.length) {
|
||||||
replace(list, h("li", { class: "empty" }, "No plays in this period."));
|
replace(list, h("li", { class: "empty" }, "No plays in this period."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const max = items[0].playcount;
|
const max = items[0].playcount;
|
||||||
|
const meterOffset = withArt ? "5.75rem" : "2.75rem";
|
||||||
replace(
|
replace(
|
||||||
list,
|
list,
|
||||||
items.map((item) =>
|
items.map((item) => {
|
||||||
h(
|
const by = withArtist ? h("span", { class: "by" }, item.artist) : null;
|
||||||
|
const name = linkToSong
|
||||||
|
? h("a", { class: "name", href: songHref(item.artist, item.name) }, item.name, by)
|
||||||
|
: h("span", { class: "name" }, item.name, by);
|
||||||
|
return h(
|
||||||
"li",
|
"li",
|
||||||
{},
|
{},
|
||||||
|
withArt ? artThumb(item.artist, item.name) : null,
|
||||||
h("span", { class: "rank" }, item.rank),
|
h("span", { class: "rank" }, item.rank),
|
||||||
h("span", { class: "name" }, item.name, withArtist ? h("span", { class: "by" }, item.artist) : null),
|
name,
|
||||||
h("span", { class: "plays" }, num(item.playcount)),
|
h("span", { class: "plays" }, num(item.playcount)),
|
||||||
h("span", {
|
h("span", {
|
||||||
class: "meter",
|
class: "meter",
|
||||||
"aria-hidden": "true",
|
"aria-hidden": "true",
|
||||||
style: `width: calc((100% - 2.75rem) * ${item.playcount / max})`,
|
style: `width: calc((100% - ${meterOffset}) * ${item.playcount / max})`,
|
||||||
}),
|
}),
|
||||||
),
|
);
|
||||||
),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function songHref(artist, track) {
|
||||||
|
return `song.html?artist=${encodeURIComponent(artist)}&track=${encodeURIComponent(track)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Song search --------------------------------------------------------------
|
||||||
|
|
||||||
|
function initSongSearch() {
|
||||||
|
const input = document.getElementById("song-search");
|
||||||
|
const results = document.getElementById("song-search-results");
|
||||||
|
let debounce;
|
||||||
|
let hideTimer;
|
||||||
|
|
||||||
|
input.addEventListener("input", () => {
|
||||||
|
clearTimeout(debounce);
|
||||||
|
const q = input.value.trim();
|
||||||
|
if (q.length < 2) {
|
||||||
|
results.hidden = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
debounce = setTimeout(() => runSearch(q), 250);
|
||||||
|
});
|
||||||
|
input.addEventListener("focus", () => {
|
||||||
|
if (results.childElementCount) results.hidden = false;
|
||||||
|
});
|
||||||
|
input.addEventListener("blur", () => {
|
||||||
|
hideTimer = setTimeout(() => (results.hidden = true), 150);
|
||||||
|
});
|
||||||
|
// Keep focus on mousedown so the subsequent click still lands on the result.
|
||||||
|
results.addEventListener("mousedown", (event) => event.preventDefault());
|
||||||
|
|
||||||
|
async function runSearch(q) {
|
||||||
|
let matches;
|
||||||
|
try {
|
||||||
|
matches = await api(`/me/tracks/search?q=${encodeURIComponent(q)}&limit=10`);
|
||||||
|
} catch {
|
||||||
|
return; // a flaky search box isn't worth surfacing an error for
|
||||||
|
}
|
||||||
|
clearTimeout(hideTimer);
|
||||||
|
if (!matches.length) {
|
||||||
|
replace(results, h("li", { class: "empty" }, "No matches."));
|
||||||
|
} else {
|
||||||
|
replace(
|
||||||
|
results,
|
||||||
|
matches.map((m) =>
|
||||||
|
h(
|
||||||
|
"li",
|
||||||
|
{},
|
||||||
|
h("a", { href: songHref(m.artist, m.track) }, m.track, h("span", { class: "by" }, m.artist)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
results.hidden = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---- Recently played ----------------------------------------------------------
|
// ---- Recently played ----------------------------------------------------------
|
||||||
|
|
||||||
async function loadRecent() {
|
async function loadRecent() {
|
||||||
@@ -247,8 +264,14 @@ async function loadRecent() {
|
|||||||
h(
|
h(
|
||||||
"li",
|
"li",
|
||||||
{},
|
{},
|
||||||
|
artThumb(s.album_artist || s.artist, s.album),
|
||||||
h("time", { datetime: s.played_at, title: new Date(s.played_at).toLocaleString() }, timeAgo(s.played_at)),
|
h("time", { datetime: s.played_at, title: new Date(s.played_at).toLocaleString() }, timeAgo(s.played_at)),
|
||||||
h("span", {}, h("span", { class: "track" }, s.track), h("span", { class: "by" }, ` by ${s.artist}`)),
|
h(
|
||||||
|
"a",
|
||||||
|
{ href: songHref(s.artist, s.track) },
|
||||||
|
h("span", { class: "track" }, s.track),
|
||||||
|
h("span", { class: "by" }, s.artist),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { api } from "./api.js";
|
import { api } from "./api.js";
|
||||||
|
import { artThumb } from "./art.js";
|
||||||
import { errorBox, formatDay, formatTime, h, num, replace } from "./dom.js";
|
import { errorBox, formatDay, formatTime, h, num, replace } from "./dom.js";
|
||||||
import { signedInPage } from "./layout.js";
|
import { signedInPage } from "./layout.js";
|
||||||
|
|
||||||
@@ -38,11 +39,12 @@ function render(result) {
|
|||||||
h("h2", { class: "log-day" }, formatDay(scrobbles[0].played_at)),
|
h("h2", { class: "log-day" }, formatDay(scrobbles[0].played_at)),
|
||||||
h(
|
h(
|
||||||
"ol",
|
"ol",
|
||||||
{ class: "log log-clock" },
|
{ class: "log log-clock log-art" },
|
||||||
scrobbles.map((s) =>
|
scrobbles.map((s) =>
|
||||||
h(
|
h(
|
||||||
"li",
|
"li",
|
||||||
{},
|
{},
|
||||||
|
artThumb(s.album_artist || s.artist, s.album),
|
||||||
h("time", { datetime: s.played_at }, formatTime(s.played_at)),
|
h("time", { datetime: s.played_at }, formatTime(s.played_at)),
|
||||||
h(
|
h(
|
||||||
"span",
|
"span",
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
// Shared page shell: site header, navigation, sign-in guard.
|
// Shared page shell: site header, navigation, sign-in guard.
|
||||||
|
|
||||||
import { api, getToken, redirectToLogin, setToken } from "./api.js";
|
import { api, getToken, redirectToLogin, setToken } from "./api.js";
|
||||||
|
import { avatarImage } from "./avatar.js";
|
||||||
import { h, replace } from "./dom.js";
|
import { h, replace } from "./dom.js";
|
||||||
|
|
||||||
const NAV = [
|
const NAV = [
|
||||||
["index.html", "Overview"],
|
["index.html", "Overview"],
|
||||||
["history.html", "History"],
|
["history.html", "History"],
|
||||||
|
["art.html", "Album art"],
|
||||||
["apps.html", "Apps"],
|
["apps.html", "Apps"],
|
||||||
["sessions.html", "Sessions"],
|
["sessions.html", "Sessions"],
|
||||||
["import.html", "Import"],
|
["import.html", "Import"],
|
||||||
@@ -25,7 +27,12 @@ export async function signedInPage(active) {
|
|||||||
h(
|
h(
|
||||||
"div",
|
"div",
|
||||||
{ class: "account" },
|
{ class: "account" },
|
||||||
h("span", { class: "account-name" }, user.username),
|
h(
|
||||||
|
"a",
|
||||||
|
{ class: "account-link", href: "account.html", title: "Your profile image" },
|
||||||
|
h("span", { class: "account-avatar" }, avatarImage(user, "avatar-sm")),
|
||||||
|
h("span", { class: "account-name" }, user.username),
|
||||||
|
),
|
||||||
h("button", { type: "button", class: "link-button", onclick: signOut }, "Sign out"),
|
h("button", { type: "button", class: "link-button", onclick: signOut }, "Sign out"),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -37,7 +44,13 @@ export function publicPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function brand() {
|
function brand() {
|
||||||
return h("a", { class: "brand", href: "index.html" }, h("span", { class: "brand-mark", "aria-hidden": "true" }), "Scrobbler");
|
return h(
|
||||||
|
"a",
|
||||||
|
{ class: "brand", href: "index.html" },
|
||||||
|
h("span", { class: "brand-mark", "aria-hidden": "true" }),
|
||||||
|
h("span", { class: "brand-word", "aria-hidden": "true" }),
|
||||||
|
h("span", { class: "visually-hidden" }, "Scrobbled"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function nav(active) {
|
function nav(active) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ try {
|
|||||||
`/federation/profiles/${encodeURIComponent(username)}/posts/${encodeURIComponent(postId)}`,
|
`/federation/profiles/${encodeURIComponent(username)}/posts/${encodeURIComponent(postId)}`,
|
||||||
{ auth: false },
|
{ auth: false },
|
||||||
);
|
);
|
||||||
document.title = `${post.display_name} · Scrobbler`;
|
document.title = `${post.display_name} · Scrobbled`;
|
||||||
replace(
|
replace(
|
||||||
root,
|
root,
|
||||||
h(
|
h(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { api } from "./api.js";
|
import { api } from "./api.js";
|
||||||
|
import { avatarImage } from "./avatar.js";
|
||||||
import { errorBox, h, replace } from "./dom.js";
|
import { errorBox, h, replace } from "./dom.js";
|
||||||
import { publicPage } from "./layout.js";
|
import { publicPage } from "./layout.js";
|
||||||
|
|
||||||
@@ -10,7 +11,7 @@ publicPage();
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const profile = await api(`/federation/profiles/${encodeURIComponent(username)}`, { auth: false });
|
const profile = await api(`/federation/profiles/${encodeURIComponent(username)}`, { auth: false });
|
||||||
document.title = `${profile.display_name} · Scrobbler`;
|
document.title = `${profile.display_name} · Scrobbled`;
|
||||||
const copy = h("button", { type: "button", class: "button button-quiet" }, "Copy handle");
|
const copy = h("button", { type: "button", class: "button button-quiet" }, "Copy handle");
|
||||||
copy.addEventListener("click", async () => {
|
copy.addEventListener("click", async () => {
|
||||||
try {
|
try {
|
||||||
@@ -22,6 +23,9 @@ try {
|
|||||||
});
|
});
|
||||||
replace(
|
replace(
|
||||||
root,
|
root,
|
||||||
|
profile.has_avatar
|
||||||
|
? avatarImage(profile, "avatar-xl", `/federation/profiles/${encodeURIComponent(username)}/avatar`)
|
||||||
|
: null,
|
||||||
h("h1", {}, profile.display_name),
|
h("h1", {}, profile.display_name),
|
||||||
h("div", { class: "approve-app handle" }, profile.handle),
|
h("div", { class: "approve-app handle" }, profile.handle),
|
||||||
profile.bio ? h("p", { class: "lede profile-bio" }, profile.bio) : null,
|
profile.bio ? h("p", { class: "lede profile-bio" }, profile.bio) : null,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const FIELDS = [
|
|||||||
"post_milestones",
|
"post_milestones",
|
||||||
"timezone",
|
"timezone",
|
||||||
"now_playing_mode",
|
"now_playing_mode",
|
||||||
|
"share_avatar",
|
||||||
"display_name",
|
"display_name",
|
||||||
"bio",
|
"bio",
|
||||||
];
|
];
|
||||||
@@ -155,6 +156,7 @@ async function save(event) {
|
|||||||
post_milestones: form.elements.post_milestones.checked,
|
post_milestones: form.elements.post_milestones.checked,
|
||||||
timezone: form.elements.timezone.value.trim() || "UTC",
|
timezone: form.elements.timezone.value.trim() || "UTC",
|
||||||
now_playing_mode: form.querySelector("input[name=now_playing_mode]:checked").value,
|
now_playing_mode: form.querySelector("input[name=now_playing_mode]:checked").value,
|
||||||
|
share_avatar: form.elements.share_avatar.checked,
|
||||||
display_name: form.elements.display_name.value.trim() || null,
|
display_name: form.elements.display_name.value.trim() || null,
|
||||||
bio: form.elements.bio.value.trim() || null,
|
bio: form.elements.bio.value.trim() || null,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
import { api } from "./api.js";
|
||||||
|
import { artThumb } from "./art.js";
|
||||||
|
import { errorBox, formatDate, formatDay, formatDuration, formatTime, h, num, replace } from "./dom.js";
|
||||||
|
import { signedInPage } from "./layout.js";
|
||||||
|
import { spectrum } from "./spectrum.js";
|
||||||
|
|
||||||
|
const PER_PAGE = 50;
|
||||||
|
const panel = document.getElementById("panel");
|
||||||
|
const meta = document.getElementById("song-meta");
|
||||||
|
const history = document.getElementById("song-history");
|
||||||
|
const pager = document.getElementById("pager");
|
||||||
|
|
||||||
|
await signedInPage(null); // a permalink, not a top-level nav section
|
||||||
|
|
||||||
|
const params = new URLSearchParams(location.search);
|
||||||
|
const artist = params.get("artist") ?? "";
|
||||||
|
const track = params.get("track") ?? "";
|
||||||
|
const page = Math.max(1, Number.parseInt(params.get("page"), 10) || 1);
|
||||||
|
|
||||||
|
if (!artist || !track) {
|
||||||
|
replace(panel, h("p", { class: "notice" }, "Use the search box on the dashboard to find a song."));
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const result = await api(
|
||||||
|
`/me/tracks?artist=${encodeURIComponent(artist)}&track=${encodeURIComponent(track)}&page=${page}&limit=${PER_PAGE}`,
|
||||||
|
);
|
||||||
|
render(result);
|
||||||
|
} catch (error) {
|
||||||
|
replace(
|
||||||
|
panel,
|
||||||
|
error.status === 404
|
||||||
|
? h("p", { class: "notice" }, `You've never scrobbled "${track}" by ${artist}.`)
|
||||||
|
: errorBox(error.message),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function render(result) {
|
||||||
|
document.title = `${result.track} · Scrobbled`;
|
||||||
|
const m = result.metadata;
|
||||||
|
|
||||||
|
const body = h(
|
||||||
|
"div",
|
||||||
|
{ class: "display-body" },
|
||||||
|
h("p", { class: "display-status" }, "Now viewing"),
|
||||||
|
h("p", { class: "display-track" }, result.track),
|
||||||
|
h(
|
||||||
|
"p",
|
||||||
|
{ class: "display-meta" },
|
||||||
|
h("strong", {}, result.artist),
|
||||||
|
m.album ? [" from ", h("strong", {}, m.album)] : null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const display = m.album
|
||||||
|
? h("div", { class: "display display-with-art" }, artThumb(m.album_artist || result.artist, m.album, "display-art"), body)
|
||||||
|
: h("div", { class: "display" }, body);
|
||||||
|
replace(panel, display, readouts(m), spectrum(result.counts, `Plays of ${result.track}`, "90 days"));
|
||||||
|
|
||||||
|
const row = (label, value) =>
|
||||||
|
value === null || value === undefined ? null : h("div", {}, h("dt", {}, label), h("dd", {}, value));
|
||||||
|
replace(
|
||||||
|
meta,
|
||||||
|
row("Album artist", m.album_artist),
|
||||||
|
row("Track number", m.track_number),
|
||||||
|
row("Duration", m.duration ? formatDuration(m.duration) : null),
|
||||||
|
row("MusicBrainz ID", m.mbid),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!result.items.length) {
|
||||||
|
replace(history, h("p", { class: "empty" }, "Nothing here yet."));
|
||||||
|
} else {
|
||||||
|
// Group by local calendar day, same as the full history page.
|
||||||
|
const days = new Map();
|
||||||
|
for (const scrobble of result.items) {
|
||||||
|
const key = new Date(scrobble.played_at).toDateString();
|
||||||
|
if (!days.has(key)) days.set(key, []);
|
||||||
|
days.get(key).push(scrobble);
|
||||||
|
}
|
||||||
|
replace(
|
||||||
|
history,
|
||||||
|
[...days.values()].map((scrobbles) => [
|
||||||
|
h("h3", { class: "log-day" }, formatDay(scrobbles[0].played_at)),
|
||||||
|
h(
|
||||||
|
"ol",
|
||||||
|
{ class: "log log-clock" },
|
||||||
|
scrobbles.map((s) =>
|
||||||
|
h(
|
||||||
|
"li",
|
||||||
|
{},
|
||||||
|
h("time", { datetime: s.played_at }, formatTime(s.played_at)),
|
||||||
|
s.album ? h("span", { class: "by" }, `from ${s.album}`) : h("span"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const link = (p) => `?artist=${encodeURIComponent(artist)}&track=${encodeURIComponent(track)}&page=${p}`;
|
||||||
|
replace(
|
||||||
|
pager,
|
||||||
|
result.page > 1 ? h("a", { class: "button button-quiet", href: link(result.page - 1) }, "Newer") : h("span"),
|
||||||
|
result.page < result.total_pages
|
||||||
|
? h("a", { class: "button button-quiet", href: link(result.page + 1) }, "Older")
|
||||||
|
: h("span"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function readouts(m) {
|
||||||
|
const item = (value, label) => h("div", {}, h("dt", {}, label), h("dd", {}, value));
|
||||||
|
return h(
|
||||||
|
"dl",
|
||||||
|
{ class: "readouts" },
|
||||||
|
item(num(m.playcount), "plays"),
|
||||||
|
item(formatDate(m.first_played_at), "first played"),
|
||||||
|
item(formatDate(m.last_played_at), "last played"),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// A segmented level meter: daily play counts drawn as columns of lit/unlit segments,
|
||||||
|
// like a hi-fi spectrum analyser. Shared by the dashboard (30 days, all plays) and the
|
||||||
|
// song page (90 days, one track).
|
||||||
|
|
||||||
|
import { formatDate, h, num } from "./dom.js";
|
||||||
|
|
||||||
|
const SEGMENTS = 10; // lit segments per column at the busiest day
|
||||||
|
|
||||||
|
export function spectrum(counts, subject = "Plays", windowLabel = "30 days") {
|
||||||
|
const NS = "http://www.w3.org/2000/svg";
|
||||||
|
const width = 1000;
|
||||||
|
const height = 96;
|
||||||
|
const gap = 4;
|
||||||
|
const max = Math.max(1, ...counts.map((c) => c.count));
|
||||||
|
const columnWidth = width / counts.length;
|
||||||
|
const segmentHeight = height / SEGMENTS;
|
||||||
|
const total = counts.reduce((sum, c) => sum + c.count, 0);
|
||||||
|
|
||||||
|
const svg = document.createElementNS(NS, "svg");
|
||||||
|
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
||||||
|
svg.setAttribute("preserveAspectRatio", "none");
|
||||||
|
svg.setAttribute("role", "img");
|
||||||
|
svg.setAttribute("aria-label", `${subject} per day over the last ${counts.length} days: ${num(total)} in total`);
|
||||||
|
|
||||||
|
counts.forEach((day, i) => {
|
||||||
|
const lit = day.count ? Math.max(1, Math.round((day.count / max) * SEGMENTS)) : 0;
|
||||||
|
const group = document.createElementNS(NS, "g");
|
||||||
|
const title = document.createElementNS(NS, "title");
|
||||||
|
title.textContent = `${formatDate(day.start)}: ${num(day.count)} ${day.count === 1 ? "play" : "plays"}`;
|
||||||
|
group.append(title);
|
||||||
|
for (let s = 0; s < SEGMENTS; s++) {
|
||||||
|
const rect = document.createElementNS(NS, "rect");
|
||||||
|
rect.setAttribute("x", i * columnWidth + gap / 2);
|
||||||
|
rect.setAttribute("y", height - (s + 1) * segmentHeight + 1.5);
|
||||||
|
rect.setAttribute("width", columnWidth - gap);
|
||||||
|
rect.setAttribute("height", segmentHeight - 3);
|
||||||
|
rect.setAttribute("class", s < lit ? "seg-on" : "seg-off");
|
||||||
|
group.append(rect);
|
||||||
|
}
|
||||||
|
svg.append(group);
|
||||||
|
});
|
||||||
|
|
||||||
|
return h(
|
||||||
|
"div",
|
||||||
|
{ class: "spectrum" },
|
||||||
|
svg,
|
||||||
|
h(
|
||||||
|
"div",
|
||||||
|
{ class: "spectrum-axis" },
|
||||||
|
h("span", {}, formatDate(counts[0].start)),
|
||||||
|
h("span", {}, `${num(total)} ${subject.toLowerCase()} in ${windowLabel}`),
|
||||||
|
h("span", {}, "Today"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Sign in · Scrobbler</title>
|
<title>Sign in · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/login.js"></script>
|
<script type="module" src="js/login.js"></script>
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Post · Scrobbler</title>
|
<title>Post · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/post.js"></script>
|
<script type="module" src="js/post.js"></script>
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Posts · Scrobbler</title>
|
<title>Posts · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/posts.js"></script>
|
<script type="module" src="js/posts.js"></script>
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Profile · Scrobbler</title>
|
<title>Profile · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/profile.js"></script>
|
<script type="module" src="js/profile.js"></script>
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Create an account · Scrobbler</title>
|
<title>Create an account · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/register.js"></script>
|
<script type="module" src="js/register.js"></script>
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Sessions · Scrobbler</title>
|
<title>Sessions · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/sessions.js"></script>
|
<script type="module" src="js/sessions.js"></script>
|
||||||
@@ -13,7 +17,7 @@
|
|||||||
<header class="site-header" id="site-header"></header>
|
<header class="site-header" id="site-header"></header>
|
||||||
<main id="main">
|
<main id="main">
|
||||||
<h1 class="page-title">Sessions</h1>
|
<h1 class="page-title">Sessions</h1>
|
||||||
<p class="lede">Players you've signed in to Scrobbler. Revoking one signs it out straight away; it has to sign in again before it can scrobble.</p>
|
<p class="lede">Players you've signed in to Scrobbled. Revoking one signs it out straight away; it has to sign in again before it can scrobble.</p>
|
||||||
<div id="messages"></div>
|
<div id="messages"></div>
|
||||||
<ul class="rows" id="sessions"></ul>
|
<ul class="rows" id="sessions"></ul>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Sharing · Scrobbler</title>
|
<title>Sharing · Scrobbled</title>
|
||||||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='%231c2330'/%3E%3Ccircle cx='8' cy='8' r='3.5' fill='%23f2a541'/%3E%3C/svg%3E">
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="config.js"></script>
|
<script src="config.js"></script>
|
||||||
<script type="module" src="js/sharing.js"></script>
|
<script type="module" src="js/sharing.js"></script>
|
||||||
@@ -110,6 +114,10 @@
|
|||||||
<textarea id="bio" name="bio" maxlength="500" rows="3"></textarea>
|
<textarea id="bio" name="bio" maxlength="500" rows="3"></textarea>
|
||||||
<span class="hint">Shown on your fediverse profile. Plain text.</span>
|
<span class="hint">Shown on your fediverse profile. Plain text.</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="choice">
|
||||||
|
<input type="checkbox" id="share_avatar" name="share_avatar">
|
||||||
|
<label for="share_avatar"><strong>Share my profile image</strong><span class="muted">Show the image from your <a href="account.html">profile</a> on your public profile page, and send it to other servers as your picture. Without this it stays private.</span></label>
|
||||||
|
</div>
|
||||||
<p class="muted" id="profile-link"></p>
|
<p class="muted" id="profile-link"></p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "Scrobbled",
|
||||||
|
"short_name": "Scrobbled",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "icon-192.png",
|
||||||
|
"sizes": "192x192",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icon-512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "icon-maskable-512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "maskable"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"theme_color": "#1F1C28",
|
||||||
|
"background_color": "#1F1C28",
|
||||||
|
"display": "standalone"
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Song · Scrobbled</title>
|
||||||
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
||||||
|
<link rel="icon" href="favicon.svg" type="image/svg+xml">
|
||||||
|
<link rel="apple-touch-icon" href="apple-touch-icon.png">
|
||||||
|
<link rel="manifest" href="site.webmanifest">
|
||||||
|
<meta name="theme-color" content="#1F1C28">
|
||||||
|
<link rel="stylesheet" href="css/style.css">
|
||||||
|
<script src="config.js"></script>
|
||||||
|
<script type="module" src="js/song.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="site-header" id="site-header"></header>
|
||||||
|
<main id="main">
|
||||||
|
<h1 class="visually-hidden">Song</h1>
|
||||||
|
<div id="panel" class="panel" aria-live="polite"></div>
|
||||||
|
<dl class="song-meta" id="song-meta"></dl>
|
||||||
|
<section aria-labelledby="song-history-title">
|
||||||
|
<h2 id="song-history-title">History</h2>
|
||||||
|
<div id="song-history"></div>
|
||||||
|
<nav class="pager" aria-label="Pages" id="pager"></nav>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -11,11 +11,21 @@ wsgi_app = "scrobbler:create_app()"
|
|||||||
bind = os.environ.get("BIND", "0.0.0.0:8000")
|
bind = os.environ.get("BIND", "0.0.0.0:8000")
|
||||||
workers = int(os.environ.get("WEB_CONCURRENCY", "2"))
|
workers = int(os.environ.get("WEB_CONCURRENCY", "2"))
|
||||||
accesslog = "-"
|
accesslog = "-"
|
||||||
|
loglevel = os.environ.get("LOG_LEVEL", "INFO").lower()
|
||||||
forwarded_allow_ips = os.environ.get("FORWARDED_ALLOW_IPS", "127.0.0.1")
|
forwarded_allow_ips = os.environ.get("FORWARDED_ALLOW_IPS", "127.0.0.1")
|
||||||
# gunicorn 26's control socket lives in $HOME, which the container user doesn't have.
|
# gunicorn 26's control socket lives in $HOME, which the container user doesn't have.
|
||||||
control_socket_disable = True
|
control_socket_disable = True
|
||||||
|
|
||||||
|
|
||||||
|
def post_fork(server, worker):
|
||||||
|
# Gunicorn's own messages go through the app's handler too, so the format is uniform.
|
||||||
|
import logging
|
||||||
|
|
||||||
|
gunicorn_error = logging.getLogger("gunicorn.error")
|
||||||
|
gunicorn_error.handlers.clear()
|
||||||
|
gunicorn_error.propagate = True
|
||||||
|
|
||||||
|
|
||||||
def on_starting(server):
|
def on_starting(server):
|
||||||
# Stale files from a previous run would double-count.
|
# Stale files from a previous run would double-count.
|
||||||
shutil.rmtree(MULTIPROC_DIR, ignore_errors=True)
|
shutil.rmtree(MULTIPROC_DIR, ignore_errors=True)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""Send realistic traffic to a running Scrobbler, e.g. to see the Grafana dashboards move.
|
"""Send realistic traffic to a running Scrobbled, e.g. to see the Grafana dashboards move.
|
||||||
|
|
||||||
uv run python scripts/generate_traffic.py --api http://localhost:5050 --minutes 5
|
uv run python scripts/generate_traffic.py --api http://localhost:5050 --minutes 5
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# docker compose for the federation interop stack (Scrobbler + GoToSocial).
|
# docker compose for the federation interop stack (Scrobbled + GoToSocial).
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
root="$(cd "$(dirname "$0")/../.." && pwd)"
|
root="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||||
# INTEROP_PROJECT and INTEROP_SUBNET let concurrent runs (e.g. in CI) stay apart.
|
# INTEROP_PROJECT (with a distinct SCROBBLER_IMAGE_TAG) lets concurrent runs (e.g. in CI) stay apart.
|
||||||
exec docker compose -p "${INTEROP_PROJECT:-scrobbler-interop}" \
|
exec docker compose -p "${INTEROP_PROJECT:-scrobbler-interop}" \
|
||||||
-f "$root/docker-compose.yml" -f "$root/deploy/interop/docker-compose.interop.yml" "$@"
|
-f "$root/docker-compose.yml" -f "$root/deploy/interop/docker-compose.interop.yml" "$@"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
"""Federation interop test: a real GoToSocial account follows a Scrobbler user.
|
"""Federation interop test: a real GoToSocial account follows a Scrobbled user.
|
||||||
|
|
||||||
Runs inside the interop compose network (see deploy/interop/). Standard library only.
|
Runs inside the interop compose network (see deploy/interop/). Standard library only.
|
||||||
Exits non-zero, with a description, on the first thing that doesn't work.
|
Exits non-zero, with a description, on the first thing that doesn't work.
|
||||||
@@ -164,7 +164,7 @@ def wait_for(description, check, timeout=60):
|
|||||||
fail(f"timed out waiting for: {description}")
|
fail(f"timed out waiting for: {description}")
|
||||||
|
|
||||||
|
|
||||||
class Scrobbler:
|
class Scrobbled:
|
||||||
def __init__(self, username="alice", password="interop-password-1"):
|
def __init__(self, username="alice", password="interop-password-1"):
|
||||||
status, body = api(
|
status, body = api(
|
||||||
"POST",
|
"POST",
|
||||||
@@ -185,7 +185,7 @@ class Scrobbler:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
if status not in (200, 201):
|
if status not in (200, 201):
|
||||||
fail(f"signing in to Scrobbler: {status} {body}")
|
fail(f"signing in to Scrobbled: {status} {body}")
|
||||||
self.token = body["token"]
|
self.token = body["token"]
|
||||||
|
|
||||||
def settings(self, **changes):
|
def settings(self, **changes):
|
||||||
@@ -193,7 +193,7 @@ class Scrobbler:
|
|||||||
"PATCH", f"{SCROBBLER_API}/federation/settings", self.token, body=changes
|
"PATCH", f"{SCROBBLER_API}/federation/settings", self.token, body=changes
|
||||||
)
|
)
|
||||||
if status != 200:
|
if status != 200:
|
||||||
fail(f"changing Scrobbler settings: {status} {body}")
|
fail(f"changing Scrobbled settings: {status} {body}")
|
||||||
return body
|
return body
|
||||||
|
|
||||||
def followers(self, state=None):
|
def followers(self, state=None):
|
||||||
@@ -275,8 +275,8 @@ def main():
|
|||||||
step("Getting a GoToSocial access token")
|
step("Getting a GoToSocial access token")
|
||||||
gts = GoToSocial(gotosocial_token())
|
gts = GoToSocial(gotosocial_token())
|
||||||
|
|
||||||
step("Alice starts sharing on Scrobbler")
|
step("Alice starts sharing on Scrobbled")
|
||||||
alice = Scrobbler()
|
alice = Scrobbled()
|
||||||
alice.settings(
|
alice.settings(
|
||||||
enabled=True,
|
enabled=True,
|
||||||
display_name="Alice Interop",
|
display_name="Alice Interop",
|
||||||
@@ -294,14 +294,14 @@ def main():
|
|||||||
step("Follow: GoToSocial sees it accepted (our signed Accept verified)")
|
step("Follow: GoToSocial sees it accepted (our signed Accept verified)")
|
||||||
gts.follow(account_id)
|
gts.follow(account_id)
|
||||||
wait_for("GoToSocial to be following", lambda: gts.relationship(account_id)["following"])
|
wait_for("GoToSocial to be following", lambda: gts.relationship(account_id)["following"])
|
||||||
followers = wait_for("Scrobbler to list the follower", lambda: alice.followers("accepted"))
|
followers = wait_for("Scrobbled to list the follower", lambda: alice.followers("accepted"))
|
||||||
print(f" Scrobbler follower: {followers[0]['handle']}")
|
print(f" Scrobbled follower: {followers[0]['handle']}")
|
||||||
if followers[0]["handle"] != "@gtsuser@gts.test":
|
if followers[0]["handle"] != "@gtsuser@gts.test":
|
||||||
fail(f"unexpected follower {followers[0]['handle']}")
|
fail(f"unexpected follower {followers[0]['handle']}")
|
||||||
|
|
||||||
step("Unfollow: Scrobbler drops the follower (their signed Undo verified)")
|
step("Unfollow: Scrobbled drops the follower (their signed Undo verified)")
|
||||||
gts.unfollow(account_id)
|
gts.unfollow(account_id)
|
||||||
wait_for("Scrobbler to drop the follower", lambda: not alice.followers())
|
wait_for("Scrobbled to drop the follower", lambda: not alice.followers())
|
||||||
|
|
||||||
step("Manual approval: the follow waits as a request")
|
step("Manual approval: the follow waits as a request")
|
||||||
alice.settings(manually_approves_followers=True)
|
alice.settings(manually_approves_followers=True)
|
||||||
@@ -309,7 +309,7 @@ def main():
|
|||||||
wait_for(
|
wait_for(
|
||||||
"GoToSocial to show a pending request", lambda: gts.relationship(account_id)["requested"]
|
"GoToSocial to show a pending request", lambda: gts.relationship(account_id)["requested"]
|
||||||
)
|
)
|
||||||
pending = wait_for("Scrobbler to list the request", lambda: alice.followers("pending"))
|
pending = wait_for("Scrobbled to list the request", lambda: alice.followers("pending"))
|
||||||
if gts.relationship(account_id)["following"]:
|
if gts.relationship(account_id)["following"]:
|
||||||
fail("following before being approved")
|
fail("following before being approved")
|
||||||
|
|
||||||
@@ -317,7 +317,7 @@ def main():
|
|||||||
alice.act(pending[0]["id"], "approve")
|
alice.act(pending[0]["id"], "approve")
|
||||||
wait_for("GoToSocial to be following", lambda: gts.relationship(account_id)["following"])
|
wait_for("GoToSocial to be following", lambda: gts.relationship(account_id)["following"])
|
||||||
|
|
||||||
step("Remove the follower: Scrobbler drops them and sends a Reject")
|
step("Remove the follower: Scrobbled drops them and sends a Reject")
|
||||||
alice.act(alice.followers()[0]["id"], "remove")
|
alice.act(alice.followers()[0]["id"], "remove")
|
||||||
if alice.followers():
|
if alice.followers():
|
||||||
fail("the follower is still listed after removal")
|
fail("the follower is still listed after removal")
|
||||||
@@ -338,7 +338,7 @@ def main():
|
|||||||
|
|
||||||
step("Block a follower: GoToSocial drops the follow (it honours Block)")
|
step("Block a follower: GoToSocial drops the follow (it honours Block)")
|
||||||
gts.follow(account_id)
|
gts.follow(account_id)
|
||||||
pending = wait_for("Scrobbler to list the request", lambda: alice.followers("pending"))
|
pending = wait_for("Scrobbled to list the request", lambda: alice.followers("pending"))
|
||||||
alice.act(pending[0]["id"], "approve")
|
alice.act(pending[0]["id"], "approve")
|
||||||
wait_for("GoToSocial to be following", lambda: gts.relationship(account_id)["following"])
|
wait_for("GoToSocial to be following", lambda: gts.relationship(account_id)["following"])
|
||||||
alice.act(alice.followers()[0]["id"], "block")
|
alice.act(alice.followers()[0]["id"], "block")
|
||||||
@@ -358,7 +358,7 @@ def main():
|
|||||||
|
|
||||||
step("Decline a request: GoToSocial's request is withdrawn")
|
step("Decline a request: GoToSocial's request is withdrawn")
|
||||||
gts.follow(account_id)
|
gts.follow(account_id)
|
||||||
pending = wait_for("Scrobbler to list the request", lambda: alice.followers("pending"))
|
pending = wait_for("Scrobbled to list the request", lambda: alice.followers("pending"))
|
||||||
alice.act(pending[0]["id"], "decline")
|
alice.act(pending[0]["id"], "decline")
|
||||||
wait_for(
|
wait_for(
|
||||||
"GoToSocial's request to go away",
|
"GoToSocial's request to go away",
|
||||||
@@ -385,7 +385,7 @@ def check_posts():
|
|||||||
profile field GoToSocial has cached is updated by the periodic push."""
|
profile field GoToSocial has cached is updated by the periodic push."""
|
||||||
step("Getting a GoToSocial access token")
|
step("Getting a GoToSocial access token")
|
||||||
gts = GoToSocial(gotosocial_token())
|
gts = GoToSocial(gotosocial_token())
|
||||||
alice = Scrobbler() # register-or-login: the same account main() set up
|
alice = Scrobbled() # register-or-login: the same account main() set up
|
||||||
account = gts.resolve("@alice@scrobble.test")
|
account = gts.resolve("@alice@scrobble.test")
|
||||||
account_id = account["id"]
|
account_id = account["id"]
|
||||||
if not gts.relationship(account_id)["following"]:
|
if not gts.relationship(account_id)["following"]:
|
||||||
|
|||||||
@@ -6,11 +6,18 @@ here="$(cd "$(dirname "$0")" && pwd)"
|
|||||||
compose="$here/compose.sh"
|
compose="$here/compose.sh"
|
||||||
keep=0; [ "${1:-}" = "--keep" ] && keep=1
|
keep=0; [ "${1:-}" = "--keep" ] && keep=1
|
||||||
|
|
||||||
cleanup() { [ "$keep" = 1 ] || "$compose" down -v --remove-orphans >/dev/null 2>&1; }
|
cleanup() {
|
||||||
|
[ "$keep" = 1 ] && return 0
|
||||||
|
"$compose" down -v --remove-orphans --rmi local >/dev/null 2>&1
|
||||||
|
# Per-run api/ui images (tagged with SCROBBLER_IMAGE_TAG) would otherwise pile up
|
||||||
|
[ -n "${SCROBBLER_IMAGE_TAG:-}" ] && "$compose" config --images 2>/dev/null \
|
||||||
|
| grep ":${SCROBBLER_IMAGE_TAG}$" | xargs -r docker rmi >/dev/null 2>&1
|
||||||
|
return 0
|
||||||
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
"$compose" down -v --remove-orphans >/dev/null 2>&1
|
"$compose" down -v --remove-orphans >/dev/null 2>&1
|
||||||
echo "==> Building and starting Scrobbler + GoToSocial"
|
echo "==> Building and starting Scrobbled + GoToSocial"
|
||||||
"$compose" up -d --build --wait db api ui worker tls gotosocial || { "$compose" ps; exit 1; }
|
"$compose" up -d --build --wait db api ui worker tls gotosocial || { "$compose" ps; exit 1; }
|
||||||
|
|
||||||
echo "==> Waiting for GoToSocial"
|
echo "==> Waiting for GoToSocial"
|
||||||
@@ -25,7 +32,7 @@ echo "==> Creating the GoToSocial test user"
|
|||||||
"$compose" exec -T gotosocial /gotosocial/gotosocial admin account confirm --username gtsuser >/dev/null
|
"$compose" exec -T gotosocial /gotosocial/gotosocial admin account confirm --username gtsuser >/dev/null
|
||||||
|
|
||||||
diagnose() {
|
diagnose() {
|
||||||
echo "==> Scrobbler federation state"
|
echo "==> Scrobbled federation state"
|
||||||
"$compose" exec -T db psql -U scrobbler -d scrobbler -c \
|
"$compose" exec -T db psql -U scrobbler -d scrobbler -c \
|
||||||
"select activity_type, status, reason, attempts from federation_inbox order by id" -c \
|
"select activity_type, status, reason, attempts from federation_inbox order by id" -c \
|
||||||
"select a.activity_type, d.status, d.attempts, d.last_status, left(d.last_error, 200) as error
|
"select a.activity_type, d.status, d.attempts, d.last_status, left(d.last_error, 200) as error
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ def create_app(config_object=None):
|
|||||||
app = Flask(__name__, static_folder=None) # API only: the UI is hosted separately
|
app = Flask(__name__, static_folder=None) # API only: the UI is hosted separately
|
||||||
app.config.from_object(config_object or Config)
|
app.config.from_object(config_object or Config)
|
||||||
|
|
||||||
|
from scrobbler.logsetup import configure_logging
|
||||||
|
|
||||||
|
configure_logging(app.config["LOG_LEVEL"], app.config["LOG_FORMAT"])
|
||||||
|
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
migrate.init_app(app, db, directory=_migrations_dir())
|
migrate.init_app(app, db, directory=_migrations_dir())
|
||||||
http_metrics.init_app(app)
|
http_metrics.init_app(app)
|
||||||
@@ -42,11 +46,13 @@ def create_app(config_object=None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
from scrobbler.cli import imports_cli, worker_command
|
from scrobbler.cli import imports_cli, worker_command
|
||||||
|
from scrobbler.services import art as art_service
|
||||||
from scrobbler.services import imports as import_service
|
from scrobbler.services import imports as import_service
|
||||||
|
|
||||||
app.cli.add_command(worker_command)
|
app.cli.add_command(worker_command)
|
||||||
app.cli.add_command(imports_cli)
|
app.cli.add_command(imports_cli)
|
||||||
import_service.register_worker_tasks(app)
|
import_service.register_worker_tasks(app)
|
||||||
|
art_service.register_worker_tasks(app)
|
||||||
|
|
||||||
from scrobbler.metrics import db as db_metrics
|
from scrobbler.metrics import db as db_metrics
|
||||||
|
|
||||||
|
|||||||
@@ -48,14 +48,28 @@ def init_app(app: Flask) -> None:
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
from scrobbler.api import apps, auth, health, imports, sessions, stats, tokens
|
from scrobbler.api import (
|
||||||
|
apps,
|
||||||
|
art,
|
||||||
|
auth,
|
||||||
|
avatar,
|
||||||
|
health,
|
||||||
|
imports,
|
||||||
|
sessions,
|
||||||
|
stats,
|
||||||
|
tokens,
|
||||||
|
tracks,
|
||||||
|
)
|
||||||
|
|
||||||
api.register_blueprint(auth.blp, url_prefix="/api/v1/auth")
|
api.register_blueprint(auth.blp, url_prefix="/api/v1/auth")
|
||||||
api.register_blueprint(apps.blp, url_prefix="/api/v1/apps")
|
api.register_blueprint(apps.blp, url_prefix="/api/v1/apps")
|
||||||
api.register_blueprint(sessions.blp, url_prefix="/api/v1/sessions")
|
api.register_blueprint(sessions.blp, url_prefix="/api/v1/sessions")
|
||||||
api.register_blueprint(tokens.blp, url_prefix="/api/v1/tokens")
|
api.register_blueprint(tokens.blp, url_prefix="/api/v1/tokens")
|
||||||
api.register_blueprint(stats.blp, url_prefix="/api/v1/me")
|
api.register_blueprint(stats.blp, url_prefix="/api/v1/me")
|
||||||
|
api.register_blueprint(tracks.blp, url_prefix="/api/v1/me/tracks")
|
||||||
api.register_blueprint(imports.blp, url_prefix="/api/v1/imports")
|
api.register_blueprint(imports.blp, url_prefix="/api/v1/imports")
|
||||||
|
api.register_blueprint(art.blp, url_prefix="/api/v1/art")
|
||||||
|
api.register_blueprint(avatar.blp, url_prefix="/api/v1/me/avatar")
|
||||||
api.register_blueprint(health.blp)
|
api.register_blueprint(health.blp)
|
||||||
|
|
||||||
from scrobbler.openapi import lastfm
|
from scrobbler.openapi import lastfm
|
||||||
|
|||||||
@@ -0,0 +1,178 @@
|
|||||||
|
import math
|
||||||
|
|
||||||
|
from flask import Response, current_app, g, request
|
||||||
|
from flask_smorest import Blueprint, abort
|
||||||
|
|
||||||
|
from scrobbler import metrics
|
||||||
|
from scrobbler.api.decorators import authenticated
|
||||||
|
from scrobbler.schemas import (
|
||||||
|
AlbumArtArgsSchema,
|
||||||
|
AlbumArtCorrectionSchema,
|
||||||
|
AlbumArtFailuresPageSchema,
|
||||||
|
AlbumArtOverrideSchema,
|
||||||
|
AlbumArtUploadSchema,
|
||||||
|
ErrorSchema,
|
||||||
|
PageArgsSchema,
|
||||||
|
)
|
||||||
|
from scrobbler.services import art
|
||||||
|
|
||||||
|
blp = Blueprint(
|
||||||
|
"Art",
|
||||||
|
__name__,
|
||||||
|
description=(
|
||||||
|
"Album art, resolved from MusicBrainz / Cover Art Archive by a background worker. "
|
||||||
|
"You can also upload your own art, or correct a failed lookup; those only change "
|
||||||
|
"what you see."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("/album", methods=["GET"])
|
||||||
|
@authenticated(blp)
|
||||||
|
@blp.arguments(AlbumArtArgsSchema, location="query")
|
||||||
|
@blp.response(
|
||||||
|
200, content_type="image/jpeg", description="The album's cover art (JPEG, PNG or WebP)"
|
||||||
|
)
|
||||||
|
@blp.alt_response(404, schema=ErrorSchema, description="No cover art available yet")
|
||||||
|
def album_art(args):
|
||||||
|
"""An album's cover art
|
||||||
|
|
||||||
|
Your own uploaded or corrected art comes first. Otherwise it's served from a local
|
||||||
|
cache that a background worker task keeps filled; this endpoint never makes a live
|
||||||
|
MusicBrainz/Cover Art Archive call, so it can't be slowed down by one. An album seen
|
||||||
|
for the first time returns 404 until the worker resolves it, typically within a few
|
||||||
|
seconds - cache this response client-side and retry later.
|
||||||
|
"""
|
||||||
|
own = art.get_override(g.user.id, args["artist"], args["album"])
|
||||||
|
if own is not None and own.status == "found":
|
||||||
|
data = art.read_override_file(own)
|
||||||
|
if data is not None:
|
||||||
|
metrics.art_requests_total.labels("override").inc()
|
||||||
|
response = Response(data, mimetype=own.content_type or "image/jpeg")
|
||||||
|
response.headers["Cache-Control"] = "private, no-cache" # revalidate: it can change
|
||||||
|
response.add_etag()
|
||||||
|
return response.make_conditional(request)
|
||||||
|
|
||||||
|
row = art.get_cached(args["artist"], args["album"])
|
||||||
|
if row is None:
|
||||||
|
art.want(args["artist"], args["album"])
|
||||||
|
metrics.art_requests_total.labels("queued").inc()
|
||||||
|
abort(404, code="no_album_art", message="Not resolved yet")
|
||||||
|
image = art.read_file(row.id) if row.status == "found" else None
|
||||||
|
if image is None:
|
||||||
|
if row.status == "found":
|
||||||
|
art.requeue(row) # resolved before, but the file is missing - ask again
|
||||||
|
result = "file_missing"
|
||||||
|
else:
|
||||||
|
result = "pending" if row.status == "pending" else "unavailable"
|
||||||
|
metrics.art_requests_total.labels(result).inc()
|
||||||
|
abort(404, code="no_album_art", message="No cover art found for this album")
|
||||||
|
metrics.art_requests_total.labels("served").inc()
|
||||||
|
response = Response(image, mimetype="image/jpeg")
|
||||||
|
response.headers["Cache-Control"] = "private, max-age=604800" # 7 days; art rarely changes
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("/album", methods=["POST"])
|
||||||
|
@authenticated(blp)
|
||||||
|
@blp.arguments(AlbumArtUploadSchema, location="files")
|
||||||
|
@blp.arguments(AlbumArtArgsSchema, location="query")
|
||||||
|
@blp.response(201, AlbumArtOverrideSchema)
|
||||||
|
@blp.alt_response(400, schema=ErrorSchema, description="Empty file")
|
||||||
|
@blp.alt_response(413, schema=ErrorSchema, description="Image too large")
|
||||||
|
@blp.alt_response(415, schema=ErrorSchema, description="Not a JPEG, PNG or WebP image")
|
||||||
|
def upload_art(files, args):
|
||||||
|
"""Upload your own art for an album
|
||||||
|
|
||||||
|
Replaces any earlier upload or correction of yours for this album. Only you see it.
|
||||||
|
"""
|
||||||
|
limit = current_app.config["ART_UPLOAD_MAX_BYTES"]
|
||||||
|
data = files["file"].read(limit + 1)
|
||||||
|
if not data:
|
||||||
|
metrics.art_uploads_total.labels("empty").inc()
|
||||||
|
abort(400, code="empty_file", message="That file is empty.")
|
||||||
|
if len(data) > limit:
|
||||||
|
metrics.art_uploads_total.labels("too_large").inc()
|
||||||
|
abort(413, code="file_too_large", message="That image is larger than this server accepts.")
|
||||||
|
try:
|
||||||
|
content_type = art.sniff_image_type(data)
|
||||||
|
except art.UnsupportedImage:
|
||||||
|
metrics.art_uploads_total.labels("bad_type").inc()
|
||||||
|
abort(415, code="unsupported_image", message="Upload a JPEG, PNG or WebP image.")
|
||||||
|
art.save_upload(g.user.id, args["artist"], args["album"], data, content_type)
|
||||||
|
metrics.art_uploads_total.labels("ok").inc()
|
||||||
|
metrics.art_upload_bytes.observe(len(data))
|
||||||
|
return art.get_override(g.user.id, args["artist"], args["album"])
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("/album", methods=["DELETE"])
|
||||||
|
@authenticated(blp)
|
||||||
|
@blp.arguments(AlbumArtArgsSchema, location="query")
|
||||||
|
@blp.response(204)
|
||||||
|
@blp.alt_response(404, schema=ErrorSchema, description="You have no art of your own for this album")
|
||||||
|
def delete_override(args):
|
||||||
|
"""Remove your own art for an album
|
||||||
|
|
||||||
|
The album goes back to the shared lookup result, if there is one.
|
||||||
|
"""
|
||||||
|
if not art.delete_override(g.user.id, args["artist"], args["album"]):
|
||||||
|
abort(404, code="not_found", message="You have no art of your own for this album")
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("/album/correction", methods=["PUT"])
|
||||||
|
@authenticated(blp)
|
||||||
|
@blp.arguments(AlbumArtCorrectionSchema)
|
||||||
|
@blp.response(202, AlbumArtOverrideSchema)
|
||||||
|
def correct_art(body):
|
||||||
|
"""Correct a failed lookup
|
||||||
|
|
||||||
|
Queues a new lookup with different search text, or straight from a MusicBrainz
|
||||||
|
release-group or release ID. The background worker resolves it; poll the failures list, or just
|
||||||
|
fetch the art later. Replaces any earlier upload or correction of yours.
|
||||||
|
"""
|
||||||
|
mbid = body.get("release_group_mbid")
|
||||||
|
release_mbid = body.get("release_mbid")
|
||||||
|
art.request_correction(
|
||||||
|
g.user.id,
|
||||||
|
body["artist"],
|
||||||
|
body["album"],
|
||||||
|
body.get("search_artist"),
|
||||||
|
body.get("search_album"),
|
||||||
|
str(mbid) if mbid else None,
|
||||||
|
str(release_mbid) if release_mbid else None,
|
||||||
|
)
|
||||||
|
return art.get_override(g.user.id, body["artist"], body["album"])
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("/album/retry", methods=["POST"])
|
||||||
|
@authenticated(blp)
|
||||||
|
@blp.arguments(AlbumArtArgsSchema, location="query")
|
||||||
|
@blp.response(202)
|
||||||
|
@blp.alt_response(409, schema=ErrorSchema, description="Nothing to retry")
|
||||||
|
def retry_art(args):
|
||||||
|
"""Look an album up again
|
||||||
|
|
||||||
|
Re-queues the shared lookup for an album whose search found nothing or failed.
|
||||||
|
"""
|
||||||
|
if not art.retry(args["artist"], args["album"]):
|
||||||
|
abort(409, code="nothing_to_retry", message="This album's art is found or already queued")
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("/failures", methods=["GET"])
|
||||||
|
@authenticated(blp)
|
||||||
|
@blp.arguments(PageArgsSchema, location="query")
|
||||||
|
@blp.response(200, AlbumArtFailuresPageSchema)
|
||||||
|
def failures(args):
|
||||||
|
"""Albums of yours without art
|
||||||
|
|
||||||
|
Albums you've scrobbled whose lookup found nothing or failed, plus ones where your
|
||||||
|
own correction didn't work, most-scrobbled first. Albums you've fixed drop off.
|
||||||
|
"""
|
||||||
|
items, total = art.list_failures(g.user.id, args["page"], args["limit"])
|
||||||
|
return {
|
||||||
|
"items": items,
|
||||||
|
"page": args["page"],
|
||||||
|
"per_page": args["limit"],
|
||||||
|
"total": total,
|
||||||
|
"total_pages": math.ceil(total / args["limit"]),
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
from flask import Response, current_app, g, request
|
||||||
|
from flask_smorest import Blueprint, abort
|
||||||
|
|
||||||
|
from scrobbler import metrics
|
||||||
|
from scrobbler.api.decorators import authenticated
|
||||||
|
from scrobbler.schemas import AvatarUploadSchema, ErrorSchema, UserSchema
|
||||||
|
from scrobbler.services import avatars
|
||||||
|
|
||||||
|
blp = Blueprint(
|
||||||
|
"Avatar",
|
||||||
|
__name__,
|
||||||
|
description=(
|
||||||
|
"Your profile image: upload one, use your Gravatar (if this server allows it), "
|
||||||
|
"or remove it."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("", methods=["GET"])
|
||||||
|
@authenticated(blp)
|
||||||
|
@blp.response(200, content_type="image/jpeg", description="Your profile image (JPEG, PNG or WebP)")
|
||||||
|
@blp.alt_response(404, schema=ErrorSchema, description="You have no profile image")
|
||||||
|
def get_avatar():
|
||||||
|
"""Your profile image"""
|
||||||
|
data = avatars.read(g.user)
|
||||||
|
if data is None:
|
||||||
|
abort(404, code="no_avatar", message="You have no profile image")
|
||||||
|
response = Response(data, mimetype=g.user.avatar_content_type or "image/jpeg")
|
||||||
|
response.headers["Cache-Control"] = "private, no-cache" # revalidate: it can change
|
||||||
|
response.add_etag()
|
||||||
|
return response.make_conditional(request)
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("", methods=["PUT"])
|
||||||
|
@authenticated(blp)
|
||||||
|
@blp.arguments(AvatarUploadSchema, location="files")
|
||||||
|
@blp.response(200, UserSchema)
|
||||||
|
@blp.alt_response(400, schema=ErrorSchema, description="Empty file")
|
||||||
|
@blp.alt_response(413, schema=ErrorSchema, description="Image too large")
|
||||||
|
@blp.alt_response(415, schema=ErrorSchema, description="Not a JPEG, PNG or WebP image")
|
||||||
|
def upload_avatar(files):
|
||||||
|
"""Upload a profile image
|
||||||
|
|
||||||
|
Replaces your current one, whatever its source.
|
||||||
|
"""
|
||||||
|
limit = current_app.config["AVATAR_UPLOAD_MAX_BYTES"]
|
||||||
|
data = files["file"].read(limit + 1)
|
||||||
|
if not data:
|
||||||
|
metrics.avatar_uploads_total.labels("empty").inc()
|
||||||
|
abort(400, code="empty_file", message="That file is empty.")
|
||||||
|
if len(data) > limit:
|
||||||
|
metrics.avatar_uploads_total.labels("too_large").inc()
|
||||||
|
abort(413, code="file_too_large", message="That image is larger than this server accepts.")
|
||||||
|
try:
|
||||||
|
content_type = avatars.sniff_image_type(data)
|
||||||
|
except avatars.UnsupportedImage:
|
||||||
|
metrics.avatar_uploads_total.labels("bad_type").inc()
|
||||||
|
abort(415, code="unsupported_image", message="Upload a JPEG, PNG or WebP image.")
|
||||||
|
avatars.save(g.user, data, content_type, "upload")
|
||||||
|
metrics.avatar_uploads_total.labels("ok").inc()
|
||||||
|
metrics.avatar_upload_bytes.observe(len(data))
|
||||||
|
return g.user
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("/gravatar", methods=["POST"])
|
||||||
|
@authenticated(blp)
|
||||||
|
@blp.response(200, UserSchema)
|
||||||
|
@blp.alt_response(404, schema=ErrorSchema, description="Gravatar is off, or has no image for you")
|
||||||
|
@blp.alt_response(502, schema=ErrorSchema, description="Gravatar couldn't be reached")
|
||||||
|
def use_gravatar():
|
||||||
|
"""Use your Gravatar as your profile image
|
||||||
|
|
||||||
|
The server fetches the image for your account email from Gravatar (sending it a hash
|
||||||
|
of the address) and keeps a copy. Call again to refresh it. Only available when the
|
||||||
|
server's admin has enabled it; see `gravatar_enabled` on `/auth/me`.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
avatars.use_gravatar(g.user)
|
||||||
|
except avatars.GravatarDisabled:
|
||||||
|
abort(404, code="gravatar_disabled", message="This server doesn't use Gravatar.")
|
||||||
|
except avatars.GravatarMissing:
|
||||||
|
abort(404, code="no_gravatar", message="Gravatar has no image for your email address.")
|
||||||
|
except avatars.GravatarUnavailable:
|
||||||
|
abort(502, code="gravatar_unavailable", message="Gravatar couldn't be reached.")
|
||||||
|
return g.user
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("", methods=["DELETE"])
|
||||||
|
@authenticated(blp)
|
||||||
|
@blp.response(204)
|
||||||
|
@blp.alt_response(404, schema=ErrorSchema, description="You have no profile image")
|
||||||
|
def delete_avatar():
|
||||||
|
"""Remove your profile image"""
|
||||||
|
if not avatars.remove(g.user):
|
||||||
|
abort(404, code="no_avatar", message="You have no profile image")
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
from flask import g
|
||||||
|
from flask_smorest import Blueprint, abort
|
||||||
|
|
||||||
|
from scrobbler.api.decorators import authenticated
|
||||||
|
from scrobbler.schemas import (
|
||||||
|
ErrorSchema,
|
||||||
|
TrackDetailArgsSchema,
|
||||||
|
TrackDetailSchema,
|
||||||
|
TrackSearchArgsSchema,
|
||||||
|
TrackSearchResultSchema,
|
||||||
|
)
|
||||||
|
from scrobbler.services import stats
|
||||||
|
|
||||||
|
blp = Blueprint("Tracks", __name__, description="Look up a specific song's history and metadata")
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("/search", methods=["GET"])
|
||||||
|
@authenticated(blp)
|
||||||
|
@blp.arguments(TrackSearchArgsSchema, location="query")
|
||||||
|
@blp.response(200, TrackSearchResultSchema(many=True))
|
||||||
|
def search(args):
|
||||||
|
"""Find a song by track or artist name"""
|
||||||
|
return stats.track_search(g.user, args["q"], args["limit"])
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("", methods=["GET"])
|
||||||
|
@authenticated(blp)
|
||||||
|
@blp.arguments(TrackDetailArgsSchema, location="query")
|
||||||
|
@blp.response(200, TrackDetailSchema)
|
||||||
|
@blp.alt_response(404, schema=ErrorSchema, description="You've never scrobbled this song")
|
||||||
|
def detail(args):
|
||||||
|
"""A song's play history and recorded metadata"""
|
||||||
|
metadata = stats.track_metadata(g.user, args["artist"], args["track"])
|
||||||
|
if metadata is None:
|
||||||
|
abort(404, code="not_found", message="You've never scrobbled this song")
|
||||||
|
history = stats.recent(
|
||||||
|
g.user,
|
||||||
|
page=args["page"],
|
||||||
|
per_page=args["limit"],
|
||||||
|
artist=args["artist"],
|
||||||
|
track=args["track"],
|
||||||
|
)
|
||||||
|
counts = stats.listen_counts(
|
||||||
|
g.user, period="3month", bucket="day", artist=args["artist"], track=args["track"]
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
"artist": metadata.artist,
|
||||||
|
"track": metadata.track,
|
||||||
|
"metadata": metadata,
|
||||||
|
"items": history.items,
|
||||||
|
"counts": counts,
|
||||||
|
"page": history.page,
|
||||||
|
"per_page": history.per_page,
|
||||||
|
"total": history.total,
|
||||||
|
"total_pages": history.total_pages,
|
||||||
|
}
|
||||||
@@ -8,7 +8,6 @@ from flask.cli import AppGroup, with_appcontext
|
|||||||
def _run_worker(once: bool, poll: float, serve_metrics: bool) -> None:
|
def _run_worker(once: bool, poll: float, serve_metrics: bool) -> None:
|
||||||
from scrobbler import worker
|
from scrobbler import worker
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
|
||||||
if serve_metrics:
|
if serve_metrics:
|
||||||
from scrobbler.metrics.server import start_metrics_server
|
from scrobbler.metrics.server import start_metrics_server
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,16 @@ class Config:
|
|||||||
CORS_ORIGINS = _csv(os.environ.get("CORS_ORIGINS", "http://localhost:8080"))
|
CORS_ORIGINS = _csv(os.environ.get("CORS_ORIGINS", "http://localhost:8080"))
|
||||||
UI_BASE_URL = os.environ.get("UI_BASE_URL", "http://localhost:8080").rstrip("/")
|
UI_BASE_URL = os.environ.get("UI_BASE_URL", "http://localhost:8080").rstrip("/")
|
||||||
|
|
||||||
|
LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO").upper()
|
||||||
|
LOG_FORMAT = os.environ.get("LOG_FORMAT", "text").lower() # "text" or "json"
|
||||||
|
|
||||||
METRICS_PORT = int(os.environ.get("METRICS_PORT", "9100"))
|
METRICS_PORT = int(os.environ.get("METRICS_PORT", "9100"))
|
||||||
# Start the metrics HTTP server from create_app (dev server). Under gunicorn the
|
# Start the metrics HTTP server from create_app (dev server). Under gunicorn the
|
||||||
# server is started by gunicorn.conf.py instead, so this stays off there.
|
# server is started by gunicorn.conf.py instead, so this stays off there.
|
||||||
START_METRICS_SERVER = os.environ.get("START_METRICS_SERVER", "0") == "1"
|
START_METRICS_SERVER = os.environ.get("START_METRICS_SERVER", "0") == "1"
|
||||||
|
|
||||||
# OpenAPI document and docs (flask-smorest)
|
# OpenAPI document and docs (flask-smorest)
|
||||||
API_TITLE = "Scrobbler API"
|
API_TITLE = "Scrobbled API"
|
||||||
API_VERSION = "v1"
|
API_VERSION = "v1"
|
||||||
OPENAPI_VERSION = "3.1.0"
|
OPENAPI_VERSION = "3.1.0"
|
||||||
OPENAPI_URL_PREFIX = "/api"
|
OPENAPI_URL_PREFIX = "/api"
|
||||||
@@ -54,6 +57,33 @@ class Config:
|
|||||||
LASTFM_API_KEY = os.environ.get("LASTFM_API_KEY", "")
|
LASTFM_API_KEY = os.environ.get("LASTFM_API_KEY", "")
|
||||||
LASTFM_API_URL = os.environ.get("LASTFM_API_URL", "https://ws.audioscrobbler.com/2.0/")
|
LASTFM_API_URL = os.environ.get("LASTFM_API_URL", "https://ws.audioscrobbler.com/2.0/")
|
||||||
LASTFM_REQUEST_INTERVAL = float(os.environ.get("LASTFM_REQUEST_INTERVAL", "0.25"))
|
LASTFM_REQUEST_INTERVAL = float(os.environ.get("LASTFM_REQUEST_INTERVAL", "0.25"))
|
||||||
|
|
||||||
|
# Album art: MusicBrainz release-group search + Cover Art Archive, both free and keyless.
|
||||||
|
MUSICBRAINZ_API_URL = os.environ.get("MUSICBRAINZ_API_URL", "https://musicbrainz.org/ws/2/")
|
||||||
|
COVERART_API_URL = os.environ.get("COVERART_API_URL", "https://coverartarchive.org/")
|
||||||
|
# MusicBrainz requires a descriptive contact in the User-Agent or it throttles/blocks us.
|
||||||
|
MUSICBRAINZ_CONTACT = os.environ.get("MUSICBRAINZ_CONTACT", "") or UI_BASE_URL
|
||||||
|
MUSICBRAINZ_REQUEST_INTERVAL = float(os.environ.get("MUSICBRAINZ_REQUEST_INTERVAL", "1.0"))
|
||||||
|
MUSICBRAINZ_RETRIES = int(os.environ.get("MUSICBRAINZ_RETRIES", "2"))
|
||||||
|
ART_NOT_FOUND_RETRY_DAYS = int(os.environ.get("ART_NOT_FOUND_RETRY_DAYS", "30"))
|
||||||
|
ART_ERROR_RETRY_SECONDS = int(os.environ.get("ART_ERROR_RETRY_SECONDS", "3600"))
|
||||||
|
# Downloaded art is kept here, named by the album_art row's id. Needs write access
|
||||||
|
# from the worker (which downloads it) and read access from the api (which serves it).
|
||||||
|
ART_STORAGE_DIR = os.environ.get("ART_STORAGE_DIR", "var/album-art")
|
||||||
|
# Largest image a user may upload as their own album art.
|
||||||
|
ART_UPLOAD_MAX_BYTES = int(os.environ.get("ART_UPLOAD_MAX_BYTES", str(5 * 1024 * 1024)))
|
||||||
|
# Profile images live in an "avatars" folder inside ART_STORAGE_DIR. This is the
|
||||||
|
# largest one a user may upload.
|
||||||
|
AVATAR_UPLOAD_MAX_BYTES = int(os.environ.get("AVATAR_UPLOAD_MAX_BYTES", str(2 * 1024 * 1024)))
|
||||||
|
# Lets users pick their Gravatar as their profile image. Off by default: using one
|
||||||
|
# sends a hash of the user's email address to Gravatar (from this server, not their browser).
|
||||||
|
AVATAR_GRAVATAR_ENABLED = os.environ.get("AVATAR_GRAVATAR_ENABLED", "").lower() in (
|
||||||
|
"1",
|
||||||
|
"true",
|
||||||
|
"yes",
|
||||||
|
)
|
||||||
|
GRAVATAR_URL = os.environ.get("GRAVATAR_URL", "https://gravatar.com/avatar/")
|
||||||
|
|
||||||
IMPORT_MAX_BYTES = int(os.environ.get("IMPORT_MAX_BYTES", str(200 * 1024 * 1024)))
|
IMPORT_MAX_BYTES = int(os.environ.get("IMPORT_MAX_BYTES", str(200 * 1024 * 1024)))
|
||||||
MAX_CONTENT_LENGTH = IMPORT_MAX_BYTES + 1024 * 1024 # uploads are the largest requests
|
MAX_CONTENT_LENGTH = IMPORT_MAX_BYTES + 1024 * 1024 # uploads are the largest requests
|
||||||
# IMPORT_WORKER_METRICS_PORT is the pre-0.3 name, still honoured.
|
# IMPORT_WORKER_METRICS_PORT is the pre-0.3 name, still honoured.
|
||||||
@@ -76,6 +106,8 @@ class TestConfig(Config):
|
|||||||
"postgresql+psycopg://scrobbler:scrobbler@localhost:5432/scrobbler_test",
|
"postgresql+psycopg://scrobbler:scrobbler@localhost:5432/scrobbler_test",
|
||||||
)
|
)
|
||||||
START_METRICS_SERVER = False
|
START_METRICS_SERVER = False
|
||||||
|
LOG_LEVEL = "INFO"
|
||||||
|
LOG_FORMAT = "text"
|
||||||
# Tests never inherit optional features or URLs from a developer's .env or
|
# Tests never inherit optional features or URLs from a developer's .env or
|
||||||
# environment; tests that need them turn them on, or override them, explicitly.
|
# environment; tests that need them turn them on, or override them, explicitly.
|
||||||
LASTFM_API_KEY = ""
|
LASTFM_API_KEY = ""
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ for users with it on, every 30 seconds). All are registered only when federation
|
|||||||
|
|
||||||
## Interop
|
## Interop
|
||||||
|
|
||||||
`scripts/interop/run.sh` runs Scrobbler against a real GoToSocial server on a private
|
`scripts/interop/run.sh` runs Scrobbled against a real GoToSocial server on a private
|
||||||
`.test` network. `scripts/interop/gotosocial_interop.py` checks the whole follow life
|
`.test` network. `scripts/interop/gotosocial_interop.py` checks the whole follow life
|
||||||
cycle, then `run.sh` seeds a scrobble and a now-playing track, runs
|
cycle, then `run.sh` seeds a scrobble and a now-playing track, runs
|
||||||
`flask federation post-weekly --now` directly in the `api` container, and runs the
|
`flask federation post-weekly --now` directly in the `api` container, and runs the
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""ActivityPub federation: optional, self-contained, replaceable.
|
"""ActivityPub federation: optional, self-contained, replaceable.
|
||||||
|
|
||||||
The rest of Scrobbler only calls `init_app(app)` (from `create_app`) and sends domain
|
The rest of Scrobbled only calls `init_app(app)` (from `create_app`) and sends domain
|
||||||
events (`scrobbler.events`). Everything else about federation lives in this package;
|
events (`scrobbler.events`). Everything else about federation lives in this package;
|
||||||
see README.md here and docs/design/activitypub.md.
|
see README.md here and docs/design/activitypub.md.
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,15 @@ def now_playing_field(user, settings) -> list[tuple[str, str]]:
|
|||||||
return [(NOW_PLAYING_FIELD, text)] if text else []
|
return [(NOW_PLAYING_FIELD, text)] if text else []
|
||||||
|
|
||||||
|
|
||||||
|
def avatar_icon(urls: vocab.ActorUrls, user, settings) -> tuple[str, str] | None:
|
||||||
|
"""The actor's picture: only if they've chosen to share one. The URL carries the
|
||||||
|
image's age so other servers, which cache by URL, fetch a changed picture."""
|
||||||
|
if not settings.share_avatar or not user.has_avatar:
|
||||||
|
return None
|
||||||
|
version = int(user.avatar_updated_at.timestamp()) if user.avatar_updated_at else 0
|
||||||
|
return f"{urls.avatar}?v={version}", user.avatar_content_type or "image/jpeg"
|
||||||
|
|
||||||
|
|
||||||
def build_document(urls: vocab.ActorUrls, user, settings) -> dict:
|
def build_document(urls: vocab.ActorUrls, user, settings) -> dict:
|
||||||
return vocab.person(
|
return vocab.person(
|
||||||
urls,
|
urls,
|
||||||
@@ -46,4 +55,5 @@ def build_document(urls: vocab.ActorUrls, user, settings) -> dict:
|
|||||||
indexable=settings.indexable,
|
indexable=settings.indexable,
|
||||||
published=settings.created_at.isoformat().replace("+00:00", "Z"),
|
published=settings.created_at.isoformat().replace("+00:00", "Z"),
|
||||||
fields=now_playing_field(user, settings),
|
fields=now_playing_field(user, settings),
|
||||||
|
icon=avatar_icon(urls, user, settings),
|
||||||
)
|
)
|
||||||
@@ -178,10 +178,28 @@ def public_profile(username):
|
|||||||
"now_playing": actors.now_playing_text(user)
|
"now_playing": actors.now_playing_text(user)
|
||||||
if settings.now_playing_mode != "off"
|
if settings.now_playing_mode != "off"
|
||||||
else None,
|
else None,
|
||||||
|
"has_avatar": settings.share_avatar and user.has_avatar,
|
||||||
**{k: v for k, v in _identity(user.username).items() if k != "profile_url"},
|
**{k: v for k, v in _identity(user.username).items() if k != "profile_url"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@blp.route("/profiles/<string:username>/avatar", methods=["GET"])
|
||||||
|
@blp.response(200, content_type="image/jpeg", description="The profile image (JPEG, PNG or WebP)")
|
||||||
|
@blp.alt_response(404, schema=ErrorSchema, description="No image shared under that name")
|
||||||
|
def public_avatar(username):
|
||||||
|
"""A public profile image
|
||||||
|
|
||||||
|
For the web UI's profile page. Only served when the user shares and has chosen to
|
||||||
|
share their image.
|
||||||
|
"""
|
||||||
|
found = sharing.shared_avatar(username)
|
||||||
|
if found is None:
|
||||||
|
fed_metrics.lookups_total.labels(kind="avatar", result="not_found").inc()
|
||||||
|
abort(404, code="not_found", message="No shared profile image under that name.")
|
||||||
|
fed_metrics.lookups_total.labels(kind="avatar", result="found").inc()
|
||||||
|
return sharing.avatar_response(*found)
|
||||||
|
|
||||||
|
|
||||||
@blp.route("/profiles/<string:username>/posts/<string:post_uuid>", methods=["GET"])
|
@blp.route("/profiles/<string:username>/posts/<string:post_uuid>", methods=["GET"])
|
||||||
@blp.response(200, PublicPostSchema)
|
@blp.response(200, PublicPostSchema)
|
||||||
@blp.alt_response(404, schema=ErrorSchema, description="Not found, not public, or deleted")
|
@blp.alt_response(404, schema=ErrorSchema, description="Not found, not public, or deleted")
|
||||||
|
|||||||
@@ -68,6 +68,13 @@ def _retry_or_abandon(delivery: FederationDelivery, error: str, status: int | No
|
|||||||
delivery.last_status, delivery.last_error = status, error[:1000]
|
delivery.last_status, delivery.last_error = status, error[:1000]
|
||||||
if _now() - delivery.created_at >= GIVE_UP_AFTER:
|
if _now() - delivery.created_at >= GIVE_UP_AFTER:
|
||||||
delivery.status = "abandoned"
|
delivery.status = "abandoned"
|
||||||
|
log.warning(
|
||||||
|
"delivery %s to %s abandoned after %s attempts: %s",
|
||||||
|
delivery.id,
|
||||||
|
delivery.inbox,
|
||||||
|
delivery.attempts,
|
||||||
|
error[:200],
|
||||||
|
)
|
||||||
return "abandoned"
|
return "abandoned"
|
||||||
delay = (
|
delay = (
|
||||||
RETRY_DELAYS[delivery.attempts - 1]
|
RETRY_DELAYS[delivery.attempts - 1]
|
||||||
@@ -75,6 +82,14 @@ def _retry_or_abandon(delivery: FederationDelivery, error: str, status: int | No
|
|||||||
else LATER_DELAY
|
else LATER_DELAY
|
||||||
)
|
)
|
||||||
delivery.next_attempt_at = _now() + delay
|
delivery.next_attempt_at = _now() + delay
|
||||||
|
log.warning(
|
||||||
|
"delivery %s to %s failed (attempt %s), retrying in %s: %s",
|
||||||
|
delivery.id,
|
||||||
|
delivery.inbox,
|
||||||
|
delivery.attempts,
|
||||||
|
delay,
|
||||||
|
error[:200],
|
||||||
|
)
|
||||||
return "retry"
|
return "retry"
|
||||||
|
|
||||||
|
|
||||||
@@ -135,7 +150,7 @@ def _deliver_in_context(app, delivery_id: int) -> str:
|
|||||||
try:
|
try:
|
||||||
return deliver(delivery_id)
|
return deliver(delivery_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception("delivery %s failed unexpectedly", delivery_id)
|
log.exception("delivery %s failed unexpectedly (will be retried)", delivery_id)
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
return "retry" # the lease expires and it becomes due again
|
return "retry" # the lease expires and it becomes due again
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
@@ -224,7 +224,13 @@ def process(item: FederationInboxItem) -> None:
|
|||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
transient = isinstance(err, FetchError) and err.reason == "network"
|
transient = isinstance(err, FetchError) and err.reason == "network"
|
||||||
if not transient:
|
if not transient:
|
||||||
log.exception("inbox item %s failed", item.id)
|
log.exception(
|
||||||
|
"inbox item %s (%s) failed on attempt %s of %s",
|
||||||
|
item.id,
|
||||||
|
item.activity_type,
|
||||||
|
item.attempts,
|
||||||
|
MAX_ATTEMPTS,
|
||||||
|
)
|
||||||
if item.attempts < MAX_ATTEMPTS:
|
if item.attempts < MAX_ATTEMPTS:
|
||||||
_finish(item, "queued", f"retrying: {err}"[:255], done=False)
|
_finish(item, "queued", f"retrying: {err}"[:255], done=False)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from prometheus_client import Counter, Gauge, Histogram
|
|||||||
|
|
||||||
lookups_total = Counter(
|
lookups_total = Counter(
|
||||||
"scrobbler_federation_lookups_total",
|
"scrobbler_federation_lookups_total",
|
||||||
"Fediverse lookups answered: WebFinger, actor, NodeInfo, profile",
|
"Fediverse lookups answered: WebFinger, actor, NodeInfo, profile, avatar",
|
||||||
["kind", "result"],
|
["kind", "result"],
|
||||||
)
|
)
|
||||||
sharing_changes_total = Counter(
|
sharing_changes_total = Counter(
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ class FederationSettings(db.Model):
|
|||||||
indexable: Mapped[bool] = mapped_column(Boolean, default=False)
|
indexable: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||||
display_name: Mapped[str | None] = mapped_column(String(100))
|
display_name: Mapped[str | None] = mapped_column(String(100))
|
||||||
bio: Mapped[str | None] = mapped_column(Text)
|
bio: Mapped[str | None] = mapped_column(Text)
|
||||||
|
# Offer the user's profile image to other servers (as the actor's icon) and on the
|
||||||
|
# public profile page. Off until they say so.
|
||||||
|
share_avatar: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||||
# An IANA zone name (validated with zoneinfo), used to decide when a Monday starts.
|
# An IANA zone name (validated with zoneinfo), used to decide when a Monday starts.
|
||||||
timezone: Mapped[str] = mapped_column(String(64), default="UTC")
|
timezone: Mapped[str] = mapped_column(String(64), default="UTC")
|
||||||
post_weekly_summary: Mapped[bool] = mapped_column(Boolean, default=True)
|
post_weekly_summary: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||||
|
|||||||
@@ -130,6 +130,20 @@ _OPERATIONS = {
|
|||||||
"404": {"description": "Not found, not listed, or deleted"},
|
"404": {"description": "Not found, not listed, or deleted"},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
"federation.actor_avatar": (
|
||||||
|
"get",
|
||||||
|
"Profile image",
|
||||||
|
"The user's profile image, which their actor document names as its `icon`. Only "
|
||||||
|
"served when the user shares and has chosen to share their image.",
|
||||||
|
[_USERNAME],
|
||||||
|
{
|
||||||
|
"200": {
|
||||||
|
"description": "A JPEG, PNG or WebP image",
|
||||||
|
"content": {"image/*": {"schema": {"type": "string", "format": "binary"}}},
|
||||||
|
},
|
||||||
|
"404": _NOT_FOUND,
|
||||||
|
},
|
||||||
|
),
|
||||||
"federation.followers": (
|
"federation.followers": (
|
||||||
"get",
|
"get",
|
||||||
"Followers",
|
"Followers",
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ def client() -> Client:
|
|||||||
|
|
||||||
config = current_app.extensions["federation"]
|
config = current_app.extensions["federation"]
|
||||||
existing = Client(
|
existing = Client(
|
||||||
user_agent=f"Scrobbler/{__version__} (+{config.base_url})",
|
user_agent=f"Scrobbled/{__version__} (+{config.base_url})",
|
||||||
insecure_testing=config.insecure_testing,
|
insecure_testing=config.insecure_testing,
|
||||||
)
|
)
|
||||||
current_app.extensions["federation_client"] = existing
|
current_app.extensions["federation_client"] = existing
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
NodeInfo documents, HTTP signature schemes.
|
NodeInfo documents, HTTP signature schemes.
|
||||||
|
|
||||||
Rule: nothing in this package imports Flask, SQLAlchemy, Werkzeug or any other part of
|
Rule: nothing in this package imports Flask, SQLAlchemy, Werkzeug or any other part of
|
||||||
Scrobbler; only the standard library and `cryptography`. Spec changes land here and are
|
Scrobbled; only the standard library and `cryptography`. Spec changes land here and are
|
||||||
tested with spec test vectors alone. (Enforced by tests/test_federation_boundary.py.)
|
tested with spec test vectors alone. (Enforced by tests/test_federation_boundary.py.)
|
||||||
"""
|
"""
|
||||||
@@ -7,7 +7,7 @@ line of a post is its own paragraph.
|
|||||||
|
|
||||||
import html
|
import html
|
||||||
|
|
||||||
HASHTAG = "Scrobbler"
|
HASHTAG = "Scrobbled"
|
||||||
|
|
||||||
|
|
||||||
def escape(text: str) -> str:
|
def escape(text: str) -> str:
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class ActorUrls:
|
|||||||
shared_inbox: str
|
shared_inbox: str
|
||||||
key_id: str
|
key_id: str
|
||||||
profile_page: str
|
profile_page: str
|
||||||
|
avatar: str
|
||||||
|
|
||||||
|
|
||||||
def actor_urls(base_url: str, username: str, profile_page: str) -> ActorUrls:
|
def actor_urls(base_url: str, username: str, profile_page: str) -> ActorUrls:
|
||||||
@@ -49,6 +50,7 @@ def actor_urls(base_url: str, username: str, profile_page: str) -> ActorUrls:
|
|||||||
shared_inbox=f"{base_url}/inbox",
|
shared_inbox=f"{base_url}/inbox",
|
||||||
key_id=f"{actor}#main-key",
|
key_id=f"{actor}#main-key",
|
||||||
profile_page=profile_page,
|
profile_page=profile_page,
|
||||||
|
avatar=f"{actor}/avatar",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -79,8 +81,10 @@ def person(
|
|||||||
indexable: bool,
|
indexable: bool,
|
||||||
published: str | None = None,
|
published: str | None = None,
|
||||||
fields: list[tuple[str, str]] = (),
|
fields: list[tuple[str, str]] = (),
|
||||||
|
icon: tuple[str, str] | None = None,
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""A user's actor document. `fields` are (name, plain-text value) profile fields."""
|
"""A user's actor document. `fields` are (name, plain-text value) profile fields;
|
||||||
|
`icon` is the profile picture's (url, media type)."""
|
||||||
doc = {
|
doc = {
|
||||||
"@context": ACTOR_CONTEXT,
|
"@context": ACTOR_CONTEXT,
|
||||||
"id": urls.id,
|
"id": urls.id,
|
||||||
@@ -106,6 +110,8 @@ def person(
|
|||||||
}
|
}
|
||||||
if published:
|
if published:
|
||||||
doc["published"] = published
|
doc["published"] = published
|
||||||
|
if icon:
|
||||||
|
doc["icon"] = {"type": "Image", "url": icon[0], "mediaType": icon[1]}
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
|
|
||||||
@@ -235,7 +241,7 @@ def update(activity_id: str, actor_id: str, obj: dict, *, to: list[str]) -> dict
|
|||||||
|
|
||||||
|
|
||||||
def hashtag(name: str) -> dict:
|
def hashtag(name: str) -> dict:
|
||||||
"""A Hashtag tag, e.g. #Scrobbler. No href: we don't serve tag pages, and Mastodon
|
"""A Hashtag tag, e.g. #Scrobbled. No href: we don't serve tag pages, and Mastodon
|
||||||
still recognises and indexes the tag from `name` alone."""
|
still recognises and indexes the tag from `name` alone."""
|
||||||
return {"type": "Hashtag", "name": f"#{name}"}
|
return {"type": "Hashtag", "name": f"#{name}"}
|
||||||
|
|
||||||
@@ -250,10 +256,11 @@ def note(
|
|||||||
to: list[str],
|
to: list[str],
|
||||||
cc: list[str],
|
cc: list[str],
|
||||||
tags: list[str] = (),
|
tags: list[str] = (),
|
||||||
|
attachment: list[dict] = (),
|
||||||
) -> dict:
|
) -> dict:
|
||||||
"""A post (weekly summary or milestone). No `@context`: it's always embedded in the
|
"""A post (now playing, weekly summary or milestone). No `@context`: it's always
|
||||||
Create that carries the same addressing, as Mastodon does."""
|
embedded in the Create that carries the same addressing, as Mastodon does."""
|
||||||
return {
|
doc = {
|
||||||
"id": note_id,
|
"id": note_id,
|
||||||
"type": "Note",
|
"type": "Note",
|
||||||
"attributedTo": actor_id,
|
"attributedTo": actor_id,
|
||||||
@@ -266,6 +273,9 @@ def note(
|
|||||||
"tag": [hashtag(t) for t in tags],
|
"tag": [hashtag(t) for t in tags],
|
||||||
"sensitive": False,
|
"sensitive": False,
|
||||||
}
|
}
|
||||||
|
if attachment:
|
||||||
|
doc["attachment"] = list(attachment)
|
||||||
|
return doc
|
||||||
|
|
||||||
|
|
||||||
def create(activity_id: str, actor_id: str, obj: dict, *, to: list[str], cc: list[str]) -> dict:
|
def create(activity_id: str, actor_id: str, obj: dict, *, to: list[str], cc: list[str]) -> dict:
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from scrobbler.federation import metrics as fed_metrics
|
|||||||
from scrobbler.federation.models import FederationActivity, FederationPost
|
from scrobbler.federation.models import FederationActivity, FederationPost
|
||||||
from scrobbler.federation.protocol import addressing, vocab
|
from scrobbler.federation.protocol import addressing, vocab
|
||||||
|
|
||||||
DEFAULT_TAGS = ("Scrobbler",)
|
DEFAULT_TAGS = ("Scrobbled",)
|
||||||
OUTBOX_PAGE_SIZE = 20
|
OUTBOX_PAGE_SIZE = 20
|
||||||
LISTED_VISIBILITIES = ("public", "unlisted") # followers-only posts aren't listed unauthenticated
|
LISTED_VISIBILITIES = ("public", "unlisted") # followers-only posts aren't listed unauthenticated
|
||||||
|
|
||||||
@@ -87,6 +87,7 @@ def publish(
|
|||||||
text: str,
|
text: str,
|
||||||
html: str,
|
html: str,
|
||||||
tags: tuple[str, ...] = DEFAULT_TAGS,
|
tags: tuple[str, ...] = DEFAULT_TAGS,
|
||||||
|
attachment: list[dict] = (),
|
||||||
) -> FederationPost | None:
|
) -> FederationPost | None:
|
||||||
"""Post `text`/`html` for the user, keyed by `kind:key`.
|
"""Post `text`/`html` for the user, keyed by `kind:key`.
|
||||||
|
|
||||||
@@ -116,6 +117,7 @@ def publish(
|
|||||||
to=to,
|
to=to,
|
||||||
cc=cc,
|
cc=cc,
|
||||||
tags=list(tags),
|
tags=list(tags),
|
||||||
|
attachment=list(attachment),
|
||||||
)
|
)
|
||||||
# activity.id is a Python-generated UUID (see activities.store), so it's already
|
# activity.id is a Python-generated UUID (see activities.store), so it's already
|
||||||
# usable below without a flush.
|
# usable below without a flush.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ from scrobbler.federation import activities, actors, followers, publishing, shar
|
|||||||
from scrobbler.federation import metrics as fed_metrics
|
from scrobbler.federation import metrics as fed_metrics
|
||||||
from scrobbler.federation.models import FederationNowPlaying, FederationPost, FederationSettings
|
from scrobbler.federation.models import FederationNowPlaying, FederationPost, FederationSettings
|
||||||
from scrobbler.federation.protocol import content, vocab
|
from scrobbler.federation.protocol import content, vocab
|
||||||
from scrobbler.services import accounts
|
from scrobbler.services import accounts, art
|
||||||
from scrobbler.services.scrobbles import get_now_playing
|
from scrobbler.services.scrobbles import get_now_playing
|
||||||
|
|
||||||
KIND = "now_playing"
|
KIND = "now_playing"
|
||||||
@@ -80,10 +80,36 @@ def _build_content(playing) -> tuple[str, str]:
|
|||||||
return text, html
|
return text, html
|
||||||
|
|
||||||
|
|
||||||
|
def _attachment_for(playing) -> list[dict]:
|
||||||
|
"""Cover art for the post, if we have an album and can resolve it. Cover Art
|
||||||
|
Archive's sized convenience endpoints (what art.lookup() resolves to) are always
|
||||||
|
JPEG, whatever the original upload was."""
|
||||||
|
if not playing.album:
|
||||||
|
return []
|
||||||
|
result = art.lookup(playing.artist, playing.album)
|
||||||
|
if result.status != "found":
|
||||||
|
return []
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"type": "Image",
|
||||||
|
"mediaType": "image/jpeg",
|
||||||
|
"url": result.image_url,
|
||||||
|
"name": f"Cover art for {playing.album}",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def _post_now_playing(user, playing, key: str, state: FederationNowPlaying, now: datetime) -> str:
|
def _post_now_playing(user, playing, key: str, state: FederationNowPlaying, now: datetime) -> str:
|
||||||
text, html = _build_content(playing)
|
text, html = _build_content(playing)
|
||||||
post = publishing.publish(
|
post = publishing.publish(
|
||||||
user.id, user.username, KIND, key, text=text, html=html, tags=("Scrobbler", "NowPlaying")
|
user.id,
|
||||||
|
user.username,
|
||||||
|
KIND,
|
||||||
|
key,
|
||||||
|
text=text,
|
||||||
|
html=html,
|
||||||
|
tags=("Scrobbled", "NowPlaying"),
|
||||||
|
attachment=_attachment_for(playing),
|
||||||
)
|
)
|
||||||
if post is None:
|
if post is None:
|
||||||
return "none"
|
return "none"
|
||||||
|
|||||||
@@ -55,6 +55,14 @@ class SharingSettingsSchema(Schema):
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
share_avatar = fields.Boolean(
|
||||||
|
metadata={
|
||||||
|
"description": (
|
||||||
|
"Show your profile image on your public profile and send it to other "
|
||||||
|
"servers as your picture. Off by default; has no effect if you have no image."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
handle = fields.String(dump_only=True, metadata={"example": "@alice@scrobble.example"})
|
handle = fields.String(dump_only=True, metadata={"example": "@alice@scrobble.example"})
|
||||||
actor_url = fields.String(dump_only=True)
|
actor_url = fields.String(dump_only=True)
|
||||||
profile_url = fields.String(dump_only=True)
|
profile_url = fields.String(dump_only=True)
|
||||||
@@ -71,6 +79,9 @@ class PublicProfileSchema(Schema):
|
|||||||
now_playing = fields.String(
|
now_playing = fields.String(
|
||||||
allow_none=True, metadata={"description": '"Track by Artist", or null'}
|
allow_none=True, metadata={"description": '"Track by Artist", or null'}
|
||||||
)
|
)
|
||||||
|
has_avatar = fields.Boolean(
|
||||||
|
metadata={"description": "Whether there's a profile image at `/profiles/{username}/avatar`"}
|
||||||
|
)
|
||||||
handle = fields.String(metadata={"example": "@alice@scrobble.example"})
|
handle = fields.String(metadata={"example": "@alice@scrobble.example"})
|
||||||
actor_url = fields.String()
|
actor_url = fields.String()
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
"""Per-user sharing settings: whether a user federates, and how."""
|
"""Per-user sharing settings: whether a user federates, and how."""
|
||||||
|
|
||||||
|
from flask import Response, request
|
||||||
|
|
||||||
from scrobbler.extensions import db
|
from scrobbler.extensions import db
|
||||||
from scrobbler.federation import keys
|
from scrobbler.federation import keys
|
||||||
from scrobbler.federation.models import NOW_PLAYING_MODES, VISIBILITIES, FederationSettings
|
from scrobbler.federation.models import NOW_PLAYING_MODES, VISIBILITIES, FederationSettings
|
||||||
from scrobbler.federation.protocol.schedule import is_valid_timezone
|
from scrobbler.federation.protocol.schedule import is_valid_timezone
|
||||||
from scrobbler.services import accounts
|
from scrobbler.services import accounts, avatars
|
||||||
|
|
||||||
EDITABLE = (
|
EDITABLE = (
|
||||||
"enabled",
|
"enabled",
|
||||||
@@ -18,6 +20,7 @@ EDITABLE = (
|
|||||||
"post_weekly_summary",
|
"post_weekly_summary",
|
||||||
"post_milestones",
|
"post_milestones",
|
||||||
"now_playing_mode",
|
"now_playing_mode",
|
||||||
|
"share_avatar",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -38,6 +41,7 @@ def settings_for(user_id: int) -> FederationSettings:
|
|||||||
post_weekly_summary=True,
|
post_weekly_summary=True,
|
||||||
post_milestones=True,
|
post_milestones=True,
|
||||||
now_playing_mode="off",
|
now_playing_mode="off",
|
||||||
|
share_avatar=False,
|
||||||
)
|
)
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
@@ -81,6 +85,27 @@ def shared_user(username: str):
|
|||||||
return user, settings
|
return user, settings
|
||||||
|
|
||||||
|
|
||||||
|
def shared_avatar(username: str):
|
||||||
|
"""(user, image bytes) for a sharing user who has chosen to share their profile image
|
||||||
|
and has one, else None - indistinguishable from 'no such user', like shared_user."""
|
||||||
|
found = shared_user(username)
|
||||||
|
if found is None:
|
||||||
|
return None
|
||||||
|
user, settings = found
|
||||||
|
if not settings.share_avatar:
|
||||||
|
return None
|
||||||
|
data = avatars.read(user)
|
||||||
|
return None if data is None else (user, data)
|
||||||
|
|
||||||
|
|
||||||
|
def avatar_response(user, data: bytes):
|
||||||
|
"""The public image response: cacheable by anyone, but briefly, as it can change."""
|
||||||
|
response = Response(data, mimetype=user.avatar_content_type or "image/jpeg")
|
||||||
|
response.headers["Cache-Control"] = "public, max-age=300"
|
||||||
|
response.add_etag()
|
||||||
|
return response.make_conditional(request)
|
||||||
|
|
||||||
|
|
||||||
def sharing_count() -> int:
|
def sharing_count() -> int:
|
||||||
return db.session.scalar(
|
return db.session.scalar(
|
||||||
db.select(db.func.count()).select_from(FederationSettings).filter_by(enabled=True)
|
db.select(db.func.count()).select_from(FederationSettings).filter_by(enabled=True)
|
||||||
|
|||||||