Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Feature) Resolutions System #1379

Merged
merged 52 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e269456
add: resolutions migration
HDVinnie Jun 6, 2020
bfb8600
Revert "add: resolutions migration"
HDVinnie Jun 6, 2020
a1e8037
add: resolutions migration
HDVinnie Jun 6, 2020
870b5be
add: resolution model
HDVinnie Jun 6, 2020
5a37509
add: staff resolution controller
HDVinnie Jun 6, 2020
7a86b12
add: staff resolution views
HDVinnie Jun 6, 2020
cbe5bae
add: staff resolution routes
HDVinnie Jun 6, 2020
394716b
update: torrent upload view
HDVinnie Jun 6, 2020
66b2d07
update: torrent edit view
HDVinnie Jun 6, 2020
9422f54
update: torrents list view
HDVinnie Jun 6, 2020
6096613
update: request faceted repository
HDVinnie Jun 7, 2020
60819ae
update: torrent faceted repository
HDVinnie Jun 7, 2020
f8e93da
update: api torrent controller
HDVinnie Jun 7, 2020
8b6682f
update: torrent controller
HDVinnie Jun 7, 2020
3106a45
update: torrent views
HDVinnie Jun 7, 2020
907fa4d
update: staff nav
HDVinnie Jun 7, 2020
2f7bc13
update: rss controllers
HDVinnie Jun 7, 2020
025cd5e
update: rss model
HDVinnie Jun 7, 2020
c160782
update: rss views
HDVinnie Jun 7, 2020
1fc58b9
update: torrent model
HDVinnie Jun 7, 2020
c9c59ca
update: torrent request model
HDVinnie Jun 7, 2020
65f427d
update: torrent request controller
HDVinnie Jun 7, 2020
4e19b2a
add: torrents/requests resolution_id migrations
HDVinnie Jun 7, 2020
c8adeb7
Apply fixes from StyleCI
HDVinnie Jun 7, 2020
dc5b831
Merge pull request #1378 from HDInnovations/analysis-1blP95
HDVinnie Jun 7, 2020
5756be5
update: tests
HDVinnie Jun 7, 2020
231c339
chore: styleci
HDVinnie Jun 7, 2020
5ae474c
update: upload helper js
HDVinnie Jun 7, 2020
296e4f5
update: torrent api controller
HDVinnie Jun 7, 2020
eace559
update: torrent controller
HDVinnie Jun 7, 2020
b44cb8e
update: torrent resource
HDVinnie Jun 7, 2020
1cad55a
update: torrent moderation view
HDVinnie Jun 7, 2020
2b08698
update: torrent groupings view
HDVinnie Jun 7, 2020
d25a753
update: torrent list view
HDVinnie Jun 7, 2020
b7b5e2a
update: torrent cards view
HDVinnie Jun 7, 2020
47bf783
update: torrent grouping views
HDVinnie Jun 7, 2020
2fb1004
add: resolutions database seeder
HDVinnie Jun 7, 2020
f58e890
update: upload parser
HDVinnie Jun 8, 2020
299a9ab
update: staff category controller
HDVinnie Jun 8, 2020
7f47c78
update: torrent views
HDVinnie Jun 8, 2020
53faae3
update: torrent requests views
HDVinnie Jun 8, 2020
7a6b4f1
update: categories table seeder
HDVinnie Jun 8, 2020
4d664e8
update: torrent upload view
HDVinnie Jun 8, 2020
dace076
update: types table seeder
HDVinnie Jun 8, 2020
03464d8
update: secure-headers config
HDVinnie Jun 8, 2020
0f393cf
update: lang
HDVinnie Jun 8, 2020
975b739
update: torrent grouping view
HDVinnie Jun 8, 2020
ae32af5
update: top torrents block
HDVinnie Jun 9, 2020
fc0bff7
update: category view
HDVinnie Jun 9, 2020
ee7c6f1
fix: categories table seeder
HDVinnie Jun 9, 2020
a5fdd8a
update: torrent upload view
HDVinnie Jun 9, 2020
868c0ce
update: resolution migrations
HDVinnie Jun 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 32 additions & 25 deletions app/Http/Controllers/API/TorrentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ public function store(Request $request, Torrent $torrent)
$torrent->size = $meta['size'];
$torrent->nfo = ($request->hasFile('nfo')) ? TorrentTools::getNfo($request->file('nfo')) : '';
$torrent->category_id = $category->id;
$torrent->type_id = $request->input('type_id');
$torrent->resolution_id = $request->input('resolution_id');
$torrent->user_id = $user->id;
$torrent->imdb = $request->input('imdb');
$torrent->tvdb = $request->input('tvdb');
$torrent->tmdb = $request->input('tmdb');
$torrent->mal = $request->input('mal');
$torrent->igdb = $request->input('igdb');
$torrent->type_id = $request->input('type_id');
$torrent->anon = $request->input('anonymous');
$torrent->stream = $request->input('stream');
$torrent->sd = $request->input('sd');
Expand All @@ -133,30 +134,31 @@ public function store(Request $request, Torrent $torrent)

