From 491bf1c7303d424228bad975ad7b5d2b537f60e0 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 1 Jun 2022 16:36:13 +0200 Subject: [PATCH] Proxy streaming, cache trailer, start using migration --- .gitignore | 1 + fuel/app/classes/controller/movie.php | 29 ++++++++ fuel/app/classes/controller/rest/install.php | 26 +++---- fuel/app/classes/file.php | 3 +- fuel/app/classes/model/movie.php | 22 ++++-- fuel/app/classes/model/trailer.php | 74 ++++++++++++------- fuel/app/config/routes.php | 3 +- .../migrations/001_create_configurations.php | 20 +++++ fuel/app/migrations/002_create_library.php | 30 ++++++++ .../003_create_library_permission.php | 28 +++++++ fuel/app/migrations/004_create_movie.php | 44 +++++++++++ fuel/app/migrations/005_create_permission.php | 30 ++++++++ fuel/app/migrations/006_create_season.php | 32 ++++++++ fuel/app/migrations/007_create_server.php | 35 +++++++++ fuel/app/migrations/008_create_tvshow.php | 39 ++++++++++ fuel/app/migrations/009_create_user.php | 29 ++++++++ .../migrations/010_create_user_history.php | 29 ++++++++ .../migrations/011_create_user_permission.php | 31 ++++++++ .../migrations/012_create_user_settings.php | 28 +++++++ fuel/app/views/movie/index.php | 6 +- 20 files changed, 487 insertions(+), 52 deletions(-) create mode 100644 fuel/app/migrations/001_create_configurations.php create mode 100644 fuel/app/migrations/002_create_library.php create mode 100644 fuel/app/migrations/003_create_library_permission.php create mode 100644 fuel/app/migrations/004_create_movie.php create mode 100644 fuel/app/migrations/005_create_permission.php create mode 100644 fuel/app/migrations/006_create_season.php create mode 100644 fuel/app/migrations/007_create_server.php create mode 100644 fuel/app/migrations/008_create_tvshow.php create mode 100644 fuel/app/migrations/009_create_user.php create mode 100644 fuel/app/migrations/010_create_user_history.php create mode 100644 fuel/app/migrations/011_create_user_permission.php create mode 100644 fuel/app/migrations/012_create_user_settings.php diff --git a/.gitignore b/.gitignore index 3f96fa6..c11b000 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ /fuel/app/config/db.php /fuel/app/config/crypt.php /fuel/app/config/lock.php +/fuel/app/config/development/ /packages /vendor diff --git a/fuel/app/classes/controller/movie.php b/fuel/app/classes/controller/movie.php index 47d85ab..91d8e18 100644 --- a/fuel/app/classes/controller/movie.php +++ b/fuel/app/classes/controller/movie.php @@ -108,5 +108,34 @@ class Controller_Movie extends Controller_Home } } + public function action_stream() + { + $movie_id = $this->param('movie_id'); + $transcode = $this->param('transcode'); + $session = $this->param('session'); + $base = $this->param('base'); + $extension = Input::extension(); + + if (!$movie_id) + throw new FuelException('No movie id'); + + /** @var Model_Movie $movie */ + $movie = Model_Movie::find_by_pk($movie_id); + if (!$movie) + throw new FuelException('No movie found'); + + if (Model_Permission::isGranted('RIGHT_WATCH_DISABLED', $movie->getLibrary())) + throw new FuelException('You dont have the permission to watch in this library!'); + + $url = ($movie->getServer()->https === '1' ? 'https' : 'http') . '://'; + $url .= $movie->getServer()->url . ($movie->getServer()->port ? ':' . $movie->getServer()->port : '') . '/'; + $url .= 'video/:/'; + $url .= 'transcode/' . $transcode . '/'; + $url .= 'session/' . $session . '/'; + $url .= 'base/' . $base . '.' . $extension; + + readfile($url); + exit; + } } \ No newline at end of file diff --git a/fuel/app/classes/controller/rest/install.php b/fuel/app/classes/controller/rest/install.php index cb6b8f4..ed5cc3b 100755 --- a/fuel/app/classes/controller/rest/install.php +++ b/fuel/app/classes/controller/rest/install.php @@ -503,19 +503,19 @@ class Controller_Rest_Install extends Controller_Rest return $this->response(['error' => false, 'message' => $logs]); } catch (FuelException $e) { try { - DBUtil::drop_table('user_history'); - DBUtil::drop_table('user_permission'); - DBUtil::drop_table('user_settings'); - DBUtil::drop_table('library_permission'); - DBUtil::drop_table('movie'); - DBUtil::drop_table('season'); - DBUtil::drop_table('tvshow'); - DBUtil::drop_table('library'); - DBUtil::drop_table('server'); - DBUtil::drop_table('configurations'); - DBUtil::drop_table('user'); - DBUtil::drop_table('permission'); - DBUtil::drop_table('library'); + DBUtil::drop_table('user_history'); + DBUtil::drop_table('user_permission'); + DBUtil::drop_table('user_settings'); + DBUtil::drop_table('library_permission'); + DBUtil::drop_table('movie'); + DBUtil::drop_table('season'); + DBUtil::drop_table('tvshow'); + DBUtil::drop_table('library'); + DBUtil::drop_table('server'); + DBUtil::drop_table('configurations'); + DBUtil::drop_table('user'); + DBUtil::drop_table('permission'); + DBUtil::drop_table('library'); return $this->response(array('error' => true, 'message' => $e->getMessage()), 400); } catch (FuelException $e) { diff --git a/fuel/app/classes/file.php b/fuel/app/classes/file.php index 59ae7c8..8e18472 100644 --- a/fuel/app/classes/file.php +++ b/fuel/app/classes/file.php @@ -12,11 +12,10 @@ class File extends Fuel\Core\File * * @return int */ - public static function readChunked(string $file_path, int $speed_limit, bool $return_bytes = TRUE) + public static function readChunked(string $file_path, int $speed_limit, int $tickrate = 1024, bool $return_bytes = TRUE) { $buffer = ''; $speed_limit += $speed_limit * 0.2; - $tickrate = 1024; $cnt = 0; $handle = fopen($file_path, "rb"); diff --git a/fuel/app/classes/model/movie.php b/fuel/app/classes/model/movie.php index a559731..3324ac5 100644 --- a/fuel/app/classes/model/movie.php +++ b/fuel/app/classes/model/movie.php @@ -309,7 +309,7 @@ class Model_Movie extends Model_Overwrite $request .= '://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : ''); //$request .= '/video/:/transcode/universal/decision?hasMDE=1'; // DASH $request .= '/video/:/transcode/universal/start.m3u8'; // HLS - $request .= '?identifier=[PlexShare]'; + $request .= '?identifier=[PlexShare_V0.0.1]'; $request .= '&path=http%3A%2F%2F127.0.0.1%3A32400' . urlencode($this->plex_key); $request .= '&mediaIndex=0'; $request .= '&partIndex=0'; @@ -324,7 +324,7 @@ class Model_Movie extends Model_Overwrite $request .= '&audioBoost=100'; $request .= '&videoResolution=1920x1080'; $request .= '&Accept-Language=' . $language; - $request .= '&X-Plex-Platform=Chrome'; + $request .= '&X-Plex-Platform=Firefox'; $request .= '&X-Plex-Token=' . $this->_server->token; $curl = Request::forge($request, 'curl'); @@ -339,7 +339,7 @@ class Model_Movie extends Model_Overwrite $curl->execute(); if ($curl->response()->status !== 200) - throw new FuelException('No session found!'); + throw new FuelException('Error to create a session on plex!'); preg_match('/session\/[a-z0-9\-]+\/base\/index\.m3u8/', $curl->response()->body, $matches); @@ -353,7 +353,8 @@ class Model_Movie extends Model_Overwrite $this->_session = $split[1]; - return ($this->_server->https === '1' ? 'https' : 'http') . '://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '') . '/video/:/transcode/universal/session/' . $this->_session . '/base/index.m3u8'; + return '/movie/' . $this->id . '/video/:/transcode/universal/session/' . $this->_session . '/base/index.m3u8'; + //return ($this->_server->https === '1' ? 'https' : 'http') . '://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '') . '/video/:/transcode/universal/session/' . $this->_session . '/base/index.m3u8'; } catch (Exception $exception) { if($exception->getCode() === 403) throw new FuelException('Cannot connect to the server.
The token must be outdated!',$exception->getCode()); @@ -483,7 +484,16 @@ class Model_Movie extends Model_Overwrite public function getTrailer() { - $trailer = new Model_Trailer($this->originalTitle ?: $this->title, $this->year, $this->type); - $this->trailer = $trailer->getTrailer(); + try { + $this->trailer = Cache::get($this->id.'.trailer'); + return $this->trailer; + } catch (CacheNotFoundException $e) + { + $trailer = new Model_Trailer($this->id, $this->originalTitle ?: $this->title, $this->year, $this->type); + $this->trailer = $trailer->getTrailer(); + + Cache::set($this->id . '.trailer', $this->trailer, 24 * 60 * 60); + return $this->trailer; + } } } diff --git a/fuel/app/classes/model/trailer.php b/fuel/app/classes/model/trailer.php index 383798e..df8592f 100644 --- a/fuel/app/classes/model/trailer.php +++ b/fuel/app/classes/model/trailer.php @@ -4,18 +4,21 @@ use Fuel\Core\Debug; class Model_Trailer { + private $_movie_id; + private $_title; private $_year; private $_type; - private $_url; - private $_trailer; - public function __construct($title, $year, $type) + private $_trailer_url; + + public function __construct($movie_id, $title, $year, $type) { + $this->_movie_id = $movie_id; $this->_title = $title; $this->_year = $year; $this->_type = $type; @@ -23,7 +26,7 @@ class Model_Trailer if($this->_type === 'movie') { $this->getUrl(); - if($this->_url === null) + if($this->_trailer_url === null) return; $this->getMovieTrailer(); @@ -38,36 +41,54 @@ class Model_Trailer */ public function getTrailer() { - return $this->_trailer; + if($this->_type !== 'movie') + return; + + try + { + $trailer = $this->getMovieTrailer(); + + if(!$trailer) + $trailer = $this->getMovieTeaser(); + + return $trailer; + } catch (Exception $e) { + return; + } } private function getUrl() { - $html = Request::forge('https://www.themoviedb.org/search/movie?query=' . urlencode($this->_title) . '+y%3A' . $this->_year . '&language=us', 'curl'); - $html->set_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0'); + try { + $this->_trailer_url = Cache::get($this->_movie_id.'.trailer_url'); + return $this->_trailer_url; + } catch (CacheNotFoundException $e) + { + $html = Request::forge('https://www.themoviedb.org/search/movie?query=' . urlencode($this->_title) . '+y%3A' . $this->_year . '&language=us', 'curl'); + $html->set_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0'); - $html->execute(); + $html->execute(); - if ($html->response()->status !== 200) - return false; + if ($html->response()->status !== 200) return false; - $media = $html->response()->body; + $media = $html->response()->body; - $regex = '//i'; + $regex = '//i'; - preg_match($regex, $media, $urls); + preg_match($regex, $media, $urls); - //Debug::dump($urls);die(); + if (!isset($urls[1])) return false; - if (!isset($urls[1])) - return false; + $this->_trailer_url = explode('?', $urls[1])[0]; - $this->_url = explode('?', $urls[1])[0]; + Cache::set($this->_movie_id . '.trailer_url', $this->_trailer_url, 24 * 60 * 60); + return $this->_trailer_url; + } } private function getMovieTrailer() { - $html = Request::forge('https://www.themoviedb.org' . $this->_url . '/videos?active_nav_item=Trailers&video_language=en-US&language=en-US', 'curl'); + $html = Request::forge('https://www.themoviedb.org' . $this->getUrl() . '/videos?active_nav_item=Trailers&video_language=en-US&language=en-US', 'curl'); $html->set_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0'); $html->set_options(array( CURLOPT_FOLLOWLOCATION => true, @@ -90,20 +111,18 @@ class Model_Trailer $youtube = '//www.youtube.com/embed/'.$youtube[1].'?enablejsapi=1&autoplay=0&hl=en-US&modestbranding=1&fs=1'; $this->_trailer = $youtube; + + return $this->_trailer; } private function getMovieTeaser() { - $html = Request::forge('https://www.themoviedb.org' . $this->_url . '/videos?active_nav_item=Teasers&video_language=en-US&language=en-US', 'curl'); + $html = Request::forge('https://www.themoviedb.org' . $this->getUrl() . '/videos?active_nav_item=Teasers&video_language=en-US&language=en-US', 'curl'); $html->set_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0'); - $html->set_options(array( - CURLOPT_FOLLOWLOCATION => true, - ) - ); + $html->set_options([CURLOPT_FOLLOWLOCATION => true,]); $html->execute(); - if ($html->response()->status !== 200) - return false; + if ($html->response()->status !== 200) return false; $media = $html->response()->body; @@ -111,11 +130,12 @@ class Model_Trailer preg_match($regex, $media, $youtube); - if (!isset($youtube[1])) - return false; + if (!isset($youtube[1])) return false; $youtube = preg_replace('/\&origin\=https%3A%2F%2Fwww\.themoviedb\.org/i', '', $youtube[1]); $this->_trailer = $youtube; + + return $this->_trailer; } } \ No newline at end of file diff --git a/fuel/app/config/routes.php b/fuel/app/config/routes.php index 4873861..ace2e67 100755 --- a/fuel/app/config/routes.php +++ b/fuel/app/config/routes.php @@ -4,13 +4,14 @@ return array( '_404_' => 'error/404', // The main 404 route 'home(/:server_id)?' => 'home/index', - 'movie/list' => 'movie/list', 'library/:library_id' => 'library/index', 'tvshow/:tvshow_id' => 'tvshow/index', 'season/:season_id' => 'season/index', 'episode/:movie_id/download' => 'movie/download', 'episode/:episode_id' => 'episode/index', + 'movie/:movie_id/video/\:/transcode/:transcode/session/:session/base/:base' => 'movie/stream', 'movie/:movie_id/download' => 'movie/download', 'movie/:movie_id' => 'movie/index', + 'movie/list' => 'movie/list', 'settings/libraries/premissions/:library_id' => 'settings/libraries/permissions' ); diff --git a/fuel/app/migrations/001_create_configurations.php b/fuel/app/migrations/001_create_configurations.php new file mode 100644 index 0000000..7739729 --- /dev/null +++ b/fuel/app/migrations/001_create_configurations.php @@ -0,0 +1,20 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'name' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'data' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + ), array('id')); + } + + public function down() + { + \DBUtil::drop_table('configurations'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/002_create_library.php b/fuel/app/migrations/002_create_library.php new file mode 100644 index 0000000..ebd384b --- /dev/null +++ b/fuel/app/migrations/002_create_library.php @@ -0,0 +1,30 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'server_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'plex_key' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'name' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'type' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'updatedAt' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'createdAt' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'scannedAt' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintServerLibrary ON library(`server_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintServerLibrary ON library')->execute(); + + \DBUtil::drop_table('library'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/003_create_library_permission.php b/fuel/app/migrations/003_create_library_permission.php new file mode 100644 index 0000000..c7ab039 --- /dev/null +++ b/fuel/app/migrations/003_create_library_permission.php @@ -0,0 +1,28 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'permission_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'library_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'value' => array('type' => 'varchar', 'null' => true, 'constraint' => 36), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintPermissionLibrariesPermission ON library_permission(`permission_id`)')->execute(); + \DB::query('CREATE INDEX constraintLibraryLibrariesPermission ON library_permission(`library_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintPermissionLibrariesPermission ON library_permission')->execute(); + \DB::query('DROP INDEX constraintLibraryLibrariesPermission ON library_permission')->execute(); + + \DBUtil::drop_table('library_permission'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/004_create_movie.php b/fuel/app/migrations/004_create_movie.php new file mode 100644 index 0000000..2ab6823 --- /dev/null +++ b/fuel/app/migrations/004_create_movie.php @@ -0,0 +1,44 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'library_id' => array('type' => 'varchar', 'null' => true, 'constraint' => 36), + 'season_id' => array('type' => 'varchar', 'null' => true, 'constraint' => 36), + 'plex_key' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'type' => array('type' => 'varchar', 'null' => false, 'constraint' => 20), + 'number' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'studio' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'title' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'originalTitle' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'summary' => array('type' => 'text', 'null' => true), + 'rating' => array('type' => 'varchar', 'null' => true, 'constraint' => 4), + 'year' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'thumb' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'art' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'duration' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'originallyAvailableAt' => array('type' => 'varchar', 'null' => true, 'constraint' => 11), + 'addedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'updatedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintMovieLibrary ON movie(`library_id`)')->execute(); + \DB::query('CREATE INDEX constraintMovieSeason ON movie(`season_id`)')->execute(); + \DB::query('CREATE INDEX searchTitle ON movie(`title` DESC)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintMovieLibrary ON movie')->execute(); + \DB::query('DROP INDEX constraintMovieSeason ON movie')->execute(); + \DB::query('DROP INDEX searchTitle ON movie')->execute(); + + \DBUtil::drop_table('movie'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/005_create_permission.php b/fuel/app/migrations/005_create_permission.php new file mode 100644 index 0000000..9943f20 --- /dev/null +++ b/fuel/app/migrations/005_create_permission.php @@ -0,0 +1,30 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'name' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'parameters' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + DB::insert('permission')->set(['id' => Str::random('uuid'), 'name' => 'RIGHT_WATCH_DISABLED'])->execute(); + DB::insert('permission')->set(['id' => Str::random('uuid'), 'name' => 'RIGHT_DOWNLOAD_DISABLED'])->execute(); + DB::insert('permission')->set(['id' => Str::random('uuid'), 'name' => 'RIGHT_TRAILER_DISABLED'])->execute(); + DB::insert('permission')->set(['id' => Str::random('uuid'), 'name' => 'RIGHT_MAX_WATCH', 'parameters' => 1])->execute(); + DB::insert('permission')->set(['id' => Str::random('uuid'), 'name' => 'RIGHT_MAX_QUALITY', 'parameters' => 1])->execute(); + DB::insert('permission')->set(['id' => Str::random('uuid'), 'name' => 'RIGHT_MAX_CONCURRENT_STREAM', 'parameters' => 1])->execute(); + DB::insert('permission')->set(['id' => Str::random('uuid'), 'name' => 'RIGHT_MAX_DOWNLOAD', 'parameters' => 1])->execute(); + DB::insert('permission')->set(['id' => Str::random('uuid'), 'name' => 'RIGHT_MAX_DOWNLOAD_SPEED', 'parameters' => 1])->execute(); + } + + public function down() + { + \DBUtil::drop_table('permission'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/006_create_season.php b/fuel/app/migrations/006_create_season.php new file mode 100644 index 0000000..0f48f19 --- /dev/null +++ b/fuel/app/migrations/006_create_season.php @@ -0,0 +1,32 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'tv_show_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'plex_key' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'number' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'title' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'thumb' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'art' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'leafCount' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'addedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'updatedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintSeasonTvShow ON season(`tv_show_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintSeasonTvShow ON season')->execute(); + + \DBUtil::drop_table('season'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/007_create_server.php b/fuel/app/migrations/007_create_server.php new file mode 100644 index 0000000..c8466bd --- /dev/null +++ b/fuel/app/migrations/007_create_server.php @@ -0,0 +1,35 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'user_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'https' => array('type' => 'int', 'null' => false, 'constraint' => 1), + 'url' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'port' => array('type' => 'int', 'null' => true, 'constraint' => 2), + 'token' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'lastcheck' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'name' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'plateforme' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'platformVersion' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'updatedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'version' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'online' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintServerUser ON server(`user_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintServerUser ON server')->execute(); + + \DBUtil::drop_table('server'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/008_create_tvshow.php b/fuel/app/migrations/008_create_tvshow.php new file mode 100644 index 0000000..0080914 --- /dev/null +++ b/fuel/app/migrations/008_create_tvshow.php @@ -0,0 +1,39 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'library_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'plex_key' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'studio' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'title' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'contentRating' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'summary' => array('type' => 'text', 'null' => true), + 'rating' => array('type' => 'varchar', 'null' => true, 'constraint' => 4), + 'year' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'thumb' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'art' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'banner' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'theme' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'originallyAvailableAt' => array('type' => 'varchar', 'null' => true, 'constraint' => 255), + 'leafCount' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'addedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'updatedAt' => array('type' => 'int', 'null' => true, 'constraint' => 11), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintTvShowLibrary ON tvshow(`library_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintTvShowLibrary ON tvshow')->execute(); + + \DBUtil::drop_table('tvshow'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/009_create_user.php b/fuel/app/migrations/009_create_user.php new file mode 100644 index 0000000..f31b51a --- /dev/null +++ b/fuel/app/migrations/009_create_user.php @@ -0,0 +1,29 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'username' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'email' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'password' => array('type' => 'varchar', 'null' => false, 'constraint' => 255), + 'admin' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + 'lastlogin' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'parent_id' => array('type' => 'varchar', 'null' => true, 'constraint' => 36), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintUserUser ON user(`parent_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintUserUser ON user')->execute(); + + \DBUtil::drop_table('user'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/010_create_user_history.php b/fuel/app/migrations/010_create_user_history.php new file mode 100644 index 0000000..450da8b --- /dev/null +++ b/fuel/app/migrations/010_create_user_history.php @@ -0,0 +1,29 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'user_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'movie_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'watching_time' => array('type' => 'int', 'null' => false, 'constraint' => 11), + 'ended_time' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 11), + 'is_ended' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintUserUserHistory ON user_history(`user_id`)')->execute(); + \DB::query('CREATE INDEX constraintMovieHistory ON user_history(`movie_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintUserUserHistory ON user_history')->execute(); + \DB::query('DROP INDEX constraintMovieHistory ON user_history')->execute(); + + \DBUtil::drop_table('user_history'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/011_create_user_permission.php b/fuel/app/migrations/011_create_user_permission.php new file mode 100644 index 0000000..659c7c9 --- /dev/null +++ b/fuel/app/migrations/011_create_user_permission.php @@ -0,0 +1,31 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'permission_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'user_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'library_id' => array('type' => 'varchar', 'null' => true, 'constraint' => 36), + 'value' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'disable' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 1), + ), array('id')); + + \DB::query('CREATE INDEX constraintPermissionUserPermission ON user_permission(`permission_id`)')->execute(); + \DB::query('CREATE INDEX constraintUserUserPermission ON user_permission(`user_id`)')->execute(); + \DB::query('CREATE INDEX constraintLibraryUserPermission ON user_permission(`library_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintPermissionUserPermission ON user_permission')->execute(); + \DB::query('DROP INDEX constraintUserUserPermission ON user_permission')->execute(); + \DB::query('DROP INDEX constraintLibraryUserPermission ON user_permission')->execute(); + + \DBUtil::drop_table('user_permission'); + } +} \ No newline at end of file diff --git a/fuel/app/migrations/012_create_user_settings.php b/fuel/app/migrations/012_create_user_settings.php new file mode 100644 index 0000000..f55ed27 --- /dev/null +++ b/fuel/app/migrations/012_create_user_settings.php @@ -0,0 +1,28 @@ + array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'user_id' => array('type' => 'varchar', 'null' => false, 'constraint' => 36), + 'language' => array('default' => 'english', 'type' => 'varchar', 'null' => false, 'constraint' => 36), + 'trailer_type' => array('default' => 'Upcoming', 'type' => 'varchar', 'null' => false, 'constraint' => 36), + 'trailer' => array('default' => '0', 'type' => 'int', 'null' => false, 'constraint' => 11), + 'subtitle' => array('default' => '100', 'type' => 'int', 'null' => false, 'constraint' => 11), + 'maxdownloadspeed' => array('default' => '-1', 'type' => 'int', 'null' => false, 'constraint' => 11), + ), array('id')); + + \DB::query('CREATE INDEX constraintUserUserSetting ON user_settings(`user_id`)')->execute(); + } + + public function down() + { + \DB::query('DROP INDEX constraintUserUserSetting ON user_settings')->execute(); + + \DBUtil::drop_table('user_settings'); + } +} \ No newline at end of file diff --git a/fuel/app/views/movie/index.php b/fuel/app/views/movie/index.php index 986693d..2dd27d9 100644 --- a/fuel/app/views/movie/index.php +++ b/fuel/app/views/movie/index.php @@ -19,7 +19,7 @@ class="ToolbarButton-toolbarButton-3xzHJ Link-link-2XYrU Link-default-32xSO" type="button"> - trailer !== null) : ?> + getTrailer() !== null) : ?> @@ -77,7 +77,7 @@ - trailer !== null) : ?> + getTrailer() !== null) : ?>