mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-03-31 17:15:38 +00:00
replace bencode library to rhilip/bencode, fix files tree builder #11
This commit is contained in:
parent
387acb59b6
commit
86e1455c6b
9 changed files with 175 additions and 130 deletions
|
|
@ -189,7 +189,7 @@ class PageController extends AbstractController
|
|||
continue;
|
||||
}
|
||||
|
||||
if (empty($torrentService->getTorrentFilenameByFilepath($file->getPathName())))
|
||||
if (empty($torrentService->getTorrentInfoNameByFilepath($file->getPathName())))
|
||||
{
|
||||
$form['torrent']['error'][] = $translator->trans('Could not parse torrent file');
|
||||
|
||||
|
|
|
|||
|
|
@ -40,28 +40,63 @@ class TorrentController extends AbstractController
|
|||
$request->getClientIp()
|
||||
);
|
||||
|
||||
// Init torrent
|
||||
if (!$torrent = $torrentService->getTorrent($request->get('id')))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Init file
|
||||
try
|
||||
{
|
||||
$file = \Rhilip\Bencode\TorrentFile::load(
|
||||
$torrentService->getStoragePathById(
|
||||
$torrent->getId()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
catch (ParseException $e)
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
/*
|
||||
if (!$torrent = $torrentService->getTorrentLocales($request->get('id')))
|
||||
{
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
*/
|
||||
|
||||
//print_r($file->getFileTree());exit;
|
||||
return $this->render('default/torrent/info.html.twig', [
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $torrent->getId(),
|
||||
'added' => 0, // @TODO
|
||||
'locales' => [], //$torrent->getLocales(),
|
||||
'pages' => []
|
||||
],
|
||||
'file' => $torrentService->decodeTorrentById(
|
||||
$torrent->getId()
|
||||
),
|
||||
'file' =>
|
||||
[
|
||||
'name' => $file->getName(),
|
||||
'size' => $file->getSize(),
|
||||
'count' => $file->getFileCount(),
|
||||
'pieces' => $file->getPieceLength(),
|
||||
'created' => $file->getCreationDate(),
|
||||
'software' => $file->getCreatedBy(),
|
||||
'protocol' => $file->getProtocol(),
|
||||
'private' => $file->isPrivate(),
|
||||
'source' => $file->getSource(),
|
||||
'comment' => $file->getComment(),
|
||||
'tree' => $file->getFileTree(),
|
||||
'trackers' => $file->getAnnounceList(),
|
||||
'hash' =>
|
||||
[
|
||||
'v1' => $file->getInfoHashV1(false),
|
||||
'v2' => $file->getInfoHashV2(false)
|
||||
],
|
||||
'magnet' => $file->getMagnetLink()
|
||||
],
|
||||
'trackers' => explode('|', $this->getParameter('app.trackers')),
|
||||
]);
|
||||
}
|
||||
|
|
@ -158,7 +193,7 @@ class TorrentController extends AbstractController
|
|||
$form['torrent']['error'][] = $translator->trans('Torrent file out of size limit');
|
||||
}
|
||||
|
||||
if (empty($torrentService->getTorrentFilenameByFilepath($file->getPathName())))
|
||||
if (empty($torrentService->getTorrentInfoNameByFilepath($file->getPathName())))
|
||||
{
|
||||
$form['torrent']['error'][] = $translator->trans('Could not parse torrent file');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue