Add settings numbers servers and libraries, show error on login and register, applying user's settings on streaming and change settings name and in the installation, add admin option enable/disable libraries in panel, optimize settings and admin libraries button enable/disable

pull/9/head
Chewbaka69 6 years ago
parent 2fce7056d6
commit 56c47c3352

1
.gitignore vendored

@ -21,5 +21,6 @@
/fuel/app/config/plex.php
/fuel/app/config/db.php
/fuel/app/config/crypt.php
/fuel/app/config/lock.php
/.idea

@ -8,13 +8,18 @@ use Fuel\Core\Asset;
class Controller_Install extends Controller
{
public function action_index()
public function before()
{
parent::before();
$lock = Config::load('lock', true);
if($lock)
Response::redirect('/login');
}
public function action_index()
{
$view = View::forge('install/index');
$js = Asset::js('plex_alert.js');

@ -14,32 +14,38 @@ class Controller_Login extends Controller
public function before()
{
parent::before();
$user = Session::get('user');
$lock = Config::load('lock', true);
if($user)
Response::redirect('/home');
if(!$lock)
Response::redirect('/install');
}
public function action_index()
{
$view = View::forge('login/index');
$start_js = Asset::js('jquery.min.js');
$end_js = Asset::js(['plex_alert.js']);
try {
$config = Config::load('db', true);
$login = Input::post('email');
$password = Input::post('password');
$password = hash('sha512', $config['default']['hash'] . $password);
if (Input::method() === 'POST') {
$login = Input::post('email');
$password = Input::post('password');
$password = hash('sha512', $config['default']['hash'] . $password);
if($user = Model_User::Login($login, $password)) {
$user->lastlogin = time();
$user->save();
Session::set('user', $user);
Response::redirect('/home');
} else {
$view->set('error','Username or password is incorrect.');
}
}
} catch (FuelException $e) {
@ -47,7 +53,6 @@ class Controller_Login extends Controller
}
$view->set_safe('start_js', $start_js);
$view->set_safe('end_js', $end_js);
return Response::forge($view);
}

@ -22,15 +22,17 @@ class Controller_Register extends Controller
{
$view = View::forge('register/index');
$start_js = Asset::js('jquery.min.js');
$end_js = Asset::js(['pwstrength-bootstrap.min.js', 'plex_alert.js']);
$end_js = Asset::js(['pwstrength-bootstrap.min.js']);
try {
$email = Input::post('email');
$username = Input::post('username');
$password = Input::post('password');
$c_password = Input::post('confirm_password');
if (Input::method() === 'POST') {
$email = Input::post('email');
$username = Input::post('username');
$password = Input::post('password');
$c_password = Input::post('confirm_password');
if(!$email || !$username || !$password || !$c_password)
throw new FuelException('Field(s) is/are empty!');

@ -327,7 +327,7 @@ class Controller_Rest_Install extends Controller_Rest
'trailer_type' => array('constraint' => 36, 'type' => 'varchar', 'default' => 'Upcoming'),
'trailer' => array('constraint' => 11, 'type' => 'int', 'default' => 0),
'subtitle' => array('constraint' => 11, 'type' => 'int', 'default' => 100),
'quality' => array('constraint' => 11, 'type' => 'int', 'default' => -1)
'maxdownloadspeed' => array('constraint' => 11, 'type' => 'int', 'default' => -1)
),
array('id'), false, 'InnoDB', 'utf8_unicode_ci'
);

@ -18,8 +18,11 @@ class Controller_Rest_Movie extends Controller_Rest
if(!$movie)
throw new FuelException('No movie found');
$user_settings = Model_Settings::find_one_by('user_id', Session::get('user')->id);
$view = View::forge('stream/index');
$view->set('user_settings', $user_settings);
$view->set('movie', $movie);
return $this->response($view->render());

@ -1,5 +1,6 @@
<?php
use Fuel\Core\Config;
use Fuel\Core\Controller_Template;
use Fuel\Core\Input;
use Fuel\Core\Response;
@ -20,6 +21,32 @@ class Controller_Settings extends Controller_Template
if(!$this->_user)
Response::redirect('/login');
$user_id = $this->_user->id;
$servers = Model_Server::find(function($query) use($user_id) {
$query
->where('user_id', $user_id)
;
});
$libraries = Model_Library::find(function($query) use($user_id) {
$query
->select('library.*')
->join('server', 'LEFT')
->on('server.id', '=','library.server_id' )
->where('server.user_id', $user_id)
->and_where('server.disable', 0)
;
});
$this->template->countServers = count($servers);
$this->template->countLibraries = count($libraries);
$this->template->servers = $servers;
$this->template->libraries = $libraries;
$this->template->user = $this->_user;
$this->template->js_bottom = [];
@ -27,6 +54,8 @@ class Controller_Settings extends Controller_Template
public function action_index()
{
$default_settings = Config::load('user_settings');
$settings = Model_Settings::find_one_by('user_id', Session::get('user')->id);
$is_submit = Input::post('submit');
@ -39,12 +68,13 @@ class Controller_Settings extends Controller_Template
'trailer_type'=> Input::post('typeTrailer'),
'trailer' => Input::post('trailerCount'),
'subtitle' => Input::post('subtitleSize'),
'quality' => Input::post('remoteQuality')
'maxdownloadspeed' => Input::post('maxdownloadspeed')
]);
$settings->save();
}
$body = View::forge('settings/index');
$body->set('default_settings', $default_settings);
$body->set('settings', $settings);
$this->template->body = $body;
@ -56,15 +86,7 @@ class Controller_Settings extends Controller_Template
$body = View::forge('settings/servers');
$user_id = Session::get('user')->id;
$servers = Model_Server::find(function($query) use($user_id) {
$query
->where('user_id', $user_id)
;
});
$body->set('servers', $servers);
$body->set('servers', $this->template->servers);
$body->set('user', Session::get('user'));
$this->template->body = $body;

@ -11,19 +11,7 @@ class Controller_Settings_Libraries extends Controller_Settings
$body = View::forge('settings/libraries');
$user_id = Session::get('user')->id;
$libraries = Model_Library::find(function($query) use($user_id) {
$query
->select('library.*')
->join('server', 'LEFT')
->on('server.id', '=','library.server_id' )
->where('server.user_id', $user_id)
->and_where('server.disable', 0)
;
});
$body->set('libraries', $libraries);
$body->set('libraries', $this->template->libraries);
$body->set('user', Session::get('user'));
$this->template->body = $body;

@ -1,420 +1,444 @@
<?php
use Fuel\Core\Config;
use Fuel\Core\DB;
use Fuel\Core\Format;
use Fuel\Core\Request;
use Fuel\Core\Cache;
use Fuel\Core\CacheNotFoundException;
use Fuel\Core\Database_Query_Builder_Select;
use Fuel\Core\FuelException;
class Model_Movie extends Model_Overwrite
{
protected static $_table_name = 'movie';
protected static $_primary_key = 'id';
protected static $_properties = array(
'id',
'library_id',
'season_id',
'plex_key',
'type',
'number',
'studio',
'title',
'originalTitle',
'summary',
'rating',
'year',
'thumb',
'art',
'duration',
'originallyAvailableAt',
'addedAt',
'updatedAt',
'disable'
);
public $metadata = [];
private $_session = null;
private $_season = null;
private $_tv_show = null;
private $_library = null;
private $_server = null;
public $trailer = null;
public function getSeason()
{
if(!$this->_season)
$this->_season = Model_Season::find_by_pk($this->season_id);
return $this->_season;
}
public function getTvShow()
{
if(!$this->_tv_show) {
$season = $this->getSeason();
$this->_tv_show = Model_Tvshow::find_by_pk($season->tv_show_id);
}
return $this->_tv_show;
}
public function getLibrary()
{
if(!$this->_library) {
if($this->type === 'episode') {
$tvshow = $this->getTvShow();
$this->_library = Model_Library::find_by_pk($tvshow->library_id);
} else if($this->type === 'movie') {
$this->_library = Model_Library::find_by_pk($this->library_id);
}
}
return $this->_library;
}
public function getServer()
{
if(!$this->_server) {
$library = $this->getLibrary();
$this->_server = Model_Server::find_by_pk($library->server_id);
}
return $this->_server;
}
public function getCover($width = null, $height = null)
{
if(!$this->_server)
$this->getServer();
$path_cache = null;
$thumb = null;
if(!$width && !$height)
$path_cache = '.cover';
else
$path_cache = '.cover_' . $width . '_' . $height;
try {
$thumb = Cache::get($this->id . $path_cache);
if ($thumb)
return $thumb;
} catch (CacheNotFoundException $e) {
if($this->type === 'episode')
$this->getPicture($this->_season->thumb,$path_cache, $width, $height);
else if($this->type === 'movie')
$this->getPicture($this->thumb, $path_cache, $width, $height);
$thumb = Cache::get($this->id . $path_cache);
return $thumb;
}
}
private function getPicture($path, $path_cache, $width = null, $height = null)
{
if(!$this->_server)
$this->getServer();
$curl = null;
if(!$width && !$height)
$curl = Request::forge('http://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '') . $path . '?X-Plex-Token=' . $this->_server->token, 'curl');
else
$curl = Request::forge('http://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '') . '/photo/:/transcode?width='.$width.'&height='.$height.'&minSize=1&url='.$path.'&X-Plex-Token='.$this->_server->token, 'curl');
$curl->execute();
if ($curl->response()->status !== 200)
return false;
Cache::set($this->id . $path_cache, $curl->response()->body);
}
public function getThumb($width = null, $height = null)
{
$path_cache = null;
$thumb = null;
if(!$width && !$height)
$path_cache = '.preview';
else
$path_cache = '.preview_' . $width . '_' . $height;
try {
$thumb = Cache::get($this->id . $path_cache);
if ($thumb)
return $thumb;
} catch (CacheNotFoundException $e) {
$this->getPicture($this->thumb, $path_cache, $width, $height);
$thumb = Cache::get($this->id . $path_cache);
return $thumb;
}
}
/**
* @return array|mixed
* @throws FuelException
*/
public function getMetaData()
{
try {
$this->metadata = Cache::get($this->id . '.metadata');
if ($this->metadata)
return $this->metadata;
} catch (CacheNotFoundException $e) {
if(!$this->_server)
$this->getServer();
$curl = Request::forge('http://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '') . $this->plex_key . '?X-Plex-Token=' . $this->_server->token, 'curl');
$curl->execute();
$array = Format::forge($curl->response()->body, 'xml')->to_array();
//MEDIA
$this->metadata['Media'] = $array['Video']['Media'];
//GENRE
$this->metadata['Genre'] = isset($array['Video']['Genre']) ? $array['Video']['Genre'] : null;
//DIRECTOR
$this->metadata['Director'] = isset($array['Video']['Director']) ? $array['Video']['Director'] : null;
//WRITER
$this->metadata['Writer'] = isset($array['Video']['Writer']) ? $array['Video']['Writer'] : null;
//ROLES
$this->metadata['Role'] = isset($array['Video']['Role']) ? $array['Video']['Role'] : null;
$this->metadata['Stream'] = [];
$this->metadata['Stream']['Video'] = [];
$this->metadata['Stream']['Audio'] = [];
$this->metadata['Stream']['SubTitle'] = [];
if(isset($array['Video']['Media']['Part']['Stream'])) {
foreach ($array['Video']['Media']['Part']['Stream'] as $stream) {
if($stream['@attributes']['streamType'] === '1')
$this->metadata['Stream']['Video'][] = $stream['@attributes'];
else if($stream['@attributes']['streamType'] === '2')
$this->metadata['Stream']['Audio'][] = $stream['@attributes'];
else if($stream['@attributes']['streamType'] === '3')
$this->metadata['Stream']['SubTitle'][] = $stream['@attributes'];
}
}
Cache::set($this->id . '.metadata', $this->metadata);
return $this->metadata;
} catch (Exception $exception) {
throw new FuelException($exception->getMessage(),$exception->getCode());
}
}
public function getReleaseDate()
{
if(!$this->originallyAvailableAt)
return null;
$date = new DateTime($this->originallyAvailableAt);
return $date->format('d F Y');
}
public function getDuration()
{
$init = $this->duration;
$hours = floor($init / (3600 * 1000));
$minutes = floor(($init / (60 * 1000)) % 60);
return ($hours > 0 ? $hours . ' h ' : '') . $minutes . ' min';
}
public function getDurationMovie()
{
$init = $this->duration;
$hours = floor($init / (3600 * 1000));
$minutes = floor(($init / (60 * 1000)) % 60);
$secondes = floor(($init - ($hours * 3600 * 1000) - ($minutes * 60 * 1000)) / 1000);
return ($hours > 0 ? $hours . ':' : '') . ($minutes > 0 ? $minutes . ':' : '0:') . $secondes;
}
public function getStreamUrl()
{
try {
if (!$this->_server)
$this->getServer();
$curl = Request::forge('http://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '') . '/video/:/transcode/universal/start.m3u8?identifier=[PlexShare]&path=http%3A%2F%2F127.0.0.1%3A32400' . urlencode($this->plex_key) . '&mediaIndex=0&partIndex=0&protocol=hls&offset=0&fastSeek=1&directStream=0&directPlay=1&videoQuality=100&maxVideoBitrate=2294&subtitleSize=100&audioBoost=100&X-Plex-Platform=Chrome&X-Plex-Token=' . $this->_server->token, 'curl');
//$curl = Request::forge('http://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '') . '/video/:/transcode/universal/start?identifier=[PlexShare]&path=http%3A%2F%2F127.0.0.1%3A32400' . urlencode($this->plex_key) . '&mediaIndex=0&partIndex=0&protocol=hls&offset=0&fastSeek=1&directStream=0&directPlay=1&videoQuality=100&videoResolution=576x320&maxVideoBitrate=2294&subtitleSize=100&audioBoost=100&X-Plex-Platform=Chrome&X-Plex-Token=' . $this->_server->token, 'curl');
$curl->execute();
if ($curl->response()->status !== 200)
throw new FuelException('No session found!');
preg_match('/session\/[a-z0-9\-]+\/base\/index\.m3u8/', $curl->response()->body, $matches);
if (count($matches) <= 0)
throw new FuelException('No session found!');
$split = preg_split('/\//', $matches[0]);
if (count($split) <= 0)
throw new FuelException('No session found!');
$this->_session = $split[1];
return 'http://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '') . '/video/:/transcode/universal/session/' . $this->_session . '/base/index.m3u8';
} catch (Exception $exception) {
throw new FuelException('Cannot connect to the server.<br/>The token must be outdated!',$exception->getCode());
}
}
/**
* @param $server
* @param $movies
* @param null $library
* @param null $season
* @return bool
* @throws Exception
* @throws FuelException
* @throws HttpNotFoundException
* @throws \FuelException
*/
public static function BrowseMovies($server, $movies, $library = null, $season = null)
{
$movies_id_array = [];
foreach ($movies as $XMLmovie) {
$XMLmovie = !isset($movies['@attributes']) ? $XMLmovie : $movies;
$library_id = isset($library->id) ? $library->id : null;
$season_id = isset($season->id) ? $season->id : null;
$movie = Model_Movie::find(function ($query) use ($XMLmovie, $library_id, $season_id){
/** @var Database_Query_Builder_Select $query */
return $query
->select('*')
->where('plex_key', $XMLmovie['@attributes']['key'])
->and_where_open()
->where('season_id', $season_id)
->and_where('library_id', $library_id)
->and_where_close()
;
})[0] ?: Model_Movie::forge();
if($library === null && $season === null)
throw new FuelException('Missing Parameters for the movie');
$movie->set([
'library_id' => $library ? $library->id : null,
'season_id' => $season ? $season->id : null,
'plex_key' => $XMLmovie['@attributes']['key'],
'type' => $XMLmovie['@attributes']['type'],
'number' => isset($XMLmovie['@attributes']['index']) ? $XMLmovie['@attributes']['index'] : null,
'studio' => isset($XMLmovie['@attributes']['studio']) ? $XMLmovie['@attributes']['studio'] : null,
'title' => $XMLmovie['@attributes']['title'],
'originalTitle' => isset($XMLmovie['@attributes']['originalTitle']) ? $XMLmovie['@attributes']['originalTitle'] : null,
'summary' => $XMLmovie['@attributes']['summary'],
'rating' => isset($XMLmovie['@attributes']['rating']) ? $XMLmovie['@attributes']['rating'] : null,
'year' => isset($XMLmovie['@attributes']['year']) ? $XMLmovie['@attributes']['year'] : null,
'thumb' => isset($XMLmovie['@attributes']['thumb']) ? $XMLmovie['@attributes']['thumb'] : null,
'art' => isset($XMLmovie['@attributes']['art']) ? $XMLmovie['@attributes']['art'] : null,
'duration' => isset($XMLmovie['@attributes']['duration']) ? $XMLmovie['@attributes']['duration'] : null,
'originallyAvailableAt' => isset($XMLmovie['@attributes']['originallyAvailableAt']) ? $XMLmovie['@attributes']['originallyAvailableAt'] : null,
'addedAt' => $XMLmovie['@attributes']['addedAt'],
'updatedAt' => $XMLmovie['@attributes']['updatedAt']
]);
$movie->save();
$movies_id_array[]= ['id' => $movie->id, 'name' => $movie->title];
if(isset($movies['@attributes']))
break;
}
return $movies_id_array;
}
public static function getMovieMetadata($server, $movie)
{
/*$curl = Request::forge('http://' . $server->url . ($server->port ? ':' . $server->port : '') . $movie->plex_key . '?X-Plex-Token=' . $server->token, 'curl');
$curl->execute();
if ($curl->response()->status !== 200)
return false;
$media = Format::forge($curl->response()->body, 'xml')->to_array();
if(isset($movies['Video']))
$this->getMovies($server, $movies['Video']);*/
}
public static function getThirtyLastedTvShows($server)
{
$conf = Config::get('db');
return self::find(function ($query) use ($server, $conf) {
/** @var Database_Query_Builder_Select $query */
return $query
->select('movie.*', DB::expr('COUNT(' . $conf['default']['table_prefix'] . 'movie.type) AS count'))
->join('season', 'LEFT')
->on('movie.season_id', '=', 'season.id')
->join('tvshow', 'LEFT')
->on('season.tv_show_id', '=', 'tvshow.id')
->join('library', 'LEFT')
->on('tvshow.library_id', '=', 'library.id')
->join('server', 'LEFT')
->on('library.server_id', '=', 'server.id')
->where('server.id', $server->id)
->and_where('movie.type', 'episode')
->order_by('movie.addedAt', 'DESC')
->order_by(DB::expr('MAX(' . $conf['default']['table_prefix'] .'movie.addedAt)'), 'DESC ')//'movie.addedAt', 'DESC')
->group_by('movie.season_id')
->limit(30)
;
});
}
public static function getThirtyLastedMovies($server)
{
return self::find(function ($query) use ($server) {
/** @var Database_Query_Builder_Select $query */
return $query
->select('movie.*')
->join('library', 'LEFT')
->on('movie.library_id', '=', 'library.id')
->join('server', 'LEFT')
->on('library.server_id', '=', 'server.id')
->where('server.id', $server->id)
->and_where('movie.type', 'movie')
->order_by('movie.addedAt', 'DESC')
->limit(30)
;
});
}
public static function getList()
{
return self::find(function ($query) {
/** @var Database_Query_Builder_Select $query */
return $query
->select('*')
->where('type', 'movie')
->order_by('title', 'ASC')
;
});
}
public function getTrailer()
{
$trailer = new Model_Trailer($this->originalTitle ?: $this->title, $this->year, $this->type);
$this->trailer = $trailer->trailer;
}
<?php
use Fuel\Core\Config;
use Fuel\Core\DB;
use Fuel\Core\Format;
use Fuel\Core\Request;
use Fuel\Core\Cache;
use Fuel\Core\CacheNotFoundException;
use Fuel\Core\Database_Query_Builder_Select;
use Fuel\Core\FuelException;
class Model_Movie extends Model_Overwrite
{
protected static $_table_name = 'movie';
protected static $_primary_key = 'id';
protected static $_properties = array(
'id',
'library_id',
'season_id',
'plex_key',
'type',
'number',
'studio',
'title',
'originalTitle',
'summary',
'rating',
'year',
'thumb',
'art',
'duration',
'originallyAvailableAt',
'addedAt',
'updatedAt',
'disable'
);
public $metadata = [];
private $_session = null;
private $_season = null;
private $_tv_show = null;
private $_library = null;
private $_server = null;
public $trailer = null;
public function getSeason()
{
if(!$this->_season)
$this->_season = Model_Season::find_by_pk($this->season_id);
return $this->_season;
}
public function getTvShow()
{
if(!$this->_tv_show) {
$season = $this->getSeason();
$this->_tv_show = Model_Tvshow::find_by_pk($season->tv_show_id);
}
return $this->_tv_show;
}
public function getLibrary()
{
if(!$this->_library) {
if($this->type === 'episode') {
$tvshow = $this->getTvShow();
$this->_library = Model_Library::find_by_pk($tvshow->library_id);
} else if($this->type === 'movie') {
$this->_library = Model_Library::find_by_pk($this->library_id);
}
}
return $this->_library;
}
public function getServer()
{
if(!$this->_server) {
$library = $this->getLibrary();
$this->_server = Model_Server::find_by_pk($library->server_id);
}
return $this->_server;
}
public function getCover($width = null, $height = null)
{
if(!$this->_server)
$this->getServer();
$path_cache = null;
$thumb = null;
if(!$width && !$height)
$path_cache = '.cover';
else
$path_cache = '.cover_' . $width . '_' . $height;
try {
$thumb = Cache::get($this->id . $path_cache);
if ($thumb)
return $thumb;
} catch (CacheNotFoundException $e) {
if($this->type === 'episode')
$this->getPicture($this->_season->thumb,$path_cache, $width, $height);
else if($this->type === 'movie')
$this->getPicture($this->thumb, $path_cache, $width, $height);
$thumb = Cache::get($this->id . $path_cache);
return $thumb;
}
}
private function getPicture($path, $path_cache, $width = null, $height = null)
{
if(!$this->_server)
$this->getServer();
$curl = null;
if(!$width && !$height)
$curl = Request::forge('http://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '') . $path . '?X-Plex-Token=' . $this->_server->token, 'curl');
else
$curl = Request::forge('http://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '') . '/photo/:/transcode?width='.$width.'&height='.$height.'&minSize=1&url='.$path.'&X-Plex-Token='.$this->_server->token, 'curl');
$curl->execute();
if ($curl->response()->status !== 200)
return false;
Cache::set($this->id . $path_cache, $curl->response()->body);
}
public function getThumb($width = null, $height = null)
{
$path_cache = null;
$thumb = null;
if(!$width && !$height)
$path_cache = '.preview';
else
$path_cache = '.preview_' . $width . '_' . $height;
try {
$thumb = Cache::get($this->id . $path_cache);
if ($thumb)
return $thumb;
} catch (CacheNotFoundException $e) {
$this->getPicture($this->thumb, $path_cache, $width, $height);
$thumb = Cache::get($this->id . $path_cache);
return $thumb;
}
}
/**
* @return array|mixed
* @throws FuelException
*/
public function getMetaData()
{
try {
$this->metadata = Cache::get($this->id . '.metadata');
if ($this->metadata)
return $this->metadata;
} catch (CacheNotFoundException $e) {
if(!$this->_server)
$this->getServer();
$curl = Request::forge('http://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '') . $this->plex_key . '?X-Plex-Token=' . $this->_server->token, 'curl');
$curl->execute();
$array = Format::forge($curl->response()->body, 'xml')->to_array();
//MEDIA
$this->metadata['Media'] = $array['Video']['Media'];
//GENRE
$this->metadata['Genre'] = isset($array['Video']['Genre']) ? $array['Video']['Genre'] : null;
//DIRECTOR
$this->metadata['Director'] = isset($array['Video']['Director']) ? $array['Video']['Director'] : null;
//WRITER
$this->metadata['Writer'] = isset($array['Video']['Writer']) ? $array['Video']['Writer'] : null;
//ROLES
$this->metadata['Role'] = isset($array['Video']['Role']) ? $array['Video']['Role'] : null;
$this->metadata['Stream'] = [];
$this->metadata['Stream']['Video'] = [];
$this->metadata['Stream']['Audio'] = [];
$this->metadata['Stream']['SubTitle'] = [];
if(isset($array['Video']['Media']['Part']['Stream'])) {
foreach ($array['Video']['Media']['Part']['Stream'] as $stream) {
if($stream['@attributes']['streamType'] === '1')
$this->metadata['Stream']['Video'][] = $stream['@attributes'];
else if($stream['@attributes']['streamType'] === '2')
$this->metadata['Stream']['Audio'][] = $stream['@attributes'];
else if($stream['@attributes']['streamType'] === '3')
$this->metadata['Stream']['SubTitle'][] = $stream['@attributes'];
}
}
Cache::set($this->id . '.metadata', $this->metadata);
return $this->metadata;
} catch (Exception $exception) {
throw new FuelException($exception->getMessage(),$exception->getCode());
}
}
public function getReleaseDate()
{
if(!$this->originallyAvailableAt)
return null;
$date = new DateTime($this->originallyAvailableAt);
return $date->format('d F Y');
}
public function getDuration()
{
$init = $this->duration;
$hours = floor($init / (3600 * 1000));
$minutes = floor(($init / (60 * 1000)) % 60);
return ($hours > 0 ? $hours . ' h ' : '') . $minutes . ' min';
}
public function getDurationMovie()
{
$init = $this->duration;
$hours = floor($init / (3600 * 1000));
$minutes = floor(($init / (60 * 1000)) % 60);
$secondes = floor(($init - ($hours * 3600 * 1000) - ($minutes * 60 * 1000)) / 1000);
return ($hours > 0 ? $hours . ':' : '') . ($minutes > 0 ? $minutes . ':' : '0:') . $secondes;
}
public function getStreamUrl($user_settings)
{
try {
if (!$this->_server)
$this->getServer();
$maxVideoBitrate = isset($user_settings->maxdownloadspeed) ? $user_settings->maxdownloadspeed : 10000;
$subtitleSize = isset($user_settings->subtitle) ? $user_settings->subtitle : 100;
$language = isset($user_settings->language) ? $user_settings->language : false;
$request = 'http://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '');
$request .= '/video/:/transcode/universal/start.m3u8';
$request .= '?identifier=[PlexShare]';
$request .= '&path=http%3A%2F%2F127.0.0.1%3A32400' . urlencode($this->plex_key);
$request .= '&mediaIndex=0';
$request .= '&partIndex=0';
$request .= '&protocol=hls';
$request .= '&offset=0';
$request .= '&fastSeek=1';
$request .= '&directStream=0';
$request .= '&directPlay=1';
$request .= '&videoQuality=100';
$request .= '&maxVideoBitrate=' . $maxVideoBitrate;
$request .= '&subtitleSize=' . $subtitleSize;
$request .= '&audioBoost=100';
$request .= '&videoResolution=1920x1080';
$request .= '&Accept-Language=' . $language;
$request .= '&X-Plex-Platform=Chrome';
$request .= '&X-Plex-Token=' . $this->_server->token;
$curl = Request::forge($request, 'curl');
$curl->execute();
if ($curl->response()->status !== 200)
throw new FuelException('No session found!');
preg_match('/session\/[a-z0-9\-]+\/base\/index\.m3u8/', $curl->response()->body, $matches);
if (count($matches) <= 0)
throw new FuelException('No session found!');
$split = preg_split('/\//', $matches[0]);
if (count($split) <= 0)
throw new FuelException('No session found!');
$this->_session = $split[1];
return 'http://' . $this->_server->url . ($this->_server->port ? ':' . $this->_server->port : '') . '/video/:/transcode/universal/session/' . $this->_session . '/base/index.m3u8';
} catch (Exception $exception) {
throw new FuelException('Cannot connect to the server.<br/>The token must be outdated!',$exception->getCode());
}
}
/**
* @param $server
* @param $movies
* @param null $library
* @param null $season
* @return bool
* @throws Exception
* @throws FuelException
* @throws HttpNotFoundException
* @throws \FuelException
*/
public static function BrowseMovies($server, $movies, $library = null, $season = null)
{
$movies_id_array = [];
foreach ($movies as $XMLmovie) {
$XMLmovie = !isset($movies['@attributes']) ? $XMLmovie : $movies;
$library_id = isset($library->id) ? $library->id : null;
$season_id = isset($season->id) ? $season->id : null;
$movie = Model_Movie::find(function ($query) use ($XMLmovie, $library_id, $season_id){
/** @var Database_Query_Builder_Select $query */
return $query
->select('*')
->where('plex_key', $XMLmovie['@attributes']['key'])
->and_where_open()
->where('season_id', $season_id)
->and_where('library_id', $library_id)
->and_where_close()
;
})[0] ?: Model_Movie::forge();
if($library === null && $season === null)
throw new FuelException('Missing Parameters for the movie');
$movie->set([
'library_id' => $library ? $library->id : null,
'season_id' => $season ? $season->id : null,
'plex_key' => $XMLmovie['@attributes']['key'],
'type' => $XMLmovie['@attributes']['type'],
'number' => isset($XMLmovie['@attributes']['index']) ? $XMLmovie['@attributes']['index'] : null,
'studio' => isset($XMLmovie['@attributes']['studio']) ? $XMLmovie['@attributes']['studio'] : null,
'title' => $XMLmovie['@attributes']['title'],
'originalTitle' => isset($XMLmovie['@attributes']['originalTitle']) ? $XMLmovie['@attributes']['originalTitle'] : null,
'summary' => $XMLmovie['@attributes']['summary'],
'rating' => isset($XMLmovie['@attributes']['rating']) ? $XMLmovie['@attributes']['rating'] : null,
'year' => isset($XMLmovie['@attributes']['year']) ? $XMLmovie['@attributes']['year'] : null,
'thumb' => isset($XMLmovie['@attributes']['thumb']) ? $XMLmovie['@attributes']['thumb'] : null,
'art' => isset($XMLmovie['@attributes']['art']) ? $XMLmovie['@attributes']['art'] : null,
'duration' => isset($XMLmovie['@attributes']['duration']) ? $XMLmovie['@attributes']['duration'] : null,
'originallyAvailableAt' => isset($XMLmovie['@attributes']['originallyAvailableAt']) ? $XMLmovie['@attributes']['originallyAvailableAt'] : null,
'addedAt' => $XMLmovie['@attributes']['addedAt'],
'updatedAt' => $XMLmovie['@attributes']['updatedAt']
]);
$movie->save();
$movies_id_array[]= ['id' => $movie->id, 'name' => $movie->title];
if(isset($movies['@attributes']))
break;
}
return $movies_id_array;
}
public static function getMovieMetadata($server, $movie)
{
/*$curl = Request::forge('http://' . $server->url . ($server->port ? ':' . $server->port : '') . $movie->plex_key . '?X-Plex-Token=' . $server->token, 'curl');
$curl->execute();
if ($curl->response()->status !== 200)
return false;
$media = Format::forge($curl->response()->body, 'xml')->to_array();
if(isset($movies['Video']))
$this->getMovies($server, $movies['Video']);*/
}
public static function getThirtyLastedTvShows($server)
{
$conf = Config::get('db');
return self::find(function ($query) use ($server, $conf) {
/** @var Database_Query_Builder_Select $query */
return $query
->select('movie.*', DB::expr('COUNT(' . $conf['default']['table_prefix'] . 'movie.type) AS count'))
->join('season', 'LEFT')
->on('movie.season_id', '=', 'season.id')
->join('tvshow', 'LEFT')
->on('season.tv_show_id', '=', 'tvshow.id')
->join('library', 'LEFT')
->on('tvshow.library_id', '=', 'library.id')
->join('server', 'LEFT')
->on('library.server_id', '=', 'server.id')
->where('server.id', $server->id)
->and_where('movie.type', 'episode')
->order_by('movie.addedAt', 'DESC')
->order_by(DB::expr('MAX(' . $conf['default']['table_prefix'] .'movie.addedAt)'), 'DESC ')//'movie.addedAt', 'DESC')
->group_by('movie.season_id')
->limit(30)
;
});
}
public static function getThirtyLastedMovies($server)
{
return self::find(function ($query) use ($server) {
/** @var Database_Query_Builder_Select $query */
return $query
->select('movie.*')
->join('library', 'LEFT')
->on('movie.library_id', '=', 'library.id')
->join('server', 'LEFT')
->on('library.server_id', '=', 'server.id')
->where('server.id', $server->id)
->and_where('movie.type', 'movie')
->order_by('movie.addedAt', 'DESC')
->limit(30)
;
});
}
public static function getList()
{
return self::find(function ($query) {
/** @var Database_Query_Builder_Select $query */
return $query
->select('*')
->where('type', 'movie')
->order_by('title', 'ASC')
;
});
}
public function getTrailer()
{
$trailer = new Model_Trailer($this->originalTitle ?: $this->title, $this->year, $this->type);
$this->trailer = $trailer->trailer;
}
}

@ -14,6 +14,6 @@ class Model_Settings extends Model_Overwrite
'trailer_type',
'trailer',
'subtitle',
'quality',
'maxdownloadspeed',
);
}

@ -43,7 +43,9 @@ class Model_Trailer
$media = $html->response()->body;
preg_match('/<a id="[a-z0-9_]*" data-id="[a-z0-9]*" data-media-type="movie" data-media-adult="[a-z]*" class="[a-z]*" href="(\/movie\/[\d]*\?language\=us)" title=".*" alt=".*">/i', $media, $urls);
$regex = '/<a id="[a-z0-9_]*" data-id="[a-z0-9]*" data-media-type="movie" data-media-adult="[a-z]*" class="[a-z]*" href="(\/movie\/[\d]*\?language\=us)" title=".*" alt=".*">/i';
preg_match($regex, $media, $urls);
if (!isset($urls[1]))
return false;
@ -65,7 +67,9 @@ class Model_Trailer
$media = $html->response()->body;
preg_match('/<iframe type="text\/html" src="(\/\/www.youtube.com\/embed\/[a-zA-Z0-9\_\-]*\?enablejsapi\=1&autoplay\=0\&origin\=https%3A%2F%2Fwww\.themoviedb\.org\&hl\=en-US\&modestbranding\=1\&fs\=1)" frameborder\="0" allowfullscreen><\/iframe>/', $media, $youtube);
$regex = '/<iframe type="text\/html" src="(\/\/www.youtube.com\/embed\/[a-zA-Z0-9\_\-]*\?enablejsapi\=1&autoplay\=0\&origin\=https%3A%2F%2Fwww\.themoviedb\.org\&hl\=en-US\&modestbranding\=1\&fs\=1)" frameborder\="0" allowfullscreen><\/iframe>/';
preg_match($regex, $media, $youtube);
if (!isset($youtube[1]))
return false;
@ -87,7 +91,9 @@ class Model_Trailer
$media = $html->response()->body;
preg_match('/<iframe type="text\/html" src="(\/\/www.youtube.com\/embed\/[a-zA-Z0-9\_]*\?enablejsapi\=1&autoplay\=0\&origin\=https%3A%2F%2Fwww\.themoviedb\.org\&hl\=en-US\&modestbranding\=1\&fs\=1)" frameborder\="0" allowfullscreen><\/iframe>/', $media, $youtube);
$regex = '/<iframe type="text\/html" src="(\/\/www.youtube.com\/embed\/[a-zA-Z0-9\_]*\?enablejsapi\=1&autoplay\=0\&origin\=https%3A%2F%2Fwww\.themoviedb\.org\&hl\=en-US\&modestbranding\=1\&fs\=1)" frameborder\="0" allowfullscreen><\/iframe>/';
preg_match($regex, $media, $youtube);
if (!isset($youtube[1]))
return false;

@ -0,0 +1,34 @@
<?php
return [
'language' => [
'english' => 'English',
'french' => 'Français'
],
'trailer_type' => [
'Cinema' => 'Cinema',
'Upcoming' => 'Upcoming'
],
'subtitle' => [
'50' => 'Tiny',
'75' => 'Small',
'100' => 'Normal',
'125' => 'Large',
'200' => 'Huge'
],
'maxdownloadspeed' => [
'-1' => 'Maximale',
'20000' => '20 Mbps, 1080p',
'15000' => '15 Mbps, 1080p',
'10000' => '10 Mbps, 1080p',
'8000' => '8 Mbps, 1080p',
'4000' => '4 Mbps, 720p',
'3000' => '3 Mbps, 720p',
'2000' => '2 Mbps, 720p',
'1500' => '1.5 Mbps, 480p',
'1000' => '1 Mbps, 480p',
'700' => '0.7 Mbps',
'300' => '0.5 Mbps',
'200' => '0.2 Mbps'
]
];

@ -138,7 +138,7 @@
alert_status.html('Start browsing your library');
});
});
$('button.disable-library-btn').on('click', function () {
$(document).on('click', 'button.disable-library-btn', function () {
var button = this;
var library_id = $(this).data('library-id');
$.ajax({
@ -147,12 +147,31 @@
data: {library_id: library_id}
}).done(function (data) {
show_alert('success', 'Library disable succesfully!');
$(button).removeClass('disable-library-btn btn-danger').addClass('enable-library-btn btn-success');
$(button).find('i').removeClass('ban').addClass('ok-2');
$(button).closest('.card.card-device').addClass('disabled');
}).fail(function (data) {
data = JSON.parse(data.responseText);
show_alert('error', data.message);
});
});
$(document).on('click', 'button.enable-library-btn', function () {
var button = this;
var library_id = $(this).data('library-id');
$.ajax({
method: 'put',
url: '/rest/settings/library.json',
data: {library_id: library_id}
}).done(function (data) {
show_alert('success', 'Library enable succesfully!');
$(button).removeClass('enable-library-btn btn-success').addClass('disable-library-btn btn-danger');
$(button).find('i').removeClass('ok-2').addClass('ban');
$(button).closest('.card.card-device').removeClass('disabled');
}).fail(function (data) {
data = JSON.parse(data.responseText);
show_alert('error', data.message);
});
});
// REFRESH ALL LIBRARIES
$('.filter-bar .refresh').on('click', function () {

@ -280,7 +280,7 @@
var next = $(parent).find('button[data-hubcell-action="next"]');
if ($(this).data('hubcell-action') === 'previous') {
$('#' + select + '_list').animate({scrollLeft: $('#' + select + '_list').scrollLeft() - 152 * 2}, 500);
$('#' + select + '_list').animate({scrollLeft: $('#' + select + '_list').scrollLeft() - 152 * 2}, 200);
setTimeout(function () {
if ($('#' + select + '_list').scrollLeft() <= (150 * 19)) {
$(next).removeClass('isDisabled');
@ -289,10 +289,10 @@
if ($('#' + select + '_list').scrollLeft() === 0) {
$(previous).addClass('isDisabled');
}
}, 500);
}, 200);
}
if ($(this).data('hubcell-action') === 'next') {
$('#' + select + '_list').animate({scrollLeft: $('#' + select + '_list').scrollLeft() + 152 * 2}, 500);
$('#' + select + '_list').animate({scrollLeft: $('#' + select + '_list').scrollLeft() + 152 * 2}, 300);
setTimeout(function () {
if ($('#' + select + '_list').scrollLeft() > 0) {
$(previous).removeClass('isDisabled');
@ -305,7 +305,7 @@
if ($('#' + select + '_list').scrollLeft() === 0) {
$(next).addClass('isDisabled');
}
}, 500);
}, 300);
}
});
});

@ -48,6 +48,11 @@
<div>Share</div>
</div>
<div class="_2zl_7T">
<?php if(isset($error) && $error) : ?>
<div class="_3arxVY">
<span class="FCU2Ru"><?php echo $error; ?></span>
</div>
<?php endif; ?>
<form action method="post" class="_19Nqmf" novalidate="">
<div class="_192KBC Gtcqpe"><label class="_3XRky5 _2aLJ9b " for="email">
Email or Username</label><input
@ -67,8 +72,10 @@
</div>
<button type="submit" role="button"
class="_1SYIVj _1I3Olm _1A8EcL _2kT68l _2n0yJn _3S9UdJ _1A8EcL _2kT68l _2n0yJn _2kT68l _2n0yJn _3fwLzo _3S9UdJ _2n0yJn _2XA2bN">
<span class="_1NdZWc"><div class="_1TgDPI Niere7 _2kLwt_ _3PStHE Niere7 _2kLwt_"
aria-label="Loading"></div></span><span class="qxG01S">Sign in</span>
<span class="_1NdZWc">
<div class="_1TgDPI Niere7 _2kLwt_ _3PStHE Niere7 _2kLwt_" aria-label="Loading"></div>
</span>
<span class="qxG01S">Sign in</span>
</button>
</form>
<span class="_3kVXYV _3TSWy2">Need an account? <a href="/register" role="link" class=" _2n0yJn _1vcAGA ">Create an account!</a></span>
@ -78,11 +85,5 @@
</div>
</div>
</div>
<?php echo $end_js; ?>
<script type="text/javascript">
<?php if(isset($error) && $error) : ?>
show_alert('error', '<?php echo $error; ?>');
<?php endif; ?>
</script>
</body>
</html>

@ -98,7 +98,7 @@
<span>
<span>
<a title="<?php echo $movie->year; ?>"
href="#!/server/df1de861fbaba243c18ed9275fd42e3248d19336/details?key=%2Flibrary%2Fmetadata%2F28083"
href="#"
role="link"
class=" Link-link-2XYrU Link-default-32xSO"><?php echo $movie->year; ?></a>
</span>
@ -257,6 +257,7 @@
</button>
</div>
</div>
<?php if(isset($movie->getMetadata()['Role'])) : ?>
<div class="PrePlayMetadataListInnerContent-innerContent-2CsIz">
<div class="PrePlayMetadataInnerContent-innerContent-1BPzw">
<div class="PrePlayCastList-castList-3dQB5">
@ -277,7 +278,6 @@
<div class="HubCell-hubScroller-2qgkr VirtualListScroller-scroller-37EU_ Scroller-horizontal-cOKsq Scroller-scroller-3GqQc Scroller-horizontal-cOKsq ">
<?php $translate = -143; ?>
<div class=" " style="width: 5012px; height: 183px;">
<?php if(isset($movie->getMetadata()['Role'])) : ?>
<?php foreach ($movie->getMetadata()['Role'] as $role) : ?>
<?php $translate += 148; ?>
<div data-qa-id="cellItem" style="position: absolute; width: 118px; height: 168px; transform: translate3d(<?php echo $translate; ?>px, 10px, 0px);">
@ -307,7 +307,6 @@
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<div class="Measure-scrollContainer-1c6dy">
@ -322,6 +321,7 @@
</div>
</div>
</div>
<?php endif; ?>
</div>
<div class="PrePlayMetadataListInnerContent-innerContent-2CsIz">
<div class="PrePlayMetadataInnerContent-innerContent-1BPzw">

@ -6,6 +6,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="shortcut icon"
href="//assets.plex.tv/deploys/desktop/env-eb2798cc3c7d9533df5b563963d5c394/3.34.1-b51c37a/favicon.ico">
<?php
echo \Asset::css(['normalize_login.css', 'normalize.css', 'plex_login.css']);
?>
@ -73,6 +75,11 @@
<div>Share</div>
</div>
<div class="_2zl_7T">
<?php if(isset($error) && $error) : ?>
<div class="_3arxVY">
<span class="FCU2Ru"><?php echo $error; ?></span>
</div>
<?php endif; ?>
<form method="post" action="" class="_19Nqmf">
<div class="_192KBC Gtcqpe"><label class="_3XRky5 _2aLJ9b" for="email">
Email address</label><input
@ -115,9 +122,6 @@
if($('.progress').length === 0)
$('#password').pwstrength();
});
<?php if(isset($error) && $error) : ?>
show_alert('error', '<?php echo $error; ?>');
<?php endif; ?>
</script>
</body>
</html>