// Validation
$v = validator($torrent->toArray(), [
'name' => 'required|unique:torrents',
'slug' => 'required',
'description' => 'required',
'info_hash' => 'required|unique:torrents',
'file_name' => 'required',
'num_file' => 'required|numeric',
'announce' => 'required',
'size' => 'required',
'category_id' => 'required',
'user_id' => 'required',
'imdb' => 'required|numeric',
'tvdb' => 'required|numeric',
'tmdb' => 'required|numeric',
'mal' => 'required|numeric',
'igdb' => 'required|numeric',
'type_id' => 'required',
'anon' => 'required',
'stream' => 'required',
'sd' => 'required',
'internal' => 'required',
'featured' => 'required',
'free' => 'required',
'doubleup' => 'required',
'sticky' => 'required',
'name' => 'required|unique:torrents',
'slug' => 'required',
'description' => 'required',
'info_hash' => 'required|unique:torrents',
'file_name' => 'required',
'num_file' => 'required|numeric',
'announce' => 'required',
'size' => 'required',
'category_id' => 'required|exists:categories,id',
'type_id' => 'required|exists:types,id',
'resolution_id' => 'exists:resolutions,id',
'user_id' => 'required|exists:users,id',
'imdb' => 'required|numeric',
'tvdb' => 'required|numeric',
'tmdb' => 'required|numeric',
'mal' => 'required|numeric',
'igdb' => 'required|numeric',
'anon' => 'required',
'stream' => 'required',
'sd' => 'required',
'internal' => 'required',
'featured' => 'required',
'free' => 'required',
'doubleup' => 'required',
'sticky' => 'required',
]);

if ($v->fails()) {
Expand Down Expand Up @@ -328,6 +330,7 @@ public function filter(Request $request, Torrent $torrent)
$end_year = $request->input('end_year');
$categories = $request->input('categories');
$types = $request->input('types');
$resolutions = $request->input('resolutions');
$genres = $request->input('genres');
$freeleech = $request->input('freeleech');
$doubleupload = $request->input('doubleupload');
Expand Down Expand Up @@ -426,6 +429,10 @@ public function filter(Request $request, Torrent $torrent)
$torrent->whereIn('torrents.type_id', $types);
}

if ($request->has('resolutions') && $request->input('resolutions') != null) {
$torrent->whereIn('torrents.resolution_id', $resolutions);
}

if ($request->has('genres') && $request->input('genres') != null) {
$genreID = TagTorrent::select(['torrent_id'])->distinct()->whereIn('tag_name', $genres)->get();
$torrent->whereIn('torrents.id', $genreID);
Expand Down
71 changes: 44 additions & 27 deletions app/Http/Controllers/RequestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use App\Achievements\UserFilled75Requests;
use App\Models\BonTransactions;
use App\Models\Category;
use App\Models\Resolution;
use App\Models\Torrent;
use App\Models\TorrentRequest;
use App\Models\TorrentRequestBounty;
Expand Down Expand Up @@ -119,6 +120,7 @@ public function faceted(Request $request, TorrentRequest $torrentRequest)
$igdb = $request->input('igdb');
$categories = $request->input('categories');
$types = $request->input('types');
$resolutions = $request->input('resolutions');
$myrequests = $request->input('myrequests');

$terms = explode(' ', $search);
Expand Down Expand Up @@ -161,6 +163,10 @@ public function faceted(Request $request, TorrentRequest $torrentRequest)
$torrentRequest->whereIn('type_id', $types);
}

if ($request->has('resolutions') && $request->input('resolutions') != null) {
$torrentRequest->whereIn('resolution_id', $resolutions);
}

if ($request->has('unfilled') && $request->input('unfilled') != null) {
$torrentRequest->where('filled_hash', '=', null);
}
Expand Down Expand Up @@ -280,12 +286,13 @@ public function addRequestForm(Request $request, $title = '', $imdb = 0, $tmdb =
$user = $request->user();

return view('requests.add_request', [
'categories' => Category::all()->sortBy('position'),
'types' => Type::all()->sortBy('position'),
'user' => $user,
'title' => $title,
'imdb' => str_replace('tt', '', $imdb),
'tmdb' => $tmdb,
'categories' => Category::all()->sortBy('position'),
'types' => Type::all()->sortBy('position'),
'resolutions' => Resolution::all()->sortBy('position'),
'user' => $user,
'title' => $title,
'imdb' => str_replace('tt', '', $imdb),
'tmdb' => $tmdb,
]);
}

