137 lines
3.5 KiB
PHP
Executable file
137 lines
3.5 KiB
PHP
Executable file
<?php
|
|
|
|
include "common.php";
|
|
|
|
use Animarr\Release\Release;
|
|
|
|
$aid = 0;
|
|
|
|
if(isset($_GET["aid"])){
|
|
$aid = intval($_GET["aid"]);
|
|
}
|
|
|
|
$info = $aniDB->getAnime($aid);
|
|
if($info === null){
|
|
header("Location: index.php");
|
|
die();
|
|
}
|
|
|
|
|
|
$preferList = $database->getTrackGroups($aid);
|
|
|
|
|
|
if(isset($_GET["add"]) and !in_array($_GET["add"], $preferList)){
|
|
$preferList[] = $_GET["add"];
|
|
$database->saveTrackGroups($aid, $preferList);
|
|
}elseif(isset($_GET["del"]) and in_array($_GET["del"], $preferList)){
|
|
foreach($preferList as $k => $g){
|
|
if($g === $_GET["del"]){
|
|
unset($preferList[$k]);
|
|
}
|
|
}
|
|
$database->saveTrackGroups($aid, $preferList);
|
|
}
|
|
|
|
printHeader("Groups: " . $info["title"]);
|
|
|
|
echo "<h1>Groups: ".$info["title"]." [anidb-$aid]</h1>";
|
|
echo "<p>";
|
|
|
|
echo "<table class=\"table table-striped table-hover\">";
|
|
|
|
|
|
echo "<tr><th>Group</th><th>Release #</th><th>Best Source</th><th>Best Quality</th><th>Actions</th></tr>";
|
|
|
|
$groups = [];
|
|
|
|
foreach($database->getAnimeEpisodes($aid) as $r){
|
|
/** @var Release[] $r */
|
|
|
|
foreach($r as $episode => $release){
|
|
$group = $release->getGroup();
|
|
|
|
if(!isset($groups[$group])){
|
|
$groups[$group] = [
|
|
"name" => $group,
|
|
"trusted" => false,
|
|
"best" => false,
|
|
"releases" => 0,
|
|
"source" => Release::SOURCE_UNKNOWN,
|
|
"quality" => Release::QUALITY_UNKNOWN,
|
|
];
|
|
}
|
|
|
|
$groups[$group]["releases"]++;
|
|
if($release->getSource() > $groups[$group]["source"]){
|
|
$groups[$group]["source"] = $release->getSource();
|
|
}
|
|
|
|
if($release->getQuality() > $groups[$group]["quality"]){
|
|
$groups[$group]["quality"] = $release->getQuality();
|
|
}
|
|
|
|
if($release->isTrusted()){
|
|
$groups[$group]["trusted"] = true;
|
|
}
|
|
|
|
if($release->isBest()){
|
|
$groups[$group]["best"] = true;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
foreach($groups as $group){
|
|
if($group["name"] === "UNKNOWN" or $group["name"] == ""){
|
|
continue;
|
|
}
|
|
|
|
if($group["trusted"]){
|
|
$name = "<span class=\"label label-success\">".$group["name"]."</span>";
|
|
}else{
|
|
$name = "<span class=\"label label-default\">".$group["name"]."</span>";
|
|
}
|
|
|
|
|
|
$source = $group["source"];
|
|
if($source === Release::SOURCE_BLURAY){
|
|
$source = "<span class=\"label label-primary\">BLURAY</span>";
|
|
}elseif($source === Release::SOURCE_DVD){
|
|
$source = "<span class=\"label label-success\">DVD</span>";
|
|
}elseif($source === Release::SOURCE_LASERDISC){
|
|
$source = "<span class=\"label label-success\">LD</span>";
|
|
}elseif($source === Release::SOURCE_TV){
|
|
$source = "<span class=\"label label-info\">TV</span>";
|
|
}elseif($source === Release::SOURCE_WEB){
|
|
$source = "<span class=\"label label-default\">WEB</span>";
|
|
}else{
|
|
$source = "<span class=\"label label-default\">$source</span>";
|
|
}
|
|
|
|
$quality = $group["quality"];
|
|
if($quality === Release::QUALITY_1080){
|
|
$quality = "<span class=\"label label-primary\">1080p</span>";
|
|
}elseif($quality === Release::QUALITY_720){
|
|
$quality = "<span class=\"label label-success\">720p</span>";
|
|
}else{
|
|
$quality = "<span class=\"label label-default\">{$quality}p</span>";
|
|
}
|
|
|
|
$actions = "";
|
|
|
|
if(in_array($group["name"], $preferList)){
|
|
$actions .= '<a href="groups.php?aid='.$aid.'&del='.urlencode($group["name"]).'"><span class="glyphicon glyphicon-remove text-danger"></span></a>';
|
|
}else{
|
|
$actions .= '<a href="groups.php?aid='.$aid.'&add='.urlencode($group["name"]).'"><span class="glyphicon glyphicon-plus text-success"></span></a>';
|
|
}
|
|
|
|
echo "<tr class=\"".($group["best"] ? "info" : ($group["trusted"] ? "success" : ""))."\"><td>$name</td><td>".$group["releases"]."</td><td>$source</td><td>$quality</td><td>$actions</td></tr>";
|
|
|
|
}
|
|
|
|
echo "</table>";
|
|
|
|
echo "</p>";
|
|
|
|
printFooter();
|