mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-10 15:07:53 +00:00
fix announcement generation for wanted torrents #27
This commit is contained in:
parent
0d96cd3e3a
commit
b4c6a98d49
@ -2418,25 +2418,40 @@ class TorrentController extends AbstractController
|
|||||||
?\Rhilip\Bencode\TorrentFile $file, bool $yggdrasil, string $regex = '/^0{0,1}[2-3][a-f0-9]{0,2}:/'
|
?\Rhilip\Bencode\TorrentFile $file, bool $yggdrasil, string $regex = '/^0{0,1}[2-3][a-f0-9]{0,2}:/'
|
||||||
): ?\Rhilip\Bencode\TorrentFile
|
): ?\Rhilip\Bencode\TorrentFile
|
||||||
{
|
{
|
||||||
|
// Init trackers registry
|
||||||
|
$allTrackers = [];
|
||||||
|
|
||||||
// Get app trackers
|
// Get app trackers
|
||||||
$appTrackers = explode('|', $this->getParameter('app.trackers'));
|
$appTrackers = explode('|', $this->getParameter('app.trackers'));
|
||||||
|
|
||||||
// Get original file announcements
|
|
||||||
$announceList = $file->getAnnounceList();
|
|
||||||
|
|
||||||
// Append app trackers
|
// Append app trackers
|
||||||
foreach ($appTrackers as $appTracker)
|
foreach ($appTrackers as $appTracker)
|
||||||
{
|
{
|
||||||
// Append application trackers
|
$allTrackers[] = $appTracker;
|
||||||
$announceList[0][] = $appTracker;
|
|
||||||
|
|
||||||
// Append application re-trackers
|
|
||||||
$announceList[1][] = $appTracker;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicated
|
// Get original file announcements
|
||||||
$announceList[0] = array_unique($announceList[0]);
|
$announceList = $file->getAnnounceList();
|
||||||
$announceList[1] = array_unique($announceList[1]);
|
|
||||||
|
// Append original file announcements
|
||||||
|
foreach ($announceList as $announce)
|
||||||
|
{
|
||||||
|
if (is_array($announce))
|
||||||
|
{
|
||||||
|
foreach ($announce as $value)
|
||||||
|
{
|
||||||
|
$allTrackers[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$allTrackers[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove duplicates
|
||||||
|
$allTrackers = array_unique($allTrackers);
|
||||||
|
|
||||||
// Yggdrasil-only mode
|
// Yggdrasil-only mode
|
||||||
if ($yggdrasil)
|
if ($yggdrasil)
|
||||||
@ -2450,45 +2465,20 @@ class TorrentController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove non-Yggdrasil trackers from announcement list
|
// Remove non-Yggdrasil trackers from announcement list
|
||||||
foreach ($announceList[0] as $key => $value)
|
foreach ($allTrackers as $key => $value)
|
||||||
{
|
{
|
||||||
// trackers
|
// trackers
|
||||||
if (!preg_match($regex, str_replace(['[',']'], false, parse_url($value, PHP_URL_HOST))))
|
if (!preg_match($regex, str_replace(['[',']'], false, parse_url($value, PHP_URL_HOST))))
|
||||||
{
|
{
|
||||||
unset($announceList[0][$key]);
|
unset($allTrackers[$key]);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove non-Yggdrasil re-trackers from announcement list
|
|
||||||
foreach ($announceList[1] as $key => $value)
|
|
||||||
{
|
|
||||||
// trackers
|
|
||||||
if (!preg_match($regex, str_replace(['[',']'], false, parse_url($value, PHP_URL_HOST))))
|
|
||||||
{
|
|
||||||
unset($announceList[1][$key]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicates in list
|
|
||||||
$values = [];
|
|
||||||
|
|
||||||
foreach ($announceList[0] as $value)
|
|
||||||
{
|
|
||||||
$values[] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($announceList[1] as $value)
|
|
||||||
{
|
|
||||||
$values[] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
$values = array_unique($values);
|
|
||||||
|
|
||||||
// Format announce list
|
// Format announce list
|
||||||
$trackers = [];
|
$trackers = [];
|
||||||
|
|
||||||
foreach ($values as $value)
|
foreach ($allTrackers as $value)
|
||||||
{
|
{
|
||||||
$trackers[] = [$value];
|
$trackers[] = [$value];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user