Proxy streaming, cache trailer, start using migration

master
root 2 years ago
parent d7c9baf791
commit 491bf1c730

1
.gitignore vendored

@ -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

@ -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;
}
}

@ -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) {

@ -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");

@ -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.<br/>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;
}
}
}

@ -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 = '/<a data-id="[a-z0-9]*" data-media-type="movie" data-media-adult="[a-z]*" class="[a-z]*" href="(\/movie\/[\d]*\?language\=us)">/i';
$regex = '/<a data-id="[a-z0-9]*" data-media-type="movie" data-media-adult="[a-z]*" class="[a-z]*" href="(\/movie\/[\d]*\?language\=us)">/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;
}
}

@ -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'
);

@ -0,0 +1,20 @@
<?php
namespace Fuel\Migrations;
class Create_configurations
{
public function up()
{
\DBUtil::create_table('configurations', array(
'id' => 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');
}
}

@ -0,0 +1,30 @@
<?php
namespace Fuel\Migrations;
class Create_library
{
public function up()
{
\DBUtil::create_table('library', array(
'id' => 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');
}
}

@ -0,0 +1,28 @@
<?php
namespace Fuel\Migrations;
class Create_library_permission
{
public function up()
{
\DBUtil::create_table('library_permission', array(
'id' => 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');
}
}

@ -0,0 +1,44 @@
<?php
namespace Fuel\Migrations;
class Create_movie
{
public function up()
{
\DBUtil::create_table('movie', array(
'id' => 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');
}
}

@ -0,0 +1,30 @@
<?php
namespace Fuel\Migrations;
class Create_permission
{
public function up()
{
\DBUtil::create_table('permission', array(
'id' => 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');
}
}

@ -0,0 +1,32 @@
<?php
namespace Fuel\Migrations;
class Create_season
{
public function up()
{
\DBUtil::create_table('season', array(
'id' => 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');
}
}

@ -0,0 +1,35 @@
<?php
namespace Fuel\Migrations;
class Create_server
{
public function up()
{
\DBUtil::create_table('server', array(
'id' => 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');
}
}

@ -0,0 +1,39 @@
<?php
namespace Fuel\Migrations;
class Create_tvshow
{
public function up()
{
\DBUtil::create_table('tvshow', array(
'id' => 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');
}
}

@ -0,0 +1,29 @@
<?php
namespace Fuel\Migrations;
class Create_user
{
public function up()
{
\DBUtil::create_table('user', array(
'id' => 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');
}
}

@ -0,0 +1,29 @@
<?php
namespace Fuel\Migrations;
class Create_user_history
{
public function up()
{
\DBUtil::create_table('user_history', array(
'id' => 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');
}
}

@ -0,0 +1,31 @@
<?php
namespace Fuel\Migrations;
class Create_user_permission
{
public function up()
{
\DBUtil::create_table('user_permission', array(
'id' => 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');
}
}

@ -0,0 +1,28 @@
<?php
namespace Fuel\Migrations;
class Create_user_settings
{
public function up()
{
\DBUtil::create_table('user_settings', array(
'id' => 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');
}
}

@ -19,7 +19,7 @@
class="ToolbarButton-toolbarButton-3xzHJ Link-link-2XYrU Link-default-32xSO"
type="button"><i class="plex-icon-toolbar-play-560" aria-hidden="true"></i>
</button>
<?php if($movie->trailer !== null) : ?>
<?php if($movie->getTrailer() !== null) : ?>
<button id="id-362" title="<?php echo __('watch_trailer'); ?>" data-placement="bottom" data-toggle="tooltip" role="button" class="ToolbarButton-toolbarButton-3xzHJ Link-link-2XYrU Link-default-32xSO" type="button">
<i class="plex-icon-toolbar-play-trailer-560" aria-hidden="true"></i>
</button>
@ -77,7 +77,7 @@
</div>
</div>
</div>
<?php if($movie->trailer !== null) : ?>
<?php if($movie->getTrailer() !== null) : ?>
<div style="font-size: 20px;padding: 0;" class="col-sm-12 text-center">
<button id="id-362" class="Link-link-2XYrU Link-default-32xSO" style="background: #dc3535;border-radius: 3px;padding: 0 7px;width: 100%;margin-top: 15px;">
<i class="glyphicon video-hd"></i> <?php echo __('watch_trailer'); ?>
@ -398,7 +398,7 @@
var height = $(window).height();
var width = $(window).width();
$(document).find('body').append('<div id="youtube-iframe" style="position: absolute; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8); z-index:1;">' +
'<iframe style="position: absolute; margin: auto; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index:2;" width="' + (width/3*2) + '" height="' + (height/3*2) + '" src="<?php echo $movie->trailer; ?>" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>' +
'<iframe style="position: absolute; margin: auto; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index:2;" width="' + (width/3*2) + '" height="' + (height/3*2) + '" src="<?php echo $movie->getTrailer(); ?>" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>' +
'</div>');
});
$(document).on('click', '#youtube-iframe', function (event) {

Loading…
Cancel
Save