Expand All @@ -312,22 +319,24 @@ public function addrequest(Request $request)
$tr->mal = $request->input('mal');
$tr->igdb = $request->input('igdb');
$tr->type_id = $request->input('type_id');
$tr->resolution_id = $request->input('resolution_id');
$tr->bounty = $request->input('bounty');
$tr->votes = 1;
$tr->anon = $request->input('anon');

$v = validator($tr->toArray(), [
'name' => 'required|max:180',
'imdb' => 'required|numeric',
'tvdb' => 'required|numeric',
'tmdb' => 'required|numeric',
'mal' => 'required|numeric',
'igdb' => 'required|numeric',
'category_id' => 'required|exists:categories,id',
'type_id' => 'required|exists:types,id',
'description' => 'required|string',
'bounty' => sprintf('required|numeric|min:0|max:%s', $user->seedbonus),
'anon' => 'required',
'name' => 'required|max:180',
'imdb' => 'required|numeric',
'tvdb' => 'required|numeric',
'tmdb' => 'required|numeric',
'mal' => 'required|numeric',
'igdb' => 'required|numeric',
'category_id' => 'required|exists:categories,id',
'type_id' => 'required|exists:types,id',
'resolution_id' => 'required|exists:resolutions,id',
'description' => 'required|string',
'bounty' => sprintf('required|numeric|min:0|max:%s', $user->seedbonus),
'anon' => 'required',
]);

if ($v->fails()) {
Expand Down Expand Up @@ -384,6 +393,7 @@ public function editRequestForm(Request $request, $id)
return view('requests.edit_request', [
'categories' => Category::all()->sortBy('position'),
'types' => Type::all()->sortBy('position'),
'resolutions' => Resolution::all()->sortBy('position'),
'user' => $user,
'torrentRequest' => $torrentRequest, ]);
}
Expand Down Expand Up @@ -411,6 +421,7 @@ public function editrequest(Request $request, $id)
$igdb = $request->input('igdb');
$category = $request->input('category_id');
$type = $request->input('type_id');
$resolution = $request->input('resolution_id');
$description = $request->input('description');
$anon = $request->input('anon');

Expand All @@ -422,20 +433,22 @@ public function editrequest(Request $request, $id)
$torrentRequest->igdb = $igdb;
$torrentRequest->category_id = $category;
$torrentRequest->type_id = $type;
$torrentRequest->resolution_id = $resolution;
$torrentRequest->description = $description;
$torrentRequest->anon = $anon;

$v = validator($torrentRequest->toArray(), [
'name' => 'required|max:180',
'imdb' => 'required|numeric',
'tvdb' => 'required|numeric',
'tmdb' => 'required|numeric',
'mal' => 'required|numeric',
'igdb' => 'required|numeric',
'category_id' => 'required|exists:categories,id',
'type_id' => 'required|exists:types,id',
'description' => 'required|string',
'anon' => 'required',
'name' => 'required|max:180',
'imdb' => 'required|numeric',
'tvdb' => 'required|numeric',
'tmdb' => 'required|numeric',
'mal' => 'required|numeric',
'igdb' => 'required|numeric',
'category_id' => 'required|exists:categories,id',
'type_id' => 'required|exists:types,id',
'resolution_id' => 'required|exists:resolutions,id',
'description' => 'required|string',
'anon' => 'required',
]);

if ($v->fails()) {
Expand Down Expand Up @@ -680,6 +693,8 @@ public function rejectRequest(Request $request, $id)
* @param \Illuminate\Http\Request $request
* @param \App\Models\TorrentRequest $id
*
* @throws \Exception
*
* @return \Illuminate\Http\RedirectResponse
*/
public function deleteRequest(Request $request, $id)
Expand Down Expand Up @@ -743,6 +758,8 @@ public function claimRequest(Request $request, $id)
* @param \Illuminate\Http\Request $request
* @param \App\Models\TorrentRequest $id
*
* @throws \Exception
*
* @return \Illuminate\Http\RedirectResponse
*/
public function unclaimRequest(Request $request, $id)
Expand Down
22 changes: 17 additions & 5 deletions app/Http/Controllers/RssController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use App\Models\Category;
use App\Models\Group;
use App\Models\Resolution;
use App\Models\Rss;
use App\Models\TagTorrent;
use App\Models\Torrent;
Expand Down Expand Up @@ -46,7 +47,7 @@ public function __construct(TorrentFacetedRepository $torrent_faceted)
* @param \Illuminate\Http\Request $request
* @param string $hash
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request, $hash = null)
{
Expand All @@ -68,7 +69,7 @@ public function index(Request $request, $hash = null)
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function create(Request $request)
{
Expand All @@ -79,6 +80,7 @@ public function create(Request $request)
'torrent_repository' => $torrent_repository,
'categories' => Category::all()->sortBy('position'),
'types' => Type::all()->sortBy('position'),
'resolutions' => Resolution::all()->sortBy('position'),
'user' => $user,
]);
}
Expand All @@ -101,12 +103,13 @@ public function store(Request $request)
'uploader' => 'max:255',
'categories' => 'sometimes|array|max:999',
'types' => 'sometimes|array|max:999',
'resolutions' => 'sometimes|array|max:999',
'genres' => 'sometimes|array|max:999',
'position' => 'sometimes|integer|max:9999',
]);

