Gazelle/sections/ajax/better/single.php

52 lines
1.4 KiB
PHP
Raw Normal View History

2012-01-19 08:00:18 +00:00
<?
if(($GroupIDs = $Cache->get_value('better_single_groupids')) === false) {
$DB->query("SELECT t.ID AS TorrentID,
t.GroupID AS GroupID
FROM xbt_files_users AS x
JOIN torrents AS t ON t.ID=x.fid
WHERE t.Format='FLAC'
GROUP BY x.fid
HAVING COUNT(x.uid) = 1
ORDER BY t.LogScore DESC, t.Time ASC LIMIT 30");
$GroupIDs = $DB->to_array('GroupID');
$Cache->cache_value('better_single_groupids', $GroupIDs, 30*60);
}
2012-10-11 08:00:15 +00:00
$Results = Torrents::get_groups(array_keys($GroupIDs));
2012-01-19 08:00:18 +00:00
$Results = $Results['matches'];
$JsonResults = array();
foreach ($Results as $GroupID=>$Group) {
list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel, $GroupCatalogueNumber, $TagList, $ReleaseType, $GroupVanityHouse, $Torrents, $Artists) = array_values($Group);
$FlacID = $GroupIDs[$GroupID]['TorrentID'];
2012-03-29 08:00:19 +00:00
$JsonArtists = array();
2012-01-19 08:00:18 +00:00
if(count($Artists)>0) {
2012-03-29 08:00:19 +00:00
foreach ($Artists as $Artist) {
$JsonArtists[] = array(
'id' => (int) $Artist['id'],
'name' => $Artist['name'],
'aliasId' => (int) $Artist['aliasid']
);
}
2012-01-19 08:00:18 +00:00
}
$JsonResults[] = array(
2012-01-28 08:00:29 +00:00
'torrentId' => (int) $FlacID,
'groupId' => (int) $GroupID,
2012-03-29 08:00:19 +00:00
'artist' => $JsonArtists,
2012-01-19 08:00:18 +00:00
'groupName' => $GroupName,
2012-01-28 08:00:29 +00:00
'groupYear' => (int) $GroupYear,
2012-01-19 08:00:18 +00:00
'downloadUrl' => 'torrents.php?action=download&id='.$FlacID.'&authkey='.$LoggedUser['AuthKey'].'&torrent_pass='.$LoggedUser['torrent_pass']
);
}
print json_encode(
array(
'status' => 'success',
'response' => $JsonResults
)
2012-01-28 08:00:29 +00:00
);