From 992245bbccc0a9ec3a516cbc3abacd182edbc9ae Mon Sep 17 00:00:00 2001 From: HDVinnie Date: Wed, 28 Oct 2020 20:42:44 +0000 Subject: [PATCH] Apply fixes from StyleCI [ci skip] [skip ci] --- app/Console/Commands/FetchMeta.php | 5 +- .../Controllers/API/TorrentController.php | 5 +- app/Http/Controllers/CategoryController.php | 4 +- app/Http/Controllers/CommentController.php | 87 +++---- .../MediaHub/CollectionController.php | 19 +- .../MediaHub/CompanyController.php | 7 +- .../Controllers/MediaHub/GenreController.php | 5 +- .../Controllers/MediaHub/HomeController.php | 23 +- .../Controllers/MediaHub/MovieController.php | 7 +- .../MediaHub/NetworkController.php | 7 +- .../Controllers/MediaHub/PersonController.php | 10 +- .../MediaHub/TvSeasonController.php | 9 +- .../Controllers/MediaHub/TvShowController.php | 7 +- app/Http/Controllers/PlaylistController.php | 6 +- app/Http/Controllers/RequestController.php | 10 +- app/Http/Controllers/TorrentController.php | 31 +-- app/Http/Livewire/CollectionSearch.php | 7 +- app/Http/Livewire/CompanySearch.php | 6 +- app/Http/Livewire/MovieSearch.php | 4 +- app/Http/Livewire/NetworkSearch.php | 6 +- app/Http/Livewire/PersonSearch.php | 4 +- app/Http/Livewire/TvSearch.php | 4 +- app/Interfaces/WishInterface.php | 2 +- app/Jobs/ProcessCollectionJob.php | 12 +- app/Jobs/ProcessCompanyJob.php | 12 +- app/Jobs/ProcessMovieJob.php | 85 +++--- app/Jobs/ProcessTvJob.php | 165 ++++++------ app/Models/Cast.php | 1 - app/Models/Crew.php | 1 - app/Models/Episode.php | 2 +- app/Models/GuestStar.php | 2 - app/Models/Movie.php | 7 +- app/Models/Network.php | 1 + app/Models/Person.php | 1 - app/Models/Tv.php | 7 +- app/Repositories/TorrentFacetedRepository.php | 2 +- app/Repositories/WishRepository.php | 6 +- app/Services/Tmdb/Client/Collection.php | 37 ++- app/Services/Tmdb/Client/Company.php | 65 +++-- app/Services/Tmdb/Client/Episode.php | 30 +-- app/Services/Tmdb/Client/FindMovie.php | 14 +- app/Services/Tmdb/Client/FindTv.php | 13 +- app/Services/Tmdb/Client/Genre.php | 120 +++++---- app/Services/Tmdb/Client/Movie.php | 167 ++++++------ app/Services/Tmdb/Client/Network.php | 124 +++++---- app/Services/Tmdb/Client/Person.php | 124 +++++---- app/Services/Tmdb/Client/Season.php | 79 +++--- app/Services/Tmdb/Client/TV.php | 245 ++++++++++-------- app/Services/Tmdb/TMDB.php | 62 ++--- app/Services/Tmdb/TMDBScraper.php | 121 +++++---- .../2019_07_30_210848_create_tv_table.php | 4 +- ...2019_07_30_210849_create_seasons_table.php | 4 +- .../2019_07_30_210850_create_cast_table.php | 4 +- ...9_07_30_210850_create_collection_table.php | 4 +- ...19_07_30_210850_create_companies_table.php | 4 +- ...019_07_30_210850_create_episodes_table.php | 4 +- .../2019_07_30_210850_create_genres_table.php | 4 +- .../2019_07_30_210850_create_movie_table.php | 4 +- ...019_07_30_210850_create_networks_table.php | 4 +- .../2019_07_30_210850_create_person_table.php | 4 +- ...07_31_210850_create_cast_episode_table.php | 5 +- ...9_07_31_210850_create_cast_movie_table.php | 4 +- ..._07_31_210850_create_cast_season_table.php | 4 +- ...2019_07_31_210850_create_cast_tv_table.php | 4 +- ...9_07_31_210850_create_company_tv_table.php | 4 +- ...07_31_210850_create_crew_episode_table.php | 4 +- ...9_07_31_210850_create_crew_movie_table.php | 4 +- ..._07_31_210850_create_crew_season_table.php | 4 +- ...2019_07_31_210850_create_crew_tv_table.php | 4 +- ...210850_create_episode_guest_star_table.php | 4 +- ..._31_210850_create_episode_person_table.php | 4 +- ...019_07_31_210850_create_genre_tv_table.php | 4 +- ...9_07_31_210850_create_network_tv_table.php | 4 +- ...07_31_210850_create_person_movie_table.php | 4 +- ...19_07_31_210850_create_person_tv_table.php | 4 +- ...1_210851_create_collection_movie_table.php | 4 +- ...7_31_210851_create_company_movie_table.php | 4 +- ..._07_31_210851_create_genre_movie_table.php | 4 +- ...7_31_210851_create_person_season_table.php | 4 +- ...020_03_02_031656_update_comments_table.php | 4 +- 80 files changed, 1009 insertions(+), 892 deletions(-) diff --git a/app/Console/Commands/FetchMeta.php b/app/Console/Commands/FetchMeta.php index 05f193b7c..f84d887da 100644 --- a/app/Console/Commands/FetchMeta.php +++ b/app/Console/Commands/FetchMeta.php @@ -13,12 +13,11 @@ namespace App\Console\Commands; -use Exception; -use App\Models\Tv; use App\Models\Movie; use App\Models\Torrent; -use Illuminate\Console\Command; +use App\Models\Tv; use App\Services\Tmdb\TMDBScraper; +use Illuminate\Console\Command; class FetchMeta extends Command { diff --git a/app/Http/Controllers/API/TorrentController.php b/app/Http/Controllers/API/TorrentController.php index 60b70d43c..fb71d0717 100644 --- a/app/Http/Controllers/API/TorrentController.php +++ b/app/Http/Controllers/API/TorrentController.php @@ -17,7 +17,6 @@ use App\Helpers\Bencode; use App\Helpers\MediaInfo; use App\Helpers\TorrentHelper; use App\Helpers\TorrentTools; -use App\Services\Tmdb\TMDBScraper; use App\Http\Resources\TorrentResource; use App\Http\Resources\TorrentsResource; use App\Models\Category; @@ -26,6 +25,7 @@ use App\Models\Torrent; use App\Models\TorrentFile; use App\Models\User; use App\Repositories\ChatRepository; +use App\Services\Tmdb\TMDBScraper; use Carbon\Carbon; use DB; use Illuminate\Http\Request; @@ -67,8 +67,9 @@ class TorrentController extends BaseController * * @param \Illuminate\Http\Request $request * - * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response * @throws \Illuminate\Contracts\Container\BindingResolutionException + * + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response */ public function store(Request $request) { diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 5688eac7a..95ac49cc4 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -13,8 +13,8 @@ namespace App\Http\Controllers; -use App\Models\Category; use App\Models\Bookmark; +use App\Models\Category; use App\Models\PersonalFreeleech; use App\Models\Torrent; use Illuminate\Http\Request; @@ -57,7 +57,7 @@ class CategoryController extends Controller 'user' => $user, 'category' => $category, 'personal_freeleech' => $personal_freeleech, - 'bookmarks' => $bookmarks + 'bookmarks' => $bookmarks, ]); } } diff --git a/app/Http/Controllers/CommentController.php b/app/Http/Controllers/CommentController.php index e90210035..7e0bb596c 100644 --- a/app/Http/Controllers/CommentController.php +++ b/app/Http/Controllers/CommentController.php @@ -90,79 +90,78 @@ class CommentController extends Controller $comment->collection_id = $collection->id; $v = validator($comment->toArray(), [ - 'content' => 'required', - 'user_id' => 'required', + 'content' => 'required', + 'user_id' => 'required', 'collection_id' => 'required', - 'anon' => 'required', + 'anon' => 'required', ]); if ($v->fails()) { return redirect()->route('collection.show', ['id' => $collection->id]) ->withErrors($v->errors()); - } else { - $comment->save(); + } + $comment->save(); - $collection_url = href_collection($collection); - $profile_url = href_profile($user); + $collection_url = href_collection($collection); + $profile_url = href_profile($user); - // Auto Shout - if ($comment->anon == 0) { - $this->chatRepository->systemMessage( + // Auto Shout + if ($comment->anon == 0) { + $this->chatRepository->systemMessage( "[url={$profile_url}]{$user->username}[/url] has left a comment on collection [url={$collection_url}]{$collection->name}[/url]" ); - } else { - $this->chatRepository->systemMessage( + } else { + $this->chatRepository->systemMessage( "An anonymous user has left a comment on collection [url={$collection_url}]{$collection->name}[/url]" ); - } + } - if ($this->taggedUserRepository->hasTags($request->input('content'))) { - if ($this->taggedUserRepository->contains($request->input('content'), '@here') && $user->group->is_modo) { - $users = collect([]); + if ($this->taggedUserRepository->hasTags($request->input('content'))) { + if ($this->taggedUserRepository->contains($request->input('content'), '@here') && $user->group->is_modo) { + $users = collect([]); - $collection->comments()->get()->each(function ($c, $v) use ($users) { - $users->push($c->user); - }); - $this->tag->messageCommentUsers( + $collection->comments()->get()->each(function ($c, $v) use ($users) { + $users->push($c->user); + }); + $this->tag->messageCommentUsers( 'collection', $users, $user, 'Staff', $comment ); + } else { + if ($comment->anon) { + $sender = 'Anonymous'; } else { - if ($comment->anon) { - $sender = 'Anonymous'; - } else { - $sender = $user->username; - } - $this->taggedUserRepository->messageTaggedCommentUsers( + $sender = $user->username; + } + $this->taggedUserRepository->messageTaggedCommentUsers( 'collection', $request->input('content'), $user, $sender, $comment ); - } } - - // Achievements - $user->unlock(new UserMadeComment(), 1); - $user->addProgress(new UserMadeTenComments(), 1); - $user->addProgress(new UserMade50Comments(), 1); - $user->addProgress(new UserMade100Comments(), 1); - $user->addProgress(new UserMade200Comments(), 1); - $user->addProgress(new UserMade300Comments(), 1); - $user->addProgress(new UserMade400Comments(), 1); - $user->addProgress(new UserMade500Comments(), 1); - $user->addProgress(new UserMade600Comments(), 1); - $user->addProgress(new UserMade700Comments(), 1); - $user->addProgress(new UserMade800Comments(), 1); - $user->addProgress(new UserMade900Comments(), 1); - - return redirect()->route('mediahub.collections.show', ['id' => $collection->id, 'hash' => '#comments']) - ->withSuccess('Your Comment Has Been Added!'); } + + // Achievements + $user->unlock(new UserMadeComment(), 1); + $user->addProgress(new UserMadeTenComments(), 1); + $user->addProgress(new UserMade50Comments(), 1); + $user->addProgress(new UserMade100Comments(), 1); + $user->addProgress(new UserMade200Comments(), 1); + $user->addProgress(new UserMade300Comments(), 1); + $user->addProgress(new UserMade400Comments(), 1); + $user->addProgress(new UserMade500Comments(), 1); + $user->addProgress(new UserMade600Comments(), 1); + $user->addProgress(new UserMade700Comments(), 1); + $user->addProgress(new UserMade800Comments(), 1); + $user->addProgress(new UserMade900Comments(), 1); + + return redirect()->route('mediahub.collections.show', ['id' => $collection->id, 'hash' => '#comments']) + ->withSuccess('Your Comment Has Been Added!'); } /** diff --git a/app/Http/Controllers/MediaHub/CollectionController.php b/app/Http/Controllers/MediaHub/CollectionController.php index 1373b1806..2565cefb6 100644 --- a/app/Http/Controllers/MediaHub/CollectionController.php +++ b/app/Http/Controllers/MediaHub/CollectionController.php @@ -1,11 +1,12 @@ $company, ]); } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/MediaHub/GenreController.php b/app/Http/Controllers/MediaHub/GenreController.php index 42fa7bd2a..ce765ad0f 100644 --- a/app/Http/Controllers/MediaHub/GenreController.php +++ b/app/Http/Controllers/MediaHub/GenreController.php @@ -1,11 +1,12 @@ $movies, ]); } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/MediaHub/HomeController.php b/app/Http/Controllers/MediaHub/HomeController.php index 83d9cbdf4..fb21997c1 100644 --- a/app/Http/Controllers/MediaHub/HomeController.php +++ b/app/Http/Controllers/MediaHub/HomeController.php @@ -1,24 +1,25 @@ $tv, - 'movies' => $movies, + 'tv' => $tv, + 'movies' => $movies, 'collections' => $collections, - 'persons' => $persons, - 'genres' => $genres, - 'networks' => $networks, - 'companies' => $companies, + 'persons' => $persons, + 'genres' => $genres, + 'networks' => $networks, + 'companies' => $companies, ]); } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/MediaHub/MovieController.php b/app/Http/Controllers/MediaHub/MovieController.php index 0c1e2dade..88457bfe2 100644 --- a/app/Http/Controllers/MediaHub/MovieController.php +++ b/app/Http/Controllers/MediaHub/MovieController.php @@ -1,19 +1,20 @@ $network, ]); } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/MediaHub/PersonController.php b/app/Http/Controllers/MediaHub/PersonController.php index fe69969e8..e5cee6430 100644 --- a/app/Http/Controllers/MediaHub/PersonController.php +++ b/app/Http/Controllers/MediaHub/PersonController.php @@ -1,25 +1,25 @@ $show, ]); } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/MediaHub/TvShowController.php b/app/Http/Controllers/MediaHub/TvShowController.php index ea88f6437..a01286fe4 100644 --- a/app/Http/Controllers/MediaHub/TvShowController.php +++ b/app/Http/Controllers/MediaHub/TvShowController.php @@ -1,19 +1,20 @@ $show, ]); } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/PlaylistController.php b/app/Http/Controllers/PlaylistController.php index df0bcc509..22a8ea821 100644 --- a/app/Http/Controllers/PlaylistController.php +++ b/app/Http/Controllers/PlaylistController.php @@ -13,17 +13,17 @@ namespace App\Http\Controllers; -use ZipArchive; -use App\Models\Tv; +use App\Helpers\Bencode; use App\Models\Movie; use App\Models\Playlist; -use App\Helpers\Bencode; use App\Models\PlaylistTorrent; use App\Models\Torrent; +use App\Models\Tv; use App\Repositories\ChatRepository; use Illuminate\Http\Request; use Illuminate\Support\Facades\File; use Intervention\Image\Facades\Image; +use ZipArchive; /** * @see \Tests\Todo\Feature\Http\Controllers\PlaylistControllerTest diff --git a/app/Http/Controllers/RequestController.php b/app/Http/Controllers/RequestController.php index 348724673..660e39043 100644 --- a/app/Http/Controllers/RequestController.php +++ b/app/Http/Controllers/RequestController.php @@ -13,20 +13,19 @@ namespace App\Http\Controllers; -use App\Models\Tv; -use App\Models\Movie; -use App\Services\Tmdb\TMDBScraper; use App\Achievements\UserFilled100Requests; use App\Achievements\UserFilled25Requests; use App\Achievements\UserFilled50Requests; use App\Achievements\UserFilled75Requests; use App\Models\BonTransactions; use App\Models\Category; +use App\Models\Movie; use App\Models\Resolution; use App\Models\Torrent; use App\Models\TorrentRequest; use App\Models\TorrentRequestBounty; use App\Models\TorrentRequestClaim; +use App\Models\Tv; use App\Models\Type; use App\Models\User; use App\Notifications\NewRequestBounty; @@ -37,6 +36,7 @@ use App\Notifications\NewRequestFillReject; use App\Notifications\NewRequestUnclaim; use App\Repositories\ChatRepository; use App\Repositories\RequestFacetedRepository; +use App\Services\Tmdb\TMDBScraper; use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -261,9 +261,9 @@ class RequestController extends Controller if ($torrentRequest->category->game_meta) { if ($torrentRequest->igdb || $torrentRequest->igdb != 0) { $meta = Game::with([ - 'cover' => ['url', 'image_id'], + 'cover' => ['url', 'image_id'], 'artworks' => ['url', 'image_id'], - 'genres' => ['name'] + 'genres' => ['name'], ])->find($torrentRequest->igdb); } } diff --git a/app/Http/Controllers/TorrentController.php b/app/Http/Controllers/TorrentController.php index c8c77ca67..1139c67d7 100644 --- a/app/Http/Controllers/TorrentController.php +++ b/app/Http/Controllers/TorrentController.php @@ -13,14 +13,10 @@ namespace App\Http\Controllers; -use App\Models\Tv; -use App\Models\Movie; -use App\Models\Keyword; use App\Bots\IRCAnnounceBot; use App\Helpers\Bbcode; use App\Helpers\Bencode; use App\Helpers\MediaInfo; -use App\Models\GenreTorrent; use App\Helpers\TorrentHelper; use App\Helpers\TorrentTools; use App\Models\BonTransactions; @@ -28,8 +24,11 @@ use App\Models\Bookmark; use App\Models\Category; use App\Models\FeaturedTorrent; use App\Models\FreeleechToken; +use App\Models\GenreTorrent; use App\Models\Graveyard; use App\Models\History; +use App\Models\Keyword; +use App\Models\Movie; use App\Models\Peer; use App\Models\PersonalFreeleech; use App\Models\PlaylistTorrent; @@ -39,13 +38,14 @@ use App\Models\Subtitle; use App\Models\Torrent; use App\Models\TorrentFile; use App\Models\TorrentRequest; +use App\Models\Tv; use App\Models\Type; use App\Models\User; use App\Models\Warning; -use App\Services\Tmdb\TMDBScraper; use App\Notifications\NewReseedRequest; use App\Repositories\ChatRepository; use App\Repositories\TorrentFacetedRepository; +use App\Services\Tmdb\TMDBScraper; use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Pagination\LengthAwarePaginator as Paginator; @@ -203,9 +203,9 @@ class TorrentController extends Controller if ($torrent->category->game_meta) { if ($torrent->igdb || $torrent->igdb != 0) { $meta = Game::with([ - 'cover' => ['url', 'image_id'], + 'cover' => ['url', 'image_id'], 'artworks' => ['url', 'image_id'], - 'genres' => ['name'] + 'genres' => ['name'], ])->find($torrent->igdb); } } @@ -336,9 +336,9 @@ class TorrentController extends Controller if ($d['chunk']->category->game_meta) { if ($d['chunk']->igdb || $d['chunk']->igdb != 0) { $meta = Game::with([ - 'cover' => ['url', 'image_id'], + 'cover' => ['url', 'image_id'], 'artworks' => ['url', 'image_id'], - 'genres' => ['name'] + 'genres' => ['name'], ])->find($d['chunk']->igdb); } } @@ -838,9 +838,9 @@ class TorrentController extends Controller if ($d['chunk']->category->game_meta) { if ($d['chunk']->igdb || $d['chunk']->igdb != 0) { $meta = Game::with([ - 'cover' => ['url', 'image_id'], + 'cover' => ['url', 'image_id'], 'artworks' => ['url', 'image_id'], - 'genres' => ['name'] + 'genres' => ['name'], ])->find($d['chunk']->igdb); } } @@ -869,9 +869,9 @@ class TorrentController extends Controller if ($torrent->category->game_meta) { if ($torrent->igdb || $torrent->igdb != 0) { $meta = Game::with([ - 'cover' => ['url', 'image_id'], + 'cover' => ['url', 'image_id'], 'artworks' => ['url', 'image_id'], - 'genres' => ['name'] + 'genres' => ['name'], ])->find($torrent->igdb); } } @@ -935,13 +935,14 @@ class TorrentController extends Controller * * @return array */ - private static function parseKeywords($text) { + private static function parseKeywords($text) + { $parts = explode(', ', $text); $len = count($parts); $result = []; foreach ($parts as $part) { $part = trim($part); - if ($part != "") { + if ($part != '') { array_push($result, $part); } } diff --git a/app/Http/Livewire/CollectionSearch.php b/app/Http/Livewire/CollectionSearch.php index d24f759f0..3804eac3a 100644 --- a/app/Http/Livewire/CollectionSearch.php +++ b/app/Http/Livewire/CollectionSearch.php @@ -2,9 +2,8 @@ namespace App\Http\Livewire; -use App\Models\Person; -use Livewire\Component; use App\Models\Collection; +use Livewire\Component; use Livewire\WithPagination; class CollectionSearch extends Component @@ -32,10 +31,10 @@ class CollectionSearch extends Component public function render() { - $search_term = '%' . $this->searchTerm . '%'; + $search_term = '%'.$this->searchTerm.'%'; return view('livewire.collection-search', [ - 'collections' => Collection::withCount('movie')->with('movie')->where('name', 'LIKE', $search_term)->orderBy('name', 'asc')->paginate(25) + 'collections' => Collection::withCount('movie')->with('movie')->where('name', 'LIKE', $search_term)->orderBy('name', 'asc')->paginate(25), ]); } } diff --git a/app/Http/Livewire/CompanySearch.php b/app/Http/Livewire/CompanySearch.php index 9073007a9..5b9023ed0 100644 --- a/app/Http/Livewire/CompanySearch.php +++ b/app/Http/Livewire/CompanySearch.php @@ -2,8 +2,8 @@ namespace App\Http\Livewire; -use Livewire\Component; use App\Models\Company; +use Livewire\Component; use Livewire\WithPagination; class CompanySearch extends Component @@ -31,10 +31,10 @@ class CompanySearch extends Component public function render() { - $search_term = '%' . $this->searchTerm . '%'; + $search_term = '%'.$this->searchTerm.'%'; return view('livewire.company-search', [ - 'companies' => Company::withCount('tv', 'movie')->where('name', 'LIKE', $search_term)->orderBy('name', 'asc')->paginate(30) + 'companies' => Company::withCount('tv', 'movie')->where('name', 'LIKE', $search_term)->orderBy('name', 'asc')->paginate(30), ]); } } diff --git a/app/Http/Livewire/MovieSearch.php b/app/Http/Livewire/MovieSearch.php index c3d708d00..102c8b24c 100644 --- a/app/Http/Livewire/MovieSearch.php +++ b/app/Http/Livewire/MovieSearch.php @@ -31,10 +31,10 @@ class MovieSearch extends Component public function render() { - $search_term = '%' . $this->searchTerm . '%'; + $search_term = '%'.$this->searchTerm.'%'; return view('livewire.movie-search', [ - 'movies' => Movie::with('companies', 'genres')->withCount('torrents')->where('title', 'LIKE', $search_term)->orderBy('title', 'asc')->paginate(30) + 'movies' => Movie::with('companies', 'genres')->withCount('torrents')->where('title', 'LIKE', $search_term)->orderBy('title', 'asc')->paginate(30), ]); } } diff --git a/app/Http/Livewire/NetworkSearch.php b/app/Http/Livewire/NetworkSearch.php index 68ac9f132..8a6c4bab5 100644 --- a/app/Http/Livewire/NetworkSearch.php +++ b/app/Http/Livewire/NetworkSearch.php @@ -2,8 +2,8 @@ namespace App\Http\Livewire; -use Livewire\Component; use App\Models\Network; +use Livewire\Component; use Livewire\WithPagination; class NetworkSearch extends Component @@ -31,10 +31,10 @@ class NetworkSearch extends Component public function render() { - $search_term = '%' . $this->searchTerm . '%'; + $search_term = '%'.$this->searchTerm.'%'; return view('livewire.network-search', [ - 'networks' => Network::withCount('tv')->where('name', 'LIKE', $search_term)->orderBy('name', 'asc')->paginate(30) + 'networks' => Network::withCount('tv')->where('name', 'LIKE', $search_term)->orderBy('name', 'asc')->paginate(30), ]); } } diff --git a/app/Http/Livewire/PersonSearch.php b/app/Http/Livewire/PersonSearch.php index b11f92a0f..b20ff4c3a 100644 --- a/app/Http/Livewire/PersonSearch.php +++ b/app/Http/Livewire/PersonSearch.php @@ -31,10 +31,10 @@ class PersonSearch extends Component public function render() { - $search_term = '%' . $this->searchTerm . '%'; + $search_term = '%'.$this->searchTerm.'%'; return view('livewire.person-search', [ - 'persons' => Person::select(['id', 'still', 'name'])->whereNotNull('still')->where('name', 'LIKE', $search_term)->orderBy('name', 'asc')->paginate(30) + 'persons' => Person::select(['id', 'still', 'name'])->whereNotNull('still')->where('name', 'LIKE', $search_term)->orderBy('name', 'asc')->paginate(30), ]); } } diff --git a/app/Http/Livewire/TvSearch.php b/app/Http/Livewire/TvSearch.php index 64e60e0b9..c63e2327e 100644 --- a/app/Http/Livewire/TvSearch.php +++ b/app/Http/Livewire/TvSearch.php @@ -31,10 +31,10 @@ class TvSearch extends Component public function render() { - $search_term = '%' . $this->searchTerm . '%'; + $search_term = '%'.$this->searchTerm.'%'; return view('livewire.tv-search', [ - 'shows' => Tv::with('networks', 'genres', 'torrents')->withCount('torrents', 'seasons')->where('name', 'LIKE', $search_term)->orderBy('name', 'asc')->paginate(30) + 'shows' => Tv::with('networks', 'genres', 'torrents')->withCount('torrents', 'seasons')->where('name', 'LIKE', $search_term)->orderBy('name', 'asc')->paginate(30), ]); } } diff --git a/app/Interfaces/WishInterface.php b/app/Interfaces/WishInterface.php index 2a9bda0c7..c46b5aa3c 100644 --- a/app/Interfaces/WishInterface.php +++ b/app/Interfaces/WishInterface.php @@ -16,7 +16,7 @@ namespace App\Interfaces; interface WishInterface { public function all(); - + public function findById($id); public function findByTitle($title); diff --git a/app/Jobs/ProcessCollectionJob.php b/app/Jobs/ProcessCollectionJob.php index 4401b62ab..1cbc08018 100644 --- a/app/Jobs/ProcessCollectionJob.php +++ b/app/Jobs/ProcessCollectionJob.php @@ -15,14 +15,17 @@ namespace App\Jobs; use App\Services\Tmdb\TMDBScraper; use Illuminate\Bus\Queueable; -use Illuminate\Queue\SerializesModels; -use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; class ProcessCollectionJob implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Dispatchable; + use InteractsWithQueue; + use Queueable; + use SerializesModels; public $collection; @@ -43,8 +46,7 @@ class ProcessCollectionJob implements ShouldQueue */ public function handle() { - foreach ($this->collection["parts"] as $parts) { - + foreach ($this->collection['parts'] as $parts) { $metadata = new TMDBScraper(); $metadata->movie($parts['id']); } diff --git a/app/Jobs/ProcessCompanyJob.php b/app/Jobs/ProcessCompanyJob.php index fd0999d6d..c2b27d119 100644 --- a/app/Jobs/ProcessCompanyJob.php +++ b/app/Jobs/ProcessCompanyJob.php @@ -15,14 +15,17 @@ namespace App\Jobs; use App\Services\Tmdb\TMDBScraper; use Illuminate\Bus\Queueable; -use Illuminate\Queue\SerializesModels; -use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; class ProcessCompanyJob implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Dispatchable; + use InteractsWithQueue; + use Queueable; + use SerializesModels; public $company; @@ -43,8 +46,7 @@ class ProcessCompanyJob implements ShouldQueue */ public function handle() { - foreach ($this->company["movie"] as $movie) { - + foreach ($this->company['movie'] as $movie) { $metadata = new TMDBScraper(); $metadata->movie($movie['id']); } diff --git a/app/Jobs/ProcessMovieJob.php b/app/Jobs/ProcessMovieJob.php index b0e70f4bd..273216140 100644 --- a/app/Jobs/ProcessMovieJob.php +++ b/app/Jobs/ProcessMovieJob.php @@ -13,86 +13,87 @@ namespace App\Jobs; -use App\Models\Person; -use App\Services\Tmdb\TMDB; -use Illuminate\Bus\Queueable; -use Illuminate\Queue\SerializesModels; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Bus\Dispatchable; use App\Models\Cast; -use App\Services\Tmdb\Client; -use App\Models\Company; use App\Models\Collection; +use App\Models\Company; use App\Models\Crew; use App\Models\Genre; +use App\Models\Person; +use App\Services\Tmdb\Client; +use App\Services\Tmdb\TMDB; +use Illuminate\Bus\Queueable; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; class ProcessMovieJob implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - + use Dispatchable; + use InteractsWithQueue; + use Queueable; + use SerializesModels; + public $movie; public function __construct($movie) { $this->movie = $movie; } - + public function handle() { $helper = new TMDB(); - - foreach ($this->movie["genres"] as $genre) { + + foreach ($this->movie['genres'] as $genre) { if (isset($genre['name'])) { - Genre::updateOrCreate(["id" => $genre['id']], $genre)->movie()->syncWithoutDetaching([$this->movie['id']]); + Genre::updateOrCreate(['id' => $genre['id']], $genre)->movie()->syncWithoutDetaching([$this->movie['id']]); } } - foreach ($this->movie["production_companies"] as $production_company) { - + foreach ($this->movie['production_companies'] as $production_company) { $client = new Client\Company($production_company['id']); $production_company = $client->index(); if (isset($production_company['name'])) { - $production_company_array = [ - "description" => $production_company['description'] ?? null, - "headquarters" => $production_company['headquarters'] ?? null, - "homepage" => $production_company['homepage'] ?? null, - "logo" => $helper->image('logo', $production_company), - "name" => $production_company['name'] ?? null, - "origin_country" => $production_company['origin_country'], + $production_company_array = [ + 'description' => $production_company['description'] ?? null, + 'headquarters' => $production_company['headquarters'] ?? null, + 'homepage' => $production_company['homepage'] ?? null, + 'logo' => $helper->image('logo', $production_company), + 'name' => $production_company['name'] ?? null, + 'origin_country' => $production_company['origin_country'], ]; - Company::updateOrCreate(["id" => $production_company['id']], $production_company_array)->movie()->syncWithoutDetaching([$this->movie['id']]); + Company::updateOrCreate(['id' => $production_company['id']], $production_company_array)->movie()->syncWithoutDetaching([$this->movie['id']]); } } - if (isset($this->movie["belongs_to_collection"]['id'])) { - $client = new Client\Collection($this->movie["belongs_to_collection"]['id']); + if (isset($this->movie['belongs_to_collection']['id'])) { + $client = new Client\Collection($this->movie['belongs_to_collection']['id']); $belongs_to_collection = $client->index(); - if(isset($belongs_to_collection['name'])){ + if (isset($belongs_to_collection['name'])) { + $titleSort = addslashes(str_replace(['The ', 'An ', 'A ', '"'], [''], $belongs_to_collection['name'])); - $titleSort = addslashes(str_replace(["The ", "An ", "A ", "\""], [""], $belongs_to_collection['name'])); - - $belongs_to_collection_array = [ - "name" => $belongs_to_collection['name'] ?? null, - "name_sort" => $titleSort, - "parts" => count($belongs_to_collection['parts']), - "overview" => $belongs_to_collection['overview'] ?? null, - "poster" => $helper->image('poster', $belongs_to_collection), - "backdrop" => $helper->image('backdrop', $belongs_to_collection), + $belongs_to_collection_array = [ + 'name' => $belongs_to_collection['name'] ?? null, + 'name_sort' => $titleSort, + 'parts' => count($belongs_to_collection['parts']), + 'overview' => $belongs_to_collection['overview'] ?? null, + 'poster' => $helper->image('poster', $belongs_to_collection), + 'backdrop' => $helper->image('backdrop', $belongs_to_collection), ]; - Collection::updateOrCreate(["id" => $belongs_to_collection['id']], $belongs_to_collection_array)->movie()->syncWithoutDetaching([$this->movie['id']]); + Collection::updateOrCreate(['id' => $belongs_to_collection['id']], $belongs_to_collection_array)->movie()->syncWithoutDetaching([$this->movie['id']]); } } - foreach ($this->movie['credits']["cast"] as $person) { + foreach ($this->movie['credits']['cast'] as $person) { if (isset($person['id'])) { - Cast::updateOrCreate(["id" => $person['id']], $helper->cast_array($person))->movie()->syncWithoutDetaching([$this->movie['id']]); - Person::updateOrCreate(["id" => $person['id']], $helper->person_array($person))->movie()->syncWithoutDetaching([$this->movie['id']]); + Cast::updateOrCreate(['id' => $person['id']], $helper->cast_array($person))->movie()->syncWithoutDetaching([$this->movie['id']]); + Person::updateOrCreate(['id' => $person['id']], $helper->person_array($person))->movie()->syncWithoutDetaching([$this->movie['id']]); $client = new Client\Person($person['id']); $people = $client->index(); - Crew::updateOrCreate(["id" => $people['id']], $helper->person_array($people))->movie()->syncWithoutDetaching([$this->movie['id']]); + Crew::updateOrCreate(['id' => $people['id']], $helper->person_array($people))->movie()->syncWithoutDetaching([$this->movie['id']]); } } } diff --git a/app/Jobs/ProcessTvJob.php b/app/Jobs/ProcessTvJob.php index bb730b5ef..8cf504d96 100644 --- a/app/Jobs/ProcessTvJob.php +++ b/app/Jobs/ProcessTvJob.php @@ -13,29 +13,33 @@ namespace App\Jobs; -use App\Services\Tmdb\TMDB; -use Illuminate\Support\Str; -use Illuminate\Bus\Queueable; -use Illuminate\Queue\SerializesModels; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Foundation\Bus\Dispatchable; -use App\Services\Tmdb\Client; -use App\Models\Season; -use App\Models\Episode; use App\Models\Cast; -use App\Models\Crew; use App\Models\Company; +use App\Models\Crew; +use App\Models\Episode; use App\Models\Genre; use App\Models\GuestStar; use App\Models\Network; use App\Models\Person; +use App\Models\Season; +use App\Services\Tmdb\Client; +use App\Services\Tmdb\TMDB; +use Illuminate\Bus\Queueable; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Foundation\Bus\Dispatchable; +use Illuminate\Queue\InteractsWithQueue; +use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Str; class ProcessTvJob implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Dispatchable; + use InteractsWithQueue; + use Queueable; + use SerializesModels; - public $tv, $id; + public $tv; + public $id; public function __construct($tv, $id) { @@ -47,130 +51,125 @@ class ProcessTvJob implements ShouldQueue { $helper = new TMDB(); - foreach ($this->tv["production_companies"] as $production_company) { - if(isset($production_company['name'])) { - - $production_company_array = [ - "description" => $helper->ifExists('description', $production_company), - "name" => $production_company['name'], - "headquarters" => $helper->ifExists('headquarters', $production_company), - "homepage" => $helper->ifExists('homepage', $production_company), - "logo" => $helper->image('logo', $production_company), - "origin_country" => $helper->ifExists('origin_country', $production_company), + foreach ($this->tv['production_companies'] as $production_company) { + if (isset($production_company['name'])) { + $production_company_array = [ + 'description' => $helper->ifExists('description', $production_company), + 'name' => $production_company['name'], + 'headquarters' => $helper->ifExists('headquarters', $production_company), + 'homepage' => $helper->ifExists('homepage', $production_company), + 'logo' => $helper->image('logo', $production_company), + 'origin_country' => $helper->ifExists('origin_country', $production_company), ]; - Company::updateOrCreate(["id" => $production_company['id']], $production_company_array)->tv()->syncWithoutDetaching([$this->tv['id']]); + Company::updateOrCreate(['id' => $production_company['id']], $production_company_array)->tv()->syncWithoutDetaching([$this->tv['id']]); } } - foreach ($this->tv["created_by"] as $person) { + foreach ($this->tv['created_by'] as $person) { if (isset($person['id'])) { - Person::updateOrCreate(["id" => $person['id']], $helper->person_array($person))->tv()->syncWithoutDetaching([$this->id]); + Person::updateOrCreate(['id' => $person['id']], $helper->person_array($person))->tv()->syncWithoutDetaching([$this->id]); } } - foreach ($this->tv["networks"] as $network) { + foreach ($this->tv['networks'] as $network) { $client = new Client\Network($network['id']); $network = $client->index(); if (isset($network['name'])) { if (isset($network['images']['logos'][0]) && array_key_exists('file_path', $network['images']['logos'][0])) { - $logo = "https://image.tmdb.org/t/p/original" . $network['images']['logos'][0]['file_path']; + $logo = 'https://image.tmdb.org/t/p/original'.$network['images']['logos'][0]['file_path']; } else { $logo = null; } - $network_array = [ - "headquarters" => $helper->ifExists('headquarters', $network), - "homepage" => $helper->ifExists('homepage', $network), - "logo" => $logo, - "name" => $network['name'], - "origin_country" => $network['origin_country'], + $network_array = [ + 'headquarters' => $helper->ifExists('headquarters', $network), + 'homepage' => $helper->ifExists('homepage', $network), + 'logo' => $logo, + 'name' => $network['name'], + 'origin_country' => $network['origin_country'], ]; - Network::updateOrCreate(["id" => $network['id']], $network_array)->tv()->syncWithoutDetaching([$this->id]); + Network::updateOrCreate(['id' => $network['id']], $network_array)->tv()->syncWithoutDetaching([$this->id]); } } - foreach ($this->tv["genres"] as $genre) { + foreach ($this->tv['genres'] as $genre) { if (isset($genre['name'])) { - Genre::updateOrCreate(["id" => $genre['id']], $genre)->tv()->syncWithoutDetaching([$this->id]); + Genre::updateOrCreate(['id' => $genre['id']], $genre)->tv()->syncWithoutDetaching([$this->id]); } } - foreach ($this->tv["credits"]["crew"] as $crew) { + foreach ($this->tv['credits']['crew'] as $crew) { if (isset($crew['id'])) { - Crew::updateOrCreate(["id" => $crew['id']], $helper->person_array($crew))->tv()->syncWithoutDetaching([$this->id]); - Person::updateOrCreate(["id" => $crew['id']], $helper->person_array($crew))->tv()->syncWithoutDetaching([$this->id]); + Crew::updateOrCreate(['id' => $crew['id']], $helper->person_array($crew))->tv()->syncWithoutDetaching([$this->id]); + Person::updateOrCreate(['id' => $crew['id']], $helper->person_array($crew))->tv()->syncWithoutDetaching([$this->id]); } } - foreach ($this->tv["credits"]["cast"] as $cast) { + foreach ($this->tv['credits']['cast'] as $cast) { if (isset($cast['id'])) { - Cast::updateOrCreate(["id" => $cast['id']], $helper->cast_array($cast))->tv()->syncWithoutDetaching([$this->id]); - Person::updateOrCreate(["id" => $cast['id']], $helper->person_array($cast))->tv()->syncWithoutDetaching([$this->id]); + Cast::updateOrCreate(['id' => $cast['id']], $helper->cast_array($cast))->tv()->syncWithoutDetaching([$this->id]); + Person::updateOrCreate(['id' => $cast['id']], $helper->person_array($cast))->tv()->syncWithoutDetaching([$this->id]); } } - foreach ($this->tv['seasons'] as $season) { - $client = new Client\Season($this->id, sprintf("%02d", $season['season_number'])); + $client = new Client\Season($this->id, sprintf('%02d', $season['season_number'])); $season = $client->index(); - if(isset($season['season_number'])){ - $season_array = [ - 'air_date' => $helper->ifExists('air_date', $season), - 'poster' => $helper->image('poster', $season), - 'name' => $helper->ifExists('name', $season), - 'overview' => $helper->ifExists('overview', $season), - 'season_number' => sprintf("%02d", $season['season_number']), - 'tv_id' => $this->id, + if (isset($season['season_number'])) { + $season_array = [ + 'air_date' => $helper->ifExists('air_date', $season), + 'poster' => $helper->image('poster', $season), + 'name' => $helper->ifExists('name', $season), + 'overview' => $helper->ifExists('overview', $season), + 'season_number' => sprintf('%02d', $season['season_number']), + 'tv_id' => $this->id, ]; - Season::updateOrCreate(["id" => $season['id']], $season_array)->tv(); + Season::updateOrCreate(['id' => $season['id']], $season_array)->tv(); foreach ($season['episodes'] as $episode) { - - $client = new Client\Episode($this->id, sprintf("%02d", $season['season_number']), $episode['episode_number']); + $client = new Client\Episode($this->id, sprintf('%02d', $season['season_number']), $episode['episode_number']); $episode = $client->index(); - if(isset($episode['episode_number'])){ - $episode_array = [ - 'tv_id' => $this->id, - 'air_date' => $helper->ifExists('air_date', $episode), - 'name' => Str::limit($helper->ifExists('name', $episode), 200), - 'episode_number' => sprintf("%02d", $episode['episode_number']), - 'overview' => $helper->ifExists('overview', $episode), - 'still' => $helper->image('still', $episode), + if (isset($episode['episode_number'])) { + $episode_array = [ + 'tv_id' => $this->id, + 'air_date' => $helper->ifExists('air_date', $episode), + 'name' => Str::limit($helper->ifExists('name', $episode), 200), + 'episode_number' => sprintf('%02d', $episode['episode_number']), + 'overview' => $helper->ifExists('overview', $episode), + 'still' => $helper->image('still', $episode), 'production_code' => $episode['production_code'], - 'season_number' => sprintf("%02d", $episode['season_number']), - 'vote_average' => $episode['vote_average'], - 'vote_count' => $episode['vote_count'], - 'season_id' => $season['id'], + 'season_number' => sprintf('%02d', $episode['season_number']), + 'vote_average' => $episode['vote_average'], + 'vote_count' => $episode['vote_count'], + 'season_id' => $season['id'], ]; - Episode::updateOrCreate(["id" => $episode['id']], $episode_array)->season(); + Episode::updateOrCreate(['id' => $episode['id']], $episode_array)->season(); - foreach ($episode['credits']["guest_stars"] as $person) { - if(isset($person['id'])) { - GuestStar::updateOrCreate(["id" => $person['id']], $helper->person_array($person))->episode()->syncWithoutDetaching([$episode['id']]); - Person::updateOrCreate(["id" => $person['id']], $helper->person_array($person))->tv()->syncWithoutDetaching([$this->id]); + foreach ($episode['credits']['guest_stars'] as $person) { + if (isset($person['id'])) { + GuestStar::updateOrCreate(['id' => $person['id']], $helper->person_array($person))->episode()->syncWithoutDetaching([$episode['id']]); + Person::updateOrCreate(['id' => $person['id']], $helper->person_array($person))->tv()->syncWithoutDetaching([$this->id]); } } } } - foreach ($season['credits']["cast"] as $person) { - + foreach ($season['credits']['cast'] as $person) { if (isset($person['id'])) { - Cast::updateOrCreate(["id" => $person['id']], $helper->cast_array($person))->season()->syncWithoutDetaching([$season['id']]); - Cast::updateOrCreate(["id" => $person['id']], $helper->cast_array($person))->tv()->syncWithoutDetaching([$this->id]); - Person::updateOrCreate(["id" => $person['id']], $helper->person_array($person))->tv()->syncWithoutDetaching([$this->id]); + Cast::updateOrCreate(['id' => $person['id']], $helper->cast_array($person))->season()->syncWithoutDetaching([$season['id']]); + Cast::updateOrCreate(['id' => $person['id']], $helper->cast_array($person))->tv()->syncWithoutDetaching([$this->id]); + Person::updateOrCreate(['id' => $person['id']], $helper->person_array($person))->tv()->syncWithoutDetaching([$this->id]); $client = new Client\Person($person['id']); $people = $client->index(); - Crew::updateOrCreate(["id" => $people['id']], $helper->person_array($people))->season()->syncWithoutDetaching([$season['id']]); + Crew::updateOrCreate(['id' => $people['id']], $helper->person_array($people))->season()->syncWithoutDetaching([$season['id']]); } } - foreach ($season['credits']["crew"] as $crew) { - + foreach ($season['credits']['crew'] as $crew) { if (isset($crew['id'])) { - Crew::updateOrCreate(["id" => $crew['id']], $helper->person_array($crew))->season()->syncWithoutDetaching([$season['id']]); - Person::updateOrCreate(["id" => $crew['id']], $helper->person_array($crew))->tv()->syncWithoutDetaching([$this->id]); + Crew::updateOrCreate(['id' => $crew['id']], $helper->person_array($crew))->season()->syncWithoutDetaching([$season['id']]); + Person::updateOrCreate(['id' => $crew['id']], $helper->person_array($crew))->tv()->syncWithoutDetaching([$this->id]); } } } diff --git a/app/Models/Cast.php b/app/Models/Cast.php index 28436af97..8f1fb9c60 100644 --- a/app/Models/Cast.php +++ b/app/Models/Cast.php @@ -41,5 +41,4 @@ class Cast extends Model { return $this->belongsToMany(Movie::class, 'cast_movie', 'movie_id', 'cast_id'); } - } diff --git a/app/Models/Crew.php b/app/Models/Crew.php index c15e2722b..c9af49801 100644 --- a/app/Models/Crew.php +++ b/app/Models/Crew.php @@ -41,5 +41,4 @@ class Crew extends Model { return $this->belongsToMany(Movie::class, 'crew_movie', 'movie_id', 'person_id'); } - } diff --git a/app/Models/Episode.php b/app/Models/Episode.php index 8f52f3bcf..daf6be018 100644 --- a/app/Models/Episode.php +++ b/app/Models/Episode.php @@ -27,7 +27,7 @@ class Episode extends Model { return $this->belongsTo(Season::class) ->orderBy('season_id') - ->orderBy('episode_id');; + ->orderBy('episode_id'); } public function person() diff --git a/app/Models/GuestStar.php b/app/Models/GuestStar.php index 5a9bd2611..560381c5b 100644 --- a/app/Models/GuestStar.php +++ b/app/Models/GuestStar.php @@ -26,6 +26,4 @@ class GuestStar extends Model { return $this->belongsToMany(Episode::class, 'episode_guest_star', 'episode_id', 'person_id'); } - - } diff --git a/app/Models/Movie.php b/app/Models/Movie.php index 0c1994bc8..0b330b63a 100644 --- a/app/Models/Movie.php +++ b/app/Models/Movie.php @@ -13,7 +13,6 @@ namespace App\Models; -use Illuminate\Support\Facades\DB; use Illuminate\Database\Eloquent\Model; class Movie extends Model @@ -26,28 +25,34 @@ class Movie extends Model { return $this->belongsToMany(Genre::class); } + public function cast() { return $this->belongsToMany(Cast::class, 'cast_movie', 'cast_id', 'movie_id') ->orderBy('movie_id') ->take(6); } + public function crew() { return $this->belongsToMany(Crew::class, 'crew_movie', 'person_id', 'movie_id'); } + public function companies() { return $this->belongsToMany(Company::class); } + public function countries() { return $this->belongsToMany(Company::class); } + public function collection() { return $this->belongsToMany(Collection::class)->take(1); } + public function torrents() { return $this->hasMany(Torrent::class, 'tmdb', 'id'); diff --git a/app/Models/Network.php b/app/Models/Network.php index ccf11220b..dcc9e41fc 100644 --- a/app/Models/Network.php +++ b/app/Models/Network.php @@ -26,6 +26,7 @@ class Network extends Model { return $this->belongsToMany(Tv::class); } + public function movie() { return $this->belongsToMany(Movie::class); diff --git a/app/Models/Person.php b/app/Models/Person.php index 6b0be286f..a32c01c95 100644 --- a/app/Models/Person.php +++ b/app/Models/Person.php @@ -41,5 +41,4 @@ class Person extends Model { return $this->belongsToMany(Movie::class, 'person_movie', 'movie_id', 'person_id'); } - } diff --git a/app/Models/Tv.php b/app/Models/Tv.php index 7f2fe7f22..95a3822e8 100644 --- a/app/Models/Tv.php +++ b/app/Models/Tv.php @@ -13,14 +13,14 @@ namespace App\Models; -Use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Model; class Tv extends Model { protected $guarded = []; protected $primaryKey = 'id'; public $table = 'tv'; - protected $hidden = ["created_at", "updated_at"]; + protected $hidden = ['created_at', 'updated_at']; /** * Has Many Torrents. @@ -59,14 +59,17 @@ class Tv extends Model { return $this->belongsToMany(Genre::class); } + public function creators() { return $this->belongsToMany(Person::class); } + public function networks() { return $this->belongsToMany(Network::class); } + public function companies() { return $this->belongsToMany(Company::class); diff --git a/app/Repositories/TorrentFacetedRepository.php b/app/Repositories/TorrentFacetedRepository.php index 394fad2f6..fc71590c0 100644 --- a/app/Repositories/TorrentFacetedRepository.php +++ b/app/Repositories/TorrentFacetedRepository.php @@ -13,8 +13,8 @@ namespace App\Repositories; -use App\Models\Genre; use App\Models\Category; +use App\Models\Genre; use App\Models\Resolution; use App\Models\Type; diff --git a/app/Repositories/WishRepository.php b/app/Repositories/WishRepository.php index 143ed22f8..151a820e7 100644 --- a/app/Repositories/WishRepository.php +++ b/app/Repositories/WishRepository.php @@ -38,9 +38,9 @@ class WishRepository implements WishInterface /** * WishRepository constructor. * - * @param Wish $wish - * @param User $user - * @param Torrent $torrent + * @param Wish $wish + * @param User $user + * @param Torrent $torrent */ public function __construct(Wish $wish, User $user, Torrent $torrent) { diff --git a/app/Services/Tmdb/Client/Collection.php b/app/Services/Tmdb/Client/Collection.php index f9957f26f..ff985171c 100644 --- a/app/Services/Tmdb/Client/Collection.php +++ b/app/Services/Tmdb/Client/Collection.php @@ -22,21 +22,21 @@ class Collection { $this->client = new \GuzzleHttp\Client( [ - 'base_uri' => self::API_BASE_URI, - 'verify' => false, + 'base_uri' => self::API_BASE_URI, + 'verify' => false, 'http_errors' => false, - 'headers' => [ + 'headers' => [ 'Content-Type' => 'application/json', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], 'query' => [ - 'api_key' => config('api-keys.tmdb'), - 'append_to_response' => 'videos,images,credits' + 'api_key' => config('api-keys.tmdb'), + 'append_to_response' => 'videos,images,credits', ], ] ); - $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/collection/' . $id); + $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/collection/'.$id); $this->data = json_decode($response->getBody()->getContents(), true); } @@ -48,35 +48,34 @@ class Collection public function get_name() { - return preg_replace('/[[:^print:]]/', '', $this->data["name"]); + return preg_replace('/[[:^print:]]/', '', $this->data['name']); } public function get_overview() { - return preg_replace('/[[:^print:]]/', '', $this->data["overview"]); + return preg_replace('/[[:^print:]]/', '', $this->data['overview']); } public function get_id() { - return $this->data["id"]; + return $this->data['id']; } public function get_backdrop() { - if ($this->data["backdrop_path"]) { - return "https://image.tmdb.org/t/p/original" . $this->data["backdrop_path"]; - } else { - return null; + if ($this->data['backdrop_path']) { + return 'https://image.tmdb.org/t/p/original'.$this->data['backdrop_path']; } + + return null; } public function get_poster() { - if ($this->data["poster_path"]) { - return "https://image.tmdb.org/t/p/original" . $this->data["poster_path"]; - } else { - return null; + if ($this->data['poster_path']) { + return 'https://image.tmdb.org/t/p/original'.$this->data['poster_path']; } - } + return null; + } } diff --git a/app/Services/Tmdb/Client/Company.php b/app/Services/Tmdb/Client/Company.php index 9e7aacc65..2fbc1c17e 100644 --- a/app/Services/Tmdb/Client/Company.php +++ b/app/Services/Tmdb/Client/Company.php @@ -22,25 +22,26 @@ class Company { $this->client = new \GuzzleHttp\Client( [ - 'base_uri' => self::API_BASE_URI, - 'verify' => false, + 'base_uri' => self::API_BASE_URI, + 'verify' => false, 'http_errors' => false, - 'headers' => [ + 'headers' => [ 'Content-Type' => 'application/json', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], 'query' => [ - 'api_key' => config('api-keys.tmdb'), + 'api_key' => config('api-keys.tmdb'), 'append_to_response' => 'movies,videos,images,credits', - 'page' => $page, + 'page' => $page, ], ] ); - $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/company/' . $id); + $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/company/'.$id); $this->data = json_decode($response->getBody()->getContents(), true); } + public function index() { return $this->data; @@ -48,66 +49,80 @@ class Company public function get_birthday() { - return $this->data["birthday"]; + return $this->data['birthday']; } + public function get_known_for_department() { - return preg_replace('/[[:^print:]]/', '', $this->data["known_for_department"]); + return preg_replace('/[[:^print:]]/', '', $this->data['known_for_department']); } + public function get_deathday() { - return preg_replace('/[[:^print:]]/', '', $this->data["deathday"]); + return preg_replace('/[[:^print:]]/', '', $this->data['deathday']); } + public function get_id() { - return $this->data["id"]; + return $this->data['id']; } + public function get_foto() { - return "https://image.tmdb.org/t/p/original" . $this->data["profile_path"]; + return 'https://image.tmdb.org/t/p/original'.$this->data['profile_path']; } + public function get_name() { - return preg_replace('/[[:^print:]]/', '', $this->data["name"]); + return preg_replace('/[[:^print:]]/', '', $this->data['name']); } + public function get_gender() { - return $this->data["gender"]; + return $this->data['gender']; } + public function get_biography() { - return $this->data["biography"]; + return $this->data['biography']; } + public function get_popularity() { - return $this->data["popularity"]; + return $this->data['popularity']; } + public function get_place_of_birth() { - return $this->data["place_of_birth"]; + return $this->data['place_of_birth']; } + public function get_adult() { - return $this->data["adult"]; + return $this->data['adult']; } + public function get_imdb_id() { - return $this->data["imdb_id"]; + return $this->data['imdb_id']; } + public function get_homepage() { - return $this->data["homepage"]; + return $this->data['homepage']; } + public function get_movies() { - $array = array(); + $array = []; $this->page = 1; - while ($data = $this->data["movies"][$this->page++]) { - $json = json_decode($data, True); #01 - foreach ($json['results'] as $row) $array[] = $row; + while ($data = $this->data['movies'][$this->page++]) { + $json = json_decode($data, true); //01 + foreach ($json['results'] as $row) { + $array[] = $row; + } } return $array; } - } diff --git a/app/Services/Tmdb/Client/Episode.php b/app/Services/Tmdb/Client/Episode.php index c5f74914a..e03f811d3 100644 --- a/app/Services/Tmdb/Client/Episode.php +++ b/app/Services/Tmdb/Client/Episode.php @@ -22,24 +22,25 @@ class Episode { $this->client = new \GuzzleHttp\Client( [ - 'base_uri' => self::API_BASE_URI, - 'verify' => false, + 'base_uri' => self::API_BASE_URI, + 'verify' => false, 'http_errors' => false, - 'headers' => [ + 'headers' => [ 'Content-Type' => 'application/json', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], 'query' => [ - 'api_key' => config('api-keys.tmdb'), - 'append_to_response' => 'video,credits,external_ids' + 'api_key' => config('api-keys.tmdb'), + 'append_to_response' => 'video,credits,external_ids', ], ] ); - $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/tv/' . $id . '/season/' . $season . '/episode/' . $episode); + $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/tv/'.$id.'/season/'.$season.'/episode/'.$episode); $this->data = json_decode($response->getBody()->getContents(), true); } + public function index() { return $this->data; @@ -47,37 +48,36 @@ class Episode public function get_air_date() { - return $this->data["first_air_date"]; + return $this->data['first_air_date']; } public function get_name() { - return preg_replace('/[[:^print:]]/', '', $this->data["name"]); + return preg_replace('/[[:^print:]]/', '', $this->data['name']); } public function get_overview() { - return preg_replace('/[[:^print:]]/', '', $this->data["overview"]); + return preg_replace('/[[:^print:]]/', '', $this->data['overview']); } public function get_id() { - return $this->data["id"]; + return $this->data['id']; } public function get_poster() { - return "https://image.tmdb.org/t/p/original" . $this->data["poster_path"]; + return 'https://image.tmdb.org/t/p/original'.$this->data['poster_path']; } public function get_season_number() { - return sprintf("%02d", $this->data["seasons"]); + return sprintf('%02d', $this->data['seasons']); } public function get_status() { - return $this->data["status"]; + return $this->data['status']; } - } diff --git a/app/Services/Tmdb/Client/FindMovie.php b/app/Services/Tmdb/Client/FindMovie.php index a281779b4..23f2cb8ec 100644 --- a/app/Services/Tmdb/Client/FindMovie.php +++ b/app/Services/Tmdb/Client/FindMovie.php @@ -22,12 +22,12 @@ class FindMovie { $this->client = new \GuzzleHttp\Client( [ - 'base_uri' => self::API_BASE_URI, - 'verify' => false, + 'base_uri' => self::API_BASE_URI, + 'verify' => false, 'http_errors' => false, - 'headers' => [ + 'headers' => [ 'Content-Type' => 'application/json', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], // 'query' => [ // 'api_key' => config('api-keys.tmdb'), @@ -36,10 +36,11 @@ class FindMovie ] ); - $response = $this->client->request('get', 'https://api.themoviedb.org/3/search/movie?api_key=' . config('api-keys.tmdb') . '&query=' . $query . '&first_air_date_year=' . $year); + $response = $this->client->request('get', 'https://api.themoviedb.org/3/search/movie?api_key='.config('api-keys.tmdb').'&query='.$query.'&first_air_date_year='.$year); $this->data = json_decode($response->getBody()->getContents(), true); } + public function index() { return $this->data; @@ -47,7 +48,6 @@ class FindMovie public function get_homepage() { - return $this->data["homepage"]; + return $this->data['homepage']; } - } diff --git a/app/Services/Tmdb/Client/FindTv.php b/app/Services/Tmdb/Client/FindTv.php index 5e3ff68f0..1ee718d97 100644 --- a/app/Services/Tmdb/Client/FindTv.php +++ b/app/Services/Tmdb/Client/FindTv.php @@ -22,12 +22,12 @@ class FindTv { $this->client = new \GuzzleHttp\Client( [ - 'base_uri' => self::API_BASE_URI, - 'verify' => false, + 'base_uri' => self::API_BASE_URI, + 'verify' => false, 'http_errors' => false, - 'headers' => [ + 'headers' => [ 'Content-Type' => 'application/json', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], // 'query' => [ // 'api_key' => config('api-keys.tmdb'), @@ -36,10 +36,11 @@ class FindTv ] ); - $response = $this->client->request('get', 'https://api.themoviedb.org/3/search/tv?api_key=' . config('api-keys.tmdb') . '&query=' . $query . '&first_air_date_year=' . $year); + $response = $this->client->request('get', 'https://api.themoviedb.org/3/search/tv?api_key='.config('api-keys.tmdb').'&query='.$query.'&first_air_date_year='.$year); $this->data = json_decode($response->getBody()->getContents(), true); } + public function index() { return $this->data; @@ -47,6 +48,6 @@ class FindTv public function get_homepage() { - return $this->data["homepage"]; + return $this->data['homepage']; } } diff --git a/app/Services/Tmdb/Client/Genre.php b/app/Services/Tmdb/Client/Genre.php index c5f883327..c505fc379 100644 --- a/app/Services/Tmdb/Client/Genre.php +++ b/app/Services/Tmdb/Client/Genre.php @@ -22,12 +22,12 @@ class Genre { $this->client = new \GuzzleHttp\Client( [ - 'base_uri' => self::API_BASE_URI, - 'verify' => false, + 'base_uri' => self::API_BASE_URI, + 'verify' => false, 'http_errors' => false, - 'headers' => [ + 'headers' => [ 'Content-Type' => 'application/json', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], 'query' => [ 'api_key' => config('api-keys.tmdb'), @@ -35,10 +35,11 @@ class Genre ] ); - $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/genre/' . $id); + $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/genre/'.$id); $this->data = json_decode($response->getBody()->getContents(), true); } + public function index() { return $this->data; @@ -46,55 +47,66 @@ class Genre public function get_birthday() { - return $this->data["birthday"]; - } - public function get_known_for_department() - { - return preg_replace('/[[:^print:]]/', '', $this->data["known_for_department"]); - } - public function get_deathday() - { - return preg_replace('/[[:^print:]]/', '', $this->data["deathday"]); - } - public function get_id() - { - return $this->data["id"]; - } - public function get_foto() - { - return "https://image.tmdb.org/t/p/original" . $this->data["profile_path"]; - } - public function get_name() - { - return preg_replace('/[[:^print:]]/', '', $this->data["name"]); - } - public function get_gender() - { - return $this->data["gender"]; - } - public function get_biography() - { - return $this->data["biography"]; - } - public function get_popularity() - { - return $this->data["popularity"]; - } - public function get_place_of_birth() - { - return $this->data["place_of_birth"]; - } - public function get_adult() - { - return $this->data["adult"]; - } - public function get_imdb_id() - { - return $this->data["imdb_id"]; - } - public function get_homepage() - { - return $this->data["homepage"]; + return $this->data['birthday']; } + public function get_known_for_department() + { + return preg_replace('/[[:^print:]]/', '', $this->data['known_for_department']); + } + + public function get_deathday() + { + return preg_replace('/[[:^print:]]/', '', $this->data['deathday']); + } + + public function get_id() + { + return $this->data['id']; + } + + public function get_foto() + { + return 'https://image.tmdb.org/t/p/original'.$this->data['profile_path']; + } + + public function get_name() + { + return preg_replace('/[[:^print:]]/', '', $this->data['name']); + } + + public function get_gender() + { + return $this->data['gender']; + } + + public function get_biography() + { + return $this->data['biography']; + } + + public function get_popularity() + { + return $this->data['popularity']; + } + + public function get_place_of_birth() + { + return $this->data['place_of_birth']; + } + + public function get_adult() + { + return $this->data['adult']; + } + + public function get_imdb_id() + { + return $this->data['imdb_id']; + } + + public function get_homepage() + { + return $this->data['homepage']; + } } diff --git a/app/Services/Tmdb/Client/Movie.php b/app/Services/Tmdb/Client/Movie.php index d3a829b9c..851ef4230 100644 --- a/app/Services/Tmdb/Client/Movie.php +++ b/app/Services/Tmdb/Client/Movie.php @@ -22,24 +22,25 @@ class Movie { $this->client = new \GuzzleHttp\Client( [ - 'base_uri' => self::API_BASE_URI, - 'verify' => false, + 'base_uri' => self::API_BASE_URI, + 'verify' => false, 'http_errors' => false, - 'headers' => [ + 'headers' => [ 'Content-Type' => 'application/json', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], 'query' => [ - 'api_key' => config('api-keys.tmdb'), - 'append_to_response'=> 'videos,images,credits,external_ids,keywords' + 'api_key' => config('api-keys.tmdb'), + 'append_to_response'=> 'videos,images,credits,external_ids,keywords', ], ] ); - $response = $this->client->request('get', 'https://api.themoviedb.org/3/movie/' . $id); + $response = $this->client->request('get', 'https://api.themoviedb.org/3/movie/'.$id); $this->data = json_decode($response->getBody()->getContents(), true); } + public function index() { return $this->data; @@ -48,131 +49,151 @@ class Movie public function get_background() { if (isset($this->data['backdrop_path'])) { - return "https://image.tmdb.org/t/p/original" . $this->data['backdrop_path']; - } else { - return null; + return 'https://image.tmdb.org/t/p/original'.$this->data['backdrop_path']; } + + return null; } public function get_adult() { - return $this->data["adult"]; + return $this->data['adult']; } public function get_belongs_to_collection() { - return $this->data["belongs_to_collection"]; + return $this->data['belongs_to_collection']; } public function get_budget() { - return preg_replace('/[[:^print:]]/', '', $this->data["budget"]); + return preg_replace('/[[:^print:]]/', '', $this->data['budget']); } + public function get_genres() { - return $this->data["genres"]; + return $this->data['genres']; } + public function get_homepage() { - return preg_replace('/[[:^print:]]/', '', $this->data["homepage"]); + return preg_replace('/[[:^print:]]/', '', $this->data['homepage']); } + public function get_id() { - return $this->data["id"]; + return $this->data['id']; } + public function get_imdb_id() { - return preg_replace('/[[:^print:]]/', '', $this->data["imdb_id"]); + return preg_replace('/[[:^print:]]/', '', $this->data['imdb_id']); } public function get_original_title() { - return preg_replace('/[[:^print:]]/', '', $this->data["original_title"]); + return preg_replace('/[[:^print:]]/', '', $this->data['original_title']); } + public function get_overview() { - return preg_replace('/[[:^print:]]/', '', $this->data["overview"]); + return preg_replace('/[[:^print:]]/', '', $this->data['overview']); } + public function get_popularity() { - return $this->data["popularity"]; + return $this->data['popularity']; } + public function get_poster() { if (isset($this->data['poster_path'])) { - return "https://image.tmdb.org/t/p/original" . $this->data['poster_path']; - } else { - return null; + return 'https://image.tmdb.org/t/p/original'.$this->data['poster_path']; } + + return null; } + public function get_production_companies() { - return $this->data["production_companies"]; + return $this->data['production_companies']; } + public function get_production_countries() { - return $this->data["production_countries"]; + return $this->data['production_countries']; } + public function get_release_date() { - return $this->data["release_date"] ?? null; + return $this->data['release_date'] ?? null; } + public function get_revenue() { - return $this->data["revenue"]; + return $this->data['revenue']; } + public function get_runtime() { - return $this->data["runtime"]; + return $this->data['runtime']; } public function get_status() { - return $this->data["status"]; - } - public function get_tagline() - { - return preg_replace('/[[:^print:]]/', '', $this->data["tagline"]); - } - public function get_title() - { - return preg_replace('/[[:^print:]]/', '', $this->data["title"]); - } - public function get_vote_average() - { - return $this->data["vote_average"]; - } - public function get_vote_count() - { - return $this->data["vote_count"]; - } - public function get_trailer() - { - if ($this->data["videos"]["results"]) { - return "https://www.youtube.com/embed/" . $this->data["videos"]["results"][0]["key"]; - } else { - return null; - } - } - public function get_videos() - { - if ($this->data["videos"]["results"]) { - return "https://www.youtube.com/embed/" . $this->data["videos"]["results"]; - } else { - return null; - } - } - public function get_images() - { - return $this->data["images"]["results"]; - } - public function get_cast() - { - return $this->data["credits"]["cast"]; - } - public function get_crew() - { - return $this->data["credits"]["crew"]; + return $this->data['status']; } + public function get_tagline() + { + return preg_replace('/[[:^print:]]/', '', $this->data['tagline']); + } + + public function get_title() + { + return preg_replace('/[[:^print:]]/', '', $this->data['title']); + } + + public function get_vote_average() + { + return $this->data['vote_average']; + } + + public function get_vote_count() + { + return $this->data['vote_count']; + } + + public function get_trailer() + { + if ($this->data['videos']['results']) { + return 'https://www.youtube.com/embed/'.$this->data['videos']['results'][0]['key']; + } + + return null; + } + + public function get_videos() + { + if ($this->data['videos']['results']) { + return 'https://www.youtube.com/embed/'.$this->data['videos']['results']; + } + + return null; + } + + public function get_images() + { + return $this->data['images']['results']; + } + + public function get_cast() + { + return $this->data['credits']['cast']; + } + + public function get_crew() + { + return $this->data['credits']['crew']; + } } diff --git a/app/Services/Tmdb/Client/Network.php b/app/Services/Tmdb/Client/Network.php index 30e28fbaa..bf457a2c2 100644 --- a/app/Services/Tmdb/Client/Network.php +++ b/app/Services/Tmdb/Client/Network.php @@ -22,24 +22,25 @@ class Network { $this->client = new \GuzzleHttp\Client( [ - 'base_uri' => self::API_BASE_URI, - 'verify' => false, + 'base_uri' => self::API_BASE_URI, + 'verify' => false, 'http_errors' => false, - 'headers' => [ + 'headers' => [ 'Content-Type' => 'application/json', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], 'query' => [ - 'api_key' => config('api-keys.tmdb'), - 'append_to_response'=> 'images' + 'api_key' => config('api-keys.tmdb'), + 'append_to_response'=> 'images', ], ] ); - $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/network/' . $id); + $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/network/'.$id); $this->data = json_decode($response->getBody()->getContents(), true); } + public function index() { return $this->data; @@ -47,55 +48,66 @@ class Network public function get_birthday() { - return $this->data["birthday"]; - } - public function get_known_for_department() - { - return preg_replace('/[[:^print:]]/', '', $this->data["known_for_department"]); - } - public function get_deathday() - { - return preg_replace('/[[:^print:]]/', '', $this->data["deathday"]); - } - public function get_id() - { - return $this->data["id"]; - } - public function get_foto() - { - return "https://image.tmdb.org/t/p/original" . $this->data["profile_path"]; - } - public function get_name() - { - return preg_replace('/[[:^print:]]/', '', $this->data["name"]); - } - public function get_gender() - { - return $this->data["gender"]; - } - public function get_biography() - { - return $this->data["biography"]; - } - public function get_popularity() - { - return $this->data["popularity"]; - } - public function get_place_of_birth() - { - return $this->data["place_of_birth"]; - } - public function get_adult() - { - return $this->data["adult"]; - } - public function get_imdb_id() - { - return $this->data["imdb_id"]; - } - public function get_homepage() - { - return $this->data["homepage"]; + return $this->data['birthday']; } + public function get_known_for_department() + { + return preg_replace('/[[:^print:]]/', '', $this->data['known_for_department']); + } + + public function get_deathday() + { + return preg_replace('/[[:^print:]]/', '', $this->data['deathday']); + } + + public function get_id() + { + return $this->data['id']; + } + + public function get_foto() + { + return 'https://image.tmdb.org/t/p/original'.$this->data['profile_path']; + } + + public function get_name() + { + return preg_replace('/[[:^print:]]/', '', $this->data['name']); + } + + public function get_gender() + { + return $this->data['gender']; + } + + public function get_biography() + { + return $this->data['biography']; + } + + public function get_popularity() + { + return $this->data['popularity']; + } + + public function get_place_of_birth() + { + return $this->data['place_of_birth']; + } + + public function get_adult() + { + return $this->data['adult']; + } + + public function get_imdb_id() + { + return $this->data['imdb_id']; + } + + public function get_homepage() + { + return $this->data['homepage']; + } } diff --git a/app/Services/Tmdb/Client/Person.php b/app/Services/Tmdb/Client/Person.php index 928194000..f937bf35b 100644 --- a/app/Services/Tmdb/Client/Person.php +++ b/app/Services/Tmdb/Client/Person.php @@ -22,24 +22,25 @@ class Person { $this->client = new \GuzzleHttp\Client( [ - 'base_uri' => self::API_BASE_URI, - 'verify' => false, + 'base_uri' => self::API_BASE_URI, + 'verify' => false, 'http_errors' => false, - 'headers' => [ + 'headers' => [ 'Content-Type' => 'application/json', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], 'query' => [ - 'api_key' => config('api-keys.tmdb'), - 'append_to_response' => 'images,credits' + 'api_key' => config('api-keys.tmdb'), + 'append_to_response' => 'images,credits', ], ] ); - $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/person/' . $id); + $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/person/'.$id); $this->data = json_decode($response->getBody()->getContents(), true); } + public function index() { return $this->data; @@ -47,55 +48,66 @@ class Person public function get_birthday() { - return $this->data["birthday"]; - } - public function get_known_for_department() - { - return preg_replace('/[[:^print:]]/', '', $this->data["known_for_department"]); - } - public function get_deathday() - { - return preg_replace('/[[:^print:]]/', '', $this->data["deathday"]); - } - public function get_id() - { - return $this->data["id"]; - } - public function get_foto() - { - return "https://image.tmdb.org/t/p/original" . $this->data["profile_path"]; - } - public function get_name() - { - return preg_replace('/[[:^print:]]/', '', $this->data["name"]); - } - public function get_gender() - { - return $this->data["gender"]; - } - public function get_biography() - { - return $this->data["biography"]; - } - public function get_popularity() - { - return $this->data["popularity"]; - } - public function get_place_of_birth() - { - return $this->data["place_of_birth"]; - } - public function get_adult() - { - return $this->data["adult"]; - } - public function get_imdb_id() - { - return $this->data["imdb_id"]; - } - public function get_homepage() - { - return $this->data["homepage"]; + return $this->data['birthday']; } + public function get_known_for_department() + { + return preg_replace('/[[:^print:]]/', '', $this->data['known_for_department']); + } + + public function get_deathday() + { + return preg_replace('/[[:^print:]]/', '', $this->data['deathday']); + } + + public function get_id() + { + return $this->data['id']; + } + + public function get_foto() + { + return 'https://image.tmdb.org/t/p/original'.$this->data['profile_path']; + } + + public function get_name() + { + return preg_replace('/[[:^print:]]/', '', $this->data['name']); + } + + public function get_gender() + { + return $this->data['gender']; + } + + public function get_biography() + { + return $this->data['biography']; + } + + public function get_popularity() + { + return $this->data['popularity']; + } + + public function get_place_of_birth() + { + return $this->data['place_of_birth']; + } + + public function get_adult() + { + return $this->data['adult']; + } + + public function get_imdb_id() + { + return $this->data['imdb_id']; + } + + public function get_homepage() + { + return $this->data['homepage']; + } } diff --git a/app/Services/Tmdb/Client/Season.php b/app/Services/Tmdb/Client/Season.php index 3c1ac74eb..9ca013080 100644 --- a/app/Services/Tmdb/Client/Season.php +++ b/app/Services/Tmdb/Client/Season.php @@ -20,24 +20,23 @@ class Season public function __construct($id, $season) { - $this->client = new \GuzzleHttp\Client( [ - 'base_uri' => self::API_BASE_URI, - 'verify' => false, + 'base_uri' => self::API_BASE_URI, + 'verify' => false, 'http_errors' => false, - 'headers' => [ + 'headers' => [ 'Content-Type' => 'application/json', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], 'query' => [ - 'api_key' => config('api-keys.tmdb'), - 'append_to_response'=> 'videos,images,credits,external_ids' + 'api_key' => config('api-keys.tmdb'), + 'append_to_response'=> 'videos,images,credits,external_ids', ], ] ); - $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/tv/' . $id . '/season/' . $season); + $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/tv/'.$id.'/season/'.$season); $this->data = json_decode($response->getBody()->getContents(), true); } @@ -49,35 +48,41 @@ class Season public function _id() { - return $this->data["_id"]; - } - public function get_air_date() - { - return $this->data["air_date"]; - } - public function get_name() - { - return preg_replace('/[[:^print:]]/', '', $this->data["name"]); - } - public function get_overview() - { - return preg_replace('/[[:^print:]]/', '', $this->data["overview"]); - } - public function get_id() - { - return $this->data["id"]; - } - public function get_poster() - { - return "https://image.tmdb.org/t/p/original" . $this->data["poster_path"]; - } - public function get_season_number() - { - return sprintf("%02d", $this->data["seasons"]); - } - public function get_status() - { - return $this->data["status"]; + return $this->data['_id']; } + public function get_air_date() + { + return $this->data['air_date']; + } + + public function get_name() + { + return preg_replace('/[[:^print:]]/', '', $this->data['name']); + } + + public function get_overview() + { + return preg_replace('/[[:^print:]]/', '', $this->data['overview']); + } + + public function get_id() + { + return $this->data['id']; + } + + public function get_poster() + { + return 'https://image.tmdb.org/t/p/original'.$this->data['poster_path']; + } + + public function get_season_number() + { + return sprintf('%02d', $this->data['seasons']); + } + + public function get_status() + { + return $this->data['status']; + } } diff --git a/app/Services/Tmdb/Client/TV.php b/app/Services/Tmdb/Client/TV.php index 6b355599c..a97964217 100644 --- a/app/Services/Tmdb/Client/TV.php +++ b/app/Services/Tmdb/Client/TV.php @@ -22,24 +22,25 @@ class TV { $this->client = new \GuzzleHttp\Client( [ - 'base_uri' => self::API_BASE_URI, - 'verify' => false, + 'base_uri' => self::API_BASE_URI, + 'verify' => false, 'http_errors' => false, - 'headers' => [ + 'headers' => [ 'Content-Type' => 'application/json', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], 'query' => [ - 'api_key' => config('api-keys.tmdb'), - 'append_to_response'=> 'videos,images,credits,external_ids' + 'api_key' => config('api-keys.tmdb'), + 'append_to_response'=> 'videos,images,credits,external_ids', ], ] ); - $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/tv/' . $id); + $response = $this->client->request('get', 'https://api.TheMovieDB.org/3/tv/'.$id); $this->data = json_decode($response->getBody()->getContents(), true); } + public function index() { return $this->data; @@ -47,139 +48,161 @@ class TV public function get_backdrop() { - if ($this->data["backdrop_path"]) { - return "https://image.tmdb.org/t/p/original" . $this->data["backdrop_path"]; - } else { - return null; + if ($this->data['backdrop_path']) { + return 'https://image.tmdb.org/t/p/original'.$this->data['backdrop_path']; } + + return null; } public function get_creator() { - return $this->data["created_by"]; + return $this->data['created_by']; } public function get_runtime() { - return $this->data["episode_run_time"]; + return $this->data['episode_run_time']; } public function get_air_date() { - return $this->data["first_air_date"]; + return $this->data['first_air_date']; } + public function get_genres() { - return $this->data["genres"]; + return $this->data['genres']; } + public function get_homepage() { - return $this->data["homepage"]; + return $this->data['homepage']; } + public function get_id() { - return $this->data["id"]; + return $this->data['id']; } + public function get_in_production() { - return $this->data["in_production"]; + return $this->data['in_production']; } public function get_last_air_date() { - return $this->data["last_air_date"]; - } - public function get_last_episode_to_air() - { - return $this->data["last_episode_to_air"]; - } - public function get_name() - { - return preg_replace('/[[:^print:]]/', '', $this->data["name"]); - } - public function get_next_episode_to_air() - { - return $this->data["next_episode_to_air"]; - } - public function get_networks() - { - return $this->data["networks"]; - } - public function get_number_of_episodes() - { - return $this->data["number_of_episodes"]; - } - public function get_origin_country() - { - return $this->data["origin_country"]; - } - public function get_original_language() - { - return $this->data["original_language"]; - } - public function get_original_name() - { - return preg_replace('/[[:^print:]]/', '', $this->data["original_name"]); - } - public function get_overview() - { - return preg_replace('/[[:^print:]]/', '', $this->data["overview"]); - } - public function get_poster() - { - if ($this->data["poster_path"]) { - return "https://image.tmdb.org/t/p/original" . $this->data["poster_path"]; - } else { - return null; - } - } - public function get_production_companies() - { - return $this->data["production_companies"]; - } - public function get_seasons() - { - return $this->data["seasons"]; - } - public function get_status() - { - return $this->data["status"]; - } - public function get_type() - { - return $this->data["type"]; - } - public function get_vote_average() - { - return $this->data["vote_average"]; - } - public function get_vote_count() - { - return $this->data["vote_count"]; - } - public function get_trailer() - { - if ($this->data["videos"]["results"]) { - return "https://www.youtube.com/embed/" . $this->data["videos"]["results"][0]["key"]; - } else { - return null; - } - } - public function get_videos() - { - if ($this->data["videos"]["results"]) { - return "https://www.youtube.com/embed/" . $this->data["videos"]["results"]; - } else { - return null; - } - } - public function get_images() - { - if ($this->data["images"]["results"]) { - return "https://www.youtube.com/embed/" . $this->data["images"]["results"]; - } else { - return null; - } + return $this->data['last_air_date']; } + public function get_last_episode_to_air() + { + return $this->data['last_episode_to_air']; + } + + public function get_name() + { + return preg_replace('/[[:^print:]]/', '', $this->data['name']); + } + + public function get_next_episode_to_air() + { + return $this->data['next_episode_to_air']; + } + + public function get_networks() + { + return $this->data['networks']; + } + + public function get_number_of_episodes() + { + return $this->data['number_of_episodes']; + } + + public function get_origin_country() + { + return $this->data['origin_country']; + } + + public function get_original_language() + { + return $this->data['original_language']; + } + + public function get_original_name() + { + return preg_replace('/[[:^print:]]/', '', $this->data['original_name']); + } + + public function get_overview() + { + return preg_replace('/[[:^print:]]/', '', $this->data['overview']); + } + + public function get_poster() + { + if ($this->data['poster_path']) { + return 'https://image.tmdb.org/t/p/original'.$this->data['poster_path']; + } + + return null; + } + + public function get_production_companies() + { + return $this->data['production_companies']; + } + + public function get_seasons() + { + return $this->data['seasons']; + } + + public function get_status() + { + return $this->data['status']; + } + + public function get_type() + { + return $this->data['type']; + } + + public function get_vote_average() + { + return $this->data['vote_average']; + } + + public function get_vote_count() + { + return $this->data['vote_count']; + } + + public function get_trailer() + { + if ($this->data['videos']['results']) { + return 'https://www.youtube.com/embed/'.$this->data['videos']['results'][0]['key']; + } + + return null; + } + + public function get_videos() + { + if ($this->data['videos']['results']) { + return 'https://www.youtube.com/embed/'.$this->data['videos']['results']; + } + + return null; + } + + public function get_images() + { + if ($this->data['images']['results']) { + return 'https://www.youtube.com/embed/'.$this->data['images']['results']; + } + + return null; + } } diff --git a/app/Services/Tmdb/TMDB.php b/app/Services/Tmdb/TMDB.php index 42606cd0f..2e00e3ebd 100644 --- a/app/Services/Tmdb/TMDB.php +++ b/app/Services/Tmdb/TMDB.php @@ -17,68 +17,68 @@ class TMDB { public function image($type, $array) { - if (isset($array[$type . '_path'])) { - return $type = "https://image.tmdb.org/t/p/original" . $array[$type . '_path']; - } else { - return $type = null; + if (isset($array[$type.'_path'])) { + return $type = 'https://image.tmdb.org/t/p/original'.$array[$type.'_path']; } + + return $type = null; } public function trailer($array) { - if (isset($array["videos"]["results"])) { - return "https://www.youtube.com/embed/" . $array["videos"]["results"][0]["key"]; - } else { - return null; + if (isset($array['videos']['results'])) { + return 'https://www.youtube.com/embed/'.$array['videos']['results'][0]['key']; } + + return null; } public function ifHasItems($type, $array) { if (isset($array[$type][0])) { return $array[$type][0]; - } else { - return null; } + + return null; } public function ifExists($type, $array) { - if (isset($array[$type]) && !empty($array[$type])) { + if (isset($array[$type]) && ! empty($array[$type])) { return $array[$type]; - } else { - return null; } + + return null; } public function cast_array($cast) { return [ - "character" => $cast['character'], - "credit_id" => $cast['credit_id'], - "gender" => $cast['gender'], - "name" => $cast['name'], - "order" => $cast['order'], - 'still' => $this->image('profile', $cast), + 'character' => $cast['character'], + 'credit_id' => $cast['credit_id'], + 'gender' => $cast['gender'], + 'name' => $cast['name'], + 'order' => $cast['order'], + 'still' => $this->image('profile', $cast), ]; } public function person_array($person) { return [ - "birthday" => $this->ifExists('birthday', $person), - "known_for_department" => $this->ifExists('known_for_department', $person), - "deathday" => $this->ifExists('deathday', $person), - "name" => $this->ifExists('name', $person), + 'birthday' => $this->ifExists('birthday', $person), + 'known_for_department' => $this->ifExists('known_for_department', $person), + 'deathday' => $this->ifExists('deathday', $person), + 'name' => $this->ifExists('name', $person), //"also_known_as" => $person['also_known_as'] ?? null, - "gender" => $this->ifExists('gender', $person), - "biography" => $this->ifExists('biography', $person), - "popularity" => $this->ifExists('popularity', $person), - "place_of_birth" => $this->ifExists('place_of_birth', $person), - 'still' => $this->image('profile', $person), - "adult" => $this->ifExists('adult', $person), - "imdb_id" => $this->ifExists('imdb_id', $person), - "homepage" => $this->ifExists('homepage', $person), + 'gender' => $this->ifExists('gender', $person), + 'biography' => $this->ifExists('biography', $person), + 'popularity' => $this->ifExists('popularity', $person), + 'place_of_birth' => $this->ifExists('place_of_birth', $person), + 'still' => $this->image('profile', $person), + 'adult' => $this->ifExists('adult', $person), + 'imdb_id' => $this->ifExists('imdb_id', $person), + 'homepage' => $this->ifExists('homepage', $person), ]; } } diff --git a/app/Services/Tmdb/TMDBScraper.php b/app/Services/Tmdb/TMDBScraper.php index 7be6cd8f8..23ce2d9af 100644 --- a/app/Services/Tmdb/TMDBScraper.php +++ b/app/Services/Tmdb/TMDBScraper.php @@ -13,27 +13,27 @@ namespace App\Services\Tmdb; +use App\Jobs\ProcessCollectionJob; +use App\Jobs\ProcessCompanyJob; +use App\Jobs\ProcessMovieJob; +use App\Jobs\ProcessTvJob; +use App\Models\Collection; +use App\Models\Company; +use App\Models\Movie; +use App\Models\Tv; use DateTime; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Http\Request; use Illuminate\Queue\SerializesModels; -use App\Services\Tmdb\Client; -use App\Models\Collection; -use App\Models\Company; -use App\Jobs\ProcessMovieJob; -use App\Jobs\ProcessTvJob; -use App\Jobs\ProcessCollectionJob; -use App\Jobs\ProcessCompanyJob; -use App\Models\Movie; -use App\Models\Tv; use Illuminate\Support\Str; class TMDBScraper implements ShouldQueue { use SerializesModels; - public function __construct(Request $request = null){ - if($request != null){ + public function __construct(Request $request = null) + { + if ($request != null) { $this->id = $request->query('id') ?? null; } } @@ -50,28 +50,28 @@ class TMDBScraper implements ShouldQueue $tv = $client->index(); if (isset($tv['id'])) { $array = [ - 'backdrop' => $helper->image('backdrop', $tv), - 'episode_run_time' => $helper->ifHasItems('episode_run_time', $tv), - 'first_air_date' => $helper->ifExists('first_air_date', $tv), - 'homepage' => $tv['homepage'], - 'in_production' => $tv['in_production'], - 'last_air_date' => $helper->ifExists('last_air_date', $tv), - 'name' => Str::limit($tv['name'],200), - 'name_sort' => addslashes(str_replace(["The ", "An ", "A ", "\""], [""], Str::limit($tv['name'], 100))), + 'backdrop' => $helper->image('backdrop', $tv), + 'episode_run_time' => $helper->ifHasItems('episode_run_time', $tv), + 'first_air_date' => $helper->ifExists('first_air_date', $tv), + 'homepage' => $tv['homepage'], + 'in_production' => $tv['in_production'], + 'last_air_date' => $helper->ifExists('last_air_date', $tv), + 'name' => Str::limit($tv['name'], 200), + 'name_sort' => addslashes(str_replace(['The ', 'An ', 'A ', '"'], [''], Str::limit($tv['name'], 100))), 'number_of_episodes' => $tv['number_of_episodes'], - 'number_of_seasons' => $tv['number_of_seasons'], - 'origin_country' => $helper->ifHasItems('origin_country', $tv), - 'original_language' => $tv['original_language'], - 'original_name' => $tv['original_name'], - 'overview' => $tv['overview'], - 'popularity' => $tv['popularity'], - 'poster' => $helper->image('poster', $tv), - 'status' => $tv['status'], - 'vote_average' => $tv['vote_average'], - 'vote_count' => $tv['vote_count'], + 'number_of_seasons' => $tv['number_of_seasons'], + 'origin_country' => $helper->ifHasItems('origin_country', $tv), + 'original_language' => $tv['original_language'], + 'original_name' => $tv['original_name'], + 'overview' => $tv['overview'], + 'popularity' => $tv['popularity'], + 'poster' => $helper->image('poster', $tv), + 'status' => $tv['status'], + 'vote_average' => $tv['vote_average'], + 'vote_count' => $tv['vote_count'], ]; - Tv::updateOrCreate(["id" => $id], $array); + Tv::updateOrCreate(['id' => $id], $array); ProcessTvJob::dispatch($tv, $id); @@ -81,7 +81,7 @@ class TMDBScraper implements ShouldQueue public function movie($id = null) { - if($id == null) { + if ($id == null) { $id = $this->id; } @@ -95,32 +95,32 @@ class TMDBScraper implements ShouldQueue preg_match($re, $movie['title'], $matches); $year = (new DateTime($movie['release_date']))->format('Y'); - $titleSort = addslashes(str_replace(["The ", "An ", "A ", "\""], [""], - Str::limit($matches['namesort'] ? $matches['namesort']." ".$year : $movie['title'], 100))); + $titleSort = addslashes(str_replace(['The ', 'An ', 'A ', '"'], [''], + Str::limit($matches['namesort'] ? $matches['namesort'].' '.$year : $movie['title'], 100))); $array = [ - 'adult' => $movie['adult'] ?? 0, - 'backdrop' => $helper->image('backdrop', $movie), - 'budget' => $movie['budget'] ?? null, - 'homepage' => $movie['homepage'] ?? null, - 'imdb_id' => $movie['imdb_id'] ?? null, + 'adult' => $movie['adult'] ?? 0, + 'backdrop' => $helper->image('backdrop', $movie), + 'budget' => $movie['budget'] ?? null, + 'homepage' => $movie['homepage'] ?? null, + 'imdb_id' => $movie['imdb_id'] ?? null, 'original_language' => $movie['original_language'] ?? null, - 'original_title' => $movie['original_title'] ?? null, - 'overview' => $movie['overview'] ?? null, - 'popularity' => $movie['popularity'] ?? null, - 'poster' => $helper->image('poster', $movie), - 'release_date' => $helper->ifExists('release_date', $movie), - 'revenue' => $movie['revenue'] ?? null, - 'runtime' => $movie['runtime'] ?? null, - 'status' => $movie['status'] ?? null, - 'tagline' => $movie['tagline'] ?? null, - 'title' => Str::limit($movie['title'], 200), - 'title_sort' => $titleSort, - 'vote_average' => $movie['vote_average'] ?? null, - 'vote_count' => $movie['vote_count'] ?? null, + 'original_title' => $movie['original_title'] ?? null, + 'overview' => $movie['overview'] ?? null, + 'popularity' => $movie['popularity'] ?? null, + 'poster' => $helper->image('poster', $movie), + 'release_date' => $helper->ifExists('release_date', $movie), + 'revenue' => $movie['revenue'] ?? null, + 'runtime' => $movie['runtime'] ?? null, + 'status' => $movie['status'] ?? null, + 'tagline' => $movie['tagline'] ?? null, + 'title' => Str::limit($movie['title'], 200), + 'title_sort' => $titleSort, + 'vote_average' => $movie['vote_average'] ?? null, + 'vote_count' => $movie['vote_count'] ?? null, ]; - Movie::updateOrCreate(["id" => $movie['id']], $array); + Movie::updateOrCreate(['id' => $movie['id']], $array); ProcessMovieJob::dispatch($movie, $id); @@ -130,7 +130,7 @@ class TMDBScraper implements ShouldQueue public function collection($id = null) { - if($id == null) { + if ($id == null) { $id = $this->id; } @@ -140,12 +140,12 @@ class TMDBScraper implements ShouldQueue $collection = $client->index(); $array = [ - 'name' => $collection['name'], + 'name' => $collection['name'], 'overview' => $collection['overview'], 'backdrop' => $helper->image('backdrop', $collection), - 'poster' => $helper->image('poster', $collection), + 'poster' => $helper->image('poster', $collection), ]; - Collection::updateOrCreate(["id" => $collection['id']], $array); + Collection::updateOrCreate(['id' => $collection['id']], $array); ProcessCollectionJob::dispatch($collection); @@ -154,7 +154,7 @@ class TMDBScraper implements ShouldQueue public function company($id = null) { - if($id == null) { + if ($id == null) { $id = $this->id; } @@ -164,16 +164,15 @@ class TMDBScraper implements ShouldQueue $company = $client->index(); $array = [ - 'name' => $company['name'], + 'name' => $company['name'], 'overview' => $company['overview'], 'backdrop' => $helper->image('backdrop', $company), - 'poster' => $helper->image('poster', $company), + 'poster' => $helper->image('poster', $company), ]; - Company::updateOrCreate(["id" => $company['id']], $array); + Company::updateOrCreate(['id' => $company['id']], $array); ProcessCompanyJob::dispatch($company); //return ['message' => 'Company with id: ' . $id . ' Has been added to the database, But movies are loaded with the queue']; } - } diff --git a/database/migrations/2019_07_30_210848_create_tv_table.php b/database/migrations/2019_07_30_210848_create_tv_table.php index 4bb542953..9528c1897 100644 --- a/database/migrations/2019_07_30_210848_create_tv_table.php +++ b/database/migrations/2019_07_30_210848_create_tv_table.php @@ -1,8 +1,8 @@ unsignedInteger('cast_id'); $table->unsignedInteger('episode_id'); $table->primary(['cast_id', 'episode_id']); - }); } diff --git a/database/migrations/2019_07_31_210850_create_cast_movie_table.php b/database/migrations/2019_07_31_210850_create_cast_movie_table.php index e4d41e4fc..dd2d410c4 100644 --- a/database/migrations/2019_07_31_210850_create_cast_movie_table.php +++ b/database/migrations/2019_07_31_210850_create_cast_movie_table.php @@ -1,8 +1,8 @@