$params = $request->only(['name', 'search', 'description', 'uploader', 'imdb', 'tvdb', 'tmdb', 'mal', 'categories',
'types', 'genres', 'freeleech', 'doubleupload', 'featured', 'stream', 'highspeed', 'sd', 'internal', 'alive', 'dying', 'dead', ]);
'types', 'resolutions', 'genres', 'freeleech', 'doubleupload', 'featured', 'stream', 'highspeed', 'sd', 'internal', 'alive', 'dying', 'dead', ]);

$error = null;
$success = null;
Expand Down Expand Up @@ -141,7 +144,7 @@ public function store(Request $request)
* @param int $id
* @param string $rsskey
*
* @throws \Exception
* @throws \Psr\SimpleCache\InvalidArgumentException
*
* @return \Illuminate\Http\Response
*/
Expand Down Expand Up @@ -176,6 +179,7 @@ public function show($id, $rsskey)
$mal = $rss->object_torrent->mal;
$categories = $rss->object_torrent->categories;
$types = $rss->object_torrent->types;
$resolutions = $rss->object_torrent->resolutions;
$genres = $rss->object_torrent->genres;
$freeleech = $rss->object_torrent->freeleech;
$doubleupload = $rss->object_torrent->doubleupload;
Expand Down Expand Up @@ -252,6 +256,10 @@ public function show($id, $rsskey)
$torrent->whereIn('type_id', $types);
}

if ($rss->object_torrent->resolutions && is_array($rss->object_torrent->resolutions)) {
$torrent->whereIn('resolution_id', $resolutions);
}

if ($rss->object_torrent->genres && is_array($rss->object_torrent->genres)) {
$genreID = TagTorrent::select(['torrent_id'])->distinct()->whereIn('tag_name', $genres)->get();
$torrent->whereIn('id', $genreID)->cursor();
Expand Down Expand Up @@ -313,7 +321,7 @@ public function show($id, $rsskey)
* @param \Illuminate\Http\Request $request
* @param int $id
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function edit(Request $request, $id)
{
Expand All @@ -325,6 +333,7 @@ public function edit(Request $request, $id)
'torrent_repository' => $torrent_repository,
'categories' => Category::all()->sortBy('position'),
'types' => Type::all()->sortBy('position'),
'resolutions' => Resolution::all()->sortBy('position'),
'user' => $user,
'rss' => $rss,
]);
Expand All @@ -348,6 +357,7 @@ public function update(Request $request, $id)
'uploader' => 'max:255',
'categories' => 'sometimes|array|max:999',
'types' => 'sometimes|array|max:999',
'resolutions' => 'sometimes|array|max:999',
'genres' => 'sometimes|array|max:999',
'position' => 'sometimes|integer|max:9999',
]);
Expand Down Expand Up @@ -385,6 +395,8 @@ public function update(Request $request, $id)
*
* @param int $id
*
* @throws \Exception
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Staff/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function store(Request $request)
$image = $request->file('image');
$filename = 'category-'.uniqid().'.'.$image->getClientOriginalExtension();
$path = public_path('/files/img/'.$filename);
Image::make($image->getRealPath())->fit(40, 40)->encode('png', 100)->save($path);
Image::make($image->getRealPath())->fit(60, 60)->encode('png', 100)->save($path);
$category->image = $filename;
} else {
$category->image = null;
Expand Down Expand Up @@ -134,7 +134,7 @@ public function update(Request $request, $id)
$image = $request->file('image');
$filename = 'category-'.uniqid().'.'.$image->getClientOriginalExtension();
$path = public_path('/files/img/'.$filename);
Image::make($image->getRealPath())->fit(40, 40)->encode('png', 100)->save($path);
Image::make($image->getRealPath())->fit(60, 60)->encode('png', 100)->save($path);
$category->image = $filename;
}

Expand Down
Loading