if ($params['VALUE']) {
//getURL('http://127.0.0.1/rc/?command=vlc_close', 0);
$token = 'd50ef20dd7451893aa2988adad9b0d2cefea9fa7d7097addf7be52461dfb284c902458703a51ab6653fdc';
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);
$total_items=0;
$res='#EXTM3U' . "\r\n";
foreach ($xml->audio as $item) {
$res.='#EXTINF:' . $item->duration . ', ' . $item->artist . ' - ' . $item->title . "\r\n";
$res.=$item->url . "\r\n";
$res.="\r\n";
$total_items++;
}
if ($total_items>0) {
$tempPlaylist = ROOT.'cached/vkmusic.m3u';
SaveFile($tempPlaylist,$res);
getURL('http://127.0.0.1/rc/?command=vlc_play¶m='.urlencode('http://localhost/cached/vkmusic.m3u'), 0);
} else {
say("Ошибка поиска по запросу ".$params['VALUE']);
}
}