Gazelle/sections/better/transcode.php

147 lines
4.8 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
if(!isset($_GET['type']) || !is_number($_GET['type']) || $_GET['type'] > 3) { error(0); }
$Options = array('v0','v2','320');
if ($_GET['type'] == 3) {
$List = "!(v0 | v2 | 320)";
} else {
$List = '!'.$Options[$_GET['type']];
if($_GET['type'] == 0) {
$_GET['type'] = '0';
} else {
$_GET['type'] = display_str($_GET['type']);
}
}
$Query = '@format FLAC @encoding '.$List;
if(!empty($_GET['search'])) {
2012-10-16 08:00:18 +00:00
$Query.=' @(groupname,artistname,yearfulltext,taglist) '.$SS->escape_string($_GET['search']);
2011-03-28 14:21:28 +00:00
}
$SS->SetFilter('logscore', array(100));
2011-03-28 14:21:28 +00:00
$SS->SetSortMode(SPH_SORT_EXTENDED, "@random");
$SS->limit(0, TORRENTS_PER_PAGE);
$SS->set_index(SPHINX_INDEX.' delta');
$Results = $SS->search($Query, '', 0, array(), '', '');
2011-03-28 14:21:28 +00:00
if(count($Results) == 0) { error('No results found!'); }
/*
2011-03-28 14:21:28 +00:00
// If some were fetched from memcached, get their artists
if(!empty($Results['matches'])) { // Fetch the artists for groups
$GroupIDs = array_keys($Results['matches']);
2012-10-11 08:00:15 +00:00
$Artists = Artists::get_artists($GroupIDs);
2011-03-28 14:21:28 +00:00
foreach($Artists as $GroupID=>$Data) {
if(!empty($Data[1])) {
$Results['matches'][$GroupID]['Artists']=$Data[1]; // Only use main artists
}
ksort($Results['matches'][$GroupID]);
}
}
*/
2011-03-28 14:21:28 +00:00
// These ones were not found in the cache, run SQL
if(!empty($Results['notfound'])) {
2012-10-11 08:00:15 +00:00
$SQLResults = Torrents::get_groups($Results['notfound']);
2011-03-28 14:21:28 +00:00
if(is_array($SQLResults['notfound'])) { // Something wasn't found in the db, remove it from results
reset($SQLResults['notfound']);
foreach($SQLResults['notfound'] as $ID) {
unset($SQLResults['matches'][$ID]);
unset($Results['matches'][$ID]);
}
}
// Merge SQL results with memcached results
foreach($SQLResults['matches'] as $ID=>$SQLResult) {
$Results['matches'][$ID] = array_merge($Results['matches'][$ID], $SQLResult);
ksort($Results['matches'][$ID]);
}
}
$Results = $Results['matches'];
2012-10-11 08:00:15 +00:00
View::show_header('Transcode Search');
2011-03-28 14:21:28 +00:00
?>
<br />
<div class="thin">
2012-09-15 08:00:25 +00:00
<form class="search_form" name="transcodes" action="" method="get">
<table cellpadding="6" cellspacing="1" border="0" class="border" width="100%">
<tr>
<td class="label"><strong>Search:</strong></td>
<td>
<input type="hidden" name="method" value="transcode" />
<input type="hidden" name="type" value="<?=$_GET['type']?>" />
<input type="text" name="search" size="60" value="<?=(!empty($_GET['search']) ? display_str($_GET['search']) : '')?>" />
&nbsp;
<input type="submit" value="Search" />
</td>
</tr>
</table>
</form>
2012-09-01 08:00:24 +00:00
<table width="100%" class="torrent_table">
2011-03-28 14:21:28 +00:00
<tr class="colhead">
<td>Torrent</td>
<td>V2</td>
<td>V0</td>
<td>320</td>
</tr>
<?
foreach($Results as $GroupID=>$Data) {
2011-11-30 08:00:20 +00:00
$Debug->log_var($Data);
2012-02-05 08:00:20 +00:00
list($Artists, $GroupCatalogueNumber, $ExtendedArtists, $GroupID2, $GroupName, $GroupRecordLabel, $ReleaseType, $TorrentTags, $Torrents, $GroupVanityHouse, $GroupYear, $CategoryID, $FreeTorrent, $HasCue, $HasLog, $TotalLeechers, $LogScore, $ReleaseType, $ReleaseType, $TotalSeeders, $MaxSize, $TotalSnatched, $GroupTime) = array_values($Data);
2011-03-28 14:21:28 +00:00
$DisplayName = '';
if(count($Artists)>0) {
2012-10-11 08:00:15 +00:00
$DisplayName = Artists::display_artists(array('1'=>$Artists));
2011-03-28 14:21:28 +00:00
}
$DisplayName.='<a href="torrents.php?id='.$GroupID.'" title="View Torrent">'.$GroupName.'</a>';
if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; }
2012-02-09 08:00:20 +00:00
if($ReleaseType>0) { $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; }
2011-03-28 14:21:28 +00:00
$MissingEncodings = array('V0 (VBR)'=>1, 'V2 (VBR)'=>1, '320'=>1);
$FlacID = 0;
foreach($Torrents as $Torrent) {
if(!empty($MissingEncodings[$Torrent['Encoding']])) {
$MissingEncodings[$Torrent['Encoding']] = 0;
} elseif($Torrent['Format'] == 'FLAC' && $FlacID == 0) {
$FlacID = $Torrent['ID'];
}
}
if($_GET['type'] == '3' && in_array(0, $MissingEncodings)) {
continue;
}
2012-02-05 08:00:20 +00:00
$TagList=array();
if($TorrentTags!='') {
$TorrentTags=explode(' ',$TorrentTags);
foreach ($TorrentTags as $TagKey => $TagName) {
$TagName = str_replace('_','.',$TagName);
$TagList[]='<a href="torrents.php?searchtags='.$TagName.'">'.$TagName.'</a>';
}
$PrimaryTag = $TorrentTags[0];
$TagList = implode(', ', $TagList);
$TorrentTags='<br /><div class="tags">'.$TagList.'</div>';
}
2011-03-28 14:21:28 +00:00
?>
<tr>
<td>
<?=$DisplayName?>
2012-08-14 08:00:18 +00:00
[ <a href="torrents.php?action=download&amp;id=<?=$FlacID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>">DL</a> ]
2012-02-05 08:00:20 +00:00
<?=$TorrentTags?>
2011-03-28 14:21:28 +00:00
</td>
2012-02-05 08:00:20 +00:00
<td><strong><?=($MissingEncodings['V2 (VBR)'] == 0)?'<span style="color: green;">YES</span>':'<span style="color: red;">NO</span>'?></strong></td>
<td><strong><?=($MissingEncodings['V0 (VBR)'] == 0)?'<span style="color: green;">YES</span>':'<span style="color: red;">NO</span>'?></strong></td>
<td><strong><?=($MissingEncodings['320'] == 0)?'<span style="color: green;">YES</span>':'<span style="color: red;">NO</span>'?></strong></td>
2011-03-28 14:21:28 +00:00
</tr>
<? } ?>
</table>
</div>
<?
2012-10-11 08:00:15 +00:00
View::show_footer();
2011-03-28 14:21:28 +00:00
?>