From dda0e064ec578a9e5ee7ed1bb0c778ff221c8949 Mon Sep 17 00:00:00 2001 From: Vincent Date: Sun, 1 Mar 2020 13:28:21 +0100 Subject: [PATCH] . --- .idea/workspace.xml | 47 ++++++++++++++++++++------------------ config/music.php | 7 ++++-- scripts/lib/lib.php | 6 ++--- scripts/lib/scenes.php | 2 +- scripts/lib/squeezebox.php | 22 ++++++++++-------- scripts/squeeze.php | 4 ++++ 6 files changed, 51 insertions(+), 37 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 6912b86..519cd5e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,10 +3,11 @@ - + - + + @@ -1209,17 +1212,17 @@ - + - - - + + + - + @@ -1229,22 +1232,22 @@ - + - - + + - - + + - + diff --git a/config/music.php b/config/music.php index 512f04d..03c2dd5 100644 --- a/config/music.php +++ b/config/music.php @@ -41,14 +41,17 @@ function squeezeSubitems($s, $key, $label, &$shortcuts) continue; } else { $e = explode('.', $subitem['id']); - array_shift($e); + $base = array_shift($e); $id = $subitem['id']; $type = 'squeeze'; $commands = ['favorites playlist play item_id:' . $id, 'playlist repeat 2', 'playlist shuffle 1']; - if ($s['name'] == 'Ambiances') { + if ($s['name'] == 'Ambiances' || $base == 2) { $type .= '_ambiance'; array_unshift($commands, 'sync -'); } + if ($base == 1) { + $type .= '_spotify'; + } $a = array('type' => $type, 'commands' => $commands, 'label' => $subitem['name']); $allmusics[$subitem['name']] = $a; diff --git a/scripts/lib/lib.php b/scripts/lib/lib.php index a68538e..2575b07 100644 --- a/scripts/lib/lib.php +++ b/scripts/lib/lib.php @@ -221,11 +221,11 @@ function shortcut($s, $hash) } else if (isset($s['tab']) && $s['tab']) { $attrs['target'] = '_blank'; } - } else if ($s['type'] == 'squeeze') { - $attrs['href'] = 'scripts/squeeze.php?player=' . config('SQUEEZEBOX_PLAYER') . '&name=' . $s['label']; + } else if ($s['type'] == 'squeeze' || $s['type'] == 'squeeze_spotify') { + $attrs['href'] = 'scripts/squeeze.php?player=' . config('SQUEEZEBOX_PLAYER') . '&name=' . $s['label'] . '&type=' . $s['type']; $attrs['class'] = 'ajax music'; } else if ($s['type'] == 'squeeze_ambiance') { - $attrs['href'] = 'scripts/squeeze.php?player=' . config('SQUEEZEBOX_AMBIANCE_PLAYER') . '&name=' . $s['label']; + $attrs['href'] = 'scripts/squeeze.php?player=' . config('SQUEEZEBOX_AMBIANCE_PLAYER') . '&name=' . $s['label'] . '&type=' . $s['type']; $attrs['class'] = 'ajax'; $attrs['data-squeeze-volume'] = 60; $attrs['data-squeeze-player'] = config('SQUEEZEBOX_AMBIANCE_PLAYER'); diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index eb011a8..53305d7 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -713,7 +713,7 @@ function wcOn($vmc = true) } } -function planetarium($on) +function planetarium($on)0 { setState('planetarium', $on ? '1' : '0'); checkPlanetarium(false); diff --git a/scripts/lib/squeezebox.php b/scripts/lib/squeezebox.php index 4b1932e..28987b4 100644 --- a/scripts/lib/squeezebox.php +++ b/scripts/lib/squeezebox.php @@ -212,7 +212,7 @@ function getSqueezeFavorites($root = 0, $app = 'favorites', $level = 0) return $res; } -function checkSpottyLogin() +function checkSpottyLogin($force = false) { $spottybase = '/plugins/Spotty/settings/'; $hascredentials = httpRequest(SQUEEZEBOX_SERVER . $spottybase . 'basic.html?_dc=' . time(), 'get', [], null, 10, false); @@ -220,16 +220,20 @@ function checkSpottyLogin() $accounts = [ //SQUEEZEBOX_SPOTIFY_USERNAME => SQUEEZEBOX_SPOTIFY_PASSWORD, 'v12l' => 'Lr8ka&7cs@fc%lW7', - //'jrme75009' => 'tortuga5009', + 'jrme75009' => 'tortuga5009', ]; - $loggedIn = $hascredentials->getStatusCode() !== 302; - if ($loggedIn) { - $resp = $hascredentials->getBody(); - foreach ($accounts as $user => $password) { - if (!stristr($resp, $user)) { - $loggedIn = false; - break; + if ($force) { + $loggedIn = false; + } else { + $loggedIn = $hascredentials->getStatusCode() !== 302; + if ($loggedIn) { + $resp = $hascredentials->getBody(); + foreach ($accounts as $user => $password) { + if (!stristr($resp, $user)) { + $loggedIn = false; + break; + } } } } diff --git a/scripts/squeeze.php b/scripts/squeeze.php index 897941e..5629c10 100644 --- a/scripts/squeeze.php +++ b/scripts/squeeze.php @@ -22,6 +22,10 @@ if (!in_array('stop', $requests) || isset($_GET['name'])) { } } +if (isset($_GET['type']) && $_GET['type'] == 'squeeze_spotify') { + checkSpottyLogin(true); +} + if (isset($_GET['name'])) { echo $_GET['name']; squeezePlayByName($_GET['name'], $_GET['player']); -- 2.39.5