Skip to content

Commit 79a8f95

Browse files
implement scrobbling from Setlist.fm (#248)
Co-authored-by: Enrico Lamperti <[email protected]>
1 parent 6522720 commit 79a8f95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+717
-95
lines changed

.env

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ SQLITE_DB_PATH="/var/www/html/database/development.db"
88
# Optional
99
DISCOGS_API_KEY=
1010
DISCOGS_SECRET=
11+
SETLISTFM_API_KEY=
1112
REACT_APP_ANALYTICS_MEASUREMENT_ID=
1213
REACT_APP_GROWTHBOOK_API_KEY=
1314
REACT_APP_LINK_TO_TRANSLATIONS="https://github.com/elamperti/OpenWebScrobbler/blob/main/CONTRIBUTING.md#translations"

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ To join the translators team, follow the link at the bottom of the language sele
2929
* Clone the repository
3030
* Copy `.env` to `.env.development.local`, then set at least the required variables
3131
* You'll need a [Last.fm API account](https://www.last.fm/api/account/create) to be able to interact with Open Scrobbler (it's used for authentication and queries). Once you have your keys, fill in `REACT_APP_LASTFM_API_KEY` and `LASTFM_API_KEY` (same value in both) and `LASTFM_SECRET`
32-
* Optional: to interact with Discogs, create a [Discogs application](https://www.discogs.com/settings/developers) to get API keys and fill in `DISCOGS_API_KEY` and `DISCOGS_SECRET`
32+
* Optional: to interact with Discogs, create a [Discogs application](https://www.discogs.com/settings/developers) to get API keys and fill in `DISCOGS_API_KEY` and `DISCOGS_SECRET`
33+
* Optional: to interact with Setlist.fm, [create an application](https://www.setlist.fm/settings/apps) and set `SETLISTFM_API_KEY` with the corresponding API key
3334
* Run `yarn` to download the required libraries.
3435
* Run `yarn start` to initialize the docker container and run the application.
3536

public/api/v2/discogs.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
switch ($_GET['method']) {
99
case 'album.search':
1010
case 'artist.search':
11+
case 'track.search':
1112
$endpoint = 'database/search';
1213
break;
1314

@@ -39,7 +40,6 @@
3940
$params['sort_order'] = 'desc';
4041
unset($_GET['artist_id']);
4142
break;
42-
4343
default:
4444
require('inc/error.php');
4545
raiseOWSError('Invalid method', 400, 603);

public/api/v2/setlistfm.php

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
if (isset($_GET['setlistId'])) {
3+
$sanitized_setlistId = filter_var($_GET['setlistId'], FILTER_SANITIZE_STRING);
4+
$endpoint = 'setlist/' . $_GET['setlistId'];
5+
} else if (isset($_GET['artistName'])) {
6+
$sanitized_artistName = filter_var($_GET['artistName'], FILTER_SANITIZE_STRING);
7+
$endpoint = 'search/setlists?artistName=' . urlencode($sanitized_artistName);
8+
9+
if (isset($_GET['page'])) {
10+
$sanitized_p = filter_var($_GET['page'], FILTER_SANITIZE_NUMBER_INT);
11+
$endpoint .= '&p=' . $sanitized_p;
12+
}
13+
} else {
14+
require('inc/error.php');
15+
raiseOWSError('No setlist ID provided', 404, 620);
16+
}
17+
18+
$setlistfmrq = curl_init();
19+
20+
curl_setopt($setlistfmrq, CURLOPT_HTTPHEADER, [
21+
"REMOTE_ADDR: " . $_SERVER['REMOTE_ADDR'],
22+
"HTTP_X_FORWARDED_FOR: " . $_SERVER['REMOTE_ADDR'],
23+
"Accept: application/json",
24+
"x-api-key: " . getenv('SETLISTFM_API_KEY')
25+
]);
26+
curl_setopt($setlistfmrq, CURLOPT_RETURNTRANSFER, true);
27+
curl_setopt($setlistfmrq, CURLOPT_URL, 'https://api.setlist.fm/rest/1.0/' . $endpoint);
28+
29+
$response = curl_exec($setlistfmrq);
30+
header('Content-Type: ' . curl_getinfo($setlistfmrq, CURLINFO_CONTENT_TYPE));
31+
32+
require_once('inc/analytics.php');
33+
$ga = new Analytics();
34+
$ga->timing('Setlist.fm Response Time', $method, round(curl_getinfo($setlistfmrq, CURLINFO_TOTAL_TIME) * 1000));
35+
36+
curl_close($setlistfmrq);
37+
echo $response;
38+

public/locales/ast.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "La to historia",
2626
"scrobbleManually": "Scrobbliar manualmente",
2727
"scrobbleFromOtherUser": "Scrobbliar d'otru usuariu",
28+
"scrobbleFromSetlist": "Scrobbliar de setlist.fm",
2829
"otherUser": "Usuariu",
2930
"or": "o",
3031
"refresh": "Volver cargar",

public/locales/bg.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "Твоята история",
2626
"scrobbleManually": "Скробълни ръчно",
2727
"scrobbleFromOtherUser": "Скробълни от друг потребител",
28+
"scrobbleFromSetlist": "Скробълни от setlist.fm",
2829
"otherUser": "Потребител",
2930
"or": "или",
3031
"refresh": "Презареди",

public/locales/ca.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "El vostre historial",
2626
"scrobbleManually": "Envia manualment",
2727
"scrobbleFromOtherUser": "Envia des d’un altre usuari",
28+
"scrobbleFromSetlist": "Envia del setlist.fm",
2829
"otherUser": "Usuari",
2930
"or": "o",
3031
"refresh": "Actualitza",

public/locales/da.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "Din historik",
2626
"scrobbleManually": "Scrobbl manuelt",
2727
"scrobbleFromOtherUser": "Scrobbl fra anden bruger",
28+
"scrobbleFromSetlist": "Scrobbl fra setlist.fm",
2829
"otherUser": "Bruger",
2930
"or": "eller",
3031
"refresh": "Genindlæs",

public/locales/de.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "Dein Hörverlauf",
2626
"scrobbleManually": "Scrobble manuell",
2727
"scrobbleFromOtherUser": "Scrobble von einem anderen Benutzer",
28+
"scrobbleFromSetlist": "Scrobble von setlist.fm",
2829
"otherUser": "Benutzer",
2930
"or": "oder",
3031
"refresh": "Neu laden",

public/locales/el.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "Το ιστορικό σας",
2626
"scrobbleManually": "Scrobble χειροκίνητα",
2727
"scrobbleFromOtherUser": "Scrobble από άλλο χρήστη",
28+
"scrobbleFromSetlist": "Scrobble από setlist.fm",
2829
"otherUser": "Χρήστης",
2930
"or": "ή",
3031
"refresh": "Ανανέωση",

public/locales/en.json

+12-10
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
"scrobbleSelected": "Scrobble selected",
1919
"findAlbumCopy": "Enter an album or artist name",
2020
"customTimestamp": "Custom timestamp",
21-
"albumTimestampLogicDescription": "Scrobbling tracks \"now\" will scrobble the last track at the current time, backdating the previous ones accordingly (as if you had just finished listening). The \"custom timestamp\" will define the timestamp of the first track and add time to the following tracks from there (i.e. you specify the time you started listening to this album).",
21+
"albumTimestampLogicDescription": "Scrobbling tracks \"now\" will scrobble the last track at the current time, backdating the previous ones accordingly (as if you had just finished listening). The \"custom timestamp\" will define the timestamp of the first track and add time to the following tracks from there (i.e. you specify the time you started listening to this album)",
2222
"albumArtist": "Album artist",
23-
"filter": "Filter",
24-
"albumCleanupPatternDescription": "Some albums tracks are displayed with some repeated text (i.e. Demo, Live, Remastered, ...). These are patterns that could be considered annoying to scrobble, for some users. Set the full pattern (including paranthesis, dashes, ...) that you would like to be removed, from the track names.",
2523
"history": "History",
2624
"yourProfile": "Your profile",
2725
"yourHistory": "Your history",
@@ -161,12 +159,16 @@
161159
"verifyingPatreonAccount": "Verifying Patreon account",
162160
"connectingAccounts": "Connecting to Patreon...",
163161
"applications": "Applications",
164-
"autoFillAlbum": "Fill album name from last.fm",
165-
"autoFillAlbumInvalidForm": "Enter artist and track for album auto-fill",
166-
"General settings title": {
167-
"general": "General"
168-
},
169-
"learnMore": "Learn more",
170162
"connect": "Connect",
171-
"connected": "Connected"
163+
"general": "General",
164+
"learnMore": "Learn more",
165+
"connected": "Connected",
166+
"filter": "Filter",
167+
"autoFillAlbum": "Autocomplete using Last.fm",
168+
"autoFillAlbumInvalidForm": "Enter artist and track to autocomplete",
169+
"scrobbleSetlist": "Scrobble setlist",
170+
"noSetlistsFound": "No setlists found for <1>{{searchParam}}</1>",
171+
"emptySetlist": "This setlist seems to be empty.",
172+
"setlist": "Setlist",
173+
"searchSetlistPrompt": "Search by artist name or paste a setlist.fm link"
172174
}

public/locales/es.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,13 @@
161161
"connect": "Conectar",
162162
"general": "General",
163163
"learnMore": "Leer más",
164-
"connected": "Conectado"
164+
"connected": "Conectado",
165+
"filter": "Filtrar",
166+
"autoFillAlbum": "Autocompletar usando Last.fm",
167+
"autoFillAlbumInvalidForm": "Escribe un artista y título para autcompletar",
168+
"scrobbleSetlist": "Scrobblear setlist",
169+
"noSetlistsFound": "No se encontraron setlists para <1>{{searchParam}}</1>",
170+
"emptySetlist": "Esta setlist parece estar vacía.",
171+
"setlist": "Setlist",
172+
"searchSetlistPrompt": "Busca por nombre de artista o pega un link de setlist.fm"
165173
}

public/locales/fr.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "Votre historique",
2626
"scrobbleManually": "Scrobbler manuellement",
2727
"scrobbleFromOtherUser": "Scrobbler depuis un autre utilisateur",
28+
"scrobbleFromSetlist": "Scrobbler depuis setlist.fm",
2829
"otherUser": "Utilisateur",
2930
"or": "ou",
3031
"refresh": "Actualiser",

public/locales/it.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
"customTimestamp": "Timestamp personalizzato",
2121
"albumTimestampLogicDescription": "Scrobblando le canzoni \"adesso\" scrobblerà l'ultima canzone in questo momento, anticipando relativamente le precedenti (come se avessi appena finito di ascoltarle). Il \"timestamp personalizzato\" definirà il timestamp di ascolto della prima traccia ed agginguerà il relativo tempo alle canzoni successive (come se avessi iniziato ad ascoltare l'album nel timestamp selezionato)",
2222
"albumArtist": "Artista di un Album",
23-
"albumCleanupPatternDescription": "Alcune canzoni di album sono visualizzate con un certo testo ripetuto (ad esempio Demo, Live, Remastered, ...). Questi sono pattern che potrebbero risultare fastidiosi da scrobblare, per alcuni utenti. Imposta il pattern completo (incluse parentesi, trattini, ...) che desideri venga rimosso dai nomi delle canzoni.",
2423
"history": "Storico",
2524
"yourProfile": "Tuo profilo",
2625
"yourHistory": "Tuo storico",
2726
"scrobbleManually": "Scrobbla manualmente",
2827
"scrobbleFromOtherUser": "Scrobbla da un altro utente",
28+
"scrobbleFromSetlist": "Scrobbla da setlist.fm",
2929
"otherUser": "Utente",
3030
"or": "o",
3131
"refresh": "Ricarica",

public/locales/nl.json

+15-11
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717
"scrobbleSongs": "Scrobbel liedjes",
1818
"scrobbleSelected": "Scrobbel selectie",
1919
"findAlbumCopy": "Voer een album- of artiestennaam in",
20-
"customTimestamp": "Aangepast tijdstempel",
20+
"customTimestamp": "Aangepaste tijdstempel",
2121
"albumTimestampLogicDescription": "Als je tracks \"nu\" scrollt, scrollt de laatste track op het huidige tijdstip en worden de vorige tracks dienovereenkomstig geantedateerd (alsof je net klaar bent met luisteren). De \"aangepaste tijdstempel\" definieert de tijdstempel van de eerste track en voegt vanaf daar tijd toe aan de volgende tracks (d.w.z. je geeft de tijd op waarop je begon te luisteren naar dit album)",
2222
"albumArtist": "Album artiest",
2323
"history": "Geschiedenis",
2424
"yourProfile": "Je profiel",
2525
"yourHistory": "Je geschiedenis",
26-
"scrobbleManually": "Handmatig krabbelen",
26+
"scrobbleManually": "Handmatig scrobbelen",
2727
"scrobbleFromOtherUser": "Scrobble van andere gebruiker",
2828
"otherUser": "Gebruiker",
2929
"or": "of",
3030
"refresh": "Opnieuw laden",
3131
"findFriendCopy": "Voer een last.fm-gebruikersnaam in om hun laatste nummers te zien",
3232
"visitProfile": "Bekijk profiel",
33-
"search": "Zoek op",
33+
"search": "Zoeken",
3434
"backToSearch": "Terug naar zoeken",
3535
"userNotFound": "Niet gevonden gebruiker",
3636
"username": "Gebruikersnaam",
@@ -51,7 +51,7 @@
5151
"songsWillAppearHere": "Na het scrobbelen zullen liedjes hier verschijnen.",
5252
"clearHistory": "Geschiedenis wissen",
5353
"scrobbleAgain": "Scrobble opnieuw",
54-
"copyToEditor": "Kopie naar redacteur",
54+
"copyToEditor": "Kopiëren naar de editor",
5555
"swapArtistTitle": "Artiest en liedje omdraaien",
5656
"viewProfile": "Mijn Last.fm-profiel bekijken",
5757
"lockArtist": "Artiest vastzetten",
@@ -62,7 +62,7 @@
6262
"footer": {
6363
"joinCommunity": "Kom gerust een kijkje nemen op <1>onze Discord</1>!",
6464
"supportThisProject": "<1>Steun dit project</1> alsjeblieft op Patreon :)",
65-
"specialThanks": "Speciale dank aan alle donors, vertalers, en <1>de bijdragers</1>"
65+
"specialThanks": "Speciale dank aan alle donateurs, vertalers, en <1>de bijdragers</1>"
6666
},
6767
"settings": "Instellingen",
6868
"cancel": "Annuleren",
@@ -105,17 +105,17 @@
105105
"use12HoursFormat": "Twaalfuurstijd gebruiken (AM/PM)",
106106
"splitPastedText": "Geplakte tekst opsplitsen in velden artiest/titel",
107107
"welcomeToTheScrobbler": "Welkom bij de <1>Open Scrobbler</1>!",
108-
"purpose": "Deze tool laat je liedjes en albums scrobbelen die je hoorde op de radio, op vinyl, of ergens anders waar je manueel moet scrobbelen.",
109-
"authNeeded": "Geef de applicatie toegang tot je Last.fm om te beginnen!",
108+
"purpose": "Deze tool laat je liedjes en albums scrobbelen die je hoorde op de radio, op vinyl, of ergens anders waar je handmatig voor moet scrobbelen.",
109+
"authNeeded": "Geef de applicatie toegang tot je Last.fm-profiel om te beginnen!",
110110
"logInWithLastFm": "Log in met Last.fm",
111111
"logInIsSafe": "Dit wordt veilig gedaan via Last.fm",
112112
"about": {
113113
"title": "Wat is dit?",
114-
"description": "Een open source scrobbeler voor het internet, die je manueel liedjes laat invoeren om ze aan je Last.fm-profiel toe te voegen."
114+
"description": "Een open source scrobbeler voor het internet, die je handmatig liedjes laat invoeren om ze aan je Last.fm-profiel toe te voegen."
115115
},
116116
"support": {
117117
"title": "Steun dit project",
118-
"copy": "Het zou fijn zijn mocht je overwegen om dit project te steunen op Patreon! Zo help je deze site om online te blijven en steun je de ontwikkeling ervan :)",
118+
"copy": "Overweeg alsjeblieft om dit project te steunen op Patreon! Zo help je deze site om online te blijven en steun je de ontwikkeling ervan :)",
119119
"CTA": "Word een patron",
120120
"connectAccount": "Connect account",
121121
"thanksForSupporting": "Thanks for supporting this project!"
@@ -161,6 +161,10 @@
161161
"applications": "Toepassingen",
162162
"connect": "Maak verbinding met",
163163
"general": "Algemeen",
164-
"learnMore": "Learn more",
165-
"connected": "Connected"
164+
"learnMore": "Meer informatie",
165+
"connected": "Verbonden",
166+
"filter": "Filteren",
167+
"autoFillAlbum": "Automatisch aanvullen met Last.fm",
168+
"autoFillAlbumInvalidForm": "Vul een artiest en nummer in om automatisch aan te vullen",
169+
"setlist": "Setlist"
166170
}

public/locales/pl.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "Twoja historia",
2626
"scrobbleManually": "Scrobbluj manualnie",
2727
"scrobbleFromOtherUser": "Scrobbluj od innego użytkownika",
28+
"scrobbleFromSetlist": "Scrobbluj od setlist.fm",
2829
"otherUser": "Użytkownik",
2930
"or": "lub",
3031
"refresh": "Odśwież",

public/locales/pt-br.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,6 @@
162162
"connect": "Conectar",
163163
"general": "Geral",
164164
"learnMore": "Saiba mais",
165-
"connected": "Conectado"
165+
"connected": "Conectado",
166+
"filter": "Filtrar"
166167
}

public/locales/pt.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "Teu histórico",
2626
"scrobbleManually": "Scrobblar manualmente",
2727
"scrobbleFromOtherUser": "Scrobblar de outro utilizador",
28+
"scrobbleFromSetlist": "Scrobblar de setlist.fm",
2829
"otherUser": "Utilizador",
2930
"or": "ou",
3031
"refresh": "Atualizar",
@@ -89,7 +90,7 @@
8990
}
9091
},
9192
"updates": {
92-
"newVersionAvailable": "Há uma nova versão disponível! Por favor <1>recarregua a página</1>"
93+
"newVersionAvailable": "Há uma nova versão disponível! Por favor <1>recarrega a página</1>"
9394
},
9495
"errors": {
9596
"lastfmRejected": "Last.fm rejeitou este scrobble",
@@ -162,5 +163,6 @@
162163
"connect": "Conectar",
163164
"general": "Geral",
164165
"learnMore": "Saiba mais",
165-
"connected": "Conectado"
166+
"connected": "Conectado",
167+
"filter": "Filtrar"
166168
}

