$w = new Workflows();
ini_set('memory_limit', '512M');
//
// Create the library_starred_playlist.json
//
if (!file_exists($w->data() . "/library_starred_playlist.json")) {
    $array_starred_items = array();
    if (file_exists($w->data() . "/library.json")) {
        $json = file_get_contents($w->data() . "/library.json");
        $json = json_decode($json, true);
        foreach ($json as $item) {
            if ($item['data']['starred'] == true) {
                array_push($array_starred_items, $item);
            }
        }
        $w->write($array_starred_items, 'library_starred_playlist.json');
    }
}
//
// Create the playlists.json
//
if (!file_exists($w->data() . "/playlists-tmp.json")) {
    exec('mdfind -name guistate', $results);
    $theUser = "";
    $theGuiStateFile = "";
    foreach ($results as $guistateFile) {
        if (strpos($guistateFile, "Spotify/Users") !== false) {
            $theGuiStateFile = $guistateFile;
            $a = explode('/', trim($theGuiStateFile, '/'));
            $b = explode('-', $a[6]);
            $theUser = $b[0];
Esempio n. 2
0
<?php

require 'workflow.php';
require 'functions.php';
require 'BaiduMapClient.php';
isset($argv[1]) && ($query = trim($argv[1]));
$workflow = new Workflows();
$res = $workflow->write($query, BaiduMapClient::APIKEY);
$title = $res ? 'success' : 'failure';
$workflow->result($query, $query, $title, 'set baidu api key failure', 'icon.png');
print $workflow->toxml();
Esempio n. 3
0
<?php

require 'workflow.php';
require 'functions.php';
require 'GoogleMapClient.php';
isset($argv[1]) && ($query = trim($argv[1]));
$workflow = new Workflows();
$res = $workflow->write($query, GoogleMapClient::APIKEY);
$title = $res ? 'success' : 'failure';
$workflow->result($query, $query, $title, 'set google api key failure', 'icon.png');
Esempio n. 4
0
    $rgba = `osascript -e 'tell application "Alfred 2"' -e 'activate' -e 'choose color default color {65535, 65535, 65535}' -e 'end tell'`;
    $hex = '';
    if ($rgba) {
        $rgba = explode(',', $rgba);
        $rgb = array_slice($rgba, 0, 3);
        // Convert to hex
        foreach ($rgb as $c) {
            $hex .= substr('0' . dechex($c / 65535 * 255), -2);
        }
    }
    return `osascript -e 'tell application "Alfred 2" to search "hue {$id}:color:{$hex}"'`;
}
/** Cache a reference to lights. */
if (trim($query) === '') {
    // clear cache
    $lights = $w->write('', 'lights');
    $lights = $w->request("http://{$bridge_ip}" . $base_path . '/lights', array(CURLOPT_CONNECTTIMEOUT => 3));
    $lights = json_decode($lights, true);
    if ($lights) {
        $w->write($lights, 'lights');
    }
} else {
    $lights = $w->read('lights', true);
}
if (!$lights) {
    result(array('title' => 'Bridge connection failed.', 'subtitle' => 'Try running "setup-hue".', 'valid' => 'no'));
    echo $w->toxml($results);
    exit;
}
/** Generate Results */
if ($query == 'lights') {