diff --git a/sections/better/index.php b/sections/better/index.php index 3133fc51..04f23f94 100644 --- a/sections/better/index.php +++ b/sections/better/index.php @@ -7,6 +7,9 @@ case 'transcode': include(SERVER_ROOT.'/sections/better/transcode.php'); break; + case 'transcode_beta': + include(SERVER_ROOT.'/sections/better/transcode_beta.php'); + break; case 'single': include(SERVER_ROOT.'/sections/better/single.php'); break; diff --git a/sections/better/transcode_beta.php b/sections/better/transcode_beta.php new file mode 100644 index 00000000..942a0f92 --- /dev/null +++ b/sections/better/transcode_beta.php @@ -0,0 +1,322 @@ + 'V0 (VBR)', 'v2' => 'V2 (VBR)', '320' => '320'); + +function transcode_init_sphql() { + // Initializes a basic SphinxQL_Query object + $SphQL = new SphinxQL_Query(); + $SphQL->select('groupid') + ->from('better_transcode') + ->where('logscore', 100) + ->where_match('FLAC', 'format') + ->order_by('RAND()') + ->limit(0, TORRENTS_PER_PAGE, TORRENTS_PER_PAGE); + if (in_array($_GET['target'], array('v0', 'v2', '320'))) { + // v0/v2/320 is missing + $SphQL->where_match('!'.$_GET['target'], 'encoding', false); + } elseif($_GET['target'] == 'all') { + // all transcodes are missing + $SphQL->where_match('!(v0 | v2 | 320)', 'encoding', false); + } else { + // any transcode is missing + $SphQL->where_match('!(v0 v2 320)', 'encoding', false); + } + if(!empty($_GET['search'])) { + $SphQL->where_match($_GET['search'], '(groupname,artistname,year,taglist)'); + } + return $SphQL; +} + +function transcode_parse_groups($Groups) { + $TorrentGroups = array(); + foreach ($Groups as $GroupID => $Group) { + if (empty($Group['Torrents'])) { + continue; + } + foreach ($Group['Torrents'] as $TorrentID => $Torrent) { + $RemIdent = "$Torrent[Media] $Torrent[RemasterYear] $Torrent[RemasterTitle] $Torrent[RemasterRecordLabel] $Torrent[RemasterCatalogueNumber]"; + if (!isset($TorrentGroups[$GroupID])) { + $TorrentGroups[$GroupID] = array( + 'Year' => $Group['Year'], + 'ExtendedArtists' => $Group['ExtendedArtists'], + 'Name' => $Group['Name'], + 'ReleaseType' => $Group['ReleaseType'], + 'TagList' => $Group['TagList'], + 'Editions' => array() + ); + } + if (!isset($TorrentGroups[$GroupID]['Editions'][$RemIdent])) { + if($Torrent['Remastered'] && $Torrent['RemasterYear'] != 0) { + $EditionName = $Torrent['RemasterYear']; + $AddExtra = " - "; + if($Torrent['RemasterRecordLabel']) { $EditionName .= $AddExtra.display_str($Torrent['RemasterRecordLabel']); $AddExtra=' / '; } + if($Torrent['RemasterCatalogueNumber']) { $EditionName .= $AddExtra.display_str($Torrent['RemasterCatalogueNumber']); $AddExtra=' / '; } + if($Torrent['RemasterTitle']) { $EditionName .= $AddExtra.display_str($Torrent['RemasterTitle']); $AddExtra=' / '; } + $EditionName .= $AddExtra.display_str($Torrent['Media']); + } else { + $AddExtra = " / "; + if(!$Torrent['Remastered']) { + $EditionName = "Original Release"; + if($Group['RecordLabel']) { $EditionName .= $AddExtra.$Group['RecordLabel']; $AddExtra=' / '; } + if($Group['CatalogueNumber']) { $EditionName .= $AddExtra.$Group['CatalogueNumber']; $AddExtra=' / '; } + } else { + $EditionName = "Unknown Release(s)"; + } + $EditionName .= $AddExtra.display_str($Torrent['Media']); + } + $TorrentGroups[$GroupID]['Editions'][$RemIdent] = array( + 'FlacIDs' => array(), + 'MP3s' => array(), + 'Media' => $Torrent['Media'], + 'EditionName' => $EditionName, + 'FLACIsSnatched' => false + ); + } + + if ($Torrent['Format'] == 'MP3') { + $TorrentGroups[$GroupID]['Editions'][$RemIdent]['MP3s'][$Torrent['Encoding']] = true; + } elseif ($Torrent['Format'] == 'FLAC' && ($Torrent['LogScore'] == 100 || $Torrent['Media'] != 'CD') + && !isset($TorrentGroups[$GroupID]['Editions'][$RemIdent]['FlacIDs'][$TorrentID])) { + $TorrentGroups[$GroupID]['Editions'][$RemIdent]['FlacIDs'][$TorrentID] = true; + $TorrentGroups[$GroupID]['Editions'][$RemIdent]['FLACIsSnatched'] = $TorrentGroups[$GroupID]['Editions'][$RemIdent]['FLACIsSnatched'] || $Torrent['IsSnatched']; + } + } + } + return $TorrentGroups; +} + +$Groups = array(); +$ResultCount = 0; +if(in_array($_GET['filter'], array('all', 'uploaded'))) { + $SphQL = transcode_init_sphql(); + if($_GET['filter'] == 'uploaded') { + $SphQL->where('uploader', $UserID); + } + + $SphQLResult = $SphQL->query(); + $ResultCount = $SphQLResult->get_meta('total'); + if ($ResultCount != 0) { + $Results = $SphQLResult->collect('groupid'); + $Groups = Torrents::get_groups(array_values($Results)); + $Groups = transcode_parse_groups($Groups['matches']); + } + unset($SphQL, $SphQLResult, $Results); +} elseif(in_array($_GET['filter'], array('snatched', 'seeding'))) { + // Read all snatched/seeding torrents + $DB->query("SELECT t.GroupID, x.fid + FROM ".($_GET['filter'] == 'seeding' ? 'xbt_files_users' : 'xbt_snatched')." AS x + JOIN torrents AS t ON t.ID=x.fid + JOIN torrents_group AS tg ON tg.ID = t.GroupID + WHERE t.Format='FLAC' + AND (t.LogScore = '100' OR t.Media != 'CD') + AND tg.CategoryID = 1 + AND x.uid='$UserID' + ".($_GET['filter'] == 'seeding' ? "AND x.active=1 AND x.Remaining=0" : "")); + $Snatched = $DB->to_array(); + shuffle($Snatched); // randomize results + while($ResultCount < TORRENTS_PER_PAGE && count($Snatched) > 0) { + // we throw TORRENTS_PER_PAGE results into Sphinx until we have at least TORRENTS_PER_PAGE results (or no snatches left) + $SnatchedTmp = array_slice($Snatched, 0, TORRENTS_PER_PAGE); + $Snatched = array_slice($Snatched, TORRENTS_PER_PAGE); + + $SphQL = transcode_init_sphql(); + $SphQL->where('groupid', array_map(function ($row) { return $row['GroupID']; }, $SnatchedTmp)); + + $SphQLResult = $SphQL->query(); + $ResultsTmp = $SphQLResult->collect('groupid'); + $GroupsTmp = Torrents::get_groups(array_values($ResultsTmp)); + $GroupsTmp = transcode_parse_groups($GroupsTmp['matches']); + // Since we're asking SphinxQL about groups and remidents, the result can/will contain different editions that are transcodable but weren't snatched, so let's filter them out + foreach($GroupsTmp as $GroupID => $Group) { + foreach($Group['Editions'] as $RemIdent => $Edition) { + $EditionSnatched = false; + foreach($SnatchedTmp as $SnatchedTmpE) { + if(isset($Edition['FlacIDs'][$SnatchedTmpE['fid']])) { + $EditionSnatched = true; + break; + } + } + if(!$EditionSnatched || count($Edition['MP3s']) == 3) { + unset($GroupsTmp[$GroupID]['Editions'][$RemIdent]); + } + } + $ResultCount += count($GroupsTmp[$GroupID]['Editions']); + if(count($GroupsTmp[$GroupID]['Editions']) == 0) { + unset($GroupsTmp[$GroupID]); + } + } + $Groups = $GroupsTmp + $Groups; + unset($SnatchedTmp, $SphQL, $SphQLResult, $ResultsTmp, $GroupsTmp); + } +} +$Debug->log_var($Groups, 'Groups'); + +$Counter = array( + 'total' => 0, //how many FLAC torrents can be transcoded? + 'miss_total' => 0, //how many transcodes are missing? + 'miss_V0 (VBR)' => 0, //how many V0 transcodes are missing? + 'miss_V2 (VBR)' => 0, //how many V2 transcodes are missing? + 'miss_320' => 0, //how many 320 transcodes are missing? +); +foreach($Groups as $GroupID => $Group) { + foreach($Group['Editions'] as $RemIdent => $Edition) { + if (count($Edition['FlacIDs']) == 0 //no FLAC in this group + || (!empty($Edition['MP3s']) && $_GET['target'] == 'all') //at least one transcode present when we only wanted groups containing no transcodes at all + || isset($Edition['MP3s'][$Encodings[$_GET['target']]]) //the transcode we asked for is already there + || count($Edition['MP3s']) == 3) //all 3 transcodes are there already (this can happen due to the caching of Sphinx's better_transcode table) + { + $Debug->log_var($Edition, 'Skipping '.$RemIdent); + unset($Groups[$GroupID]['Editions'][$RemIdent]); + continue; + } + $edition_miss = 0; //number of transcodes missing in this edition + foreach($Encodings as $Encoding) { + if(!isset($Edition['MP3s'][$Encoding])) { + ++$edition_miss; + ++$Counter['miss_'.$Encoding]; + } + } + $Counter['miss_total'] += $edition_miss; + $Counter['total'] += (bool)$edition_miss; + } +} +$Debug->log_var($Counter, 'counter'); + +View::show_header('Transcode Search'); +?> +
+
+

Transcodes

+

Search

+
+ + + + + + + + + + + +
Filter + + +
Search + +
 
+
+

About

+
+

+ This page aims at listing random transcodable perfect FLACs matching the options you selected above, but there can be more or less matches on this page. The following numbers tell you something about the torrents currently listed below and can change if you reload.

+ + Number of perfect FLACs you can transcode:
+ Number of missing transcodes:
+ Number of missing V2 / V0 / 320 transcodes: / / +

+
+

List

+ + + + + + + + + + $Group) { + $GroupYear = $Group['Year']; + $ExtendedArtists = $Group['ExtendedArtists']; + $GroupName = $Group['Name']; + $ReleaseType = $Group['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 = ''; + } + + $TorrentTags = new Tags($Group['TagList']); + + foreach ($Group['Editions'] as $RemIdent => $Edition) { + // TODO: point to the correct FLAC (?) + $FlacID = array_search(true, $Edition['FlacIDs']); + $DisplayName = $ArtistNames . ''.$GroupName.''; + if($GroupYear > 0) { + $DisplayName .= " [".$GroupYear."]"; + } + if ($ReleaseType > 0) { + $DisplayName .= " [".$ReleaseTypes[$ReleaseType]."]"; + } + if ($Edition['FLACIsSnatched']) { + $DisplayName .= ' ' . Format::torrent_label('Snatched!'); + } +?> + > + + + + + + +
TorrentV2V0320
No results found!
+ + DL + + +
+
format('better.php?action=transcode&tags=')?>
+
YES' : 'class="important_text">NO'?>YES' : 'class="important_text">NO'?>YES' : 'class="important_text">NO'?>
+
+ diff --git a/sections/collages/collage.php b/sections/collages/collage.php index d8e2950f..d607eb76 100644 --- a/sections/collages/collage.php +++ b/sections/collages/collage.php @@ -94,7 +94,7 @@ function compare($X, $Y){ $NumGroups = 0; $NumGroupsByUser = 0; -$Artists = array(); +$TopArtists = array(); $Users = array(); $Number = 0; @@ -117,13 +117,12 @@ function compare($X, $Y){ $CountArtists = $GroupArtists; } - if($CountArtists) { + if ($CountArtists) { foreach($CountArtists as $Artist) { - if(!isset($Artists[$Artist['id']])) { - $Artists[$Artist['id']] = array('name'=>$Artist['name'], 'count'=>1); - } else { - $Artists[$Artist['id']]['count']++; - } + if (!isset($TopArtists[$Artist['id']])) + $TopArtists[$Artist['id']] = array('name'=>$Artist['name'], 'count'=>1); + else + $TopArtists[$Artist['id']]['count']++; } } @@ -455,8 +454,8 @@ function compare($X, $Y){
Stats
@@ -471,15 +470,15 @@ function compare($X, $Y){ - +
Top artists
    $Artist) { +foreach ($TopArtists as $ID => $Artist) { $i++; if($i>10) { break; } ?>