/** * secondDelimiterAlfredPlaylist function. * * @access public * @param mixed $w * @param mixed $query * @param mixed $settings * @param mixed $db * @param mixed $update_in_progress * @return void */ function secondDelimiterAlfredPlaylist($w, $query, $settings, $db, $update_in_progress) { $words = explode('▹', $query); $kind = $words[0]; $all_playlists = $settings->all_playlists; $is_alfred_playlist_active = $settings->is_alfred_playlist_active; $radio_number_tracks = $settings->radio_number_tracks; $now_playing_notifications = $settings->now_playing_notifications; $max_results = $settings->max_results; $alfred_playlist_uri = $settings->alfred_playlist_uri; $alfred_playlist_name = $settings->alfred_playlist_name; $country_code = $settings->country_code; $last_check_update_time = $settings->last_check_update_time; $oauth_client_id = $settings->oauth_client_id; $oauth_client_secret = $settings->oauth_client_secret; $oauth_redirect_uri = $settings->oauth_redirect_uri; $oauth_access_token = $settings->oauth_access_token; $oauth_expires = $settings->oauth_expires; $oauth_refresh_token = $settings->oauth_refresh_token; $display_name = $settings->display_name; $userid = $settings->userid; $echonest_api_key = $settings->echonest_api_key; $setting_kind = $words[1]; $theplaylist = $words[2]; if ($setting_kind == "Set Alfred Playlist") { $w->result(null, '', "Set your Alfred playlist", "Select one of your playlists below as your Alfred playlist", './images/settings.png', 'no', null, ''); try { if (mb_strlen($theplaylist) < 3) { $getPlaylists = "select uri,name,nb_tracks,author,username,playlist_artwork_path,ownedbyuser,nb_playable_tracks,duration_playlist from playlists where ownedbyuser=1"; $stmt = $db->prepare($getPlaylists); } else { $getPlaylists = "select uri,name,nb_tracks,author,username,playlist_artwork_path,ownedbyuser,nb_playable_tracks,duration_playlist from playlists where ownedbyuser=1 and ( name like :playlist or author like :playlist)"; $stmt = $db->prepare($getPlaylists); $stmt->bindValue(':playlist', '%' . $theplaylist . '%'); } $playlists = $stmt->execute(); } catch (PDOException $e) { handleDbIssuePdoXml($db); return; } while ($playlist = $stmt->fetch()) { $added = ' '; if (startswith($playlist[1], 'Artist radio for')) { $added = '📻 '; } $w->result(null, serialize(array('', '', '', '', '', '', 'ALFRED_PLAYLIST▹' . $playlist[0] . '▹' . $playlist[1], '', '', '', '', '', '', '', '', '')), "🎵" . $added . ucfirst($playlist[1]), $playlist[7] . " tracks ● " . $playlist[8] . " ● Select the playlist to set it as your Alfred Playlist", $playlist[5], 'yes', null, ''); } } elseif ($setting_kind == "Confirm Clear Alfred Playlist") { $w->result(null, '', "Are you sure?", "This will remove all the tracks in your current Alfred Playlist.", './images/warning.png', 'no', null, ''); $w->result(null, '', "No, cancel", "Return to Alfred Playlist", './images/uncheck.png', 'no', null, 'Alfred Playlist▹'); $w->result(null, serialize(array('', '', '', '', '', '', 'CLEAR_ALFRED_PLAYLIST▹' . $alfred_playlist_uri . '▹' . $alfred_playlist_name, '', '', '', '', '', '', '', '', '')), "Yes, go ahead", "This is undoable", './images/check.png', 'yes', null, ''); } }
echo $w->toxml(); return; } try { $db = new PDO("sqlite:{$dbfile}", "", "", array(PDO::ATTR_PERSISTENT => true)); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->query("PRAGMA synchronous = OFF"); $db->query("PRAGMA journal_mode = OFF"); $db->query("PRAGMA temp_store = MEMORY"); $db->query("PRAGMA count_changes = OFF"); $db->query("PRAGMA PAGE_SIZE = 4096"); $db->query("PRAGMA default_cache_size=700000"); $db->query("PRAGMA cache_size=700000"); $db->query("PRAGMA compile_options"); } catch (PDOException $e) { handleDbIssuePdoXml($db); return; } // // Check for workflow update $check_results = checkForUpdate($w, $last_check_update_time); if ($check_results != null && is_array($check_results)) { $w->result(null, '', 'New version ' . $check_results[0] . ' is available', $check_results[2], './images/info.png', 'no', null, ''); $w->result(null, $check_results[1], 'Please install the new version in Downloads directory', $check_results[1], 'fileicon:' . $check_results[1], 'no', '', '', 'file'); echo $w->toxml(); return; } // thanks to http://www.alfredforum.com/topic/1788-prevent-flash-of-no-result mb_internal_encoding('UTF-8'); // // Fast access to commands