Skip to content

Commit

Permalink
Spotify fixes (MiczFlor#2315)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
AlvinSchiller authored Apr 14, 2024
1 parent 28b835d commit d76a7ef
Show file tree
Hide file tree
Showing 22 changed files with 139 additions and 308 deletions.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@

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.

## Important Notice regarding Spotify Integration

**Spotify has [disabled access to libspotify on May 16, 2022](https://developer.spotify.com/community/news/2022/04/12/libspotify-sunset/).**

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)

We are working to provide an integrated solution.
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).
For Version 3 [#2164](https://github.com/MiczFlor/RPi-Jukebox-RFID/pull/2164) is laying the groundwork. Help is greatly appreciated.

## The new Phoniebox Calendar is here

Another bunch of wonderful designs!
Expand Down
2 changes: 1 addition & 1 deletion components/bluetooth-sink-switch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ If no bluetooth device is connected, the output defaults back to speakers. After

### Limitations

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.
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.

## Installation

Expand Down
45 changes: 23 additions & 22 deletions htdocs/inc.processCheckCardEditRegister.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,27 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
$messageSuccess = "";

if($post['delete'] == "delete") {
$messageAction .= "<p>The card with the ID '".$post['cardID']." has been deleted.
If you made a mistake, this is your chance to press 'Submit' to restore the card settings.
$messageAction .= "<p>The card with the ID '".$post['cardID']." has been deleted.
If you made a mistake, this is your chance to press 'Submit' to restore the card settings.
Else: Go <a href='index.php' class='mainMenu'><i class='mdi mdi-home'></i> Home</a>.</p>";
// remove $fileshortcuts to cardID file in shortcuts
$exec = "rm ".$fileshortcuts;
if($debug == "true") {
print "<pre>deleting shortcut:\n";
print $exec;
print "</pre>";
}
}
exec($exec);
} elseif($post['submit'] == "submit") {
/*
* error check
*/

// posted too little?
if(
(!isset($post['streamURL']) || !isset($post['streamType']))
&& !isset($post['audiofolder'])
&& !isset($post['YTstreamURL'])
(!isset($post['streamURL']) || !isset($post['streamType']))
&& !isset($post['audiofolder'])
&& !isset($post['YTstreamURL'])
&& !isset($post['TriggerCommand'])
) {
$messageError .= $lang['cardRegisterErrorStreamOrAudio']." (error 002)";
Expand Down Expand Up @@ -161,9 +161,9 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
}

// streamFolderName not given
if(
(isset($post['streamURL']) || isset($post['YTstreamURL']))
&& !isset($post['audiofolder'])
if(
(isset($post['streamURL']) || isset($post['YTstreamURL']))
&& !isset($post['audiofolder'])
&& !isset($post['audiofolderNew'])
) {
$messageError .= $lang['cardRegisterErrorSuggestFolder']." (error 006)";
Expand All @@ -172,7 +172,7 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
}

//wrong spotify url, convert to mopidy format
if((isset($post['streamURL']) && $post['streamType'] == "spotify") && (strpos($post['streamURL'], "https://open.spotify.com/") !== false)){
if((isset($post['streamURL']) && $post['streamType'] == "spotify") && (strpos($post['streamURL'], "https://open.spotify.com/") !== false)){
$patterns = array();
$patterns[0] = '/https\:\/\/open.spotify.com/';
$patterns[1] = '/\/(playlist|album|track|artist)\//';
Expand Down Expand Up @@ -200,15 +200,15 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
* Stream URL to be created
*/
// 20200512 included code from removed the old include('inc.processAddNewStream.php');

// create new folder
$streamfolder = $Audio_Folders_Path."/".$post['audiofolderNew']."/";
$exec = "mkdir -p '".$streamfolder."'";
exec($exec);
// New folder is created so we link a RFID to it. Write $post['audiofolderNew'] to cardID file in shortcuts
$exec = "rm ".$fileshortcuts."; echo '".$post['audiofolderNew']."' > ".$fileshortcuts."; chmod 777 ".$fileshortcuts;
exec($exec);

// figure out $streamfile depending on $post['streamType']
switch($post['streamType']) {
case "spotify":
Expand All @@ -223,7 +223,7 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
default:
$streamfile = "url.txt";
}

// write $post['streamURL'] to $streamfile and make accessible to anyone
$exec = "echo '".$post['streamURL']."' > '".$streamfolder."/".$streamfile."'; sudo chmod -R 777 '".$streamfolder."'";
exec($exec);
Expand All @@ -235,15 +235,15 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
* RFID triggers system commands
*/
// 20200512 included code from removed the old include('inc.processAddTriggerCommand.php');

// Replace the potential existing RFID value with the posted one
//print $post['cardID']."->".$post['TriggerCommand'];
$fillRfidArrAvailWithUsed[$post['TriggerCommand']] = $post['cardID'];

/******************************************
* Create new conf file based on posted values
*/

// copy sample file to conf file
exec("cp ../settings/rfid_trigger_play.conf.sample ../settings/rfid_trigger_play.conf; chmod 777 ../settings/rfid_trigger_play.conf");
// replace posted values in new conf file
Expand All @@ -255,13 +255,13 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
}
// success message
$messageSuccess = $lang['cardRegisterTriggerSuccess']." ".$post['TriggerCommand'];
}
}
elseif(isset($post['YTstreamURL'])) {
/*******************************************************
* YouTube Download
*/
// 20200512 included code from removed the old include('inc.processAddYT.php');

if(isset($post['audiofolderNew'])) {
// create new folder
$exec = "mkdir --parents '".$Audio_Folders_Path."/".$post['audiofolderNew']."'; chmod 777 '".$Audio_Folders_Path."/".$post['audiofolderNew']."'";
Expand All @@ -278,11 +278,12 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) {
// link to existing audiofolder
$foldername = $Audio_Folders_Path."/".$post['audiofolder'];
}
$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 &";
exec($exec);
$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."/*;";
# Run command in background!
exec("{ ".$exec." } > /dev/null &");
// success message
$messageSuccess = $lang['cardRegisterDownloadingYT'];
}
}
elseif(isset($post['audiofolder']) && trim($post['audiofolder']) != "false") {
/*******************************************************
* connect card with existing audio folder
Expand Down
2 changes: 1 addition & 1 deletion htdocs/lang/lang-de-DE.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
$lang['cardRegisterErrorConvertSpotifyURL'] = "Falsche Spotify URL, konvertiert in korrektes Format";
$lang['cardRegisterStream2Card'] = "Stream ist mit der Karten-ID verknüpft.";
$lang['cardRegisterFolder2Card'] = "Audio-Ordner ist nun mit der Karten-ID verknüpft.";
$lang['cardRegisterDownloadingYT'] = "<p>YouTube Audio wird heruntergeladen. Dies kann einige Minuten dauern. Du kannst die Logdatei \"youtube-dl.log\" im Ordner \"shared\" ansehen.</p>";
$lang['cardRegisterDownloadingYT'] = "<p>YouTube Audio wird heruntergeladen. Dies kann einige Minuten dauern. Du kannst die Logdatei \"youtube-download.log\" im Ordner \"shared\" ansehen.</p>";
$lang['cardRegisterSwipeUpdates'] = "Dies wird automatisch aktualisiert, wenn du eine RFID-Karte ausliest.";
$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>";
$lang['cardRegisterTriggerSuccess'] = "Die Karte ist jetzt verknüpft um die Funktion auszuführen:";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/lang/lang-en-UK.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
$lang['cardRegisterErrorConvertSpotifyURL'] = "Wrong spotify url, converted to the correct format";
$lang['cardRegisterStream2Card'] = "Stream is linked to Card ID.";
$lang['cardRegisterFolder2Card'] = "Audio folder is now linked to Card.";
$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>";
$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>";
$lang['cardRegisterSwipeUpdates'] = "This will automatically update as you swipe a RFID card.";
$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>";
$lang['cardRegisterTriggerSuccess'] = "The card is now linked to trigger the command:";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/lang/lang-fr-FR.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
$lang['cardRegisterErrorConvertSpotifyURL'] = "URL Spotify incorrecte, elle a été convertie au bon format";
$lang['cardRegisterStream2Card'] = "Le stream est lié à la carte.";
$lang['cardRegisterFolder2Card'] = "Le dossier audio est désormais lié à une carte.";
$lang['cardRegisterDownloadingYT'] = "<p>Piste YouTube en cours de téléchargement. Cela peut prendre plusieurs minutes. Log dans le fichier \"youtube-dl.log\".</p>";
$lang['cardRegisterDownloadingYT'] = "<p>Piste YouTube en cours de téléchargement. Cela peut prendre plusieurs minutes. Log dans le fichier \"youtube-download.log\".</p>";
$lang['cardRegisterSwipeUpdates'] = "Mise à jour automatique lors du passage d'une carte.";
$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>";
$lang['cardRegisterTriggerSuccess'] = "La carte est désormais lié à une commande :";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/lang/lang-nl-NL.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
$lang['cardRegisterErrorConvertSpotifyURL'] = "Verkeerde spotify url, geconverteerd naar het juiste formaat";
$lang['cardRegisterStream2Card'] = "Stream is gekoppeld aan kaart-ID.";
$lang['cardRegisterFolder2Card'] = "De audiomap is nu gekoppeld aan kaart-ID";
$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>";
$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>";
$lang['cardRegisterSwipeUpdates'] = "Dit wordt automatisch bijgewerkt terwijl je een RFID-kaart veegt.";
$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>";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[Unit]
Description=Automatically generates an wifi hotspot when a valid SSID is not in range
After=multi-user.target
Requires=network-online.target

[Service]
Type=simple
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Unit]
Description=Daemon for regular network connection if no hotspot is created
After=multi-user.target
After=network.target

[Service]
Type=simple
Expand Down
1 change: 0 additions & 1 deletion misc/sampleconfigs/autohotspot/dhcpcd/autohotspot.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[Unit]
Description=Automatically generates an wifi hotspot when a valid SSID is not in range
After=multi-user.target
Requires=network-online.target

[Service]
Type=simple
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy

[logging]
config_file = /etc/mopidy/logging.conf
debug_file = /var/log/mopidy/mopidy-debug.log

[local]
enabled = true
media_dir = %DIRaudioFolders%
Expand Down
159 changes: 0 additions & 159 deletions misc/sampleconfigs/mopidy.sample

This file was deleted.

Loading

0 comments on commit d76a7ef

Please sign in to comment.