/** * getSettings function. * * @access public * @param mixed $w * @return void */ function getSettings($w) { if (file_exists($w->data() . '/settings.db') && !file_exists($w->data() . '/settings.json')) { // migrate settings.db to settings.json // // Read settings from DB // $getSettings = 'select all_playlists,is_spotifious_active,is_alfred_playlist_active,radio_number_tracks,is_lyrics_active,max_results, alfred_playlist_uri,alfred_playlist_name,country_code,theme,last_check_update_time,oauth_client_id,oauth_client_secret,oauth_redirect_uri,oauth_access_token,oauth_expires,oauth_refresh_token,display_name,userid,echonest_api_key from settings'; $dbsettingsfile = $w->data() . '/settings.db'; try { $dbsettings = new PDO("sqlite:{$dbsettingsfile}", "", "", array(PDO::ATTR_PERSISTENT => true)); $dbsettings->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbsettings->query("PRAGMA synchronous = OFF"); $dbsettings->query("PRAGMA journal_mode = OFF"); $dbsettings->query("PRAGMA temp_store = MEMORY"); $dbsettings->query("PRAGMA count_changes = OFF"); $dbsettings->query("PRAGMA PAGE_SIZE = 4096"); $dbsettings->query("PRAGMA default_cache_size=700000"); $dbsettings->query("PRAGMA cache_size=700000"); $dbsettings->query("PRAGMA compile_options"); $stmt = $dbsettings->prepare($getSettings); $settings = $stmt->execute(); $setting = $stmt->fetch(); $migrated = array('all_playlists' => $setting[0], 'is_alfred_playlist_active' => $setting[2], 'radio_number_tracks' => $setting[3], 'now_playing_notifications' => 1, 'max_results' => $setting[5], 'alfred_playlist_uri' => $setting[6], 'alfred_playlist_name' => $setting[7], 'country_code' => $setting[8], 'last_check_update_time' => $setting[10], 'oauth_client_id' => $setting[11], 'oauth_client_secret' => $setting[12], 'oauth_redirect_uri' => 'http://localhost:15298/callback.php', 'oauth_access_token' => $setting[14], 'oauth_expires' => $setting[15], 'oauth_refresh_token' => $setting[16], 'display_name' => $setting[17], 'userid' => $setting[18], 'echonest_api_key' => '5EG94BIZEGFEY9AL9', 'is_public_playlists' => 0); $ret = $w->write($migrated, 'settings.json'); } catch (PDOException $e) { logMsg("Error(getSettings): (exception " . print_r($e) . ")"); } deleteTheFile($w->data() . '/settings.db'); } $settings = $w->read('settings.json'); if ($settings == false) { $default = array('all_playlists' => 1, 'is_alfred_playlist_active' => 1, 'radio_number_tracks' => 30, 'now_playing_notifications' => 1, 'max_results' => 50, 'alfred_playlist_uri' => '', 'alfred_playlist_name' => '', 'country_code' => '', 'last_check_update_time' => 0, 'oauth_client_id' => '', 'oauth_client_secret' => '', 'oauth_redirect_uri' => 'http://localhost:15298/callback.php', 'oauth_access_token' => '', 'oauth_expires' => 0, 'oauth_refresh_token' => '', 'display_name' => '', 'userid' => '', 'echonest_api_key' => '5EG94BIZEGFEY9AL9', 'is_public_playlists' => 0, 'quick_mode' => 0); $ret = $w->write($default, 'settings.json'); displayNotificationWithArtwork("Settings have been set to default", './images/info.png', 'Settings reset'); $settings = $w->read('settings.json'); } // add quick_mode if needed if (!isset($settings->quick_mode)) { updateSetting($w, 'quick_mode', 0); $settings = $w->read('settings.json'); } return $settings; }
} } if ($use_mopidy) { playUriWithMopidy($w, $album_uri); } else { exec("osascript -e 'tell application \"Spotify\" to play track \"{$album_uri}\"'"); } displayNotificationWithArtwork('🔈 Album ' . $album_name . ' by ' . $theartistname, getTrackOrAlbumArtwork($w, $album_uri, true), 'Play Random Album'); if ($userid != 'vdesabou') { stathat_ez_count('AlfredSpotifyMiniPlayer', 'play', 1); } addAlbumToPlayQueue($w, $album_uri, $album_name); return; } else { if ($other_action == "reset_settings") { deleteTheFile($w->data() . '/settings.json'); return; } else { if ($other_action == "biography") { displayCurrentArtistBiography($w); if ($userid != 'vdesabou') { stathat_ez_count('AlfredSpotifyMiniPlayer', 'display biography', 1); } return; } else { if ($other_action == "go_back") { $history = $w->read('history.json'); if ($history == false) { displayNotificationWithArtwork("No history yet", './images/warning.png', 'Error!'); } $query = array_pop($history);