You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PlexShare/fuel/app/classes/controller/cover.php

100 lines
2.6 KiB

7 years ago
<?php
use Fuel\Core\Debug;
7 years ago
use Fuel\Core\Response;
use Fuel\Core\FuelException;
class Controller_Cover extends Controller_Home
{
public function get_movie()
{
$movie_id = Input::get('movie_id');
if(!$movie_id)
throw new FuelException();
$width = Input::get('width');
$height = Input::get('height');
$thumb = Input::get('thumb') ?: null;
6 years ago
$art = Input::get('art') ?: null;
7 years ago
$movie = Model_Movie::find_by_pk($movie_id);
if(!$movie)
throw new FuelException();
6 years ago
if($thumb === null && $art)
$images = $movie->getArt($width, $height);
else if($thumb === null && $art === null)
7 years ago
$images = $movie->getCover($width, $height);
else
$images = $movie->getThumb($width, $height);
$response = new Response();
$response->set_header('Content-Type', 'image/jpeg');
$response->set_header('Content-Length',strlen($images));
$response->body($images);
return $response;
}
public function get_tvshow()
{
$tvshow_id = Input::get('tvshow_id');
if(!$tvshow_id)
throw new FuelException();
$width = Input::get('width');
$height = Input::get('height');
$tv_show = Model_Tvshow::find_by_pk($tvshow_id);
if(!$tv_show)
throw new FuelException();
6 years ago
$images = $tv_show->getCover($width, $height);
7 years ago
$response = new Response();
$response->set_header('Content-Type', 'image/jpeg');
$response->set_header('Content-Length',strlen($images));
$response->body($images);
return $response;
}
public function get_season()
{
try {
$season_id = Input::get('season_id');
7 years ago
if (!$season_id)
throw new FuelException();
7 years ago
$width = Input::get('width');
$height = Input::get('height');
7 years ago
$thumb = Input::get('thumb') ?: null;
7 years ago
$season = Model_Season::find_by_pk($season_id);
7 years ago
if (!$season)
throw new FuelException();
7 years ago
if (!$thumb)
$images = $season->getCover($width, $height);
else
$images = $season->getThumb($width, $height);
7 years ago
$response = new Response();
$response->set_header('Content-Type', 'image/jpeg');
$response->set_header('Content-Length', strlen($images));
$response->body($images);
7 years ago
return $response;
} catch (Exception $e) {
Debug::dump($e);die();
}
7 years ago
}
}