Example #1
0
function do_playlist_tracks($pl, $icon)
{
    global $putinplaylistarray, $playlist;
    if ($pl == '[Radio Streams]') {
        $streams = do_mpd_command('listplaylistinfo "' . $pl . '"', true);
        if (is_array($streams) && array_key_exists('file', $streams)) {
            if (!is_array($streams['file'])) {
                $temp = $streams['file'];
                $streams = array();
                $streams['file'][0] = $temp;
            }
            $c = 0;
            foreach ($streams['file'] as $st) {
                add_playlist(rawurlencode($st), htmlentities(substr($st, strrpos($st, '#') + 1, strlen($st))), 'icon-radio-tower', 'clicktrack', true, $c, false);
                $c++;
            }
        }
    } else {
        $putinplaylistarray = true;
        doCollection('listplaylistinfo "' . $pl . '"');
        $c = 0;
        foreach ($playlist as $track) {
            list($class, $link) = $track->get_checked_url();
            add_playlist(rawurlencode($link), htmlentities($track->get_artist_track_title()), 'icon-music', $class, true, $c, false);
            $c++;
        }
    }
}
Example #2
0
function print_playlists_as_json()
{
    global $putinplaylistarray, $playlist, $prefs;
    $playlists = do_mpd_command("listplaylists", true, true);
    $pls = array();
    $putinplaylistarray = true;
    if (array_key_exists('playlist', $playlists)) {
        foreach ($playlists['playlist'] as $name) {
            $playlist = array();
            $pls[rawurlencode($name)] = array();
            doCollection('listplaylistinfo "' . $name . '"');
            $c = 0;
            $plimage = "";
            $key = md5("Playlist " . htmlentities($name));
            if (file_exists('albumart/asdownloaded/' . $key . ".jpg")) {
                $plimage = 'albumart/asdownloaded/' . $key . ".jpg";
            }
            foreach ($playlist as $track) {
                list($flag, $link) = $track->get_checked_url();
                $pls[rawurlencode($name)][] = array('Uri' => $link, 'Title' => $track->tags['Title'], "Album" => $track->albumobject->name, "Artist" => $track->get_artist_string(), 'albumartist' => $track->albumobject->artist, 'duration' => $track->tags['Time'], 'Image' => $track->albumobject->getImage('small'), 'key' => $track->albumobject->getKey(), 'pos' => $c, 'plimage' => $plimage, 'Type' => $track->tags['type']);
                $c++;
            }
        }
    }
    print json_encode($pls);
}
Example #3
0
<?php

include "includes/vars.php";
include "includes/functions.php";
include "international.php";
include "collection/collection.php";
include "player/mpd/connection.php";
include "backends/sql/backend.php";
header('Content-Type: application/json; charset=utf-8');
doCollection("playlistinfo");
debuglog("Collection scan playlistinfo finished", "GETPLAYLIST");
$foundartists = array();
outputPlaylist();
debuglog("Playlist Output Is Done", "GETPLAYLIST");
function outputPlaylist()
{
    global $playlist;
    global $prefs;
    global $foundartists;
    $output = array();
    foreach ($playlist as $track) {
        // Track artists are held in the track object as an array
        $c = $track->get_artist_string();
        $t = $track->tags['Title'];
        // We can't return NULL in the JSON data for some reason that escapes me
        if ($c === null) {
            $c = "";
        }
        if ($t === null) {
            $t = "";
        }
Example #4
0
 $cmds = array();
 //
 // Assemble and format the command list and perform any command-specific backend actions
 //
 if (array_key_exists('commands', $_POST)) {
     foreach ($_POST['commands'] as $cmd) {
         switch ($cmd[0]) {
             case "additem":
                 require_once "backends/sql/backend.php";
                 debuglog("Adding Item " . $cmd[1], "POSTCOMMAND");
                 $cmds = array_merge($cmds, getItemsToAdd($cmd[1], null));
                 break;
             case "addartist":
                 require_once "backends/sql/backend.php";
                 debuglog("Getting tracks for Artist " . $cmd[1], "MPD");
                 doCollection('find "artist" "' . format_for_mpd($cmd[1]) . '"', array("spotify"));
                 $cmds = array_merge($cmds, $collection->getAllTracks("add"));
                 break;
             case "loadstreamplaylist":
                 require_once "utils/getInternetPlaylist.php";
                 $cmds = array_merge($cmds, load_internet_playlist($cmd[1], $cmd[2], $cmd[3], $cmd[4]));
                 break;
             case "loaduserstream":
                 require_once "utils/getInternetPlaylist.php";
                 $cmds = array_merge($cmds, get_tracks_from_stream_playlist($cmd[1]));
                 break;
             case "rename":
                 $oldimage = md5('Playlist ' . $cmd[1]);
                 $newimage = md5('Playlist ' . $cmd[2]);
                 if (file_exists('albumart/small/' . $oldimage . '.jpg')) {
                     debuglog("Renaming playlist image for " . $cmd[1] . " to " . $cmd[2], "MPD");
Example #5
0
     getWishlist();
 } else {
     if (array_key_exists('rebuild', $_REQUEST)) {
         // This is a request to rebuild the music collection coming from either
         // the mpd or mopidy controller
         debuglog("======================================================================", "TIMINGS", 4);
         include "player/mpd/connection.php";
         include "collection/collection.php";
         debuglog("== Starting Collection Update", "TIMINGS", 4);
         $initmem = memory_get_usage();
         debuglog("Memory Used is " . $initmem, "COLLECTION", 4);
         $now2 = time();
         $trackbytrack = true;
         cleanSearchTables();
         prepareCollectionUpdate();
         doCollection("listallinfo");
         debuglog("== Time Spent Reading Socket Data                      : " . $parse_time, "TIMTINGS", 4);
         debuglog("== Time Spent Parsing Socket Data                      : " . $rtime, "TIMTINGS", 4);
         debuglog("== Time Spent Checking/Writing to Database             : " . $db_time, "TIMTINGS", 4);
         debuglog("== Time Spent Putting Stuff into Collection Structures : " . $coll_time, "TIMTINGS", 4);
         createAlbumsList();
         $whattodump = array_key_exists('dump', $_REQUEST) ? $_REQUEST['dump'] : false;
         if ($whattodump === false) {
             print '<html></html>';
         } else {
             dumpAlbums($whattodump);
         }
         close_mpd();
         debuglog("== Collection Update And Send took " . format_time(time() - $now2), "TIMINGS", 4);
         $peakmem = memory_get_peak_usage();
         $ourmem = $peakmem - $initmem;