/** * playCurrentArtist function. * * @access public * @param mixed $w * @return void */ function playCurrentArtist($w) { // // Read settings from JSON // $settings = getSettings($w); $use_mopidy = $settings->use_mopidy; $country_code = $settings->country_code; if ($use_mopidy) { $retArr = array(getCurrentTrackInfoWithMopidy($w)); } else { // get info on current song exec("./src/track_info.ksh 2>&1", $retArr, $retVal); if ($retVal != 0) { displayNotificationWithArtwork('AppleScript Exception: ' . htmlspecialchars($retArr[0]) . ' use spot_mini_debug command', './images/warning.png', 'Error!'); exec("osascript -e 'tell application \"Alfred 2\" to search \"spot_mini_debug AppleScript Exception: " . htmlspecialchars($retArr[0]) . "\"'"); return; } } if (isset($retArr[0]) && substr_count($retArr[0], '▹') > 0) { $results = explode('▹', $retArr[0]); $tmp = explode(':', $results[4]); if (isset($tmp[1]) && $tmp[1] == 'local') { $artist_uri = getArtistUriFromSearch($w, $results[1]); } else { $artist_uri = getArtistUriFromTrack($w, $results[4]); } if ($artist_uri == false) { displayNotificationWithArtwork("Cannot get current artist", './images/warning.png', 'Error!'); return; } if ($use_mopidy) { playUriWithMopidy($w, $artist_uri); } else { exec("osascript -e 'tell application \"Spotify\" to play track \"{$artist_uri}\"'"); addArtistToPlayQueue($w, $artist_uri, escapeQuery($results[1]), $country_code); } displayNotificationWithArtwork('🔈 Artist ' . escapeQuery($results[1]), getArtistArtwork($w, $artist_uri, $results[1], true), 'Play Current Artist'); } else { displayNotificationWithArtwork("No artist is playing", './images/warning.png'); } }
if ($retVal != 0) { displayNotificationWithArtwork('AppleScript Exception: ' . htmlspecialchars($retArr[0]) . ' use spot_mini_debug command', './images/warning.png', 'Error!'); exec("osascript -e 'tell application \"Alfred 2\" to search \"spot_mini_debug AppleScript Exception: " . htmlspecialchars($retArr[0]) . "\"'"); return; } } if ($use_mopidy) { playUriWithMopidy($w, $artist_uri); } else { exec("osascript -e 'tell application \"Spotify\" to play track \"{$artist_uri}\"'"); } displayNotificationWithArtwork('🔈 Artist ' . $artist_name, $artist_artwork_path, 'Play Artist'); if ($userid != 'vdesabou') { stathat_ez_count('AlfredSpotifyMiniPlayer', 'play', 1); } addArtistToPlayQueue($w, $artist_uri, $artist_name, $country_code); return; } else { if ($other_action == "playalbum") { if ($album_uri == "") { if ($track_uri == "") { displayNotificationWithArtwork("Cannot get current album", './images/warning.png', 'Error!'); return; } $album_uri = getAlbumUriFromTrack($w, $track_uri); if ($album_uri == false) { displayNotificationWithArtwork("Cannot get album", './images/warning.png', 'Error!'); return; } } $album_artwork_path = getTrackOrAlbumArtwork($w, $album_uri, true);