mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-28 22:41:13 -05:00
Apply fixes from StyleCI
This commit is contained in:
@@ -39,8 +39,8 @@ use App\Services\TorrentTools;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Repositories\ChatRepository;
|
||||
use App\Notifications\NewReseedRequest;
|
||||
use Illuminate\Pagination\LengthAwarePaginator as Paginator;
|
||||
use App\Repositories\TorrentFacetedRepository;
|
||||
use Illuminate\Pagination\LengthAwarePaginator as Paginator;
|
||||
|
||||
class TorrentController extends Controller
|
||||
{
|
||||
@@ -82,7 +82,7 @@ class TorrentController extends Controller
|
||||
{
|
||||
$user = auth()->user();
|
||||
$personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first();
|
||||
$torrents = Torrent::with(['user', 'category'])->withCount(['thanks', 'comments'])->orderBy('created_at','desc')->paginate(25);
|
||||
$torrents = Torrent::with(['user', 'category'])->withCount(['thanks', 'comments'])->orderBy('created_at', 'desc')->paginate(25);
|
||||
$repository = $this->faceted;
|
||||
|
||||
return view('torrent.torrents', [
|
||||
@@ -112,7 +112,9 @@ class TorrentController extends Controller
|
||||
->latest()
|
||||
->get();
|
||||
|
||||
if(!$torrents || $torrents->count() < 1) { abort(404); }
|
||||
if (! $torrents || $torrents->count() < 1) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return view('torrent.similar', [
|
||||
'user' => $user,
|
||||
@@ -122,7 +124,6 @@ class TorrentController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Displays Torrent Cards View.
|
||||
*
|
||||
@@ -135,25 +136,26 @@ class TorrentController extends Controller
|
||||
$repository = $this->faceted;
|
||||
|
||||
$client = new \App\Services\MovieScrapper(config('api-keys.tmdb'), config('api-keys.tvdb'), config('api-keys.omdb'));
|
||||
foreach($torrents as $torrent) {
|
||||
foreach ($torrents as $torrent) {
|
||||
$movie = null;
|
||||
if ($torrent->category_id == 2) {
|
||||
if ($torrent->tmdb || $torrent->tmdb != 0) {
|
||||
$movie = $client->scrape('tv', null, $torrent->tmdb);
|
||||
} else if ($torrent->imdb && $torrent->imdb != 0) {
|
||||
$movie = $client->scrape('tv', 'tt' . $torrent->imdb);
|
||||
} elseif ($torrent->imdb && $torrent->imdb != 0) {
|
||||
$movie = $client->scrape('tv', 'tt'.$torrent->imdb);
|
||||
}
|
||||
} else {
|
||||
if ($torrent->tmdb || $torrent->tmdb != 0) {
|
||||
$movie = $client->scrape('movie', null, $torrent->tmdb);
|
||||
} else if ($torrent->imdb && $torrent->imdb != 0) {
|
||||
$movie = $client->scrape('movie', 'tt' . $torrent->imdb);
|
||||
} elseif ($torrent->imdb && $torrent->imdb != 0) {
|
||||
$movie = $client->scrape('movie', 'tt'.$torrent->imdb);
|
||||
}
|
||||
}
|
||||
if($movie) {
|
||||
if ($movie) {
|
||||
$torrent->movie = $movie;
|
||||
}
|
||||
}
|
||||
|
||||
return view('torrent.cards', [
|
||||
'user' => $user,
|
||||
'torrents' => $torrents,
|
||||
@@ -175,55 +177,62 @@ class TorrentController extends Controller
|
||||
$page = 0;
|
||||
$sorting = 'created_at';
|
||||
$direction = 2;
|
||||
$order = "desc";
|
||||
$order = 'desc';
|
||||
$qty = 25;
|
||||
$logger = null;
|
||||
$cache=array();
|
||||
$attributes=array();
|
||||
$cache = [];
|
||||
$attributes = [];
|
||||
|
||||
$torrent = Torrent::orderBy('sticky', 'desc')->orderBy($sorting, $order);
|
||||
$prelauncher = $torrent->pluck('imdb')->map(function ($imdb) {
|
||||
$dupes = array();
|
||||
if(in_array($imdb,$dupes)) return false;
|
||||
array_push($dupes,$imdb);
|
||||
$dupes = [];
|
||||
if (in_array($imdb, $dupes)) {
|
||||
return false;
|
||||
}
|
||||
array_push($dupes, $imdb);
|
||||
|
||||
return $imdb;
|
||||
})->toArray();
|
||||
|
||||
if(!is_array($prelauncher)) { $prelauncher=array(); }
|
||||
$links = new Paginator(array(), count($prelauncher), $qty);
|
||||
if (! is_array($prelauncher)) {
|
||||
$prelauncher = [];
|
||||
}
|
||||
$links = new Paginator([], count($prelauncher), $qty);
|
||||
|
||||
$hungry = array_chunk($prelauncher,$qty);
|
||||
if(is_array($hungry) && array_key_exists($page,$hungry)) { $fed=$hungry[$page]; }
|
||||
$totals=array();
|
||||
$hungry = array_chunk($prelauncher, $qty);
|
||||
if (is_array($hungry) && array_key_exists($page, $hungry)) {
|
||||
$fed = $hungry[$page];
|
||||
}
|
||||
$totals = [];
|
||||
$launcher = Torrent::with(['user', 'category'])->withCount(['thanks', 'comments'])->whereIn('imdb', $fed)->orderBy('sticky', 'desc')->orderBy($sorting, $order);
|
||||
foreach($launcher->cursor() as $chunk) {
|
||||
if($chunk->imdb) {
|
||||
if(!array_key_exists($chunk->imdb,$totals)) {
|
||||
$totals[$chunk->imdb]=1;
|
||||
foreach ($launcher->cursor() as $chunk) {
|
||||
if ($chunk->imdb) {
|
||||
if (! array_key_exists($chunk->imdb, $totals)) {
|
||||
$totals[$chunk->imdb] = 1;
|
||||
} else {
|
||||
$totals[$chunk->imdb] = $totals[$chunk->imdb] + 1;
|
||||
}
|
||||
if(!array_key_exists('imdb'.$chunk->imdb,$cache)) {
|
||||
$cache['imdb' . $chunk->imdb] = array();
|
||||
if (! array_key_exists('imdb'.$chunk->imdb, $cache)) {
|
||||
$cache['imdb'.$chunk->imdb] = [];
|
||||
}
|
||||
if(!array_key_exists('imdb'.$chunk->imdb,$attributes)) {
|
||||
if (! array_key_exists('imdb'.$chunk->imdb, $attributes)) {
|
||||
$attributes['imdb'.$chunk->imdb]['seeders'] = 0;
|
||||
$attributes['imdb'.$chunk->imdb]['leechers'] = 0;
|
||||
$attributes['imdb'.$chunk->imdb]['times_completed'] = 0;
|
||||
$attributes['imdb'.$chunk->imdb]['types'] = array();
|
||||
$attributes['imdb'.$chunk->imdb]['categories'] = array();
|
||||
$attributes['imdb'.$chunk->imdb]['genres'] = array();
|
||||
$attributes['imdb'.$chunk->imdb]['types'] = [];
|
||||
$attributes['imdb'.$chunk->imdb]['categories'] = [];
|
||||
$attributes['imdb'.$chunk->imdb]['genres'] = [];
|
||||
}
|
||||
$attributes['imdb'.$chunk->imdb]['times_completed'] += $chunk->times_completed;
|
||||
$attributes['imdb'.$chunk->imdb]['seeders'] += $chunk->seeders;
|
||||
$attributes['imdb'.$chunk->imdb]['leechers'] += $chunk->leechers;
|
||||
if(!array_key_exists($chunk->type,$attributes['imdb'.$chunk->imdb])) {
|
||||
if (! array_key_exists($chunk->type, $attributes['imdb'.$chunk->imdb])) {
|
||||
$attributes['imdb'.$chunk->imdb]['types'][$chunk->type] = $chunk->type;
|
||||
}
|
||||
if(!array_key_exists($chunk->category_id,$attributes['imdb'.$chunk->imdb])) {
|
||||
if (! array_key_exists($chunk->category_id, $attributes['imdb'.$chunk->imdb])) {
|
||||
$attributes['imdb'.$chunk->imdb]['categories'][$chunk->category_id] = $chunk->category_id;
|
||||
}
|
||||
$cache['imdb'.$chunk->imdb]['torrent'.$chunk->id] = array(
|
||||
$cache['imdb'.$chunk->imdb]['torrent'.$chunk->id] = [
|
||||
'created_at' => $chunk->created_at,
|
||||
'seeders' => $chunk->seeders,
|
||||
'leechers' => $chunk->leechers,
|
||||
@@ -231,10 +240,10 @@ class TorrentController extends Controller
|
||||
'times_completed' => $chunk->times_completed,
|
||||
'size' => $chunk->size,
|
||||
'chunk' => $chunk,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
if(count($cache) > 0) {
|
||||
if (count($cache) > 0) {
|
||||
$torrents = $cache;
|
||||
} else {
|
||||
$torrents = null;
|
||||
@@ -248,14 +257,14 @@ class TorrentController extends Controller
|
||||
if ($d['chunk']->category_id == 2) {
|
||||
if ($d['chunk']->tmdb || $d['chunk']->tmdb != 0) {
|
||||
$movie = $client->scrape('tv', null, $d['chunk']->tmdb);
|
||||
} else if ($d['chunk']->imdb && $d['chunk']->imdb != 0) {
|
||||
$movie = $client->scrape('tv', 'tt' . $d['chunk']->imdb);
|
||||
} elseif ($d['chunk']->imdb && $d['chunk']->imdb != 0) {
|
||||
$movie = $client->scrape('tv', 'tt'.$d['chunk']->imdb);
|
||||
}
|
||||
} else {
|
||||
if ($d['chunk']->tmdb || $d['chunk']->tmdb != 0) {
|
||||
$movie = $client->scrape('movie', null, $d['chunk']->tmdb);
|
||||
} else if ($d['chunk']->imdb && $d['chunk']->imdb != 0) {
|
||||
$movie = $client->scrape('movie', 'tt' . $d['chunk']->imdb);
|
||||
} elseif ($d['chunk']->imdb && $d['chunk']->imdb != 0) {
|
||||
$movie = $client->scrape('movie', 'tt'.$d['chunk']->imdb);
|
||||
}
|
||||
}
|
||||
if ($movie) {
|
||||
@@ -276,7 +285,6 @@ class TorrentController extends Controller
|
||||
'repository' => $repository,
|
||||
'attributes' => $attributes,
|
||||
])->render();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,7 +302,7 @@ class TorrentController extends Controller
|
||||
$personal_freeleech = PersonalFreeleech::where('user_id', '=', $user->id)->first();
|
||||
$collection = null;
|
||||
|
||||
if($request->has('view') && $request->input('view') == 'group') {
|
||||
if ($request->has('view') && $request->input('view') == 'group') {
|
||||
$collection = 1;
|
||||
}
|
||||
|
||||
@@ -350,24 +358,22 @@ class TorrentController extends Controller
|
||||
if ($request->has('direction') && $request->input('direction') != null) {
|
||||
$order = $request->input('direction');
|
||||
}
|
||||
if (!$sorting || $sorting == null || !$order || $order == null) {
|
||||
if (! $sorting || $sorting == null || ! $order || $order == null) {
|
||||
$sorting = 'created_at';
|
||||
$order = 'desc';
|
||||
}
|
||||
|
||||
if($order == "asc") {
|
||||
if ($order == 'asc') {
|
||||
$direction = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$direction = 2;
|
||||
}
|
||||
|
||||
// Redundant... but I am leaving this as a placeholder for now.
|
||||
|
||||
if($collection == 1) {
|
||||
if ($collection == 1) {
|
||||
$torrent = $torrent->with(['user', 'category'])->withCount(['thanks', 'comments']);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$torrent = $torrent->with(['user', 'category'])->withCount(['thanks', 'comments']);
|
||||
}
|
||||
|
||||
@@ -462,62 +468,67 @@ class TorrentController extends Controller
|
||||
|
||||
if ($request->has('qty')) {
|
||||
$qty = $request->input('qty');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$qty = 25;
|
||||
}
|
||||
|
||||
$logger = null;
|
||||
$cache=array();
|
||||
$attributes=array();
|
||||
if($collection == 1) {
|
||||
|
||||
$cache = [];
|
||||
$attributes = [];
|
||||
if ($collection == 1) {
|
||||
if ($logger == null) {
|
||||
$logger = 'torrent.results_groupings';
|
||||
}
|
||||
$torrent->orderBy('sticky', 'desc')->orderBy($sorting, $order);
|
||||
$prelauncher = $torrent->pluck('imdb')->map(function ($imdb) {
|
||||
$dupes = array();
|
||||
if(in_array($imdb,$dupes)) return false;
|
||||
array_push($dupes,$imdb);
|
||||
$dupes = [];
|
||||
if (in_array($imdb, $dupes)) {
|
||||
return false;
|
||||
}
|
||||
array_push($dupes, $imdb);
|
||||
|
||||
return $imdb;
|
||||
})->toArray();
|
||||
|
||||
if(!is_array($prelauncher)) { $prelauncher=array(); }
|
||||
$links = new Paginator(array(), count($prelauncher), $qty);
|
||||
if (! is_array($prelauncher)) {
|
||||
$prelauncher = [];
|
||||
}
|
||||
$links = new Paginator([], count($prelauncher), $qty);
|
||||
|
||||
$hungry = array_chunk($prelauncher,$qty);
|
||||
if(is_array($hungry) && array_key_exists($page,$hungry)) { $fed=$hungry[$page]; }
|
||||
$totals=array();
|
||||
$hungry = array_chunk($prelauncher, $qty);
|
||||
if (is_array($hungry) && array_key_exists($page, $hungry)) {
|
||||
$fed = $hungry[$page];
|
||||
}
|
||||
$totals = [];
|
||||
$launcher = Torrent::with(['user', 'category'])->withCount(['thanks', 'comments'])->whereIn('imdb', $fed)->orderBy('sticky', 'desc')->orderBy($sorting, $order);
|
||||
foreach($launcher->cursor() as $chunk) {
|
||||
if($chunk->imdb) {
|
||||
if(!array_key_exists($chunk->imdb,$totals)) {
|
||||
$totals[$chunk->imdb]=1;
|
||||
foreach ($launcher->cursor() as $chunk) {
|
||||
if ($chunk->imdb) {
|
||||
if (! array_key_exists($chunk->imdb, $totals)) {
|
||||
$totals[$chunk->imdb] = 1;
|
||||
} else {
|
||||
$totals[$chunk->imdb] = $totals[$chunk->imdb] + 1;
|
||||
}
|
||||
if(!array_key_exists('imdb'.$chunk->imdb,$cache)) {
|
||||
$cache['imdb' . $chunk->imdb] = array();
|
||||
if (! array_key_exists('imdb'.$chunk->imdb, $cache)) {
|
||||
$cache['imdb'.$chunk->imdb] = [];
|
||||
}
|
||||
if(!array_key_exists('imdb'.$chunk->imdb,$attributes)) {
|
||||
if (! array_key_exists('imdb'.$chunk->imdb, $attributes)) {
|
||||
$attributes['imdb'.$chunk->imdb]['seeders'] = 0;
|
||||
$attributes['imdb'.$chunk->imdb]['leechers'] = 0;
|
||||
$attributes['imdb'.$chunk->imdb]['times_completed'] = 0;
|
||||
$attributes['imdb'.$chunk->imdb]['types'] = array();
|
||||
$attributes['imdb'.$chunk->imdb]['categories'] = array();
|
||||
$attributes['imdb'.$chunk->imdb]['genres'] = array();
|
||||
$attributes['imdb'.$chunk->imdb]['types'] = [];
|
||||
$attributes['imdb'.$chunk->imdb]['categories'] = [];
|
||||
$attributes['imdb'.$chunk->imdb]['genres'] = [];
|
||||
}
|
||||
$attributes['imdb'.$chunk->imdb]['times_completed'] += $chunk->times_completed;
|
||||
$attributes['imdb'.$chunk->imdb]['seeders'] += $chunk->seeders;
|
||||
$attributes['imdb'.$chunk->imdb]['leechers'] += $chunk->leechers;
|
||||
if(!array_key_exists($chunk->type,$attributes['imdb'.$chunk->imdb])) {
|
||||
if (! array_key_exists($chunk->type, $attributes['imdb'.$chunk->imdb])) {
|
||||
$attributes['imdb'.$chunk->imdb]['types'][$chunk->type] = $chunk->type;
|
||||
}
|
||||
if(!array_key_exists($chunk->category_id,$attributes['imdb'.$chunk->imdb])) {
|
||||
if (! array_key_exists($chunk->category_id, $attributes['imdb'.$chunk->imdb])) {
|
||||
$attributes['imdb'.$chunk->imdb]['categories'][$chunk->category_id] = $chunk->category_id;
|
||||
}
|
||||
$cache['imdb'.$chunk->imdb]['torrent'.$chunk->id] = array(
|
||||
$cache['imdb'.$chunk->imdb]['torrent'.$chunk->id] = [
|
||||
'created_at' => $chunk->created_at,
|
||||
'seeders' => $chunk->seeders,
|
||||
'leechers' => $chunk->leechers,
|
||||
@@ -525,17 +536,15 @@ class TorrentController extends Controller
|
||||
'times_completed' => $chunk->times_completed,
|
||||
'size' => $chunk->size,
|
||||
'chunk' => $chunk,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
if(count($cache) > 0) {
|
||||
if (count($cache) > 0) {
|
||||
$torrents = $cache;
|
||||
} else {
|
||||
$torrents = null;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$torrents = $torrent->orderBy('sticky', 'desc')->orderBy($sorting, $order)->paginate($qty);
|
||||
}
|
||||
if ($collection == 1 && is_array($torrents)) {
|
||||
@@ -546,14 +555,14 @@ class TorrentController extends Controller
|
||||
if ($d['chunk']->category_id == 2) {
|
||||
if ($d['chunk']->tmdb || $d['chunk']->tmdb != 0) {
|
||||
$movie = $client->scrape('tv', null, $d['chunk']->tmdb);
|
||||
} else if ($d['chunk']->imdb && $d['chunk']->imdb != 0) {
|
||||
$movie = $client->scrape('tv', 'tt' . $d['chunk']->imdb);
|
||||
} elseif ($d['chunk']->imdb && $d['chunk']->imdb != 0) {
|
||||
$movie = $client->scrape('tv', 'tt'.$d['chunk']->imdb);
|
||||
}
|
||||
} else {
|
||||
if ($d['chunk']->tmdb || $d['chunk']->tmdb != 0) {
|
||||
$movie = $client->scrape('movie', null, $d['chunk']->tmdb);
|
||||
} else if ($d['chunk']->imdb && $d['chunk']->imdb != 0) {
|
||||
$movie = $client->scrape('movie', 'tt' . $d['chunk']->imdb);
|
||||
} elseif ($d['chunk']->imdb && $d['chunk']->imdb != 0) {
|
||||
$movie = $client->scrape('movie', 'tt'.$d['chunk']->imdb);
|
||||
}
|
||||
}
|
||||
if ($movie) {
|
||||
@@ -567,29 +576,30 @@ class TorrentController extends Controller
|
||||
$logger = 'torrent.results_cards';
|
||||
}
|
||||
$client = new \App\Services\MovieScrapper(config('api-keys.tmdb'), config('api-keys.tvdb'), config('api-keys.omdb'));
|
||||
foreach($torrents as $torrent) {
|
||||
foreach ($torrents as $torrent) {
|
||||
$movie = null;
|
||||
if ($torrent->category_id == 2) {
|
||||
if ($torrent->tmdb || $torrent->tmdb != 0) {
|
||||
$movie = $client->scrape('tv', null, $torrent->tmdb);
|
||||
} else if ($torrent->imdb && $torrent->imdb != 0) {
|
||||
$movie = $client->scrape('tv', 'tt' . $torrent->imdb);
|
||||
} elseif ($torrent->imdb && $torrent->imdb != 0) {
|
||||
$movie = $client->scrape('tv', 'tt'.$torrent->imdb);
|
||||
}
|
||||
} else {
|
||||
if ($torrent->tmdb || $torrent->tmdb != 0) {
|
||||
$movie = $client->scrape('movie', null, $torrent->tmdb);
|
||||
} else if ($torrent->imdb && $torrent->imdb != 0) {
|
||||
$movie = $client->scrape('movie', 'tt' . $torrent->imdb);
|
||||
} elseif ($torrent->imdb && $torrent->imdb != 0) {
|
||||
$movie = $client->scrape('movie', 'tt'.$torrent->imdb);
|
||||
}
|
||||
}
|
||||
if($movie) {
|
||||
if ($movie) {
|
||||
$torrent->movie = $movie;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($logger == null) {
|
||||
if ($logger == null) {
|
||||
$logger = 'torrent.results';
|
||||
}
|
||||
|
||||
return view($logger, [
|
||||
'torrents' => $torrents,
|
||||
'user' => $user,
|
||||
|
||||
Reference in New Issue
Block a user