mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-22 12:44:25 +00:00
fix cyrilic keywords extraction, add reindex all torrents toolkit
This commit is contained in:
parent
e5855d06b5
commit
06dd75eb1e
@ -134,11 +134,11 @@ class TorrentService
|
||||
}
|
||||
|
||||
public function readTorrentFileByTorrentId(
|
||||
int $id
|
||||
int $torrentId
|
||||
): ?\Rhilip\Bencode\TorrentFile
|
||||
{
|
||||
return $this->readTorrentFileByFilepath(
|
||||
$this->getStorageFilepathById($id)
|
||||
$this->getStorageFilepathByTorrentId($torrentId)
|
||||
);
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ class TorrentService
|
||||
'/[\s]+/',
|
||||
' ',
|
||||
preg_replace(
|
||||
'/[\W]+/',
|
||||
'/[\W_]+/u',
|
||||
' ',
|
||||
$list['path']
|
||||
)
|
||||
@ -196,12 +196,12 @@ class TorrentService
|
||||
return array_unique($keywords);
|
||||
}
|
||||
|
||||
public function getStorageFilepathById(int $id): string
|
||||
public function getStorageFilepathByTorrentId(int $torrentId): string
|
||||
{
|
||||
return sprintf(
|
||||
'%s/var/torrents/%s.torrent',
|
||||
$this->kernelInterface->getProjectDir(),
|
||||
implode('/', str_split($id))
|
||||
implode('/', str_split($torrentId))
|
||||
);
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ class TorrentService
|
||||
$filesystem = new Filesystem();
|
||||
$filesystem->copy(
|
||||
$filepath,
|
||||
$this->getStorageFilepathById(
|
||||
$this->getStorageFilepathByTorrentId(
|
||||
$torrent->getId()
|
||||
)
|
||||
);
|
||||
@ -445,6 +445,25 @@ class TorrentService
|
||||
}
|
||||
}
|
||||
|
||||
public function reindexTorrentKeywordsAll(): void
|
||||
{
|
||||
foreach ($this->entityManagerInterface
|
||||
->getRepository(Torrent::class)
|
||||
->findAll() as $torrent)
|
||||
{
|
||||
$torrent->setKeywords(
|
||||
$this->generateTorrentKeywordsByTorrentFilepath(
|
||||
$this->getStorageFilepathByTorrentId(
|
||||
$torrent->getId()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($torrent);
|
||||
$this->entityManagerInterface->flush();
|
||||
}
|
||||
}
|
||||
|
||||
public function setTorrentApprovedByTorrentId(
|
||||
int $torrentId,
|
||||
bool $value
|
||||
|
Loading…
x
Reference in New Issue
Block a user