Gazelle/sections/ajax/better/single.php

56 lines
1.3 KiB
PHP
Raw Normal View History

2012-01-19 08:00:18 +00:00
<?
2014-05-15 08:00:27 +00:00
if (($Results = $Cache->get_value('better_single_groupids')) === false) {
2013-05-05 08:00:31 +00:00
$DB->query("
SELECT
t.ID AS TorrentID,
2013-05-14 08:00:34 +00:00
t.GroupID AS GroupID
2012-01-19 08:00:18 +00:00
FROM xbt_files_users AS x
2014-05-15 08:00:27 +00:00
JOIN torrents AS t ON t.ID=x.fid
WHERE t.Format='FLAC'
2012-01-19 08:00:18 +00:00
GROUP BY x.fid
2013-05-05 08:00:31 +00:00
HAVING COUNT(x.uid) = 1
ORDER BY t.LogScore DESC, t.Time ASC
LIMIT 30");
2012-01-19 08:00:18 +00:00
2014-05-15 08:00:27 +00:00
$Results = $DB->to_pair('GroupID', 'TorrentID', false);
$Cache->cache_value('better_single_groupids', $Results, 30 * 60);
2012-01-19 08:00:18 +00:00
}
2014-05-15 08:00:27 +00:00
$Groups = Torrents::get_groups(array_keys($Results));
2012-01-19 08:00:18 +00:00
$JsonResults = array();
2014-05-15 08:00:27 +00:00
foreach ($Results as $GroupID => $FlacID) {
if (!isset($Groups[$GroupID])) {
2014-05-07 08:00:45 +00:00
continue;
}
2014-05-15 08:00:27 +00:00
$Group = $Groups[$GroupID];
2013-02-25 21:16:55 +00:00
extract(Torrents::array_group($Group));
2013-02-22 08:00:24 +00:00
2012-03-29 08:00:19 +00:00
$JsonArtists = array();
2013-05-05 08:00:31 +00:00
if (count($Artists) > 0) {
2012-03-29 08:00:19 +00:00
foreach ($Artists as $Artist) {
$JsonArtists[] = array(
2013-10-30 08:01:19 +00:00
'id' => (int)$Artist['id'],
2012-03-29 08:00:19 +00:00
'name' => $Artist['name'],
2013-10-30 08:01:19 +00:00
'aliasId' => (int)$Artist['aliasid']
2012-03-29 08:00:19 +00:00
);
}
2012-01-19 08:00:18 +00:00
}
2013-02-22 08:00:24 +00:00
2012-01-19 08:00:18 +00:00
$JsonResults[] = array(
2013-10-30 08:01:19 +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,
2013-10-30 08:01:19 +00:00
'groupYear' => (int)$GroupYear,
'downloadUrl' => "torrents.php?action=download&id=$FlacID&authkey=".$LoggedUser['AuthKey'].'&torrent_pass='.$LoggedUser['torrent_pass']
2012-01-19 08:00:18 +00:00
);
}
print json_encode(
array(
'status' => 'success',
'response' => $JsonResults
)
2012-01-28 08:00:29 +00:00
);