|
|
@ -707,21 +707,65 @@ class TorrentController extends AbstractController |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// Init request |
|
|
|
// Init request |
|
|
|
$query = $request->get('query') ? explode(' ', urldecode($request->get('query'))) : []; |
|
|
|
$query = $request->get('query') ? |
|
|
|
$page = $request->get('page') ? (int) $request->get('page') : 1; |
|
|
|
explode(' ', urldecode($request->get('query'))) : []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$page = $request->get('page') ? |
|
|
|
|
|
|
|
(int) $request->get('page') : 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$filter = $request->get('filter') ? |
|
|
|
|
|
|
|
true : false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($request->get('locales')) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$locales = explode('|', $request->get('locales')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$locales = $user->getLocales(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($request->get('categories')) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$categories = explode('|', $request->get('categories')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$locales = $request->get('locales') ? explode('|', $request->get('locales')) : explode('|', $this->getParameter('app.locales')); |
|
|
|
else |
|
|
|
$categories = $request->get('categories') ? explode('|', $request->get('categories')) : explode('|', $this->getParameter('app.categories')); |
|
|
|
{ |
|
|
|
$sensitive = $request->get('sensitive') ? (bool) $request->get('sensitive') : null; |
|
|
|
$categories = $user->getCategories(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch ($request->get('sensitive')) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case 'true': |
|
|
|
|
|
|
|
$sensitive = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'false': |
|
|
|
|
|
|
|
$sensitive = false; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
$sensitive = $user->isSensitive() ? false : null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$yggdrasil = $request->get('yggdrasil') ? (bool) $request->get('yggdrasil') : false; |
|
|
|
switch ($request->get('yggdrasil')) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case 'true': |
|
|
|
|
|
|
|
$yggdrasil = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'false': |
|
|
|
|
|
|
|
$yggdrasil = false; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
$yggdrasil = $user->isYggdrasil(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Init trackers |
|
|
|
// Init trackers |
|
|
|
$trackers = explode('|', $this->getParameter('app.trackers')); |
|
|
|
$trackers = explode('|', $this->getParameter('app.trackers')); |
|
|
|
|
|
|
|
|
|
|
|
// Get total torrents |
|
|
|
// Get total torrents |
|
|
|
$total = $torrentService->findTorrentsTotal( |
|
|
|
$total = $torrentService->findTorrentsTotal( |
|
|
|
$user->getId(), |
|
|
|
$filter ? 0 : $user->getId(), |
|
|
|
$query, |
|
|
|
$query, |
|
|
|
$locales, |
|
|
|
$locales, |
|
|
|
$categories, |
|
|
|
$categories, |
|
|
@ -733,7 +777,7 @@ class TorrentController extends AbstractController |
|
|
|
// Create torrents list |
|
|
|
// Create torrents list |
|
|
|
$torrents = []; |
|
|
|
$torrents = []; |
|
|
|
foreach ($torrentService->findTorrents( |
|
|
|
foreach ($torrentService->findTorrents( |
|
|
|
$user->getId(), |
|
|
|
$filter ? 0 : $user->getId(), |
|
|
|
$query, |
|
|
|
$query, |
|
|
|
$locales, |
|
|
|
$locales, |
|
|
|
$categories, |
|
|
|
$categories, |
|
|
@ -753,20 +797,6 @@ class TorrentController extends AbstractController |
|
|
|
// Apply yggdrasil filters |
|
|
|
// Apply yggdrasil filters |
|
|
|
$file = $this->filterYggdrasil($file, $yggdrasil); |
|
|
|
$file = $this->filterYggdrasil($file, $yggdrasil); |
|
|
|
|
|
|
|
|
|
|
|
// Generate url |
|
|
|
|
|
|
|
$url = []; |
|
|
|
|
|
|
|
foreach ($locales as $locale) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$url[$locale] = $this->generateUrl( |
|
|
|
|
|
|
|
'torrent_info', |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
'_locale' => $locale, |
|
|
|
|
|
|
|
'torrentId' => $torrent->getId(), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$torrents[] = |
|
|
|
$torrents[] = |
|
|
|
[ |
|
|
|
[ |
|
|
|
'torrent' => |
|
|
|
'torrent' => |
|
|
@ -774,6 +804,7 @@ class TorrentController extends AbstractController |
|
|
|
'id' => $torrent->getId(), |
|
|
|
'id' => $torrent->getId(), |
|
|
|
'added' => $torrent->getAdded(), |
|
|
|
'added' => $torrent->getAdded(), |
|
|
|
'locales' => $torrent->getLocales(), |
|
|
|
'locales' => $torrent->getLocales(), |
|
|
|
|
|
|
|
'categories' => $torrent->getCategories(), |
|
|
|
'sensitive' => $torrent->isSensitive(), |
|
|
|
'sensitive' => $torrent->isSensitive(), |
|
|
|
'file' => |
|
|
|
'file' => |
|
|
|
[ |
|
|
|
[ |
|
|
@ -796,7 +827,7 @@ class TorrentController extends AbstractController |
|
|
|
], |
|
|
|
], |
|
|
|
false |
|
|
|
false |
|
|
|
), |
|
|
|
), |
|
|
|
'urn' => $file->getMagnetLink() |
|
|
|
//'urn' => $file->getMagnetLink() |
|
|
|
], |
|
|
|
], |
|
|
|
'scrape' => |
|
|
|
'scrape' => |
|
|
|
[ |
|
|
|
[ |
|
|
@ -804,21 +835,16 @@ class TorrentController extends AbstractController |
|
|
|
'peers' => (int) $torrent->getPeers(), |
|
|
|
'peers' => (int) $torrent->getPeers(), |
|
|
|
'leechers' => (int) $torrent->getLeechers(), |
|
|
|
'leechers' => (int) $torrent->getLeechers(), |
|
|
|
], |
|
|
|
], |
|
|
|
'url' => $url |
|
|
|
'url' => $this->generateUrl( |
|
|
|
], |
|
|
|
'torrent_info', |
|
|
|
]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$url = []; |
|
|
|
|
|
|
|
foreach ($locales as $locale) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$url[$locale] = $this->generateUrl( |
|
|
|
|
|
|
|
'torrent_recent', |
|
|
|
|
|
|
|
[ |
|
|
|
[ |
|
|
|
'_locale' => $locale |
|
|
|
'_locale' => $user->getLocale(), |
|
|
|
|
|
|
|
'torrentId' => $torrent->getId(), |
|
|
|
], |
|
|
|
], |
|
|
|
false |
|
|
|
false |
|
|
|
); |
|
|
|
) |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $this->json( |
|
|
|
return $this->json( |
|
|
@ -828,7 +854,13 @@ class TorrentController extends AbstractController |
|
|
|
[ |
|
|
|
[ |
|
|
|
'name' => $this->getParameter('app.name'), |
|
|
|
'name' => $this->getParameter('app.name'), |
|
|
|
'version' => $this->getParameter('app.version'), |
|
|
|
'version' => $this->getParameter('app.version'), |
|
|
|
'url' => $url |
|
|
|
'url' => $this->generateUrl( |
|
|
|
|
|
|
|
'torrent_recent', |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
'_locale' => $user->getLocale() |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
) |
|
|
|
], |
|
|
|
], |
|
|
|
'torrents' => $torrents |
|
|
|
'torrents' => $torrents |
|
|
|
] |
|
|
|
] |
|
|
|