public/locales/ru.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "Твоя история",
2626
"scrobbleManually": "Скробблинг вручную",
2727
"scrobbleFromOtherUser": "Скробблить скробблы пользователя",
28+
"scrobbleFromSetlist": "Скробблить из setlist.fm",
2829
"otherUser": "Пользователь",
2930
"or": "или",
3031
"refresh": "Обновить",

public/locales/sr.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "Vaša istorija",
2626
"scrobbleManually": "Skrobluj ručno",
2727
"scrobbleFromOtherUser": "Skrobluj od drugog korisnika",
28+
"scrobbleFromSetlist": "Skrobluj sa setlist.fm",
2829
"otherUser": "Korisnik",
2930
"or": "ili",
3031
"refresh": "Osveži",

public/locales/tr.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "Geçmişin",
2626
"scrobbleManually": "Manuel skroplama yap",
2727
"scrobbleFromOtherUser": "Başka bir kullanıcıdan skroplama yap",
28+
"scrobbleFromSetlist": "setlist.fm skroplama",
2829
"otherUser": "Kullanıcı",
2930
"or": "veya",
3031
"refresh": "Yenile",

public/locales/uk.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"yourHistory": "Ваша історія",
2626
"scrobbleManually": "Скробблити вручну",
2727
"scrobbleFromOtherUser": "Скробблити за іншим користувачем",
28+
"scrobbleFromSetlist": "Скробблити з setlist.fm",
2829
"otherUser": "Користувач",
2930
"or": "чи",
3031
"refresh": "Оновити",

0 commit comments

Comments
 (0)