diff --git a/app/Http/Controllers/TorrentController.php b/app/Http/Controllers/TorrentController.php index 2f2194546..092c884de 100644 --- a/app/Http/Controllers/TorrentController.php +++ b/app/Http/Controllers/TorrentController.php @@ -50,8 +50,8 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; use Intervention\Image\Facades\Image; -use MarcReichel\IGDBLaravel\Models\Character; use MarcReichel\IGDBLaravel\Models\Game; +use MarcReichel\IGDBLaravel\Models\PlatformLogo; /** * @see \Tests\Todo\Feature\Http\Controllers\TorrentControllerTest @@ -159,7 +159,12 @@ class TorrentController extends Controller /** * Display The Torrent. * - * @param \App\Models\Torrent $id + * @param \Illuminate\Http\Request $request + * @param \App\Models\Torrent $id + * + * @throws \JsonException + * @throws \MarcReichel\IGDBLaravel\Exceptions\MissingEndpointException + * @throws \ReflectionException */ public function torrent(Request $request, $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View { @@ -175,6 +180,7 @@ class TorrentController extends Controller $meta = null; $trailer = null; + $platforms = null; if ($torrent->category->tv_meta && $torrent->tmdb && $torrent->tmdb != 0) { $meta = Tv::with('genres', 'cast', 'companies', 'networks', 'recommendations')->where('id', '=', $torrent->tmdb)->first(); $trailer = ( new \App\Services\Tmdb\Client\TV($torrent->tmdb))->get_trailer(); @@ -185,10 +191,19 @@ class TorrentController extends Controller $trailer = ( new \App\Services\Tmdb\Client\Movie($torrent->tmdb))->get_trailer(); } - $characters = null; if ($torrent->category->game_meta && ($torrent->igdb || $torrent->igdb != 0)) { - $meta = Game::with(['cover' => ['url', 'image_id'], 'artworks' => ['url', 'image_id'], 'genres' => ['name']])->find($torrent->igdb); - $characters = Character::whereIn('games', [$torrent->igdb])->take(6)->get(); + $meta = Game::with([ + 'cover' => ['url', 'image_id'], + 'artworks' => ['url', 'image_id'], + 'genres' => ['name'], + 'videos' => ['video_id', 'name'], + 'involved_companies.company', + 'involved_companies.company.logo', + 'platforms']) + ->find($torrent->igdb); + $link = collect($meta->videos)->take(1)->pluck('video_id'); + $trailer = 'https://www.youtube.com/embed/'.$link; + $platforms = PlatformLogo::whereIn('id', collect($meta->platforms)->pluck('platform_logo')->toArray())->get(); } $featured = $torrent->featured == 1 ? FeaturedTorrent::where('torrent_id', '=', $id)->first() : null; @@ -208,7 +223,7 @@ class TorrentController extends Controller 'freeleech_token' => $freeleechToken, 'meta' => $meta, 'trailer' => $trailer, - 'characters' => $characters, + 'platforms' => $platforms, 'total_tips' => $totalTips, 'user_tips' => $userTips, 'featured' => $featured, diff --git a/composer.json b/composer.json index 05c2471f1..7e85af4cb 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "league/flysystem-cached-adapter": "~1.0", "league/flysystem-sftp": "~1.0", "livewire/livewire": "^2.0", - "marcreichel/igdb-laravel": "^2.1.0", + "marcreichel/igdb-laravel": "^3.1.2", "mews/purifier": "^3.2", "paragonie/constant_time_encoding": "^2.0", "predis/predis": "^1.1", diff --git a/composer.lock b/composer.lock index 7b2025375..071b8ae45 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "72ca7985df39d8775ca92d1d6be838da", + "content-hash": "2cdb93faee4c22dfdd7ae1fca66d07e6", "packages": [ { "name": "andkab/laravel-joypixels", @@ -3047,26 +3047,27 @@ }, { "name": "marcreichel/igdb-laravel", - "version": "2.4.6", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/marcreichel/igdb-laravel.git", - "reference": "aaaf7da764553f4318688266db0850c5164b25f2" + "reference": "2d12908bf9f18d11e74094256fb3cd41f03d1517" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/marcreichel/igdb-laravel/zipball/aaaf7da764553f4318688266db0850c5164b25f2", - "reference": "aaaf7da764553f4318688266db0850c5164b25f2", + "url": "https://api.github.com/repos/marcreichel/igdb-laravel/zipball/2d12908bf9f18d11e74094256fb3cd41f03d1517", + "reference": "2d12908bf9f18d11e74094256fb3cd41f03d1517", "shasum": "" }, "require": { "ext-json": "*", "guzzlehttp/guzzle": "~6.0|~7.0", "laravel/framework": "^8.40.0", - "php": "^7.3 | ^7.4 | ^8.0" + "php": "^8.0" }, "require-dev": { "nunomaduro/collision": "^5.3", + "nunomaduro/larastan": "^0.7.13", "orchestra/testbench": "^6.0", "phpunit/phpunit": "^9.5.4", "roave/security-advisories": "dev-latest" @@ -3105,7 +3106,7 @@ ], "support": { "issues": "https://github.com/marcreichel/igdb-laravel/issues", - "source": "https://github.com/marcreichel/igdb-laravel/tree/2.4.6" + "source": "https://github.com/marcreichel/igdb-laravel/tree/3.1.2" }, "funding": [ { @@ -3113,7 +3114,7 @@ "type": "github" } ], - "time": "2021-06-27T09:36:13+00:00" + "time": "2021-10-23T07:45:35+00:00" }, { "name": "mews/purifier", diff --git a/config/igdb.php b/config/igdb.php index e635b9024..77b711423 100644 --- a/config/igdb.php +++ b/config/igdb.php @@ -16,7 +16,7 @@ return [ * These are the credentials you got from https://dev.twitch.tv/console/apps */ 'credentials' => [ - 'client_id' => env('TWITCH_CLIENT_ID', ''), + 'client_id' => env('TWITCH_CLIENT_ID', ''), 'client_secret' => env('TWITCH_CLIENT_SECRET', ''), ], @@ -29,7 +29,15 @@ return [ 'cache_lifetime' => env('IGDB_CACHE_LIFETIME', 3600), /* - * This is the per-page limit for your tier. + * Path where the webhooks should be handled. */ - 'per_page_limit' => 500, -]; + 'webhook_path' => 'igdb-webhook/handle', + + /* + * The webhook secret. + * + * This needs to be a string of your choice in order to use the webhook + * functionality. + */ + 'webhook_secret' => env('IGDB_WEBHOOK_SECRET'), +]; \ No newline at end of file diff --git a/public/img/igdb.png b/public/img/igdb.png new file mode 100644 index 000000000..0f6dd9e92 Binary files /dev/null and b/public/img/igdb.png differ diff --git a/resources/views/category/show.blade.php b/resources/views/category/show.blade.php index c91f370e1..fcefc66e7 100644 --- a/resources/views/category/show.blade.php +++ b/resources/views/category/show.blade.php @@ -41,403 +41,367 @@ - @if ($user->show_poster == 1) - - @else - - @endif - - - - - - - - + + + + + + + + + + - @foreach ($torrents as $torrent) - @php $meta = null; @endphp - @if ($torrent->category->tv_meta) - @if ($torrent->tmdb || $torrent->tmdb != 0) - @php $meta = App\Models\Tv::with('genres', 'networks', 'seasons')->where('id', '=', $torrent->tmdb)->first(); @endphp - @endif + @foreach($torrents as $torrent) + @php $meta = null; @endphp + @if ($torrent->category->tv_meta) + @if ($torrent->tmdb || $torrent->tmdb != 0) + @php $meta = App\Models\Tv::where('id', '=', $torrent->tmdb)->first(); @endphp @endif - @if ($torrent->category->movie_meta) - @if ($torrent->tmdb || $torrent->tmdb != 0) - @php $meta = App\Models\Movie::with('genres', 'cast', 'companies', 'collection')->where('id', '=', $torrent->tmdb)->first(); @endphp - @endif + @endif + @if ($torrent->category->movie_meta) + @if ($torrent->tmdb || $torrent->tmdb != 0) + @php $meta = App\Models\Movie::where('id', '=', $torrent->tmdb)->first(); @endphp @endif - @if ($torrent->category->game_meta) - @if ($torrent->igdb || $torrent->igdb != 0) - @php $meta = MarcReichel\IGDBLaravel\Models\Game::with(['cover' => ['url','image_id'], 'genres' => ['name']])->find($torrent->igdb); @endphp - @endif + @endif + @if ($torrent->category->game_meta) + @if ($torrent->igdb || $torrent->igdb != 0) + @php $meta = MarcReichel\IGDBLaravel\Models\Game::with(['cover' => ['url', 'image_id']])->find($torrent->igdb); @endphp @endif + @endif - @if ($torrent->sticky == 1) - - @else - - @endif - + @else + + @endif + - - - - - - + - - - - - - - - + - - - - @endforeach + @endif +
+ @livewire('small-bookmark-button', ['torrent' => $torrent->id], key($torrent->id)) +
+ + + + + + + + + @endforeach
Poster@lang('torrent.category')@lang('torrent.type')/@lang('torrent.resolution')@lang('common.name') + @lang('common.name') + +
+ +
+
+
+ +
+
+ + + + + + + + + @lang('common.created_at') +
- @if ($user->show_poster == 1) -
- @if ($torrent->category->movie_meta || $torrent->category->tv_meta) - @lang('torrent.poster') + @if ($torrent->sticky == 1) +
+ @if ($user->show_poster == 1) +
+ @if ($torrent->category->movie_meta || $torrent->category->tv_meta) + @lang('torrent.poster') + @endif + + @if ($torrent->category->game_meta) + @lang('torrent.poster') + @endif + + @if ($torrent->category->music_meta) + @lang('torrent.poster') + @endif + + @if ($torrent->category->no_meta) + @if(file_exists(public_path().'/files/img/torrent-cover_'.$torrent->id.'.jpg')) + @lang('torrent.poster') + @else + @lang('torrent.poster') @endif - - @if ($torrent->category->game_meta && isset($meta) && $meta->cover->image_id && $meta->name) - @lang('torrent.poster') - @endif - - @if ($torrent->category->music_meta) - @lang('torrent.poster') - @endif - - @if ($torrent->category->no_meta) - @if(file_exists(public_path().'/files/img/torrent-cover_'.$torrent->id.'.jpg')) - @lang('torrent.poster') - @else - @lang('torrent.poster') - @endif - @endif -
- @else -
- @endif -
- @if ($torrent->category->image != null) - -
- {{ $torrent->category->name }} -
-
- @else - -
- -
-
- @endif -
-
- - {{ $torrent->type->name }} - + @endif
-
- - {{ $torrent->resolution->name ?? 'No Res' }} - + @else +
+ @endif +
+ +
+
-
- - {{ $torrent->name }} - - - @if ($current = $user->history->where('info_hash', $torrent->info_hash)->first()) - @if ($current->seeder == 1 && $current->active == 1) - - @endif - - @if ($current->seeder == 0 && $current->active == 1) - - @endif - - @if ($current->seeder == 0 && $current->active == 0 && $current->completed_at == null) - - @endif - - @if ($current->seeder == 1 && $current->active == 0 && $current->completed_at != null) - - @endif - @endif - -
- @if ($torrent->anon == 1) - - @lang('common.anonymous') - @if ($user->id == $torrent->user->id || $user->group->is_modo) - - ({{ $torrent->user->username }}) - @endif - - @else - - - - {{ $torrent->user->username }} - - - @endif - - @if ($torrent->category->movie_meta || $torrent->category->tv_meta) - - - +
+ + {{ $torrent->type->name }} - {{ $meta->vote_average ?? 0 }}/10 ({{ $meta->vote_count ?? 0 }} @lang('torrent.votes')) - - @endif - - @if ($torrent->category->game_meta && isset($meta)) - @lang('torrent.rating'): - - - - {{ $meta->rating ? \round($meta->rating) : '0' }}/100 ({{ $meta->rating_count }} @lang('torrent.votes')) - - @endif - - - - {{ $torrent->thanks_count }} - - - - - - {{ $torrent->comments_count }} +
+ @if ($torrent->category->movie_meta || $torrent->category->tv_meta) +
+ + {{ $torrent->resolution->name ?? 'N/A' }} +
+ @endif +
+ + {{ $torrent->name }} + + @if ($current = $user->history->where('info_hash', $torrent->info_hash)->first()) + @if ($current->seeder == 1 && $current->active == 1) + + @endif + + @if ($current->seeder == 0 && $current->active == 1) + + @endif + + @if ($current->seeder == 0 && $current->active == 0 && $current->completed_at == null) + + @endif + + @if ($current->seeder == 1 && $current->active == 0 && $current->completed_at != null) + + @endif + @endif +
+ @if ($torrent->anon === 0) + + + + {{ $torrent->user->username }} + + + @else + + + {{ strtoupper(trans('common.anonymous')) }} + @if ($user->group->is_modo || $torrent->user->username === $user->username) + + ({{ $torrent->user->username }}) - - @if ($torrent->internal == 1) - + @endif + + @endif + + {{ $torrent->thanks_count }} + + + {{ $torrent->comments_count }} + + @if ($torrent->internal == 1) + - @endif + @endif - @if ($torrent->stream == 1) - + @if ($torrent->personal_release == 1) + + + + @endif + + @if ($torrent->stream == 1) + - @endif + @endif - @if ($torrent->featured == 0) - @if ($torrent->doubleup == 1) - + @if ($torrent->featured == 0) + @if ($torrent->doubleup == 1) + - @endif - @if ($torrent->free == 1) - + @endif + @if ($torrent->free == 1) + - @endif @endif + @endif - @if ($personal_freeleech) - + @if ($personal_freeleech) + - @endif + @endif - @if ($user->freeleechTokens->where('torrent_id', $torrent->id)->first()) - + @if ($user->freeleechTokens->where('torrent_id', $torrent->id)->first()) + - @endif + @endif - @if ($torrent->featured == 1) - + @if ($torrent->featured == 1) + - @endif + @endif - @if ($user->group->is_freeleech == 1) - + @if ($user->group->is_freeleech == 1) + - @endif + @endif - @if (config('other.freeleech') == 1) - + @if (config('other.freeleech') == 1) + - @endif + @endif - @if (config('other.doubleup') == 1) - + @if (config('other.doubleup') == 1) + - @endif + @endif - @if ($user->group->is_double_upload == 1) - - - - @endif + @if ($user->group->is_double_upload == 1) + + + + @endif - @if ($torrent->leechers >= 5) - + @if ($torrent->leechers >= 5) + - @endif + @endif - @if ($torrent->sticky == 1) - + @if ($torrent->sticky == 1) + - @endif + @endif - @if ($user->updated_at->getTimestamp() < $torrent->created_at->getTimestamp()) - - - - @endif + @if ($torrent->highspeed == 1) + + + + @endif - @if ($torrent->highspeed == 1) - - - - @endif + @if ($torrent->sd == 1) + + + + @endif - @if ($torrent->sd == 1) - - - - @endif - -
- - @if ($torrent->category->game_meta) - @if (isset($meta) && $meta->genres) - @foreach ($meta->genres as $genre) - - {{ $genre->name }} - - @endforeach - @endif - @endif - - @if ($torrent->category->movie_meta || $torrent->category->tv_meta) - @if (isset($meta) && $meta->genres) - @foreach($meta->genres as $genre) - - {{ $genre->name }} - - @endforeach - @endif - @endif -
- @if (file_exists(public_path().'/files/torrents/'.$torrent->file_name)) - @if (config('torrent.download_check_page') == 1) - - - - @else - - - - @endif - @else - - - - @endif - - - - - - {{ $torrent->getSize() }} - - - - {{ $torrent->seeders }} - + @if ($torrent->bumped_at != $torrent->created_at && $torrent->bumped_at < Carbon\Carbon::now()->addDay(2)) + + + + @endif + + @if (config('torrent.download_check_page') == 1) + + - - - - {{ $torrent->leechers }} - + @else + + - - - - {{ $torrent->times_completed }} @lang('common.times') - + @endif + @if (config('torrent.magnet') == 1) + + -
+ @if ($torrent->category->game_meta) + + igdb_id {{ $torrent->igdb }} +
+ {{ $meta->rating_count ?? 0 }}/100 +
+ @endif + @if ($torrent->category->movie_meta || $torrent->category->tv_meta) + + + igdb_id {{ $torrent->tmdb }} + +
+ {{ $meta->vote_average ?? 0 }}/10 +
+ @endif +
+ + {{ $torrent->getSize() }} + + + + + {{ $torrent->seeders }} + + + + + + {{ $torrent->leechers }} + + + + + + {{ $torrent->times_completed }} + + + + + {{ $torrent->created_at->diffForHumans() }} + +
diff --git a/resources/views/livewire/torrent-list-search.blade.php b/resources/views/livewire/torrent-list-search.blade.php index 0b68f24c6..a9adc2868 100644 --- a/resources/views/livewire/torrent-list-search.blade.php +++ b/resources/views/livewire/torrent-list-search.blade.php @@ -391,12 +391,17 @@ @php $meta = null; @endphp @if ($torrent->category->tv_meta) @if ($torrent->tmdb || $torrent->tmdb != 0) - @php $meta = App\Models\Tv::with('genres')->where('id', '=', $torrent->tmdb)->first(); @endphp + @php $meta = App\Models\Tv::where('id', '=', $torrent->tmdb)->first(); @endphp @endif @endif @if ($torrent->category->movie_meta) @if ($torrent->tmdb || $torrent->tmdb != 0) - @php $meta = App\Models\Movie::with('genres')->where('id', '=', $torrent->tmdb)->first(); @endphp + @php $meta = App\Models\Movie::where('id', '=', $torrent->tmdb)->first(); @endphp + @endif + @endif + @if ($torrent->category->game_meta) + @if ($torrent->igdb || $torrent->igdb != 0) + @php $meta = MarcReichel\IGDBLaravel\Models\Game::with(['cover' => ['url', 'image_id']])->find($torrent->igdb); @endphp @endif @endif @@ -413,14 +418,13 @@ class="torrent-poster-img-small" alt="@lang('torrent.poster')"> @endif - @if ($torrent->category->game_meta && isset($meta) && $meta->cover->image_id && $meta->name) - category->game_meta) + @lang('torrent.poster') @endif @if ($torrent->category->music_meta) - @lang('torrent.poster') + @lang('torrent.poster') @endif @if ($torrent->category->no_meta) @@ -434,11 +438,10 @@ @else
@endif -
- +
@@ -446,11 +449,13 @@ {{ $torrent->type->name }}
+ @if ($torrent->category->movie_meta || $torrent->category->tv_meta)
{{ $torrent->resolution->name ?? 'N/A' }}
+ @endif @@ -659,13 +664,22 @@
- - - tmdb_id {{ $torrent->tmdb }} - -
- {{ $meta->vote_average ?? 0 }}/10 - + @if ($torrent->category->game_meta) + + igdb_id {{ $torrent->igdb }} +
+ {{ $meta->rating_count ?? 0 }}/100 +
+ @endif + @if ($torrent->category->movie_meta || $torrent->category->tv_meta) + + + igdb_id {{ $torrent->tmdb }} + +
+ {{ $meta->vote_average ?? 0 }}/10 +
+ @endif @@ -735,4 +749,3 @@ - diff --git a/resources/views/torrent/partials/game_meta.blade.php b/resources/views/torrent/partials/game_meta.blade.php index 967d649b7..20eef39e3 100644 --- a/resources/views/torrent/partials/game_meta.blade.php +++ b/resources/views/torrent/partials/game_meta.blade.php @@ -1,71 +1,94 @@ -
+
- @php $igdb_poster = (isset($meta) && $meta->cover) ? 'https://images.igdb.com/igdb/image/upload/t_original/'.$meta->cover['image_id'].'.jpg' : 'https://via.placeholder.com/400x600'; @endphp - +
-
{{ $torrent->category->name }}
- @php $igdb_backdrop = (isset($meta) && $meta->artworks) ? 'https://images.igdb.com/igdb/image/upload/t_screenshot_big/'.$meta->artworks[0]['image_id'].'.jpg' : 'https://via.placeholder.com/960x540'; @endphp -
+
+ @if(isset($meta->involved_companies)) +
+ + + +
+ @endif +
+ +
-

- @if (isset($meta) && $meta->name) - {{ $meta->name }} - ({{ date('Y', strtotime($meta->first_release_date)) }}) - @else - @lang('torrent.no-meta') +

+ {{ $meta->name ?? 'No Meta Found' }} + @if(isset($meta->first_release_date)) + ({{ substr($meta->first_release_date, 0, 4) ?? '' }}) @endif

+
- @if (isset($meta) && $meta->summary) - {{ Str::limit($meta->summary, $limit = 450, $end = '...') }} - @endif + {{ isset($meta->summary) ? Str::limit($meta->summary, $limit = 600, $end = '...') : '' }}
- @if (isset($meta) && $meta->url && $torrent->igdb != 0 && $torrent->igdb != null) - - + @if (isset($meta) && $meta->url && $torrent->igdb !== 0 && $torrent->igdb !== null) + + IGDB: {{ $torrent->igdb }} @endif - @if (isset($meta) && $meta->genres) + @if (isset($trailer)) + + @lang('torrent.trailer') + + + + @endif + +
+ @if (isset($meta->genres)) @foreach ($meta->genres as $genre) - {{ $genre['name'] }} + {{ $genre['name'] }} + + @endforeach + @endif + +
+ @if ($torrent->keywords) + @foreach ($torrent->keywords as $keyword) + + + {{ $keyword->name }} + @endforeach @endif
- @if (isset($meta) && $meta->rating && $meta->rating_count) - @lang('torrent.rating'): - - - - {{ \round($meta->rating) }}/100 ({{ $meta->rating_count }} @lang('torrent.votes')) + @lang('torrent.rating'): + + - @endif + {{ round($meta->rating) ?? 0 }}/100 ({{ $meta->rating_count ?? 0 }} @lang('torrent.votes')) +
+ + Platforms: +