Skip to content

Commit d76a7ef

Browse files
Spotify fixes (MiczFlor#2315)
* feat: update spotify packages * fix: removed unnecessary mopidy user conf * fix: dont start services right away (wait for reboot) * fix: replace yotube-dl with yt-dlp. Run command in background * chore: update formatting and typo * fix: scan for mopidy on startup * fix: failure in check_chmod_chown should also fail overall tests * fix: change sudoers to seperate files * fix: python path for mopidy sudoers file * test: add special characters for spotify password * fix: handle special charactes in spotify password correctly * fix: add handling for dollar char * fix: removed unnecessary options * fix: download plugin for correct architecture * fix: also escape spotify client id and secret * fix: change targets for autohotspot services * fix: removed "spotify not working" note * fix: update Mopidy-Spotify to 5.0.0a2
1 parent 28b835d commit d76a7ef

22 files changed

+139
-308
lines changed

README.md

-10
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@
1515

1616
Phoniebox is a contactless jukebox for the Raspberry Pi, playing audio files, playlists, podcasts, web streams and spotify triggered by RFID cards. All plug and play via USB, no soldering iron needed. It also features GPIO buttons control support.
1717

18-
## Important Notice regarding Spotify Integration
19-
20-
**Spotify has [disabled access to libspotify on May 16, 2022](https://developer.spotify.com/community/news/2022/04/12/libspotify-sunset/).**
21-
22-
This means **Spotify in Phoniebox doesn't work at the moment**. For further information see [Spotify FAQ](https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/Spotify-FAQ)
23-
24-
We are working to provide an integrated solution.
25-
For Version 2 there is a possible fix to reactivate spotify with a manual installation described [here](https://github.com/MiczFlor/RPi-Jukebox-RFID/issues/1815#issuecomment-1666535983).
26-
For Version 3 [#2164](https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2164) is laying the groundwork. Help is greatly appreciated.
27-
2818
## The new Phoniebox Calendar is here
2919

3020
Another bunch of wonderful designs!

components/bluetooth-sink-switch/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If no bluetooth device is connected, the output defaults back to speakers. After
1616

1717
### Limitations
1818

19-
This feature only works for the *Classic* Edition. Why? It relies on the mpd multiple output channels feature to switch between outputs. This is no available in mopidy, which is used in the Spotify Edition.
19+
This feature only works for the *Classic* Edition. Why? It relies on the mpd multiple output channels feature to switch between outputs. This is not available in mopidy, which is used in the Spotify Edition.
2020

2121
## Installation
2222

htdocs/inc.processCheckCardEditRegister.php

+23-22
Original file line numberDiff line numberDiff line change
@@ -109,27 +109,27 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
109109
$messageSuccess = "";
110110

111111
if($post['delete'] == "delete") {
112-
$messageAction .= "<p>The card with the ID '".$post['cardID']." has been deleted.
113-
If you made a mistake, this is your chance to press 'Submit' to restore the card settings.
112+
$messageAction .= "<p>The card with the ID '".$post['cardID']." has been deleted.
113+
If you made a mistake, this is your chance to press 'Submit' to restore the card settings.
114114
Else: Go <a href='index.php' class='mainMenu'><i class='mdi mdi-home'></i> Home</a>.</p>";
115115
// remove $fileshortcuts to cardID file in shortcuts
116116
$exec = "rm ".$fileshortcuts;
117117
if($debug == "true") {
118118
print "<pre>deleting shortcut:\n";
119119
print $exec;
120120
print "</pre>";
121-
}
121+
}
122122
exec($exec);
123123
} elseif($post['submit'] == "submit") {
124124
/*
125125
* error check
126126
*/
127-
127+
128128
// posted too little?
129129
if(
130-
(!isset($post['streamURL']) || !isset($post['streamType']))
131-
&& !isset($post['audiofolder'])
132-
&& !isset($post['YTstreamURL'])
130+
(!isset($post['streamURL']) || !isset($post['streamType']))
131+
&& !isset($post['audiofolder'])
132+
&& !isset($post['YTstreamURL'])
133133
&& !isset($post['TriggerCommand'])
134134
) {
135135
$messageError .= $lang['cardRegisterErrorStreamOrAudio']." (error 002)";
@@ -161,9 +161,9 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
161161
}
162162

163163
// streamFolderName not given
164-
if(
165-
(isset($post['streamURL']) || isset($post['YTstreamURL']))
166-
&& !isset($post['audiofolder'])
164+
if(
165+
(isset($post['streamURL']) || isset($post['YTstreamURL']))
166+
&& !isset($post['audiofolder'])
167167
&& !isset($post['audiofolderNew'])
168168
) {
169169
$messageError .= $lang['cardRegisterErrorSuggestFolder']." (error 006)";
@@ -172,7 +172,7 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
172172
}
173173

174174
//wrong spotify url, convert to mopidy format
175-
if((isset($post['streamURL']) && $post['streamType'] == "spotify") && (strpos($post['streamURL'], "https://open.spotify.com/") !== false)){
175+
if((isset($post['streamURL']) && $post['streamType'] == "spotify") && (strpos($post['streamURL'], "https://open.spotify.com/") !== false)){
176176
$patterns = array();
177177
$patterns[0] = '/https\:\/\/open.spotify.com/';
178178
$patterns[1] = '/\/(playlist|album|track|artist)\//';
@@ -200,15 +200,15 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
200200
* Stream URL to be created
201201
*/
202202
// 20200512 included code from removed the old include('inc.processAddNewStream.php');
203-
203+
204204
// create new folder
205205
$streamfolder = $Audio_Folders_Path."/".$post['audiofolderNew']."/";
206206
$exec = "mkdir -p '".$streamfolder."'";
207207
exec($exec);
208208
// New folder is created so we link a RFID to it. Write $post['audiofolderNew'] to cardID file in shortcuts
209209
$exec = "rm ".$fileshortcuts."; echo '".$post['audiofolderNew']."' > ".$fileshortcuts."; chmod 777 ".$fileshortcuts;
210210
exec($exec);
211-
211+
212212
// figure out $streamfile depending on $post['streamType']
213213
switch($post['streamType']) {
214214
case "spotify":
@@ -223,7 +223,7 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
223223
default:
224224
$streamfile = "url.txt";
225225
}
226-
226+
227227
// write $post['streamURL'] to $streamfile and make accessible to anyone
228228
$exec = "echo '".$post['streamURL']."' > '".$streamfolder."/".$streamfile."'; sudo chmod -R 777 '".$streamfolder."'";
229229
exec($exec);
@@ -235,15 +235,15 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
235235
* RFID triggers system commands
236236
*/
237237
// 20200512 included code from removed the old include('inc.processAddTriggerCommand.php');
238-
238+
239239
// Replace the potential existing RFID value with the posted one
240240
//print $post['cardID']."->".$post['TriggerCommand'];
241241
$fillRfidArrAvailWithUsed[$post['TriggerCommand']] = $post['cardID'];
242-
242+
243243
/******************************************
244244
* Create new conf file based on posted values
245245
*/
246-
246+
247247
// copy sample file to conf file
248248
exec("cp ../settings/rfid_trigger_play.conf.sample ../settings/rfid_trigger_play.conf; chmod 777 ../settings/rfid_trigger_play.conf");
249249
// replace posted values in new conf file
@@ -255,13 +255,13 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
255255
}
256256
// success message
257257
$messageSuccess = $lang['cardRegisterTriggerSuccess']." ".$post['TriggerCommand'];
258-
}
258+
}
259259
elseif(isset($post['YTstreamURL'])) {
260260
/*******************************************************
261261
* YouTube Download
262262
*/
263263
// 20200512 included code from removed the old include('inc.processAddYT.php');
264-
264+
265265
if(isset($post['audiofolderNew'])) {
266266
// create new folder
267267
$exec = "mkdir --parents '".$Audio_Folders_Path."/".$post['audiofolderNew']."'; chmod 777 '".$Audio_Folders_Path."/".$post['audiofolderNew']."'";
@@ -278,11 +278,12 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
278278
// link to existing audiofolder
279279
$foldername = $Audio_Folders_Path."/".$post['audiofolder'];
280280
}
281-
$exec = "cd '".$foldername."'; youtube-dl -f bestaudio --extract-audio --audio-format mp3 ".$post['YTstreamURL']." > ".$conf['shared_abs']."/youtube-dl.log; chmod 777 ".$foldername."/* 2>&1 &";
282-
exec($exec);
281+
$exec = "cd '".$foldername."'; yt-dlp --compat-options youtube-dl -f bestaudio --extract-audio --audio-format mp3 '".$post['YTstreamURL']."' >> ".$conf['shared_abs']."/youtube-download.log 2>&1; chmod 777 ".$foldername."/*;";
282+
# Run command in background!
283+
exec("{ ".$exec." } > /dev/null &");
283284
// success message
284285
$messageSuccess = $lang['cardRegisterDownloadingYT'];
285-
}
286+
}
286287
elseif(isset($post['audiofolder']) && trim($post['audiofolder']) != "false") {
287288
/*******************************************************
288289
* connect card with existing audio folder

htdocs/lang/lang-de-DE.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
$lang['cardRegisterErrorConvertSpotifyURL'] = "Falsche Spotify URL, konvertiert in korrektes Format";
130130
$lang['cardRegisterStream2Card'] = "Stream ist mit der Karten-ID verknüpft.";
131131
$lang['cardRegisterFolder2Card'] = "Audio-Ordner ist nun mit der Karten-ID verknüpft.";
132-
$lang['cardRegisterDownloadingYT'] = "<p>YouTube Audio wird heruntergeladen. Dies kann einige Minuten dauern. Du kannst die Logdatei \"youtube-dl.log\" im Ordner \"shared\" ansehen.</p>";
132+
$lang['cardRegisterDownloadingYT'] = "<p>YouTube Audio wird heruntergeladen. Dies kann einige Minuten dauern. Du kannst die Logdatei \"youtube-download.log\" im Ordner \"shared\" ansehen.</p>";
133133
$lang['cardRegisterSwipeUpdates'] = "Dies wird automatisch aktualisiert, wenn du eine RFID-Karte ausliest.";
134134
$lang['cardRegisterManualLinks'] = "<p>Du kannst Karten auch manuell mit Ordnern verbinden. Das Handbuch erklärt, wie man sich <a href='https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/MANUAL#connect' target='-blank'>mit der Phoniebox verbindet</a> und <a href='https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/MANUAL#registering-cards-manually-through-samba-without-the-web-app' target='_blank'>Karten registriert</a>.</p>";
135135
$lang['cardRegisterTriggerSuccess'] = "Die Karte ist jetzt verknüpft um die Funktion auszuführen:";

htdocs/lang/lang-en-UK.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
$lang['cardRegisterErrorConvertSpotifyURL'] = "Wrong spotify url, converted to the correct format";
131131
$lang['cardRegisterStream2Card'] = "Stream is linked to Card ID.";
132132
$lang['cardRegisterFolder2Card'] = "Audio folder is now linked to Card.";
133-
$lang['cardRegisterDownloadingYT'] = "<p>YouTube audio is downloading. This may take a couple of minutes. You may check the logfile \"youtube-dl.log\" in the shared folder.</p>";
133+
$lang['cardRegisterDownloadingYT'] = "<p>YouTube audio is downloading. This may take a couple of minutes. You may check the logfile \"youtube-download.log\" in the shared folder.</p>";
134134
$lang['cardRegisterSwipeUpdates'] = "This will automatically update as you swipe a RFID card.";
135135
$lang['cardRegisterManualLinks'] = "<p>You can also connect cards to folders manually. The manual explains how to <a href='https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/MANUAL#connect' target='–blank'>connect to the phoniebox</a> and <a href='https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/MANUAL#registering-cards-manually-through-samba-without-the-web-app' target='_blank'>register cards</a>.</p>";
136136
$lang['cardRegisterTriggerSuccess'] = "The card is now linked to trigger the command:";

htdocs/lang/lang-fr-FR.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
$lang['cardRegisterErrorConvertSpotifyURL'] = "URL Spotify incorrecte, elle a été convertie au bon format";
131131
$lang['cardRegisterStream2Card'] = "Le stream est lié à la carte.";
132132
$lang['cardRegisterFolder2Card'] = "Le dossier audio est désormais lié à une carte.";
133-
$lang['cardRegisterDownloadingYT'] = "<p>Piste YouTube en cours de téléchargement. Cela peut prendre plusieurs minutes. Log dans le fichier \"youtube-dl.log\".</p>";
133+
$lang['cardRegisterDownloadingYT'] = "<p>Piste YouTube en cours de téléchargement. Cela peut prendre plusieurs minutes. Log dans le fichier \"youtube-download.log\".</p>";
134134
$lang['cardRegisterSwipeUpdates'] = "Mise à jour automatique lors du passage d'une carte.";
135135
$lang['cardRegisterManualLinks'] = "<p>Vous pouvez lier manuellement une carte à un dossier. Explication dans la documentation <a href='https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/MANUAL#connect' target='–blank'>connection à phoniebox</a> et <a href='https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/MANUAL#registering-cards-manually-through-samba-without-the-web-app' target='_blank'>enregistrer une carte</a>.</p>";
136136
$lang['cardRegisterTriggerSuccess'] = "La carte est désormais lié à une commande :";

htdocs/lang/lang-nl-NL.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
$lang['cardRegisterErrorConvertSpotifyURL'] = "Verkeerde spotify url, geconverteerd naar het juiste formaat";
114114
$lang['cardRegisterStream2Card'] = "Stream is gekoppeld aan kaart-ID.";
115115
$lang['cardRegisterFolder2Card'] = "De audiomap is nu gekoppeld aan kaart-ID";
116-
$lang['cardRegisterDownloadingYT'] = "<p>YouTube-audio wordt gedownload. Dit kan een paar minuten duren. U kunt het logbestand 'youtube-dl.log' in de gedeelde map controleren.</p>";
116+
$lang['cardRegisterDownloadingYT'] = "<p>YouTube-audio wordt gedownload. Dit kan een paar minuten duren. U kunt het logbestand 'youtube-download.log' in de gedeelde map controleren.</p>";
117117
$lang['cardRegisterSwipeUpdates'] = "Dit wordt automatisch bijgewerkt terwijl je een RFID-kaart veegt.";
118118
$lang['cardRegisterManualLinks'] = "<p>U kunt kaarten ook handmatig met mappen verbinden. In de handleiding wordt uitgelegd hoe u <a href='https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/MANUAL#connect' target='–blank'>verbinding maakt met de phoniebox</a> en <a href='https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/MANUAL#registering-cards-manually-through-samba-without-the-web-app' target='_blank'>kaarten registreert</a>.</p>";
119119

misc/sampleconfigs/autohotspot/NetworkManager/autohotspot.service

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[Unit]
22
Description=Automatically generates an wifi hotspot when a valid SSID is not in range
33
After=multi-user.target
4-
Requires=network-online.target
54

65
[Service]
76
Type=simple

misc/sampleconfigs/autohotspot/dhcpcd/autohotspot-daemon.service

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[Unit]
22
Description=Daemon for regular network connection if no hotspot is created
3-
After=multi-user.target
3+
After=network.target
44

55
[Service]
66
Type=simple

misc/sampleconfigs/autohotspot/dhcpcd/autohotspot.service

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[Unit]
22
Description=Automatically generates an wifi hotspot when a valid SSID is not in range
33
After=multi-user.target
4-
Requires=network-online.target
54

65
[Service]
76
Type=simple

misc/sampleconfigs/mopidy-etc.sample misc/sampleconfigs/mopidy.conf.sample

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
[core]
2-
cache_dir = /var/cache/mopidy
3-
config_dir = /etc/mopidy
4-
data_dir = /var/lib/mopidy
5-
6-
[logging]
7-
config_file = /etc/mopidy/logging.conf
8-
debug_file = /var/log/mopidy/mopidy-debug.log
9-
101
[local]
112
enabled = true
123
media_dir = %DIRaudioFolders%

misc/sampleconfigs/mopidy.sample

-159
This file was deleted.

0 commit comments

Comments
 (0)