50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Twig\Extensions;
|
|
|
|
use App\Monitor\Framework\Entity\Monitor;
|
|
use Twig\Attribute\AsTwigFilter;
|
|
|
|
class MonitorExtension
|
|
{
|
|
#[AsTwigFilter('monitor_type')]
|
|
public function type(string $type)
|
|
{
|
|
$types = [
|
|
'tvshows' => 'Show',
|
|
'tvseason' => 'Season',
|
|
'tvepisode' => 'Episode',
|
|
];
|
|
|
|
return $types[$type] ?? '-';
|
|
}
|
|
|
|
#[AsTwigFilter('as_download_type')]
|
|
public function monitorTypeToDownloadType(string $type)
|
|
{
|
|
$types = [
|
|
'tvshows' => 'tvshows',
|
|
'tvseason' => 'tvshows',
|
|
'tvepisode' => 'tvshows',
|
|
'movie' => 'movies',
|
|
];
|
|
|
|
return $types[$type] ?? '-';
|
|
}
|
|
|
|
#[AsTwigFilter('monitor_media_id')]
|
|
public function mediaId(Monitor $monitor)
|
|
{
|
|
if ($monitor->getMonitorType() === "tvseason") {
|
|
return "S". str_pad($monitor->getSeason(), 2, "0", STR_PAD_LEFT);
|
|
}
|
|
|
|
if ($monitor->getMonitorType() === "tvepisode") {
|
|
return "S". str_pad($monitor->getSeason(), 2, "0", STR_PAD_LEFT) .
|
|
"E". str_pad($monitor->getEpisode(), 2, "0", STR_PAD_LEFT);
|
|
}
|
|
|
|
return "-";
|
|
}
|
|
}
|