Browse Source

generate keywords based on content extensions

main
ghost 1 year ago
parent
commit
bd7fe4cf04
  1. 29
      src/Controller/TorrentController.php

29
src/Controller/TorrentController.php

@ -249,6 +249,7 @@ class TorrentController extends AbstractController
} }
// Generate keywords // Generate keywords
/* @TODO deprecated, based on active search result
$keywords = []; $keywords = [];
foreach ($torrent->getKeywords() as $keyword) foreach ($torrent->getKeywords() as $keyword)
{ {
@ -257,7 +258,22 @@ class TorrentController extends AbstractController
$keywords[] = $keyword; $keywords[] = $keyword;
} }
} }
*/
// Generate keywords by extension
$keywords = [];
foreach ($file->getFileList() as $item)
{
if ($keyword = pathinfo($item['path'], PATHINFO_EXTENSION))
{
$keywords[] = mb_strtolower($keyword);
}
}
$keywords = array_unique($keywords);
sort($keywords);
// Push torrent
$torrents[] = $torrents[] =
[ [
'id' => $torrent->getId(), 'id' => $torrent->getId(),
@ -383,17 +399,20 @@ class TorrentController extends AbstractController
throw $this->createNotFoundException(); // @TODO exception throw $this->createNotFoundException(); // @TODO exception
} }
// Generate keywords // Generate keywords by extension
$keywords = []; $keywords = [];
$query = explode(' ', mb_strtolower(urldecode($request->query->get('query')))); foreach ($file->getFileList() as $item)
foreach ($torrent->getKeywords() as $keyword)
{ {
if (in_array($keyword, $query)) if ($keyword = pathinfo($item['path'], PATHINFO_EXTENSION))
{ {
$keywords[] = urlencode($keyword); $keywords[] = mb_strtolower($keyword);
} }
} }
$keywords = array_unique($keywords);
sort($keywords);
// Push torrent
$torrents[] = $torrents[] =
[ [
'id' => $torrent->getId(), 'id' => $torrent->getId(),

Loading…
Cancel
Save