mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-02-02 01:54:13 +00:00
generate keywords on file parsed only
This commit is contained in:
parent
e97c4ec27f
commit
68fbafaefa
@ -154,47 +154,48 @@ class TorrentService
|
|||||||
{
|
{
|
||||||
$keywords = [];
|
$keywords = [];
|
||||||
|
|
||||||
$file = $this->readTorrentFileByFilepath($filepath);
|
if ($file = $this->readTorrentFileByFilepath($filepath))
|
||||||
|
|
||||||
foreach ($file->getFileList() as $file)
|
|
||||||
{
|
{
|
||||||
$words = explode(
|
foreach ($file->getFileList() as $file)
|
||||||
' ',
|
{
|
||||||
preg_replace(
|
$words = explode(
|
||||||
'/[\s]+/',
|
|
||||||
' ',
|
' ',
|
||||||
preg_replace(
|
preg_replace(
|
||||||
'/[\W]+/',
|
'/[\s]+/',
|
||||||
' ',
|
' ',
|
||||||
$file['path']
|
preg_replace(
|
||||||
|
'/[\W]+/',
|
||||||
|
' ',
|
||||||
|
$file['path']
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($words as $key => $value)
|
foreach ($words as $key => $value)
|
||||||
{
|
|
||||||
if (mb_strlen($value) < $minLength)
|
|
||||||
{
|
{
|
||||||
unset($words[$key]);
|
if (mb_strlen($value) < $minLength)
|
||||||
|
{
|
||||||
|
unset($words[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$words[$key] = mb_strtolower($value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
if ($hash = $file->getInfoHashV1(false))
|
||||||
{
|
{
|
||||||
$words[$key] = mb_strtolower($value);
|
$keywords[] = $hash;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($hash = $file->getInfoHashV1(false))
|
if ($hash = $file->getInfoHashV2(false))
|
||||||
{
|
{
|
||||||
$keywords[] = $hash;
|
$keywords[] = $hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($hash = $file->getInfoHashV2(false))
|
$keywords = array_merge($keywords, $words);
|
||||||
{
|
|
||||||
$keywords[] = $hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$keywords = array_merge($keywords, $words);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_unique($keywords);
|
return array_unique($keywords);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user