draft torrent info page with related features #11

This commit is contained in:
ghost 2023-10-07 01:27:11 +03:00
parent 21ffd8aa01
commit 387acb59b6
7 changed files with 349 additions and 5 deletions

View file

@ -29,6 +29,19 @@ class TorrentService
$this->entityManagerInterface = $entityManagerInterface;
}
public function decodeTorrentById(int $id): array
{
$decoder = new \BitTorrent\Decoder();
return $decoder->decodeFile(
sprintf(
'%s/var/torrents/%s.torrent',
$this->kernelInterface->getProjectDir(),
implode('/', str_split($id))
)
);
}
public function decodeTorrentByFilepath(string $filepath): array
{
$decoder = new \BitTorrent\Decoder();
@ -70,6 +83,13 @@ class TorrentService
return '';
}
public function getTorrent(int $id): ?Torrent
{
return $this->entityManagerInterface
->getRepository(Torrent::class)
->findOneByIdField($id);
}
public function submit(
string $filepath,
int $userId,