From 60503becdfb5fd8035517c9620b7c21ee1e5fb62 Mon Sep 17 00:00:00 2001 From: ghost Date: Sat, 14 Oct 2023 19:49:19 +0300 Subject: [PATCH] add info hash to torrent keywords index --- src/Service/TorrentService.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Service/TorrentService.php b/src/Service/TorrentService.php index d37bedb..0ba4e10 100644 --- a/src/Service/TorrentService.php +++ b/src/Service/TorrentService.php @@ -154,7 +154,9 @@ class TorrentService { $keywords = []; - foreach ($this->readTorrentFileByFilepath($filepath)->getFileList() as $file) + $file = $this->readTorrentFileByFilepath($filepath); + + foreach ($file->getFileList() as $file) { $words = explode( ' ', @@ -182,6 +184,16 @@ class TorrentService } } + if ($hash = $file->getInfoHashV1(false)) + { + $keywords[] = $hash; + } + + if ($hash = $file->getInfoHashV2(false)) + { + $keywords[] = $hash; + } + $keywords = array_merge($keywords, $words); }