Gazelle/sections/better/transcode.php

195 lines
6.7 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
2012-11-04 08:00:20 +00:00
if(!isset($_GET['type']) || !is_number($_GET['type']) || $_GET['type'] > 3) {
error(0);
}
2011-03-28 14:21:28 +00:00
$Options = array('v0','v2','320');
2012-11-04 08:00:20 +00:00
$Encodings = array('V0 (VBR)', 'V2 (VBR)', '320');
$EncodingKeys = array_fill_keys($Encodings, true);
2011-03-28 14:21:28 +00:00
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']);
}
}
2012-11-04 08:00:20 +00:00
$SphQL = new SphinxQL_Query();
$SphQL->select('id, groupid')
->from('better_transcode')
->where('logscore', 100)
->where_match('FLAC', 'format')
->where_match($List, 'encoding', false)
->order_by('RAND()')
->limit(0, TORRENTS_PER_PAGE, TORRENTS_PER_PAGE);
2011-03-28 14:21:28 +00:00
if(!empty($_GET['search'])) {
2012-11-04 08:00:20 +00:00
$SphQL->where_match($_GET['search'], '(groupname,artistname,year,taglist)');
2011-03-28 14:21:28 +00:00
}
2012-11-04 08:00:20 +00:00
$SphQLResult = $SphQL->query();
$TorrentCount = $SphQLResult->get_meta('total');
2011-03-28 14:21:28 +00:00
2012-11-04 08:00:20 +00:00
if ($TorrentCount == 0) {
error('No results found!');
}
2011-03-28 14:21:28 +00:00
2012-11-04 08:00:20 +00:00
$Results = $SphQLResult->to_array('groupid');
$Groups = Torrents::get_groups(array_keys($Results));
$Groups = $Groups['matches'];
2011-03-28 14:21:28 +00:00
2012-11-04 08:00:20 +00:00
$Debug->log_var(true, 'Excluding '.$Encodings[$_GET['type']]);
$TorrentGroups = array();
foreach ($Groups as $GroupID => $Group) {
if (empty($Group['Torrents'])) {
unset($Groups[$GroupID]);
continue;
2011-03-28 14:21:28 +00:00
}
2012-11-04 08:00:20 +00:00
foreach ($Group['Torrents'] as $Torrent) {
$TorRemIdent = "$Torrent[Media] $Torrent[RemasterYear] $Torrent[RemasterTitle] $Torrent[RemasterRecordLabel] $Torrent[RemasterCatalogueNumber]";
if (!isset($TorrentGroups[$Group['ID']])) {
$TorrentGroups[$Group['ID']] = array(
$TorRemIdent => array(
'FlacID' => 0,
'Formats' => array(),
'RemasterTitle' => $Torrent['RemasterTitle'],
'RemasterYear' => $Torrent['RemasterYear'],
'RemasterRecordLabel' => $Torrent['RemasterRecordLabel'],
'RemasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'],
'IsSnatched' => false
)
);
} elseif (!isset($TorrentGroups[$Group['ID']][$TorRemIdent])) {
$TorrentGroups[$Group['ID']][$TorRemIdent] = array(
'FlacID' => 0,
'Formats' => array(),
'RemasterTitle' => $Torrent['RemasterTitle'],
'RemasterYear' => $Torrent['RemasterYear'],
'RemasterRecordLabel' => $Torrent['RemasterRecordLabel'],
'RemasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'],
'IsSnatched' => false
);
}
if (isset($EncodingKeys[$Torrent['Encoding']])) {
$TorrentGroups[$Group['ID']][$TorRemIdent]['Formats'][$Torrent['Encoding']] = true;
2013-02-17 08:00:08 +00:00
} elseif ($TorrentGroups[$Group['ID']][$TorRemIdent]['FlacID'] == 0 && $Torrent['Format'] == 'FLAC' && ($Torrent['LogScore'] == 100 || $Torrent['Media'] != 'CD')) {
2012-11-04 08:00:20 +00:00
$TorrentGroups[$Group['ID']][$TorRemIdent]['FlacID'] = $Torrent['ID'];
$TorrentGroups[$Group['ID']][$TorRemIdent]['IsSnatched'] = $Torrent['IsSnatched'];
2011-03-28 14:21:28 +00:00
}
}
}
2012-11-04 08:00:20 +00:00
$Debug->log_var($TorrentGroups, 'Torrent groups');
2011-03-28 14:21:28 +00:00
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>
<?
2012-11-04 08:00:20 +00:00
foreach ($TorrentGroups as $GroupID => $Editions) {
$GroupInfo = $Groups[$GroupID];
$GroupYear = $GroupInfo['Year'];
$ExtendedArtists = $GroupInfo['ExtendedArtists'];
$GroupCatalogueNumber = $GroupInfo['CatalogueNumber'];
$GroupName = $GroupInfo['Name'];
$GroupRecordLabel = $GroupInfo['RecordLabel'];
$ReleaseType = $GroupInfo['ReleaseType'];
if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) {
unset($ExtendedArtists[2]);
unset($ExtendedArtists[3]);
$ArtistNames = Artists::display_artists($ExtendedArtists);
} else {
$ArtistNames = '';
2011-03-28 14:21:28 +00:00
}
2012-11-04 08:00:20 +00:00
$TagList = array();
$TagList = explode(' ',str_replace('_','.',$GroupInfo['TagList']));
$TorrentTags = array();
foreach ($TagList as $Tag) {
2012-11-06 08:00:20 +00:00
$TorrentTags[] = '<a href="torrents.php?taglist='.$Tag.'">'.$Tag.'</a>';
2011-03-28 14:21:28 +00:00
}
2012-11-04 08:00:20 +00:00
$TorrentTags = implode(', ', $TorrentTags);
foreach ($Editions as $RemIdent => $Edition) {
if (!$Edition['FlacID']
|| !empty($Edition['Formats']) && $_GET['type'] == 3
|| $Edition['Formats'][$Encodings[$_GET['type']]] == true) {
$Debug->log_var($Edition, 'Skipping '.$RemIdent);
continue;
2012-02-05 08:00:20 +00:00
}
2012-11-04 08:00:20 +00:00
$DisplayName = $ArtistNames . '<a href="torrents.php?id='.$GroupID.'&amp;torrentid='.$Edition['FlacID'].'#torrent'.$Edition['FlacID'].'" title="View Torrent">'.$GroupName.'</a>';
if($GroupYear > 0) {
$DisplayName .= " [".$GroupYear."]";
}
if ($ReleaseType > 0) {
$DisplayName .= " [".$ReleaseTypes[$ReleaseType]."]";
}
if ($Edition['IsSnatched']) {
2013-01-03 08:00:30 +00:00
$DisplayName .= ' ' . Format::torrent_label('Snatched!');
2012-11-04 08:00:20 +00:00
}
$EditionInfo = array();
if (!empty($Edition['RemasterYear'])) {
$ExtraInfo = $Edition['RemasterYear'];
} else {
$ExtraInfo = '';
}
if (!empty($Edition['RemasterRecordLabel'])) {
$EditionInfo[] = $Edition['RemasterRecordLabel'];
}
if (!empty($Edition['RemasterTitle'])) {
$EditionInfo[] = $Edition['RemasterTitle'];
}
if (!empty($Edition['RemasterCatalogueNumber'])) {
$EditionInfo[] = $Edition['RemasterCatalogueNumber'];
}
if (!empty($Edition['RemasterYear'])) {
$ExtraInfo .= ' - ';
}
$ExtraInfo .= implode(' / ', $EditionInfo);
2011-03-28 14:21:28 +00:00
?>
2012-11-04 08:00:20 +00:00
<tr<?=$Edition['IsSnatched'] ? ' class="snatched_torrent"' : ''?>>
2011-03-28 14:21:28 +00:00
<td>
2012-11-04 08:00:20 +00:00
<span class="torrent_links_block">
2013-02-13 08:00:35 +00:00
<a href="torrents.php?action=download&amp;id=<?=$Edition['FlacID']?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download" class="brackets">DL</a>
2012-11-04 08:00:20 +00:00
</span>
2011-03-28 14:21:28 +00:00
<?=$DisplayName?>
2012-11-04 08:00:20 +00:00
<div class="torrent_info"><?=$ExtraInfo?></div>
<div class="tags"><?=$TorrentTags?></div>
2011-03-28 14:21:28 +00:00
</td>
2013-02-13 08:00:35 +00:00
<td><?=isset($Edition['Formats']['V2 (VBR)']) ? '<strong class="important_text_alt">YES</strong>' : '<strong class="important_text">NO</strong>'?></td>
<td><?=isset($Edition['Formats']['V0 (VBR)']) ? '<strong class="important_text_alt">YES</strong>' : '<strong class="important_text">NO</strong>'?></td>
<td><?=isset($Edition['Formats']['320']) ? '<strong class="important_text_alt">YES</strong>' : '<strong class="important_text">NO</strong>'?></td>
2011-03-28 14:21:28 +00:00
</tr>
2012-11-04 08:00:20 +00:00
<?
}
}
?>
2011-03-28 14:21:28 +00:00
</table>
</div>
<?
2012-10-11 08:00:15 +00:00
View::show_footer();
2011-03-28 14:21:28 +00:00
?>