From 42c4a8c7fe1c4699acfb4135a1de83fdf53a7036 Mon Sep 17 00:00:00 2001 From: Schneelocke Date: Mon, 14 Dec 2020 23:17:21 +0100 Subject: [PATCH 1/2] Added spotify url conversion --- htdocs/inc.processCheckCardEditRegister.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/inc.processCheckCardEditRegister.php b/htdocs/inc.processCheckCardEditRegister.php index 7d96dcf53..5cd48eb2a 100755 --- a/htdocs/inc.processCheckCardEditRegister.php +++ b/htdocs/inc.processCheckCardEditRegister.php @@ -171,6 +171,21 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) { $post['audiofolderNew'] = $link = str_replace(array('http://','https://','/','=','-','.', 'www','?','&'), '', $post['streamURL']); } + //wrong spotify url, convert to mopidy format + if((isset($post['streamURL']) && $post['streamType'] == "spotify") && (strpos($post['streamURL'], "https://open.spotify.com/") !== false)){ + $messageError .= "Wrong spotify url, converted to the correct format"; + $patterns = array(); + $patterns[0] = '/https\:\/\/open.spotify.com/'; + $patterns[1] = '/\/(playlist|album|track|artist)\//'; + $patterns[2] = '/(\w+)\?(.*)/'; + $replacements = array(); + $replacements[0] = 'spotify:'; + $replacements[1] = '$1:'; + $replacements[2] = '$1'; + $post['streamURL'] = preg_replace($patterns, $replacements, $post['streamURL']); + } + + /* * any errors? */ From 22227e8ea11083ff8d16cd6c1e44980af385fa41 Mon Sep 17 00:00:00 2001 From: Schneelocke Date: Tue, 5 Jan 2021 22:03:02 +0100 Subject: [PATCH 2/2] Improved and translated error message --- htdocs/inc.processCheckCardEditRegister.php | 7 ++++--- htdocs/lang/lang-de-DE.php | 1 + htdocs/lang/lang-en-UK.php | 1 + htdocs/lang/lang-nl-NL.php | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/inc.processCheckCardEditRegister.php b/htdocs/inc.processCheckCardEditRegister.php index 5cd48eb2a..5ae713aee 100755 --- a/htdocs/inc.processCheckCardEditRegister.php +++ b/htdocs/inc.processCheckCardEditRegister.php @@ -172,8 +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)){ - $messageError .= "Wrong spotify url, converted to the correct format"; + 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)\//'; @@ -182,7 +181,9 @@ function fillRfidArrAvailWithUsed($rfidAvailArr, $rfidUsedArr=array()) { $replacements[0] = 'spotify:'; $replacements[1] = '$1:'; $replacements[2] = '$1'; - $post['streamURL'] = preg_replace($patterns, $replacements, $post['streamURL']); + $newSpotifyURL = preg_replace($patterns, $replacements, $post['streamURL']); + $messageError .= $lang['cardRegisterErrorConvertSpotifyURL']." (error 007)
".$post['streamURL']." ➔ ".$newSpotifyURL; + $post['streamURL'] = $newSpotifyURL; } diff --git a/htdocs/lang/lang-de-DE.php b/htdocs/lang/lang-de-DE.php index 386214cc4..f1992aa9f 100755 --- a/htdocs/lang/lang-de-DE.php +++ b/htdocs/lang/lang-de-DE.php @@ -124,6 +124,7 @@ $lang['cardRegisterErrorExistingAndNew'] = "

Das ist zu viel! Wähle entweder einen bestehenden Ordner aus oder erstelle einen neuen.

"; $lang['cardRegisterErrorExistingFolder'] = "

Ein Ordner mit dem gleichen Namen existiert bereits! Wähle einen anderen.

"; $lang['cardRegisterErrorSuggestFolder'] = "Ein Ordnername für den Stream muss erstellt werden. Unten im Formular steht ein Vorschlag."; +$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'] = "

YouTube Audio wird heruntergeladen. Dies kann einige Minuten dauern. Du kannst die Logdatei \"youtube-dl.log\" im Ordner \"shared\" ansehen.

"; diff --git a/htdocs/lang/lang-en-UK.php b/htdocs/lang/lang-en-UK.php index d0144c5e0..288aa4205 100755 --- a/htdocs/lang/lang-en-UK.php +++ b/htdocs/lang/lang-en-UK.php @@ -125,6 +125,7 @@ $lang['cardRegisterErrorExistingAndNew'] = "

This is too much! Either choose an existing folder or create a new one.

"; $lang['cardRegisterErrorExistingFolder'] = "

A folder named with the same name already exists! Chose a different one.

"; $lang['cardRegisterErrorSuggestFolder'] = "A folder name for the stream needs to be created. Below in the form I made a suggestion."; +$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'] = "

YouTube audio is downloading. This may take a couple of minutes. You may check the logfile \"youtube-dl.log\" in the shared folder.

"; diff --git a/htdocs/lang/lang-nl-NL.php b/htdocs/lang/lang-nl-NL.php index 6f27f51e3..1fb654509 100755 --- a/htdocs/lang/lang-nl-NL.php +++ b/htdocs/lang/lang-nl-NL.php @@ -109,6 +109,7 @@ $lang['cardRegisterErrorExistingAndNew'] = "

Dit is te veel! Kies een bestaande map of maak een nieuwe map aan.

"; $lang['cardRegisterErrorExistingFolder'] = "

Er bestaat al een map met dezelfde naam! Kies een andere.

"; $lang['cardRegisterErrorSuggestFolder'] = "Er moet een mapnaam voor de stream worden gemaakt. Hieronder in het formulier heb ik een suggestie gedaan."; +$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'] = "

YouTube-audio wordt gedownload. Dit kan een paar minuten duren. U kunt het logbestand 'youtube-dl.log' in de gedeelde map controleren.

";