Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spotify url conversion (http to mopidy format) #1203

Merged
merged 2 commits into from
Jan 7, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions htdocs/inc.processCheckCardEditRegister.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
s-martin marked this conversation as resolved.
Show resolved Hide resolved


/*
* any errors?
*/
Expand Down