diff --git a/src/Download/Framework/Entity/Download.php b/src/Download/Framework/Entity/Download.php index 73b6317..7c80dbc 100644 --- a/src/Download/Framework/Entity/Download.php +++ b/src/Download/Framework/Entity/Download.php @@ -3,8 +3,11 @@ namespace App\Download\Framework\Entity; use App\Download\Framework\Repository\DownloadRepository; +use App\Torrentio\Result\ResultFactory; +use App\Torrentio\Result\TorrentioResult; use App\User\Framework\Entity\User; use Doctrine\ORM\Mapping as ORM; +use Nihilarr\PTN; use Symfony\UX\Turbo\Attribute\Broadcast; #[ORM\Entity(repositoryClass: DownloadRepository::class)] @@ -162,4 +165,16 @@ class Download return $this; } + + public function getPtn(): object + { + $ptn = (object) (new PTN())->parse($this->filename); + + if ($this->mediaType === "tvshows") { + $ptn->season = str_pad($ptn->season, 2, "0", STR_PAD_LEFT); + $ptn->episode = str_pad($ptn->episode, 2, "0", STR_PAD_LEFT); + } + + return $ptn; + } } diff --git a/templates/components/DownloadListRow.html.twig b/templates/components/DownloadListRow.html.twig index 16d538e..b4661c5 100644 --- a/templates/components/DownloadListRow.html.twig +++ b/templates/components/DownloadListRow.html.twig @@ -1,6 +1,10 @@ {{ download.title }} + + {% if download.mediaType == "tvshows" %} + (S{{ download.ptn.season }}E{{ download.ptn.episode }}) + {% endif %} {% if isWidget == false %}