diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php
index c75df27..2938c68 100644
--- a/src/Controller/TorrentController.php
+++ b/src/Controller/TorrentController.php
@@ -1874,6 +1874,126 @@ class TorrentController extends AbstractController
return $response->setContent($data);
}
+ // Torrent download wanted file
+ #[Route(
+ '/torrent/{torrentId}/file/wanted',
+ name: 'torrent_file_wanted',
+ requirements:
+ [
+ 'torrentId' => '\d+'
+ ],
+ methods:
+ [
+ 'GET'
+ ]
+ )]
+ public function downloadFileWanted(
+ Request $request,
+ TranslatorInterface $translator,
+ UserService $userService,
+ TorrentService $torrentService,
+ ActivityService $activityService
+ ): Response
+ {
+ // Init user
+ $user = $this->initUser(
+ $request,
+ $userService,
+ $activityService
+ );
+
+ if (!$user->isStatus())
+ {
+ // @TODO
+ throw new \Exception(
+ $translator->trans('Access denied')
+ );
+ }
+
+ // Block crawler requests
+ if (in_array($request->getClientIp(), explode('|', $this->getParameter('app.crawlers'))))
+ {
+ throw $this->createNotFoundException();
+ }
+
+ // Init torrent
+ if (!$torrent = $torrentService->getTorrent($request->get('torrentId')))
+ {
+ throw $this->createNotFoundException();
+ }
+
+ if (!$file = $torrentService->readTorrentFileByTorrentId($torrent->getId()))
+ {
+ throw $this->createNotFoundException();
+ }
+
+ // Sensitive filter
+ if (!$user->isModerator() && $user->getId() != $torrent->getUserId() && $user->isSensitive())
+ {
+ throw $this->createNotFoundException();
+ }
+
+ // Approved filter
+ if (!$user->isModerator() && $user->getId() != $torrent->getUserId() && !$torrent->isApproved())
+ {
+ throw $this->createNotFoundException();
+ }
+
+ // Register download
+ $torrentService->addTorrentDownloadFile(
+ $torrent->getId(),
+ $user->getId(),
+ time()
+ );
+
+ // Register download event
+ $activityService->addEventTorrentDownloadFileAdd(
+ $user->getId(),
+ time(),
+ $torrent->getId()
+ );
+
+ // Apply filters
+ $file = $this->filterYggdrasil(
+ $file,
+ false // wanted file downloading with original trackers
+ );
+
+ // Get data
+ $data = $file->dumpToString();
+
+ // Set headers
+ $response = new Response();
+
+ $response->headers->set(
+ 'Content-type',
+ 'application/x-bittorrent'
+ );
+
+ $response->headers->set(
+ 'Content-length',
+ strlen($data)
+ );
+
+ $response->headers->set(
+ 'Content-Disposition',
+ sprintf(
+ 'attachment; filename="%s.wanted.%s.torrent";',
+ mb_strtolower(
+ $this->getParameter('app.name')
+ ),
+ mb_strtolower(
+ $file->getName()
+ )
+ )
+ );
+
+ $response->sendHeaders();
+
+ // Return file content
+ return $response->setContent($data);
+ }
+
// Torrent download magnet
#[Route(
'/torrent/{torrentId}/magnet',
diff --git a/templates/default/torrent/list.html.twig b/templates/default/torrent/list.html.twig
index 909e0ee..b16b13a 100644
--- a/templates/default/torrent/list.html.twig
+++ b/templates/default/torrent/list.html.twig
@@ -33,10 +33,11 @@
{% if torrent.scrape.leechers > 0 and torrent.scrape.seeders == 0 %}
-
+
{{ 'wanted' | trans }}
-
+
{% endif %}
{% if torrent.approved == false %}