1
0
mirror of https://github.com/devfake/flox.git synced 2024-11-15 14:42:31 +01:00
flox/backend/app/Services/Subpage.php

34 lines
814 B
PHP
Raw Normal View History

<?php
namespace App\Services;
use App\Services\Models\ItemService;
class Subpage {
private $itemService;
private $tmdb;
public function __construct(ItemService $itemService, TMDB $tmdb)
{
$this->itemService = $itemService;
$this->tmdb = $tmdb;
}
public function item($tmdbId, $mediaType)
{
if($found = $this->itemService->findBy('tmdb_id', $tmdbId)) {
return $found;
}
$found = $this->tmdb->details($tmdbId, $mediaType);
$found->genre_ids = collect($found->genres)->pluck('id')->all();
$item = $this->tmdb->createItem($found, $mediaType);
$item['youtube_key'] = $this->itemService->parseYoutubeKey($found, $mediaType);
$item['imdb_id'] = $this->itemService->parseImdbId($found);
return $item;
}
}