예제 #1
0
/**
 * 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');
    }
}
예제 #2
0
파일: action.php 프로젝트: jfloff/.dotfiles
     $album_artwork_path = getTrackOrAlbumArtwork($w, $album_uri, true);
     $mopidy_arg = "";
     if ($use_mopidy) {
         $mopidy_arg = "MOPIDY";
     }
     exec("./src/spotify_mini_player_notifications.ksh -d \"" . $w->data() . "\" -a start -m \"" . $mopidy_arg . "\"  >> \"" . $w->cache() . "/action.log\" 2>&1 & ");
     if (!$use_mopidy) {
         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 ($use_mopidy) {
         playUriWithMopidy($w, $album_uri);
     } else {
         exec("osascript -e 'tell application \"Spotify\" to play track \"{$album_uri}\"'");
     }
     displayNotificationWithArtwork('🔈 Album ' . $album_name, $album_artwork_path, 'Play Album');
     if ($userid != 'vdesabou') {
         stathat_ez_count('AlfredSpotifyMiniPlayer', 'play', 1);
     }
     addAlbumToPlayQueue($w, $album_uri, $album_name);
     return;
 } else {
     if ($other_action == "volume_up") {
         if ($use_mopidy) {
             invokeMopidyMethod($w, "core.mixer.set_volume", array('volume' => invokeMopidyMethod($w, "core.mixer.get_volume", array()) + $volume_percent));
         } else {
             # FIX THIS: Workaround for #92