@ -27,8 +27,8 @@
<div class="container">
<ul class="nav nav-header pull-right">
<li class="web-nav-item"><a class="web-btn btn-gray" href="/settings">General</a></li>
<li class="server-nav-item "><a class="server-btn btn-gray" href="/settings/servers">My Servers<span class="badge">0</span></a></li>
<li class="users-nav-item "><a class="users-btn btn-gray" href="/settings/libraries">My Libraries<span class="badge">0</span></a></li>
<li class="server-nav-item "><a class="server-btn btn-gray" href="/settings/servers">My Servers<span class="badge"><?php echo $countServers; ?></span></a></li>
<li class="users-nav-item "><a class="users-btn btn-gray" href="/settings/libraries">My Libraries<span class="badge"><?php echo $countLibraries; ?></span></a></li>
</ul>
<h2>Settings</h2>
<?php echo $body; ?>

@ -16,8 +16,9 @@
<div class="form-group">
<label for="language">Language</label>
<select id="language" name="language">
<option value="english"> English</option>
<option value="french"> Français</option>
<?php foreach ($default_settings['language'] as $key => $language) : ?>
<option value="<?php echo $key; ?>" <?php echo isset($settings) && $key === $settings->language ? 'selected=""' : ''; ?>> <?php echo $language; ?></option>
<?php endforeach; ?>
</select>
<p class="help-block">
@ -51,50 +52,37 @@
<div id="player-web-group" class="settings-group">
<h4 class="settings-header-first">Streaming</h4>
<div class="form-group">
<label for="remoteQuality">Video Quality</label>
<select id="remoteQuality" name="remoteQuality" data-type="int">
<option value="-1">Maximale</option>
<option value="20000"> 20 Mbps, 1080p</option>
<option value="12000"> 12 Mbps, 1080p</option>
<option value="10000"> 10 Mbps, 1080p</option>
<option value="8000"> 8 Mbps, 1080p</option>
<option value="4000"> 4 Mbps, 720p</option>
<option value="3000"> 3 Mbps, 720p</option>
<option value="2000" selected=""> 2 Mbps, 720p</option>
<option value="1500"> 1.5 Mbps, 480p</option>
<option value="700"> 0.7 Mbps</option>
<option value="300"> 0.3 Mbps</option>
<option value="200"> 0.2 Mbps</option>
<label for="remoteQuality">Max Download Speed</label>
<select id="remoteQuality" name="maxdownloadspeed" data-type="int">
<?php foreach ($default_settings['maxdownloadspeed'] as $key => $speed) : ?>
<option value="<?php echo $key; ?>" <?php echo isset($settings) && $key === (int)$settings->maxdownloadspeed ? 'selected=""' : ''; ?>> <?php echo $speed; ?></option>
<?php endforeach; ?>
</select>
<p class="help-block">Set the default quality for streaming video over the internet. If
quality is set too high, videos will start slowly and pause frequently.</p></div>
<div class="form-group">
<label for="subtitleSize">Subtitle Size</label>
<select id="subtitleSize" name="subtitleSize" data-type="int">
<option value="50">Tiny</option>
<option value="75">Small</option>
<option value="100" selected="">Normal</option>
<option value="125">Large</option>
<option value="200">Huge</option>
<?php foreach ($default_settings['subtitle'] as $key => $subtitle) : ?>
<option value="<?php echo $key; ?>" <?php echo isset($settings) && $key === (int)$settings->subtitle ? 'selected=""' : ''; ?>> <?php echo $subtitle; ?></option>
<?php endforeach; ?>
</select>
</div>
<h4 class="settings-header">Bonus</h4>
<div class="form-group">
<label for="typeTrailer">Cinema Trailers Type</label>
<select id="typeTrailer" name="typeTrailer" data-type="string">
<option value="Cinema">In Cinema</option>
<option value="Upcoming" selected="">Upcoming</option>
<?php foreach ($default_settings['trailer_type'] as $key => $trailer_type) : ?>
<option value="<?php echo $key; ?>" <?php echo isset($settings) && $key === $settings->trailer_type ? 'selected=""' : ''; ?>> <?php echo $trailer_type; ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="trailerCount">Cinema Trailers to Play Before Movies</label>
<select id="trailerCount" name="trailerCount" data-type="int">
<option value="0" selected="">None</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<?php for ($i = 0; $i < 6; $i++) : ?>
<option value="<?php echo $i; ?>" <?php echo isset($settings) && $i === (int)$settings->trailer ? 'selected=""' : ''; ?>> <?php echo $i; ?></option>
<?php endfor; ?>
</select>
</div>
</div>

