Каталог плагинов: полный локальный mirror в ./plugins (один directory-mount в wwwroot/plugins), доки и вычистка неиспользуемых модулей
- plugins/: скачаны все 30 плагинов store локально (sources.json - карта исходных URL);
патчи: showy.js (абсолютный хост подгрузки), pubtorr/td/torrentmanager - тела вместо лоадеров,
modss.js - local-patched копия (из каталога исключена, upstream мёртв)
- extensions.json: 32 позиции, все ссылки {localhost}/plugins/<файл>.js, удалены мёртвые
(Skaz TV x3, export.js, hotkeys/gold_theme/select_weapon/want/mult, MODS's, o.js, др.)
- compose: ./plugins:/lampac/wwwroot/plugins (один маунт вместо 30 file-mount)
- вычистка: удалены неиспользуемые mods (DatabaseEditor, ExternalBind, LogUserRequest-Lite,
Telemetry, Transcoding, WatchTogether) и дубль каталога modules/
- config/init.conf: секции Tracks/AdminPanel/Music, customPlugins без gst.js
- mods/Tracks: правки Controller.cs/plugin.js
- README.md / AGENT.md: mirror, кеш static, правила mount
This commit is contained in:
@@ -0,0 +1,982 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
function getBalancerUrl() {
|
||||
var servers = [
|
||||
'http://hdpoisk.ru:2053'
|
||||
];
|
||||
return servers[Math.floor(Math.random() * servers.length)];
|
||||
}
|
||||
// ---------------------------------------------------
|
||||
|
||||
var default_host = 'http://hdpoisk.ru:2053';
|
||||
|
||||
var Defined = {
|
||||
api: 'lampac',
|
||||
localhost: default_host + '/',
|
||||
apn: ''
|
||||
};
|
||||
|
||||
var balansers_with_search;
|
||||
|
||||
var unic_id = Lampa.Storage.get('lampac_unic_id', '');
|
||||
if (!unic_id) {
|
||||
unic_id = Lampa.Utils.uid(8).toLowerCase();
|
||||
Lampa.Storage.set('lampac_unic_id', unic_id);
|
||||
}
|
||||
|
||||
function getAndroidVersion() {
|
||||
if (Lampa.Platform.is('android')) {
|
||||
try {
|
||||
var current = AndroidJS.appVersion().split('-');
|
||||
return parseInt(current.pop());
|
||||
} catch (e) {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
var hostkey = 'hdpoisk.ru:2053'; // Используем постоянный ключ для хранилища, чтобы не терять сессию
|
||||
|
||||
if (!window.rch_nws || !window.rch_nws[hostkey]) {
|
||||
if (!window.rch_nws) window.rch_nws = {};
|
||||
|
||||
window.rch_nws[hostkey] = {
|
||||
type: Lampa.Platform.is('android') ? 'apk' : Lampa.Platform.is('tizen') ? 'cors' : undefined,
|
||||
startTypeInvoke: false,
|
||||
rchRegistry: false,
|
||||
apkVersion: getAndroidVersion()
|
||||
};
|
||||
}
|
||||
|
||||
window.rch_nws[hostkey].typeInvoke = function rchtypeInvoke(host, call) {
|
||||
if (!window.rch_nws[hostkey].startTypeInvoke) {
|
||||
window.rch_nws[hostkey].startTypeInvoke = true;
|
||||
|
||||
var check = function check(good) {
|
||||
window.rch_nws[hostkey].type = Lampa.Platform.is('android') ? 'apk' : good ? 'cors' : 'web';
|
||||
call();
|
||||
};
|
||||
|
||||
if (Lampa.Platform.is('android') || Lampa.Platform.is('tizen')) check(true);
|
||||
else {
|
||||
var net = new Lampa.Reguest();
|
||||
// Тут тоже используем динамический хост для проверки
|
||||
var check_url = getBalancerUrl();
|
||||
net.silent(check_url.indexOf(location.host) >= 0 ? 'https://github.com/' : check_url + '/cors/check', function() {
|
||||
check(true);
|
||||
}, function() {
|
||||
check(false);
|
||||
}, false, {
|
||||
dataType: 'text'
|
||||
});
|
||||
}
|
||||
} else call();
|
||||
};
|
||||
|
||||
window.rch_nws[hostkey].Registry = function RchRegistry(client, startConnection) {
|
||||
// Вызываем с динамическим хостом
|
||||
window.rch_nws[hostkey].typeInvoke(getBalancerUrl(), function() {
|
||||
|
||||
client.invoke("RchRegistry", JSON.stringify({
|
||||
version: 149,
|
||||
host: location.host,
|
||||
rchtype: Lampa.Platform.is('android') ? 'apk' : Lampa.Platform.is('tizen') ? 'cors' : window.rch_nws[hostkey].type,
|
||||
apkVersion: window.rch_nws[hostkey].apkVersion,
|
||||
player: Lampa.Storage.field('player')
|
||||
}));
|
||||
|
||||
if (client._shouldReconnect && window.rch_nws[hostkey].rchRegistry) {
|
||||
if (startConnection) startConnection();
|
||||
return;
|
||||
}
|
||||
|
||||
window.rch_nws[hostkey].rchRegistry = true;
|
||||
|
||||
client.on('RchRegistry', function(clientIp) {
|
||||
if (startConnection) startConnection();
|
||||
});
|
||||
|
||||
client.on("RchClient", function(rchId, url, data, headers, returnHeaders) {
|
||||
var network = new Lampa.Reguest();
|
||||
|
||||
function result(html) {
|
||||
if (Lampa.Arrays.isObject(html) || Lampa.Arrays.isArray(html)) {
|
||||
html = JSON.stringify(html);
|
||||
}
|
||||
|
||||
if (typeof CompressionStream !== 'undefined' && html && html.length > 1000) {
|
||||
var compressionStream = new CompressionStream('gzip');
|
||||
var encoder = new TextEncoder();
|
||||
var readable = new ReadableStream({
|
||||
start: function(controller) {
|
||||
controller.enqueue(encoder.encode(html));
|
||||
controller.close();
|
||||
}
|
||||
});
|
||||
var compressedStream = readable.pipeThrough(compressionStream);
|
||||
new Response(compressedStream).arrayBuffer()
|
||||
.then(function(compressedBuffer) {
|
||||
var compressedArray = new Uint8Array(compressedBuffer);
|
||||
if (compressedArray.length > html.length) {
|
||||
client.invoke("RchResult", rchId, html);
|
||||
} else {
|
||||
$.ajax({
|
||||
// Используем динамический хост для POST результата
|
||||
url: getBalancerUrl() + '/rch/gzresult?id=' + rchId,
|
||||
type: 'POST',
|
||||
data: compressedArray,
|
||||
async: true,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function(j) {},
|
||||
error: function() {
|
||||
client.invoke("RchResult", rchId, html);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
client.invoke("RchResult", rchId, html);
|
||||
});
|
||||
|
||||
} else {
|
||||
client.invoke("RchResult", rchId, html);
|
||||
}
|
||||
}
|
||||
|
||||
if (url == 'eval') {
|
||||
console.log('RCH', url, data);
|
||||
result(eval(data));
|
||||
} else if (url == 'ping') {
|
||||
result('pong');
|
||||
} else {
|
||||
console.log('RCH', url);
|
||||
network["native"](url, result, function() {
|
||||
console.log('RCH', 'result empty');
|
||||
result('');
|
||||
}, data, {
|
||||
dataType: 'text',
|
||||
timeout: 1000 * 8,
|
||||
headers: headers,
|
||||
returnHeaders: returnHeaders
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
client.on('Connected', function(connectionId) {
|
||||
console.log('RCH', 'ConnectionId: ' + connectionId);
|
||||
window.rch_nws[hostkey].connectionId = connectionId;
|
||||
});
|
||||
client.on('Closed', function() {
|
||||
console.log('RCH', 'Connection closed');
|
||||
});
|
||||
client.on('Error', function(err) {
|
||||
console.log('RCH', 'error:', err);
|
||||
});
|
||||
});
|
||||
};
|
||||
window.rch_nws[hostkey].typeInvoke(default_host, function() {});
|
||||
|
||||
function rchInvoke(json, call) {
|
||||
if (window.nwsClient && window.nwsClient[hostkey] && window.nwsClient[hostkey]._shouldReconnect){
|
||||
call();
|
||||
return;
|
||||
}
|
||||
if (!window.nwsClient) window.nwsClient = {};
|
||||
if (window.nwsClient[hostkey] && window.nwsClient[hostkey].socket)
|
||||
window.nwsClient[hostkey].socket.close();
|
||||
window.nwsClient[hostkey] = new NativeWsClient(json.nws, {
|
||||
autoReconnect: false
|
||||
});
|
||||
window.nwsClient[hostkey].on('Connected', function(connectionId) {
|
||||
window.rch_nws[hostkey].Registry(window.nwsClient[hostkey], function() {
|
||||
call();
|
||||
});
|
||||
});
|
||||
window.nwsClient[hostkey].connect();
|
||||
}
|
||||
|
||||
function rchRun(json, call) {
|
||||
if (typeof NativeWsClient == 'undefined') {
|
||||
// Используем динамический хост для загрузки скрипта клиента
|
||||
Lampa.Utils.putScript([getBalancerUrl() + "/js/nws-client-es5.js?v18112025"], function() {}, false, function() {
|
||||
rchInvoke(json, call);
|
||||
}, true);
|
||||
} else {
|
||||
rchInvoke(json, call);
|
||||
}
|
||||
}
|
||||
|
||||
function account(url) {
|
||||
url = url + '';
|
||||
|
||||
// --- ДИНАМИЧЕСКАЯ ПОДМЕНА ХОСТА ---
|
||||
// При каждом вызове account, мы берем новый случайный сервер
|
||||
// и заменяем любые известные домены на него.
|
||||
var random_host = getBalancerUrl();
|
||||
|
||||
// Список доменов, которые мы хотим подменять на лету
|
||||
var replaceable = [
|
||||
'http://hdpoisk.ru:2053'
|
||||
];
|
||||
|
||||
for (var i = 0; i < replaceable.length; i++) {
|
||||
if (url.indexOf(replaceable[i]) !== -1) {
|
||||
url = url.replace(replaceable[i], random_host);
|
||||
break; // Заменили один раз и выходим
|
||||
}
|
||||
}
|
||||
// ----------------------------------
|
||||
|
||||
if (url.indexOf('account_email=') == -1) {
|
||||
var email = Lampa.Storage.get('account_email');
|
||||
if (email) url = Lampa.Utils.addUrlComponent(url, 'account_email=' + encodeURIComponent(email));
|
||||
}
|
||||
if (url.indexOf('uid=') == -1) {
|
||||
var uid = Lampa.Storage.get('lampac_unic_id', '');
|
||||
if (uid) url = Lampa.Utils.addUrlComponent(url, 'uid=' + encodeURIComponent(uid));
|
||||
}
|
||||
if (url.indexOf('token=') == -1) {
|
||||
var token = '';
|
||||
if (token != '') url = Lampa.Utils.addUrlComponent(url, 'token=');
|
||||
}
|
||||
if (url.indexOf('nws_id=') == -1 && window.rch_nws && window.rch_nws[hostkey]) {
|
||||
var nws_id = window.rch_nws[hostkey].connectionId || '';
|
||||
if (nws_id) url = Lampa.Utils.addUrlComponent(url, 'nws_id=' + encodeURIComponent(nws_id));
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
var Network = Lampa.Reguest;
|
||||
|
||||
function component(object) {
|
||||
var network = new Network();
|
||||
var scroll = new Lampa.Scroll({
|
||||
mask: true,
|
||||
over: true
|
||||
});
|
||||
var files = new Lampa.Explorer(object);
|
||||
var filter = new Lampa.Filter(object);
|
||||
var sources = {};
|
||||
var last;
|
||||
var source;
|
||||
var balanser;
|
||||
var initialized;
|
||||
var balanser_timer;
|
||||
var images = [];
|
||||
var number_of_requests = 0;
|
||||
var number_of_requests_timer;
|
||||
var life_wait_times = 0;
|
||||
var life_wait_timer;
|
||||
var filter_sources = {};
|
||||
var filter_translate = {
|
||||
season: Lampa.Lang.translate('torrent_serial_season'),
|
||||
voice: Lampa.Lang.translate('torrent_parser_voice'),
|
||||
source: Lampa.Lang.translate('settings_rest_source')
|
||||
};
|
||||
var filter_find = {
|
||||
season: [],
|
||||
voice: []
|
||||
};
|
||||
|
||||
if (balansers_with_search == undefined) {
|
||||
network.timeout(10000);
|
||||
network.silent(account(Defined.localhost + 'lite/withsearch'), function(json) {
|
||||
balansers_with_search = json;
|
||||
}, function() {
|
||||
balansers_with_search = [];
|
||||
});
|
||||
}
|
||||
|
||||
function balanserName(j) {
|
||||
var bals = j.balanser;
|
||||
var name = j.name.split(' ')[0];
|
||||
return (bals || name).toLowerCase();
|
||||
}
|
||||
|
||||
function clarificationSearchAdd(value){
|
||||
var id = Lampa.Utils.hash(object.movie.number_of_seasons ? object.movie.original_name : object.movie.original_title);
|
||||
var all = Lampa.Storage.get('clarification_search','{}');
|
||||
|
||||
all[id] = value;
|
||||
|
||||
Lampa.Storage.set('clarification_search',all);
|
||||
}
|
||||
|
||||
function clarificationSearchDelete(){
|
||||
var id = Lampa.Utils.hash(object.movie.number_of_seasons ? object.movie.original_name : object.movie.original_title);
|
||||
var all = Lampa.Storage.get('clarification_search','{}');
|
||||
|
||||
delete all[id];
|
||||
|
||||
Lampa.Storage.set('clarification_search',all);
|
||||
}
|
||||
|
||||
function clarificationSearchGet(){
|
||||
var id = Lampa.Utils.hash(object.movie.number_of_seasons ? object.movie.original_name : object.movie.original_title);
|
||||
var all = Lampa.Storage.get('clarification_search','{}');
|
||||
|
||||
return all[id];
|
||||
}
|
||||
|
||||
this.initialize = function() {
|
||||
var _this = this;
|
||||
this.loading(true);
|
||||
filter.onSearch = function(value) {
|
||||
|
||||
clarificationSearchAdd(value);
|
||||
|
||||
Lampa.Activity.replace({
|
||||
search: value,
|
||||
clarification: true,
|
||||
similar: true
|
||||
});
|
||||
};
|
||||
filter.onBack = function() {
|
||||
_this.start();
|
||||
};
|
||||
filter.render().find('.selector').on('hover:enter', function() {
|
||||
clearInterval(balanser_timer);
|
||||
});
|
||||
filter.render().find('.filter--search').appendTo(filter.render().find('.torrent-filter'));
|
||||
filter.onSelect = function(type, a, b) {
|
||||
if (type == 'filter') {
|
||||
if (a.reset) {
|
||||
clarificationSearchDelete();
|
||||
|
||||
_this.replaceChoice({
|
||||
season: 0,
|
||||
voice: 0,
|
||||
voice_url: '',
|
||||
voice_name: ''
|
||||
});
|
||||
setTimeout(function() {
|
||||
Lampa.Select.close();
|
||||
Lampa.Activity.replace({
|
||||
clarification: 0,
|
||||
similar: 0
|
||||
});
|
||||
}, 10);
|
||||
} else {
|
||||
var url = filter_find[a.stype][b.index].url;
|
||||
var choice = _this.getChoice();
|
||||
if (a.stype == 'voice') {
|
||||
choice.voice_name = filter_find.voice[b.index].title;
|
||||
choice.voice_url = url;
|
||||
}
|
||||
choice[a.stype] = b.index;
|
||||
_this.saveChoice(choice);
|
||||
_this.reset();
|
||||
_this.request(url);
|
||||
setTimeout(Lampa.Select.close, 10);
|
||||
}
|
||||
} else if (type == 'sort') {
|
||||
Lampa.Select.close();
|
||||
object.lampac_custom_select = a.source;
|
||||
_this.changeBalanser(a.source);
|
||||
}
|
||||
};
|
||||
if (filter.addButtonBack) filter.addButtonBack();
|
||||
filter.render().find('.filter--sort span').text(Lampa.Lang.translate('lampac_balanser'));
|
||||
scroll.body().addClass('torrent-list');
|
||||
files.appendFiles(scroll.render());
|
||||
files.appendHead(filter.render());
|
||||
scroll.minus(files.render().find('.explorer__files-head'));
|
||||
scroll.body().append(Lampa.Template.get('lampac_content_loading'));
|
||||
Lampa.Controller.enable('content');
|
||||
this.loading(false);
|
||||
if(object.balanser){
|
||||
files.render().find('.filter--search').remove();
|
||||
sources = {};
|
||||
sources[object.balanser] = {name: object.balanser};
|
||||
balanser = object.balanser;
|
||||
filter_sources = [];
|
||||
|
||||
return network["native"](account(object.url.replace('rjson=','nojson=')), this.parse.bind(this), function(){
|
||||
files.render().find('.torrent-filter').remove();
|
||||
_this.empty();
|
||||
}, false, {
|
||||
dataType: 'text'
|
||||
});
|
||||
}
|
||||
this.externalids().then(function() {
|
||||
return _this.createSource();
|
||||
}).then(function(json) {
|
||||
if (!balansers_with_search.find(function(b) {
|
||||
return balanser.slice(0, b.length) == b;
|
||||
})) {
|
||||
filter.render().find('.filter--search').addClass('hide');
|
||||
}
|
||||
_this.search();
|
||||
})["catch"](function(e) {
|
||||
_this.noConnectToServer(e);
|
||||
});
|
||||
};
|
||||
this.rch = function(json, noreset) {
|
||||
var _this2 = this;
|
||||
rchRun(json, function() {
|
||||
if (!noreset) _this2.find();
|
||||
else noreset();
|
||||
});
|
||||
};
|
||||
this.externalids = function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (!object.movie.imdb_id || !object.movie.kinopoisk_id) {
|
||||
var query = [];
|
||||
query.push('id=' + encodeURIComponent(object.movie.id));
|
||||
query.push('serial=' + (object.movie.name ? 1 : 0));
|
||||
if (object.movie.imdb_id) query.push('imdb_id=' + (object.movie.imdb_id || ''));
|
||||
if (object.movie.kinopoisk_id) query.push('kinopoisk_id=' + (object.movie.kinopoisk_id || ''));
|
||||
var url = Defined.localhost + 'externalids?' + query.join('&');
|
||||
network.timeout(10000);
|
||||
network.silent(account(url), function(json) {
|
||||
for (var name in json) {
|
||||
object.movie[name] = json[name];
|
||||
}
|
||||
resolve();
|
||||
}, function() {
|
||||
resolve();
|
||||
});
|
||||
} else resolve();
|
||||
});
|
||||
};
|
||||
this.updateBalanser = function(balanser_name) {
|
||||
var last_select_balanser = Lampa.Storage.cache('online_last_balanser', 3000, {});
|
||||
last_select_balanser[object.movie.id] = balanser_name;
|
||||
Lampa.Storage.set('online_last_balanser', last_select_balanser);
|
||||
};
|
||||
this.changeBalanser = function(balanser_name) {
|
||||
this.updateBalanser(balanser_name);
|
||||
Lampa.Storage.set('online_balanser', balanser_name);
|
||||
var to = this.getChoice(balanser_name);
|
||||
var from = this.getChoice();
|
||||
if (from.voice_name) to.voice_name = from.voice_name;
|
||||
this.saveChoice(to, balanser_name);
|
||||
Lampa.Activity.replace();
|
||||
};
|
||||
this.requestParams = function(url) {
|
||||
var query = [];
|
||||
var card_source = object.movie.source || 'tmdb'; //Lampa.Storage.field('source')
|
||||
query.push('id=' + encodeURIComponent(object.movie.id));
|
||||
if (object.movie.imdb_id) query.push('imdb_id=' + (object.movie.imdb_id || ''));
|
||||
if (object.movie.kinopoisk_id) query.push('kinopoisk_id=' + (object.movie.kinopoisk_id || ''));
|
||||
if (object.movie.tmdb_id) query.push('tmdb_id=' + (object.movie.tmdb_id || ''));
|
||||
query.push('title=' + encodeURIComponent(object.clarification ? object.search : object.movie.title || object.movie.name));
|
||||
query.push('original_title=' + encodeURIComponent(object.movie.original_title || object.movie.original_name));
|
||||
query.push('serial=' + (object.movie.name ? 1 : 0));
|
||||
query.push('original_language=' + (object.movie.original_language || ''));
|
||||
query.push('year=' + ((object.movie.release_date || object.movie.first_air_date || '0000') + '').slice(0, 4));
|
||||
query.push('source=' + card_source);
|
||||
query.push('clarification=' + (object.clarification ? 1 : 0));
|
||||
query.push('similar=' + (object.similar ? true : false));
|
||||
query.push('rchtype=' + (((window.rch_nws && window.rch_nws[hostkey]) ? window.rch_nws[hostkey].type : (window.rch && window.rch[hostkey]) ? window.rch[hostkey].type : '') || ''));
|
||||
if (Lampa.Storage.get('account_email', '')) query.push('cub_id=' + Lampa.Utils.hash(Lampa.Storage.get('account_email', '')));
|
||||
return url + (url.indexOf('?') >= 0 ? '&' : '?') + query.join('&');
|
||||
};
|
||||
this.getLastChoiceBalanser = function() {
|
||||
var last_select_balanser = Lampa.Storage.cache('online_last_balanser', 3000, {});
|
||||
if (last_select_balanser[object.movie.id]) {
|
||||
return last_select_balanser[object.movie.id];
|
||||
} else {
|
||||
return Lampa.Storage.get('online_balanser', filter_sources.length ? filter_sources[0] : '');
|
||||
}
|
||||
};
|
||||
this.startSource = function(json) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
json.forEach(function(j) {
|
||||
var name = balanserName(j);
|
||||
sources[name] = {
|
||||
url: j.url,
|
||||
name: j.name,
|
||||
show: typeof j.show == 'undefined' ? true : j.show
|
||||
};
|
||||
});
|
||||
filter_sources = Lampa.Arrays.getKeys(sources);
|
||||
if (filter_sources.length) {
|
||||
var last_select_balanser = Lampa.Storage.cache('online_last_balanser', 3000, {});
|
||||
if (last_select_balanser[object.movie.id]) {
|
||||
balanser = last_select_balanser[object.movie.id];
|
||||
} else {
|
||||
balanser = Lampa.Storage.get('online_balanser', filter_sources[0]);
|
||||
}
|
||||
if (!sources[balanser]) balanser = filter_sources[0];
|
||||
if (!sources[balanser].show && !object.lampac_custom_select) balanser = filter_sources[0];
|
||||
source = sources[balanser].url;
|
||||
Lampa.Storage.set('active_balanser', balanser);
|
||||
resolve(json);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
};
|
||||
this.lifeSource = function() {
|
||||
var _this3 = this;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var url = _this3.requestParams(Defined.localhost + 'lifeevents?memkey=' + (_this3.memkey || ''));
|
||||
var red = false;
|
||||
var gou = function gou(json, any) {
|
||||
if (json.accsdb) return reject(json);
|
||||
var last_balanser = _this3.getLastChoiceBalanser();
|
||||
if (!red) {
|
||||
var _filter = json.online.filter(function(c) {
|
||||
return any ? c.show : c.show && c.name.toLowerCase() == last_balanser;
|
||||
});
|
||||
if (_filter.length) {
|
||||
red = true;
|
||||
resolve(json.online.filter(function(c) {
|
||||
return c.show;
|
||||
}));
|
||||
} else if (any) {
|
||||
reject();
|
||||
}
|
||||
}
|
||||
};
|
||||
var fin = function fin(call) {
|
||||
network.timeout(3000);
|
||||
network.silent(account(url), function(json) {
|
||||
life_wait_times++;
|
||||
filter_sources = [];
|
||||
sources = {};
|
||||
json.online.forEach(function(j) {
|
||||
var name = balanserName(j);
|
||||
sources[name] = {
|
||||
url: j.url,
|
||||
name: j.name,
|
||||
show: typeof j.show == 'undefined' ? true : j.show
|
||||
};
|
||||
});
|
||||
filter_sources = Lampa.Arrays.getKeys(sources);
|
||||
filter.set('sort', filter_sources.map(function(e) {
|
||||
return {
|
||||
title: sources[e].name,
|
||||
source: e,
|
||||
selected: e == balanser,
|
||||
ghost: !sources[e].show
|
||||
};
|
||||
}));
|
||||
filter.chosen('sort', [sources[balanser] ? sources[balanser].name : balanser]);
|
||||
gou(json);
|
||||
var lastb = _this3.getLastChoiceBalanser();
|
||||
if (life_wait_times > 15 || json.ready) {
|
||||
filter.render().find('.lampac-balanser-loader').remove();
|
||||
gou(json, true);
|
||||
} else if (!red && sources[lastb] && sources[lastb].show) {
|
||||
gou(json, true);
|
||||
life_wait_timer = setTimeout(fin, 1000);
|
||||
} else {
|
||||
life_wait_timer = setTimeout(fin, 1000);
|
||||
}
|
||||
}, function() {
|
||||
life_wait_times++;
|
||||
if (life_wait_times > 15) {
|
||||
reject();
|
||||
} else {
|
||||
life_wait_timer = setTimeout(fin, 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
fin();
|
||||
});
|
||||
};
|
||||
this.createSource = function() {
|
||||
var _this4 = this;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var url = _this4.requestParams(Defined.localhost + 'lite/events?life=true');
|
||||
network.timeout(15000);
|
||||
network.silent(account(url), function(json) {
|
||||
if (json.accsdb) return reject(json);
|
||||
if (json.life) {
|
||||
_this4.memkey = json.memkey;
|
||||
if (json.title) {
|
||||
if (object.movie.name) object.movie.name = json.title;
|
||||
if (object.movie.title) object.movie.title = json.title;
|
||||
}
|
||||
filter.render().find('.filter--sort').append('<span class="lampac-balanser-loader" style="width: 1.2em; height: 1.2em; margin-top: 0; background: url(./img/loader.svg) no-repeat 50% 50%; background-size: contain; margin-left: 0.5em"></span>');
|
||||
_this4.lifeSource().then(_this4.startSource).then(resolve)["catch"](reject);
|
||||
} else {
|
||||
_this4.startSource(json).then(resolve)["catch"](reject);
|
||||
}
|
||||
}, reject);
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Подготовка
|
||||
*/
|
||||
this.create = function() {
|
||||
return this.render();
|
||||
};
|
||||
/**
|
||||
* Начать поиск
|
||||
*/
|
||||
this.search = function() { //this.loading(true)
|
||||
this.filter({
|
||||
source: filter_sources
|
||||
}, this.getChoice());
|
||||
this.find();
|
||||
};
|
||||
this.find = function() {
|
||||
this.request(this.requestParams(source));
|
||||
};
|
||||
this.request = function(url) {
|
||||
number_of_requests++;
|
||||
if (number_of_requests < 10) {
|
||||
network["native"](account(url), this.parse.bind(this), this.doesNotAnswer.bind(this), false, {
|
||||
dataType: 'text'
|
||||
});
|
||||
clearTimeout(number_of_requests_timer);
|
||||
number_of_requests_timer = setTimeout(function() {
|
||||
number_of_requests = 0;
|
||||
}, 4000);
|
||||
} else this.empty();
|
||||
};
|
||||
this.parseJsonDate = function(str, name) {
|
||||
try {
|
||||
var html = $('<div>' + str + '</div>');
|
||||
var elems = [];
|
||||
html.find(name).each(function() {
|
||||
var item = $(this);
|
||||
var data = JSON.parse(item.attr('data-json'));
|
||||
var season = item.attr('s');
|
||||
var episode = item.attr('e');
|
||||
var text = item.text();
|
||||
if (!object.movie.name) {
|
||||
if (text.match(/\d+p/i)) {
|
||||
if (!data.quality) {
|
||||
data.quality = {};
|
||||
data.quality[text] = data.url;
|
||||
}
|
||||
text = object.movie.title;
|
||||
}
|
||||
if (text == 'По умолчанию') {
|
||||
text = object.movie.title;
|
||||
}
|
||||
}
|
||||
if (episode) data.episode = parseInt(episode);
|
||||
if (season) data.season = parseInt(season);
|
||||
if (text) data.text = text;
|
||||
data.active = item.hasClass('active');
|
||||
elems.push(data);
|
||||
});
|
||||
return elems;
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
this.getFileUrl = function(file, call, waiting_rch) {
|
||||
var _this = this;
|
||||
|
||||
if(Lampa.Storage.field('player') !== 'inner' && file.stream && Lampa.Platform.is('apple')){
|
||||
var newfile = Lampa.Arrays.clone(file);
|
||||
newfile.method = 'play';
|
||||
newfile.url = file.stream;
|
||||
call(newfile, {});
|
||||
}
|
||||
else if (file.method == 'play') call(file, {});
|
||||
else {
|
||||
Lampa.Loading.start(function() {
|
||||
Lampa.Loading.stop();
|
||||
Lampa.Controller.toggle('content');
|
||||
network.clear();
|
||||
});
|
||||
network["native"](account(file.url), function(json) {
|
||||
if(json.rch){
|
||||
if(waiting_rch) {
|
||||
Lampa.Loading.stop();
|
||||
call(false, {});
|
||||
}
|
||||
else {
|
||||
_this.rch(json,function(){
|
||||
Lampa.Loading.stop();
|
||||
|
||||
_this.getFileUrl(file, call, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
else{
|
||||
Lampa.Loading.stop();
|
||||
call(json, json);
|
||||
}
|
||||
}, function() {
|
||||
Lampa.Loading.stop();
|
||||
call(false, {});
|
||||
});
|
||||
}
|
||||
};
|
||||
this.toPlayElement = function(file) {
|
||||
var play = {
|
||||
title: file.title,
|
||||
url: file.url,
|
||||
quality: file.qualitys,
|
||||
timeline: file.timeline,
|
||||
subtitles: file.subtitles,
|
||||
segments: file.segments,
|
||||
callback: file.mark,
|
||||
season: file.season,
|
||||
episode: file.episode,
|
||||
voice_name: file.voice_name
|
||||
};
|
||||
return play;
|
||||
};
|
||||
this.orUrlReserve = function(data) {
|
||||
if (data.url && typeof data.url == 'string' && data.url.indexOf(" or ") !== -1) {
|
||||
var urls = data.url.split(" or ");
|
||||
data.url = urls[0];
|
||||
data.url_reserve = urls[1];
|
||||
}
|
||||
};
|
||||
this.setDefaultQuality = function(data) {
|
||||
if (Lampa.Arrays.getKeys(data.quality).length) {
|
||||
for (var q in data.quality) {
|
||||
if (parseInt(q) == Lampa.Storage.field('video_quality_default')) {
|
||||
data.url = data.quality[q];
|
||||
this.orUrlReserve(data);
|
||||
}
|
||||
if (data.quality[q].indexOf(" or ") !== -1)
|
||||
data.quality[q] = data.quality[q].split(" or ")[0];
|
||||
}
|
||||
}
|
||||
};
|
||||
this.display = function(videos) {
|
||||
var _this5 = this;
|
||||
this.draw(videos, {
|
||||
onEnter: function onEnter(item, html) {
|
||||
_this5.getFileUrl(item, function(json, json_call) {
|
||||
if (json && json.url) {
|
||||
var playlist = [];
|
||||
var first = _this5.toPlayElement(item);
|
||||
first.url = json.url;
|
||||
first.headers = json_call.headers || json.headers;
|
||||
first.quality = json_call.quality || item.qualitys;
|
||||
first.segments = json_call.segments || item.segments;
|
||||
first.hls_manifest_timeout = json_call.hls_manifest_timeout || json.hls_manifest_timeout;
|
||||
first.subtitles = json.subtitles;
|
||||
first.subtitles_call = json_call.subtitles_call || json.subtitles_call;
|
||||
if (json.vast && json.vast.url) {
|
||||
first.vast_url = json.vast.url;
|
||||
first.vast_msg = json.vast.msg;
|
||||
first.vast_region = json.vast.region;
|
||||
first.vast_platform = json.vast.platform;
|
||||
first.vast_screen = json.vast.screen;
|
||||
}
|
||||
_this5.orUrlReserve(first);
|
||||
_this5.setDefaultQuality(first);
|
||||
if (item.season) {
|
||||
videos.forEach(function(elem) {
|
||||
var cell = _this5.toPlayElement(elem);
|
||||
if (elem == item) cell.url = json.url;
|
||||
else {
|
||||
if (elem.method == 'call') {
|
||||
if (Lampa.Storage.field('player') !== 'inner') {
|
||||
cell.url = elem.stream;
|
||||
delete cell.quality;
|
||||
} else {
|
||||
cell.url = function(call) {
|
||||
_this5.getFileUrl(elem, function(stream, stream_json) {
|
||||
if (stream.url) {
|
||||
cell.url = stream.url;
|
||||
cell.quality = stream_json.quality || elem.qualitys;
|
||||
cell.segments = stream_json.segments || elem.segments;
|
||||
cell.subtitles = stream.subtitles;
|
||||
_this5.orUrlReserve(cell);
|
||||
_this5.setDefaultQuality(cell);
|
||||
elem.mark();
|
||||
} else {
|
||||
cell.url = '';
|
||||
Lampa.Noty.show(Lampa.Lang.translate('lampac_nolink'));
|
||||
}
|
||||
call();
|
||||
}, function() {
|
||||
cell.url = '';
|
||||
call();
|
||||
});
|
||||
};
|
||||
}
|
||||
} else {
|
||||
cell.url = elem.url;
|
||||
}
|
||||
}
|
||||
_this5.orUrlReserve(cell);
|
||||
_this5.setDefaultQuality(cell);
|
||||
playlist.push(cell);
|
||||
}); //Lampa.Player.playlist(playlist)
|
||||
} else {
|
||||
playlist.push(first);
|
||||
}
|
||||
if (playlist.length > 1) first.playlist = playlist;
|
||||
if (first.url) {
|
||||
var element = first;
|
||||
element.isonline = true;
|
||||
if (element.url && element.isonline) {
|
||||
// online.js
|
||||
}
|
||||
else if (element.url) {
|
||||
if (false) {
|
||||
if (Platform.is('browser') && location.host.indexOf("127.0.0.1") !== -1) {
|
||||
Noty.show('Видео открыто в playerInner', {time: 3000});
|
||||
$.get(getBalancerUrl() + '/player-inner/' + element.url);
|
||||
return;
|
||||
}
|
||||
|
||||
Player.play(element);
|
||||
}
|
||||
else {
|
||||
if (true && Platform.is('browser') && location.host.indexOf("127.0.0.1") !== -1)
|
||||
Noty.show('Внешний плеер можно указать в init.conf (playerInner)', {time: 3000});
|
||||
Player.play(element);
|
||||
}
|
||||
}
|
||||
Lampa.Player.play(element);
|
||||
Lampa.Player.playlist(playlist);
|
||||
if(element.subtitles_call) _this5.loadSubtitles(element.subtitles_call)
|
||||
item.mark();
|
||||
_this5.updateBalanser(balanser);
|
||||
} else {
|
||||
Lampa.Noty.show(Lampa.Lang.translate('lampac_nolink'));
|
||||
}
|
||||
} else Lampa.Noty.show(Lampa.Lang.translate('lampac_nolink'));
|
||||
}, true);
|
||||
},
|
||||
onContextMenu: function onContextMenu(item, html, data, call) {
|
||||
_this5.getFileUrl(item, function(stream) {
|
||||
call({
|
||||
file: stream.url,
|
||||
quality: item.qualitys
|
||||
});
|
||||
}, true);
|
||||
}
|
||||
});
|
||||
this.filter({
|
||||
season: filter_find.season.map(function(s) {
|
||||
return s.title;
|
||||
}),
|
||||
voice: filter_find.voice.map(function(b) {
|
||||
return b.title;
|
||||
})
|
||||
}, this.getChoice());
|
||||
};
|
||||
this.loadSubtitles = function(link){
|
||||
network.silent(account(link), function(subs){
|
||||
Lampa.Player.subtitles(subs)
|
||||
})
|
||||
}
|
||||
this.parse = function(str) {
|
||||
var json = Lampa.Arrays.decodeJson(str, {});
|
||||
if (Lampa.Arrays.isObject(str) && str.rch) json = str;
|
||||
if (json.rch) return this.rch(json);
|
||||
try {
|
||||
var items = this.parseJsonDate(str, '.videos__item');
|
||||
var buttons = this.parseJsonDate(str, '.videos__button');
|
||||
if (items.length == 1 && items[0].method == 'link' && !items[0].similar) {
|
||||
filter_find.season = items.map(function(s) {
|
||||
return {
|
||||
title: s.text,
|
||||
url: s.url
|
||||
};
|
||||
});
|
||||
this.replaceChoice({
|
||||
season: 0
|
||||
});
|
||||
this.request(items[0].url);
|
||||
} else {
|
||||
this.activity.loader(false);
|
||||
var videos = items.filter(function(v) {
|
||||
return v.method == 'play' || v.method == 'call';
|
||||
});
|
||||
var similar = items.filter(function(v) {
|
||||
return v.similar;
|
||||
});
|
||||
if (videos.length) {
|
||||
if (buttons.length) {
|
||||
filter_find.voice = buttons.map(function(b) {
|
||||
return {
|
||||
title: b.text,
|
||||
url: b.url
|
||||
};
|
||||
});
|
||||
var select_voice_url = this.getChoice(balanser).voice_url;
|
||||
var select_voice_name = this.getChoice(balanser).voice_name;
|
||||
var find_voice_url = buttons.find(function(v) {
|
||||
return v.url == select_voice_url;
|
||||
});
|
||||
var find_voice_name = buttons.find(function(v) {
|
||||
return v.text == select_voice_name;
|
||||
});
|
||||
var find_voice_active = buttons.find(function(v) {
|
||||
return v.active;
|
||||
}); ////console.log('b',buttons)
|
||||
////console.log('u',find_voice_url)
|
||||
////console.log('n',find_voice_name)
|
||||
////console.log('a',find_voice_active)
|
||||
if (find_voice_url && !find_voice_url.active) {
|
||||
//console.log('Lampac', 'go to voice', find_voice_url);
|
||||
this.replaceChoice({
|
||||
voice: buttons.indexOf(find_voice_url),
|
||||
voice_name: find_voice_url.text
|
||||
});
|
||||
this.request(find_voice_url.url);
|
||||
} else if (find_voice_name && !find_voice_name.active) {
|
||||
//console.log('Lampac', 'go to voice', find_voice_name);
|
||||
this.replaceChoice({
|
||||
voice: buttons.indexOf(find_voice_name),
|
||||
voice_name: find_voice_name.text
|
||||
});
|
||||
this.request(find_voice_name.url);
|
||||
} else {
|
||||
if (find_voice_active) {
|
||||
this.replaceChoice({
|
||||
voice: buttons.indexOf(find_voice_active),
|
||||
voice_name: find_voice_active.text
|
||||
});
|
||||
}
|
||||
this.display(videos);
|
||||
}
|
||||
} else {
|
||||
this.replaceChoice({
|
||||
voice: 0,
|
||||
voice_url: '',
|
||||
voice_name: ''
|
||||
});
|
||||
this.display(videos);
|
||||
}
|
||||
} else if (items.length) {
|
||||
if (similar.length) {
|
||||
this.similars(similar);
|
||||
this.activity.loader(false);
|
||||
} else { //this.activity.loader(true)
|
||||
filter_find.season = items.map(function(s) {
|
||||
return {
|
||||
title: s.text,
|
||||
url: s.url
|
||||
};
|
||||
});
|
||||
var select_season = this.getChoice(balanser).season;
|
||||
var season = filter_find.season[select_season];
|
||||
if (!season) season = filter_find.season[0];
|
||||
//console.log('Lampac', 'go to season', season);
|
||||
this.request(season.url);
|
||||
}
|
||||
} else {
|
||||
this.doesNotAnswer(json);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
//console.log('Lampac', 'error', e.stack);
|
||||
this.doesNotAnswer(e);
|
||||
}
|
||||
};
|
||||
this.similars = function(json) {
|
||||
var _this6 = this;
|
||||
scroll.clear();
|
||||
json.forEach(function(elem) {
|
||||
elem.title = elem.text;
|
||||
elem.info = '';
|
||||
var info = [];
|
||||
var year = ((elem.start_date || elem.year || object.movie.release_date || object.movie.first_air_date || '') + '').slice(0, 4);
|
||||
if (year) info.push(year);
|
||||
if (elem.details) info.push(elem.details);
|
||||
var name = elem.title || elem.text;
|
||||
elem.title
|
||||
Reference in New Issue
Block a user