if ($params['VALUE']) {
getURL('http://127.0.0.1/rc/?command=vlc_close', 0);
$token = '';
if (isset($params['COUNT'])) {
$trackCount = $params['COUNT'];
} else {
$trackCount = 1;
}
if ($params['MODE'] == 0) {
$uid = $params['VALUE'];
$link = 'https://api.vk.com/method/audio.get.xml?owner_id=' . urlencode($uid) . '&access_token=' . $token;
} elseif ($params['MODE'] == 1) {
$trackName = $params['VALUE'];
$link = 'https://api.vk.com/method/audio.search.xml?q=' . urlencode($trackName) . '&count=' . $trackCount . '&auto_complete=1&sort=2&access_token=' . $token;
} elseif ($params['MODE'] == 2) {
$performerName = $params['VALUE'];
$link = 'https://api.vk.com/method/audio.search.xml?q=' . urlencode($performerName) . '&count=' . $trackCount . '&auto_complete=1&performer_only=1&sort=2&access_token=' . $token;
} else {
if (isset($params['ALBUM'])) {
$uid = $params['VALUE'];
$link = 'https://api.vk.com/method/audio.getAlbums.xml?owner_id=' . urlencode($uid) . '&access_token=' . $token;
$res = getURL($link,0);
$xml = new SimpleXMLElement($res);
foreach ($xml->album as $item) {
if ($item->title == $params['ALBUM']) {
$albumId = $item->album_id;
break;
}
}
$link = 'https://api.vk.com/method/audio.get.xml?owner_id=' . urlencode($uid) . '&access_token=' . $token . '&album_id=' . $albumId;
}
}
$res = getURL($link,0);
$xml = new SimpleXMLElement($res);
$tempPlaylist = sys_get_temp_dir() .DIRECTORY_SEPARATOR. "playlist.m3u";
$fp = fopen($tempPlaylist, "w");
fwrite($fp, '#EXTM3U' . "\r\n");
foreach ($xml->audio as $item) {
fwrite($fp, '#EXTINF:' . $item->duration . ', ' . $item->artist . ' - ' . $item->title . "\r\n");
fwrite($fp, $item->url . "\r\n");
fwrite($fp, "\r\n");
}
fclose($fp);
getURL('http://127.0.0.1/rc/?command=vlc_play¶m='.$tempPlaylist, 0);
}