@ -109,7 +109,7 @@
alert_status.html('Start browsing your library');
});
});
$('button.disable-library-btn').on('click', function () {
$(document).on('click', 'button.disable-library-btn', function () {
var button = this;
var library_id = $(this).data('library-id');
$.ajax({
@ -118,13 +118,15 @@
data: {library_id: library_id}
}).done(function (data) {
show_alert('success', 'Library disable succesfully!');
$(button).removeClass('disable-library-btn btn-danger').addClass('enable-library-btn btn-success');
$(button).find('i').removeClass('ban').addClass('ok-2');
$(button).closest('.card.card-device').addClass('disabled');
}).fail(function (data) {
data = JSON.parse(data.responseText);
show_alert('error', data.message);
});
});
$('button.enable-library-btn').on('click', function () {
$(document).on('click', 'button.enable-library-btn', function () {
var button = this;
var library_id = $(this).data('library-id');
$.ajax({
@ -133,6 +135,8 @@
data: {library_id: library_id}
}).done(function (data) {
show_alert('success', 'Library enable succesfully!');
$(button).removeClass('enable-library-btn btn-success').addClass('disable-library-btn btn-danger');
$(button).find('i').removeClass('ok-2').addClass('ban');
$(button).closest('.card.card-device').removeClass('disabled');
}).fail(function (data) {
data = JSON.parse(data.responseText);

@ -1,4 +1,4 @@
<input id="data_movie" type="hidden" data-src="<?php echo $movie->getStreamUrl(); ?>"/>
<input id="data_movie" type="hidden" data-src="<?php echo $movie->getStreamUrl($user_settings); ?>"/>
<input id="data_movie_id" type="hidden" data-movie-id="<?php echo $movie->id; ?>"/>
<button aria-label="Lire" role="playCenter" type="button"
class="PlayPauseOverlay-playButton-25OfW PlayButton-playButton-3WX8X Link-link-2XYrU Link-default-32xSO"

Loading…
Cancel
Save