From f8e7bd8c44c63da6a2c6c45ab1c6b3c9a1033465 Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 13 Oct 2023 03:12:24 +0300 Subject: [PATCH] update announce trackers list --- src/Controller/TorrentController.php | 21 +++++++++++++-- templates/default/torrent/info.html.twig | 33 +++++++++++------------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php index c01bed0..5885f14 100644 --- a/src/Controller/TorrentController.php +++ b/src/Controller/TorrentController.php @@ -72,6 +72,23 @@ class TorrentController extends AbstractController $user->getEvents() ); + // Create trackers list + $appTrackers = explode('|', $this->getParameter('app.trackers')); + $allTrackers = []; + + foreach ($appTrackers as $tracker) + { + $allTrackers[$tracker] = true; + } + + foreach ($file->getAnnounceList() as $announce) + { + foreach ($announce as $tracker) + { + $allTrackers[$tracker] = $user->isYggdrasil() && !in_array($tracker, $appTrackers); + } + } + // Init page $page = $request->get('page') ? (int) $request->get('page') : 1; @@ -145,14 +162,14 @@ class TorrentController extends AbstractController 'source' => $file->getSource(), 'comment' => $file->getComment(), 'tree' => $file->getFileTree(), - 'trackers' => $file->getAnnounceList(), + //'trackers' => $file->getAnnounceList(), 'hash' => [ 'v1' => $file->getInfoHashV1(false), 'v2' => $file->getInfoHashV2(false) ], ], - 'trackers' => explode('|', $this->getParameter('app.trackers')), + 'trackers' => $allTrackers, 'activities' => $activityService->findLastActivitiesByTorrentId( $torrent->getId(), $user->getEvents(), diff --git a/templates/default/torrent/info.html.twig b/templates/default/torrent/info.html.twig index 5ed04ce..1aa7873 100644 --- a/templates/default/torrent/info.html.twig +++ b/templates/default/torrent/info.html.twig @@ -107,7 +107,7 @@
- {{ 'Common' | trans }} + {{ 'Common' | trans }}
@@ -283,25 +283,22 @@
{{ 'Trackers' | trans }}
-
- {% for tracker in trackers %} +
+ {% for tracker, status in trackers %}
- {{ tracker }} -
- {% endfor %} - {% for announces in trackers %} - {% for tracker in announces %} -
- {% if tracker not in trackers %} + {% if status %} + {{ tracker }} + {% else %} + {{ tracker }} - - - - - - {% endif %} -
- {% endfor %} + + + + + + + {% endif %} +
{% endfor %}