diff --git a/index.js b/index.js new file mode 100644 index 0000000..f0ebc02 --- /dev/null +++ b/index.js @@ -0,0 +1,9472 @@ +Date.now||(Date.now=function(){return(new Date.getTime())}),function(){"use strict";for(var t=["webkit","moz"],e=0;el-(this.size+6)&&this.reset(),this.element.style.top=this.y+"px",this.element.style.left=this.x+"px",this.step+=this.stepSize,y===!1?this.x+=Math.cos(this.step):this.x+=y+Math.cos(this.step),i.collection&&this.x>this.target.x&&this.xthis.target.y&&this.ythis.target.height)if(s+this.speed+this.size>this.target.height){for(;s+this.speed+this.size>this.target.height&&this.speed>0;)this.speed*=.5;t.fillStyle=o.flakeColor,void 0==n[parseInt(e)][parseInt(s+this.speed+this.size)]?(n[parseInt(e)][parseInt(s+this.speed+this.size)]=1,t.fillRect(e,s+this.speed+this.size,this.size,this.size)):(n[parseInt(e)][parseInt(s+this.speed)]=1,t.fillRect(e,s+this.speed,this.size,this.size)),this.reset()}else this.speed=1,this.stepSize=0,parseInt(e)+10&&void 0==n[parseInt(e)-1][parseInt(s)+1]?this.x--:(t.fillStyle=o.flakeColor,t.fillRect(e,s,this.size,this.size),n[parseInt(e)][parseInt(s)]=1,this.reset())}(this.x+this.size>d-c||this.x",{"class":"snowfall-canvas"}),z=[];if(u.top-g>0){t("body").append(x),x.css({position:i.flakePosition,left:u.left+"px",top:u.top-g+"px"}).prop({width:u.width,height:g});for(var v=0;vVIP buy at @modssmy_bot'); + }); + }, 500); + }); + if (Lampa.Storage.field('mods_tv_butt_ch')) Lampa.Keypad.listener.follow('keydown', function (e) { + var next = (e.code == 427 || e.code == 33 || e.code == 39); + var prev = (e.code == 428 || e.code == 34 || e.code == 37); + var none = !$('.panel--visible .focus').length && Lampa.Controller.enabled().name !== 'select'; + if (Lampa.Activity.active() && Lampa.Activity.active().component == 'modss_tv' && Lampa.Player.opened()) { + //Lampa.Noty.show('code_ '+e.code); + if (prev && none) { + //Lampa.Noty.show('code_prev'); + Lampa.PlayerPlaylist.prev(); + } + if (next && none) { + //Lampa.Noty.show('code_ next'); + Lampa.PlayerPlaylist.next(); + } + } + }); + if (!window.FX) { + window.FX = { + max_qualitie: 480, + is_max_qualitie: false, + auth: false + }; + } + if(!IP) this.getIp(); + var ads_4k = ['
', '
', '
Надоело смотреть в плохом качестве?
Хочешь смотреть в FHD и 4K? Переходи в телеграм бот @modssmy_bot для подключения VIP
', '
', '
'].join(''); + Lampa.Controller.listener.follow('toggle', function(e) { + if(e.name == 'select' && !vip) { + setTimeout(function() { + if($('.selectbox .scroll__body div:eq(0)').html().indexOf('.land') >= 0) + $('.selectbox .scroll__body div:eq(0)').remove(); + if($('.selectbox .selectbox-item__icon svg').length && Lampa.Activity.active().component == 'full') $('.selectbox .scroll__body').prepend($(ads_4k)); + }, 10); + } + }); + var mynotice = new Lampa.NoticeClassLampa({name: 'Modss',db_name: 'notice_modss'}); + Lampa.Notice.addClass('modss', mynotice); + if(Lampa.Storage.get('showModssVip', false) && leftVipD && vip && logged) setTimeout(function (){ + Modss.showModssVip(); + Lampa.Storage.set('showModssVip', false); + }, 2000); + }, + snow: function () { + $(document).snowfall(Lampa.Storage.field('mods_snow') == true ? { + deviceorientation:true, + round:true, + maxSize:10, + maxSpeed:5, + flakeCount:30, + flakeIndex:9 + } : 'clear'); + }, + radio: function () { + var ico = ' Radio '; + var menu_item = $(''); + menu_item.on('hover:enter', function () { + Lampa.Activity.push({ + url: API + 'r/record/', + title: Lampa.Lang.translate('title_radio'), + component: 'Radio_n', + page: 1 + }); + }); + if (Lampa.Storage.get('mods_radio')) $('body').find('.menu .menu__list').eq(0).append(menu_item); + else $('body').find('[data-action="Radio_n"]').remove(); + }, + + sources: function () { + var sources; + if (Lampa.Params.values && Lampa.Params.values['source']) { + sources = Object.assign({}, Lampa.Params.values['source']); + sources.pub = 'PUB'; + sources.filmix = 'FILMIX'; + } else { + sources = { + 'tmdb': 'TMDB', + 'cub': 'CUB', + 'pub': 'PUB', + 'filmix': 'FILMIX' + }; + } + + Lampa.Params.select('source', sources, 'tmdb'); + }, + showModssVip: function () { + var enabled = Lampa.Controller.enabled().name; + Lampa.Modal.open({ + title: '', + html: Lampa.Template.get('cub_premium'), + onBack: function onBack() { + Lampa.Modal.close(); + Lampa.Controller.toggle(enabled); + } + }); + Lampa.Modal.render().find('.cub-premium__title').text("MODS's VIP"); + Lampa.Modal.render().find('.cub-premium__descr:eq(0)').text('Поздравляем вас с получением VIP-статуса! Теперь у вас есть возможность наслаждаться видео в высоком разрешении 4К. Кроме того, вас ожидают дополнительные балансеры, которые помогут найти подходящий контент'); + Lampa.Modal.render().find('.cub-premium__descr:eq(1)').text('У вас осталось ' + leftVipD); + Lampa.Modal.render().find('.cub-premium__descr:eq(1)').after('👇 Кнопка для просмотра 👇

'); + Lampa.Modal.render().find('.cub-premium__url').text('@modssmy_bot'); + Lampa.Modal.render().addClass('modal--cub-premium').find('.modal__content').before(''); + }, + online: function (back) { + var params = { + url: '', + title: Lampa.Lang.translate('modss_title_online') + " MODS's ", + component: 'modss_online', + search: cards.title, + search_one: cards.title, + search_two: cards.original_title, + movie: cards, + page: 1 + }; + this.params = params; + var _this = this; + function inf() { + _this.balanser = Lampa.Storage.get('modss_last_balanser'); + _this.data = Lampa.Storage.cache('online_choice_' + _this.balanser[card.id], 3000, {}); + _this.is_continue = card.number_of_seasons && _this.data[card.id] && Lampa.Arrays.getKeys(_this.data[card.id].episodes_view).length; + _this.last_s = _this.is_continue ? ('S'+(_this.data[card.id].season + 1)+' - '+(_this.data[card.id].episodes_view[_this.data[card.id].season == 0 ? 1 : (_this.data[card.id].season +1)])+' '+Lampa.Lang.translate('torrent_serial_episode').toLowerCase()) : ''; + _this.title = _this.is_continue && Lampa.Storage.field('online_continued') ? '#{title_online_continue} ' : '#{modss_title_online}'; + } + function openOnline(){ + Lampa.Activity.push(params); + } + function shows(last) { + Lampa.Select.show({ + title: Lampa.Lang.translate('title_action'), + items: [{ + title: Lampa.Lang.translate('title_online_continue') + '? ' + _this.last_s, + yes: true + }, { + title: Lampa.Lang.translate('settings_param_no') + }], + onBack: function onBack() { + Lampa.Select.hide(); + Lampa.Controller.toggle('content'); + }, + onSelect: function onSelect(a) { + if (a.yes) { + _this.data[card.id].continued = true; + Lampa.Storage.set('online_choice_' + _this.balanser[card.id], _this.data); + } + openOnline(); + } + }); + } + var card = cards; + var balanser = this.balanser; + var data = this.data; + var is_continue = this.is_continue; + var last_s = this.last_s; + inf(); + + var loader = ''; + var ico = ''; + var button = "
" +ico + ""+this.title+"
"); + var btn = $(Lampa.Lang.translate(button)); + this.btn = btn; + // if (Lampa.Storage.field('online_but_first')) Lampa.Storage.set('full_btn_priority', Lampa.Utils.hash(btn.clone().removeClass('focus').prop('outerHTML'))); + + if(back == 'delete') Lampa.Activity.active().activity.render().find('.view--modss_online').remove(); + if(back && back !== 'delete') back.find('span').text(Lampa.Lang.translate(this.title)); + if (!back && Lampa.Storage.field('mods_onl')) { + setTimeout(function (){ + if(Lampa.Controller.enabled().name == 'full_start' && !Lampa.Activity.active().activity.render().find('.view--modss_online').length) { + if(Lampa.Activity.active().activity.render().find('.button--priority').length){ + Lampa.Activity.active().activity.render().find('.full-start-new__buttons').prepend(btn); + Lampa.Controller.toggle('full_start'); + Navigator.focus(btn[0]); + } else if((Lampa.Storage.field('online_but_first') && Lampa.Activity.active().activity.render().find('.button--play').length) || !Lampa.Activity.active().activity.render().find('.view--torrent').length){ + Lampa.Activity.active().activity.render().find('.button--play').before(btn); + Lampa.Controller.toggle('full_start'); + Navigator.focus(btn[0]); + } else { + Lampa.Activity.active().activity.render().find('.view--torrent').before(btn); + Lampa.Controller.toggle('full_start'); + } + } + //if(Lampa.Storage.field('online_but_first')) Navigator.focus(btn[0]); + }, 100); + btn.unbind('hover:enter hover.click').on('hover:enter hover.click', function () { + inf(); + Lampa.Activity.active().activity.render().find('.view--modss_online').html(Lampa.Lang.translate(ico + ''+_this.title+'')); + if(_this.is_continue && Lampa.Storage.field('online_continued')) shows(_this.last_s); + else openOnline(); + }); + } + }, + + + collections: function () { + var menu_item = $(''); + if (Lampa.Storage.get('mods_collection')) $('body').find('.menu .menu__list li:eq(3)').after(menu_item) + else $('body').find('[data-action="collection"]').remove(); + if(!API || !API.length) window.location.reload(); + menu_item.on('hover:enter', function () { + var item = [{ + /*title: Lampa.Lang.translate('menu_collections')+' '+Lampa.Lang.translate('title_on_the')+ ' filmix', + url: 'https://filmix.ac/playlists/rateup', + source: 'filmix' + }, {*/ + title: Lampa.Lang.translate('menu_collections') + ' ' + Lampa.Lang.translate('title_on_the') + ' rezka', + url: Protocol() +'hdrezka.co/collections/', + source: 'rezka' + }, { + title: Lampa.Lang.translate('menu_collections') + ' ' + Lampa.Lang.translate('title_on_the') + ' kinopub', + url: Pub.baseurl + 'v1/collections', + source: 'pub' + }]; + if (Lampa.Arrays.getKeys(Lampa.Storage.get('my_col')).length) { + item.push({ + title: Lampa.Lang.translate('title_my_collections') + ' - ' + Lampa.Arrays.getKeys(Lampa.Storage.get('my_col')).length, + url: Pub.baseurl + 'v1/collections', + source: 'my_coll' + }); + } + Lampa.Select.show({ + title: Lampa.Lang.translate('menu_collections'), + items: item, + onSelect: function onSelect(a) { + Lampa.Activity.push({ + url: a.url || '', + sourc: a.source, + source: Lampa.Storage.field('source'), + title: a.title, + card_cat: true, + category: true, + component: a.url ? 'collection' : 'collections', + page: 1 + }); + }, + onBack: function onBack() { + Lampa.Controller.toggle('content'); + } + }); + }); + }, + getIp: function () { + $.ajax({ + url: Protocol() + 'api.bigdatacloud.net/data/client-ip', + //url: 'https://api.ipify.org/?format=json', + type:'get', + dataType:'json' + }).done(function(data) { + IP = data.ipString; + }); + }, + Timer: function (tpl) { + var self = this; + self.tpl = tpl; + self.startTime = 0; + self.paused = true; + self.msElapsed = 0; + self.intervalId = null; + + self.start = function() { + self.paused = false; + self.startTime = Date.now(); + Lampa.Activity.active().activity.render().find(self.tpl).html(''); + self.intervalId = setInterval(function() { + var curTime = Date.now(); + self.msElapsed = curTime - self.startTime; + var sek = self.formatTime(self.msElapsed); + Lampa.Activity.active().activity.render().find(self.tpl).html(sek); + }, 100); + }; + self.stop = function() { + clearInterval(self.intervalId); + self.intervalId = null; + self.paused = true; + return self.formatTime(self.msElapsed); + }; + self.formatTime = function(ms) { + var totalSeconds = Math.floor(ms / 1000); + var minutes = Math.floor(totalSeconds / 60); + var seconds = totalSeconds % 60; + var milliseconds = Math.floor((ms % 1000) / 10); + var sec = seconds < 10 ? '0' + seconds : seconds; + var milsec = milliseconds < 10 ? '0' + milliseconds : milliseconds; + return sec+':'+milsec+' c'; + }; + }, + buttBack: function (pos) { + if ((/iPhone|iPad|iPod|android|x11/i.test(navigator.userAgent) || (Lampa.Platform.is('android') && window.innerHeight < 1080)) && Lampa.Storage.get('mods_butt_back')) { + $('body').find('.elem-mobile-back').remove(); + var position = Lampa.Storage.field('mods_butt_pos') == 'left' ? 'left: 0;transform: scaleX(-1);' : 'right: 0;'; + $('body').append('
'); + $(".elem-mobile-back").on("click", function () { + Lampa.Activity.back(); + }); + } + }, + last_view: function (data) { + var episodes = Lampa.TimeTable.get(data); + var viewed; + episodes.forEach(function (ep) { + var hash = Lampa.Utils.hash([ep.season_number, ep.episode_number, data.original_title].join('')); + var view = Lampa.Timeline.view(hash); + if (view.percent) viewed = { + ep: ep, + view: view + }; + }); + if (viewed) { + var ep = viewed.ep.episode_number; + var se = viewed.ep.season_number; + var last_view = 'S' + se + ':E' + ep; + if ($('body').find('.full-start__buttons,.full-start-new__buttons').length) { + $('.timeline, .card--last_view').remove(); + $('body').find('.full-start__poster,.full-start-new__poster').append("
" + last_view +"
").parent().append('
'); + $('body').find('.timeline').append(Lampa.Timeline.render(viewed.view)); + } + if ($('body').find('.filter--sort').length) $('body').find('.files__left .time-line, .card--last_view').remove(); + } else $('body').find('.timeline,.card--last_view').remove(); + if ($('body').find('.online').length == 0) $('.card--new_ser,.card--viewed').remove(); + }, + serialInfo: function (card) { + if (Lampa.Storage.field('mods_serial_info') && card.source == 'tmdb' && card.seasons && card.last_episode_to_air) { + var last_seria_inseason = card.last_episode_to_air.season_number; + var air_new_episode = card.last_episode_to_air.episode_number; + var next_episode = card.next_episode_to_air; + var last_seria = next_episode && new Date(next_episode.air_date) <= Date.now() ? next_episode.episode_number : card.last_episode_to_air.episode_number; + var new_ser; + this.last_view(card); + var count_eps_last_seas = card.seasons.find(function (eps) { + return eps.season_number == last_seria_inseason; + }).episode_count; + if(!API || !API.length) window.location.reload(); + + if (card.next_episode_to_air) { + var add_ = '' + last_seria; + var notices = Lampa.Storage.get('account_notice', []).filter(function (n) { + return n.card_id == card.id; + }); + if (notices.length) { + var notice = notices.find(function (itm) { + return itm.episode == last_seria; + }); + + if (notice) { + var episod_new = JSON.parse(notice.data).card.seasons; + if (Lampa.Utils.parseTime(notice.date).full == Lampa.Utils.parseTime(Date.now()).full) + add_ = '#{season_new} ' + episod_new[last_seria_inseason]; + } + } + new_ser = add_ + ' #{torrent_serial_episode} #{season_from} ' + count_eps_last_seas + ' - S' + last_seria_inseason; + } else new_ser = last_seria_inseason + ' #{season_ended}'; + + if(!$('.card--new_seria', Lampa.Activity.active().activity.render()).length) { + if(window.innerWidth > 585) $('.full-start__poster,.full-start-new__poster', Lampa.Activity.active().activity.render()).append("
" + Lampa.Lang.translate(new_ser) + "
"); + else { + if($('.card--new_seria', Lampa.Activity.active().activity.render()).length)$('.full-start__tags', Lampa.Activity.active().activity.render()).append('
'+ Lampa.Lang.translate(new_ser) +'
'); + else $('.full-start-new__details', Lampa.Activity.active().activity.render()).append('
'+ Lampa.Lang.translate(new_ser) +'
'); + } + } + } + }, + rating_kp_imdb:function (card) { + return new Promise(function (resolve, reject) { + var relise = (card.number_of_seasons ? card.first_air_date : card.release_date) || '0000'; + var year = parseInt((relise + '').slice(0, 4)); + // if (Lampa.Storage.field('mods_rating') && $('.rate--kp', Lampa.Activity.active().activity.render()).hasClass('hide') && !$('.wait_rating', Lampa.Activity.active().activity.render()).length) + if (['filmix', 'pub'].indexOf(card.source) == -1 && Lampa.Storage.field('mods_rating')) + if(!API || !API.length) window.location.reload(); + $('.info__rate', Lampa.Activity.active().activity.render()).after('
'); + Pub.network.clear(); + Pub.network.timeout(10000); + Pub.network.silent(API + 'KPrating', function (json) { + if(!card.kinopoisk_id && json.data && json.data.kp_id) card.kinopoisk_ID = json.data.kp_id; + var kp = json.data && json.data.kp_rating || 0; + var imdb = json.data && json.data.imdb_rating || 0; + var auth = json.data.auth; + vip = json.data.vip; + if(json.data.leftDays) leftVipD = json.data.leftDays; + if(!vip) Lampa.Storage.set('showModssVip', true); + if (logged !== auth) { + logged = auth; + window.location.reload(); + } + var kp_rating = !isNaN(kp) && kp !== null ? parseFloat(kp).toFixed(1) : '0.0'; + var imdb_rating = !isNaN(imdb) && imdb !== null ? parseFloat(imdb).toFixed(1) : '0.0'; + if (['filmix', 'pub'].indexOf(card.source) == -1 && Lampa.Storage.field('mods_rating')){ + $('.wait_rating',Lampa.Activity.active().activity.render()).remove(); + $('.rate--imdb', Lampa.Activity.active().activity.render()).removeClass('hide').find('> div').eq(0).text(imdb_rating); + $('.rate--kp', Lampa.Activity.active().activity.render()).removeClass('hide').find('> div').eq(0).text(kp_rating); + } + resolve(); + }, function (a, c) { + resolve(); + Lampa.Noty.show('MODSs ОШИБКА Рейтинг KP ' + Pub.network.errorDecode(a, c)); + }, { + title:card.title, + year: year, + card_id:card.id, + imdb: card.imdb_id, + user_id: user_id, + uid: uid + }); + }); + }, + Notice: function (data) { + var id = data.id; + var card = JSON.parse(data.data).card; + setTimeout(function() { + if(Lampa.Notice.classes.modss.notices.find(function (n) { + return n.id == id; + })) return; + + var bals = []; + for (var b in data.find){ + bals.push(''+b+' - '+data.find[b].join(', ')); + } + Lampa.Notice.pushNotice('modss',{ + id: id, + from: 'modss', + title: card.name, + text: 'Переводы на балансерах где есть '+data.episode+' серия', + time: Date.now(), + poster: card.poster_path, + card: card, + labels: bals + },function(){ + console.log('Успешно'); + },function(e){ + console.log('Чет пошло не так',e); + }); + }, 1000); + + Lampa.Notice.listener.follow('select',function (e) { + if(e.element.from == 'modss'){ + Lampa.Notice.close(); + } + }); + }, + balansers: function() { + var balansers = {"videocdn":"VideoCDN","collaps":"Collaps","kinobase":"Kinobase","filmix":"Filmix","cdnmovies":"CDNmovies","rezka":"Rezka","pub":"Pub 4K VIP","hdr":"HDR MODS's [4K] VIP","hdrezka":"HDRezka 4K VIP","qiwi":"VBMovies 4K VIP","videodb":"VideoDB VIP","zetflix":"Zetflix VIP","uakino":"UAKino VIP","eneida":"Eneida(Ukr) VIP","kodik":"Kodik VIP","anilibria":"Anilibria VIP","hdvb":"HDVB VIP","kinotochka":"KinoTochka VIP"}; + if (Lampa.Storage.get('pro_pub', false)) balansers = Object.assign({"pub":"Pub"}, balansers); + return balansers; + }, + check: function(name, call) { + var json = Modss.jack[name]; + var item = $('.settings-param__status.one'); + var item2 = $('.settings-param__status.act'); + var url = (json && json.url || Lampa.Storage.get('jackett_url')); + var u = url + '/api/v2.0/indexers/' + (Lampa.Storage.field('jackett_interview') == 'healthy' ? 'status:healthy' : 'all') + '/results?apikey=' + (json && json.key || Lampa.Storage.get('jackett_key')); + Pub.network.timeout(10000); + var check = function check (ok) { + Pub.network["native"](Protocol() + u, function (t) { + if(name && !call) item2.removeClass('active error wait').addClass('active'); + if(call) { + if(name && !Modss.jack[name].check) Modss.jack[name].check = true; + if(name && !Modss.jack[name].ok) Modss.jack[name].ok = true; + call(true); + } + }, function (a, c) { + console.error('Request', 'parser error - ', Protocol() + u); + Lampa.Noty.show(Pub.network.errorDecode(a, c) + ' - ' + url); + if(name && !call) item2.removeClass('active error wait').addClass('error'); + if(call) { + if(ok && name && !Modss.jack[name].check) Modss.jack[name].check = true; + if(ok && name && !Modss.jack[name].ok) Modss.jack[name].ok = false; + call(false); + } + }); + }; + if(name && !call) check(); + else if(call && name && !Modss.jack[name].check) check(true); + else { + if(name && Modss.jack[name].ok) if(call) call(true); + if(name && !Modss.jack[name].ok) if(call) call(false); + if(Boolean(Modss.jack[Lampa.Storage.get('jackett_url2')])) item.removeClass('wait').addClass(Modss.jack[Lampa.Storage.get('jackett_url2')].ok ? 'active' : 'error'); + } + }, + jack:{ + jacred_xyz: {url:'jacred.xyz', key:'',lang:'df_lg', interv:'all'}, + spawn_pp_ua: {url:'spawn.pp.ua:59117', key:2,lang:'df', interv:'all'}, + jacred_ru: {url:'jacred.ru', key:'',lang:'lg', interv:'healthy'}, + jac_unknown: {url:'188.119.113.252:9117', key:1,lang:'lg', interv:'healthy'}, + }, + showModal: function(text, onselect, full, xml, but) { + Lampa.Modal.open({ + title: '', + align: 'center', + zIndex: 300, + size: full ? 'full' : 'large', + html: typeof text == 'object' ? text : $('
' + text + '
'), + onBack: function onBack() { + if(xml) xml.abort(); + Lampa.Modal.close(); + Lampa.Controller.toggle('content'); + }, + buttons: [{ + name: but ? but[0] : Lampa.Lang.translate('settings_param_no'), + onSelect: function onSelect() { + if(xml) xml.abort(); + Lampa.Modal.close(); + Lampa.Controller.toggle('content'); + } + }, { + name: but ? but[1] : Lampa.Lang.translate('settings_param_yes'), + onSelect: onselect + }] + }); + }, + speedTest: function(url, params) { + Lampa.Speedtest.start({url:url}); + $('.speedtest__body').prepend('
'+params.balanser+'
').append('
'+params.title+'
('+params.info+')
'); + + return; + + var style = ''; + var html = '
'+style+'510152030601002005000.000Mbps
'; + Lampa.Template.add('speed', html); + var tpl = Lampa.Template.get('speed'); + var status = $('#status', tpl); + var timeStart = false, pl = $('#pl', tpl), m3u = false, testStart = false; + var pl_p = [[-250, -250]]; + var tout; + var xmlHTTP = new XMLHttpRequest(); + + var test = function test() { + if (testStart) return; + testUrl(url) + }; + + function hslToRgb(hue, sat, light) { + hue = hue % 360, hue += hue < 0 ? hue += 360 : 0, sat /= 100, light /= 100; + function f(n) { + var k = (n + hue/30) % 12; + var a = sat * Math.min(light, 1 - light); + return parseInt((light - a * Math.max(-1, Math.min(k - 3, 9 - k, 1))) * 255); + } + return "#" + ((1 << 24) + (f(0) << 16) + (f(8) << 8) + f(4)).toString(16).slice(1); + } + function speed2deg(v) { // 0-200 + v = parseFloat(v); + return (v>=1000?200:(v<20?v*4:(v<30?(v-20)*2+80:(v<60?(v-30)/1.5+100:(v<100?(v-60)/2+120:(v<200?(v-100)/5+140:(v<500?(v-200)/15+160:(v-500)/25+180))))))); + } + function setSpeed(v) { + v = parseFloat(v); + $('#num').html(v<1?v.toFixed(3):(v<10?v.toFixed(2):(v<100?v.toFixed(1):Math.round(v)))); + var r=speed2deg(v); + document.querySelector(".arrow").style.transform = 'rotate(' + (r-100) + 'deg)'; + var speedBg = document.querySelector('.frequencyBgSpeed'); + var strokeLength = 1256.8; // speedBg.getTotalLength(); + speedBg.style['stroke-dasharray'] = strokeLength * r / 360 + ',' + strokeLength; + speedBg.style.stroke = hslToRgb(330 + r, 100, 45); + pl.attr('points', pl_p.map(function(pt){return pt.join(',')}).join(' ')); + } + + function normalizeUrl(base, link) { + if (link[0] === '/') return base.replace(/^(https?:\/\/[^\/]+).*$/i, '$1') + link; + if (/^https?:?\/\//i.test(link)) return link; + base = base.replace(/\/[^\/]*(\?.*)?$/, '') + '/'; + return base + link; + } + function testUrl(url, isM3u8) { + if (!isM3u8 && !/\.m3u8?(\?.*)?$/i.test(url)) return speedTest(url); + var errorFn = function(e){ + console.log('speedTest', 'ERROR', e); + status.text('Ошибка тестирования'); + // todo не удалось протестить m3u8, выводим ошибку + }; + $.ajax({ + url: url, + cache: false, + dataType: 'text', + xhr: function() {return xmlHTTP}, + success: function (data) { + if (data.substr(0,7) !== '#EXTM3U') return errorFn('Not EXTM3U'); + var i = 0, links = [], bandwidth = 0, setLink = false, m, l = data.split(/\r?\n/); data = null; + for (; links.length < 100 && i < l.length; i++) { + if (!!(m = l[i].match(/^#EXTINF:\s*(-?\d+(\.\d*)?)\s*,.*$/))) { + setLink = true; + } + else if (!!(m = l[i].match(/^#EXT-X-STREAM-INF:(.+,)?\s*BANDWIDTH=(\d+)\s*(,.+)?$/))) { + if (bandwidth < parseInt(m[2])) { + bandwidth = parseInt(m[2]); + setLink = true; + } + else setLink = false; + } else if (setLink && !!(m = l[i].match(/^[^#].+$/i))) { + links.push(normalizeUrl(xmlHTTP.responseURL, m[0].trim())); + setLink = false; + } + } + if (links.length === 0) return errorFn(); + if (bandwidth > 0) return testUrl(links.pop(), true); // вконце массива плейлист с большим битрейтом + speedTest(links[0]); + }, + error: errorFn + }); + } + + function speedTest(bigFileUrl) { + if (timeStart) return; + testStart = true; + status.text(Lampa.Lang.translate('speedtest_connect')); + pl_p = [[-250, -250]]; + var speed = 0, speedMbps = 0; + setSpeed(0); + xmlHTTP.open('GET', bigFileUrl + '?_=' + ((new Date()) * 1), true); + xmlHTTP.responseType = 'arraybuffer'; + xmlHTTP.onprogress = function(e) { + if (!timeStart || timeStart === true) { + return; + } + var loadTime = e.timeStamp - timeStart; + speed = Math.ceil(e.loaded * 8000 / loadTime); // Бит в секунду + speedMbps = speed / 1000 / 1000; + var x = Math.max(Math.min(loadTime, 1e4) * 500 / 1e4, Math.min(e.loaded, 3e8) * 500 / 3e8) - 250, + y = -(speed2deg(speedMbps)/4 + 250); + pl_p.push([x.toFixed(1), y.toFixed(1)]); + setSpeed(speedMbps); + if (loadTime >= 1e4 || e.loaded > 3e8) { + xmlHTTP.abort(); + } + }; + xmlHTTP.onreadystatechange = function (e) { + if (xmlHTTP.readyState === 2) { + timeStart = e.timeStamp; + status.text(Lampa.Lang.translate('speedtest_test')); + tout = setTimeout(function(){ + xmlHTTP.abort(); + }, 15e3); + } + }; + var endTest = function(e) { + url = bigFileUrl; + tout && clearTimeout(tout); + setSpeed(speedMbps); + console.log('speedTest', 'STATUS', xmlHTTP.status); + status.text(xmlHTTP.status === 200 ? Lampa.Lang.translate('speedtest_ready') : xmlHTTP.statusText || Lampa.Lang.translate('speedtest_ready')); + testStart = false; + timeStart = false; + }; + xmlHTTP.onload = endTest; + xmlHTTP.onabort = endTest; + xmlHTTP.onerror = endTest; + xmlHTTP.send(); + } + + this.showModal(tpl, test, true, xmlHTTP, [Lampa.Lang.translate('torrent_serial_date'), Lampa.Lang.translate('search_start').split(' ')[0]]); + }, + balansPrf: 'videocdn', + CACHE_TIME: 1000 * 60 * 60 * 2, + getCache: function(key, data) { + var timestamp = new Date().getTime(); + var cache = Lampa.Storage.cache(key, 1, {}); //500 это лимит ключей + if (cache[key]) { + if ((timestamp - cache[key].timestamp) > this.CACHE_TIME) { + // Если кеш истёк, чистим его + delete cache[key]; + Lampa.Storage.set(data, cache); + return false; + } + } else return false; + return cache[key]; + }, + setCache: function(key, data) { + var timestamp = new Date().getTime(); + var cache = Lampa.Storage.cache(key, 1, {}); //500 это лимит ключей + if (!cache[key]) { + cache[key] = data; + Lampa.Storage.set(key, cache); + } else { + if ((timestamp - cache[key].timestamp) > this.CACHE_TIME) { + data.timestamp = timestamp; + cache[key] = data; + Lampa.Storage.set(key, cache); + } else data = cache[key]; + } + return data; + } + }; + var Filmix = { + network: new Lampa.Reguest(), + api_url: 'http://filmix.biz/api/v2/', + token: Lampa.Storage.get('filmix_token', ''), + user_dev: 'app_lang=ru_RU&user_dev_apk=2.1.2&user_dev_id=' + Lampa.Utils.uid(16) + '&user_dev_name=Xiaomi&user_dev_os=11&user_dev_vendor=Xiaomi&user_dev_token=', + add_new: function () { + var user_code = ''; + var user_token = ''; + var modal = $('
' + Lampa.Lang.translate('filmix_modal_text') + '
Ожидаем код...

'); + Lampa.Modal.open({ + title: '', + html: modal, + onBack: function onBack() { + Lampa.Modal.close(); + Lampa.Controller.toggle('settings_component'); + clearInterval(ping_auth); + }, + onSelect: function onSelect() { + Lampa.Utils.copyTextToClipboard(user_code, function () { + Lampa.Noty.show(Lampa.Lang.translate('filmix_copy_secuses')); + }, function () { + Lampa.Noty.show(Lampa.Lang.translate('filmix_copy_fail')); + }); + } + }); + ping_auth = setInterval(function () { + Filmix.checkPro(user_token, function (json) { + if (json && json.user_data) { + Lampa.Modal.close(); + clearInterval(ping_auth); + Lampa.Storage.set("filmix_token", user_token); + Filmix.token = user_token; + $('[data-name="filmix_token"] .settings-param__value').text(user_token); + Lampa.Controller.toggle('settings_component'); + } + }); + }, 2000); + this.network.clear(); + this.network.timeout(10000); + this.network.quiet(this.api_url + 'token_request?' + this.user_dev, function (found) { + if (found.status == 'ok') { + user_token = found.code; + user_code = found.user_code; + modal.find('.selector').text(user_code); + } else { + Lampa.Noty.show(found); + } + }, function (a, c) { + Lampa.Noty.show(Filmix.network.errorDecode(a, c)); + }); + }, + showStatus: function (ch) { + var status = Lampa.Storage.get("filmix_status", '{}'); + var statuss = $('.settings-param__status', ch).removeClass('active error wait').addClass('wait'); + var info = Lampa.Lang.translate('filmix_nodevice'); + statuss.removeClass('wait').addClass('error'); + if (status.login) { + statuss.removeClass('wait').addClass('active'); + var foto = ' ' + status.login + ''; + if (status.is_pro || status.is_pro_plus) info = foto + ' - ' + (status.is_pro ? 'PRO' : 'PRO_PLUS') + ' ' + Lampa.Lang.translate('filter_rating_to') + ' - ' + status.pro_date + ''; + else info = foto + ' - NO PRO - MAX 720p'; + } + if (ch) $('.settings-param__descr', ch).html(info); + else $('.settings-param__descr:eq(0)').html(info); + }, + checkPro: function (token, call, err) { + if (!token && typeof call == 'function') call({}); + this.network.clear(); + this.network.timeout(8000); + token = token ? token : Lampa.Storage.get("filmix_token"); + var url = this.api_url + 'user_profile?' + this.user_dev + token; + this.network.silent(url, function (json) { + window.FX.max_qualitie = 480; + window.FX.auth = false; + window.FX.is_max_qualitie = false; + if (json) { + if (json.user_data) { + window.FX.max_qualitie = 720; + Lampa.Storage.set("filmix_status", json.user_data); + if (typeof call == 'function') call(json); + } else { + Lampa.Storage.set("filmix_status", {}); + if (typeof call == 'function') call({}); + } + if(call) Filmix.showStatus(); + } + }, function (a, c) { + if(err) err(); + Lampa.Noty.show(Filmix.network.errorDecode(a, c)); + }); + } + }; + var ForkTV = { + network: new Lampa.Reguest(), + url: 'http://no_save.forktv.me', + forktv_id: Lampa.Storage.field('forktv_id'), + act_forktv_id: Lampa.Storage.field('act_forktv_id'), + user_dev: function user_dev() { + return 'box_client=lg&box_mac=' + this.forktv_id + '&initial=ForkXMLviewer|' + this.forktv_id + '|YAL-L41%20sdk%2029||MTY5NjUyODU3MQR=E1445|078FDD396E182CD|androidapi|0|Android-device_YAL-L41_sdk_29&platform=android-device&country=&tvp=0&hw=1.4&cors=android-device&box_user=&refresh=true'; + }, + openBrowser: function (url) { + if (Lampa.Platform.is('tizen')) { + var e = new tizen.ApplicationControl("https://tizen.org/appcontrol/operation/view", url); + tizen.application.launchAppControl(e, null, function () {}, function (e) { + Lampa.Noty.show(e); + }); + } else if (Lampa.Platform.is('webos')) { + webOS.service.request("luna://com.webos.applicationManager", { + method: "launch", + parameters: { + id: "com.webos.app.browser", + params: { + target: url + } + }, + onSuccess: function () {}, + onFailure: function (e) { + Lampa.Noty.show(e); + } + }); + } else window.open(url, '_blank'); + }, + init: function () { + if (Lampa.Storage.get('mods_fork')) this.check_forktv('', true); + if (this.forktv_id == 'undefined') { + this.forktv_id = this.create_dev_id(); + Lampa.Storage.set('forktv_id', this.forktv_id); + } + if (this.act_forktv_id == 'undefined') { + this.act_forktv_id = this.create__id(); + Lampa.Storage.set('act_forktv_id', this.act_forktv_id); + } + }, + create__id: function () { + var randomNum = Math.floor(Math.random() * 900000) + 100000; + return randomNum; + }, + create_dev_id: function () { + var charsets, index, result; + result = ""; + charsets = "0123456789abcdef"; + while (result.length < 12) { + index = parseInt(Math.floor(Math.random() * 15)); + result = result + charsets[index]; + } + return result; + }, + copyCode: function (id) { + Lampa.Utils.copyTextToClipboard(id, function () { + Lampa.Noty.show(Lampa.Lang.translate('filmix_copy_secuses')); + }, function () { + Lampa.Noty.show(Lampa.Lang.translate('filmix_copy_fail')); + }); + }, + cats_fork: function (json) { + var item = []; + var get_cach = Lampa.Storage.get('ForkTv_cat', ''); + if (!get_cach) { + json.forEach(function (itm, i) { + // if (itm.title !== 'Новости' /* && itm.title !== 'IPTV'*/ ) { + item.push({ + title: itm.title, + url: itm.playlist_url, + img: itm.logo_30x30, + checkbox: true + }); + //} + }); + } else item = get_cach.cat; + + function select(where, a) { + where.forEach(function (element) { + element.selected = false; + }); + a.selected = true; + } + + function main() { + Lampa.Controller.toggle('settings_component'); + var cache = Lampa.Storage.cache('ForkTv_cat', 1, {}); + var catg = []; + item.forEach(function (a) { + catg.push(a); + }); + if (catg.length > 0) { + cache = { + cat: catg + }; + Lampa.Storage.set('ForkTv_cat', cache); + } + Lampa.Controller.toggle('settings'); + Lampa.Activity.back(); + ForkTV.parse(); + } + Lampa.Select.show({ + items: item, + title: get_cach ? Lampa.Lang.translate('title_fork_edit_cats') : Lampa.Lang.translate('title_fork_add_cats'), + onBack: main, + onSelect: function onSelect(a) { + select(item, a); + main(); + } + }); + }, + but_add: function () { + var ico = ''; + var menu_item = $(''); + menu_item.on('hover:enter', this.parse); + $('body').find('[data-action="forktv"]').remove(); + if (Lampa.Storage.get('mods_fork') && Lampa.Storage.get('forktv_auth')) $('.menu .menu__list').eq(0).append(menu_item); + }, + updMac: function (itm) { + clearInterval(ping_auth); + ForkTV.check_forktv(itm); + Lampa.Noty.show('CODE ' + Lampa.Lang.translate('succes_update_noty')); + }, + parse: function () { + ForkTV.check(ForkTV.url, function (json) { + json = json.channels; + if (json.length === 1) ForkTV.checkAdd(); + else { + ForkTV.but_add(); + if (Lampa.Storage.get('ForkTv_cat') !== '') { + var get_cach = Lampa.Storage.get('ForkTv_cat'); + var itms = []; + get_cach.cat.forEach(function (it) { + if (it.checked) itms.push({ + title: it.title, + playlist_url: it.url, + logo_30x30: it.img, + home: true + }); + }); + if (itms.length > 0) { + Lampa.Activity.push({ + title: 'ForkTV', + url: { + channels: itms + }, + submenu: true, + component: 'forktv', + page: 1 + }); + } else ForkTV.cats_fork(json); + } else ForkTV.cats_fork(json); + } + }); + }, + check_forktv: function (itm, ar) { + var status = $('.settings-param__status', itm).removeClass('active error wait').addClass('wait'); + this.network["native"](ForkTV.url + '?' + ForkTV.user_dev(), function (json) { + if (json.channels.length === 1) { + ForkTV.act_forktv_id = json.channels[0].title; + Lampa.Storage.set('act_forktv_id', ForkTV.act_forktv_id); + if (ar) { + Lampa.Storage.set('forktv_auth', false); + status.removeClass('wait').addClass('error'); + $('.settings-param__descr', itm).text(Lampa.Lang.translate('filmix_nodevice')); + $('body').find('[data-action="forktv"]').remove(); + } else { + ForkTV.checkAdd(); + $('body').find('[data-action="forktv"]').remove(); + $('.settings [data-static="true"]:eq(1), .settings [data-static="true"]:eq(2)').hide(); + $('.settings [data-static="true"]:eq(0) .settings-param__status').removeClass('active').addClass('error'); + $('.settings [data-static="true"]:eq(0) .settings-param__descr').text(Lampa.Lang.translate('filmix_nodevice')); + } + } else { + ForkTV.but_add(); + Lampa.Storage.set('forktv_auth', true); + status.removeClass('wait').addClass('active'); + if (itm) { + if (itm.text().indexOf('код') == -1 || itm.text().indexOf('code') == -1) $('.settings-param__descr', itm).html(' ' + Lampa.Lang.translate('account_authorized') + ''); + if (itm.find('.settings-param__name').text().indexOf('раздел') > -1 || itm.find('.settings-param__name').text().indexOf('Sections') > -1) ForkTV.cats_fork(json.channels); + } + } + }, function (e) { + if (ar) { + Lampa.Storage.set('forktv_auth', false); + status.removeClass('wait').addClass('error'); + $('.settings-param__descr', itm).text(Lampa.Lang.translate('filmix_nodevice')); + $('body').find('[data-action="forktv"]').remove(); + } else { + ForkTV.checkAdd(); + $('body').find('[data-action="forktv"]').remove(); + $('.settings [data-static="true"]:eq(0) .settings-param__status').removeClass('active').addClass('error'); + $('.settings [data-static="true"]:eq(0) .settings-param__descr').text(Lampa.Lang.translate('filmix_nodevice')); + $('.settings [data-static="true"]:eq(1), .settings [data-static="true"]:eq(2)').hide(); + } + }, false, { + dataType: 'json' + }); + }, + checkAdd: function () { + var enabled = Lampa.Controller.enabled().name; + ForkTV.check(ForkTV.url, function (json) { + var title = json.channels[0].title; + var id = json.channels[0].description.match(/> (\d+)
' + Lampa.Lang.translate('fork_auth_modal_title') + '
' + ForkTV.act_forktv_id + '


' + Lampa.Lang.translate('fork_modal_wait') + '
'); + Lampa.Modal.open({ + title: title, + html: modal, + size: 'small', + mask: true, + onBack: function onBack() { + clearInterval(ping_auth); + Lampa.Modal.close(); + Lampa.Controller.toggle(enabled); + }, + onSelect: function onSelect() { + ForkTV.copyCode(ForkTV.act_forktv_id); + } + }); + if (!Lampa.Platform.tv()) { + setTimeout(function () { + ForkTV.copyCode(id); + }, 1000); + } + modal.find('a').on('click', function () { + ForkTV.openBrowser('http://forktv.me'); + }); + }); + + ping_auth = setInterval(function () { + ForkTV.check(ForkTV.url, function () { + Lampa.Modal.close(); + clearInterval(ping_auth); + if (enabled == 'settings_component') Lampa.Activity.back(); + Lampa.Controller.toggle(enabled); + Lampa.Storage.set('forktv_auth', true); + ForkTV.parse(); + }, true); + }, 5000); + }, + check: function (url, call, ar) { + this.network.clear(); + this.network.timeout(8000); + this.network["native"](url + '?' + ForkTV.user_dev(), function (json) { + if (json) { + if (ar && json.channels.length > 1) { + if (call) call(json); + } else if (!ar) call(json); + } + }, function (a, c) { + Lampa.Noty.show(ForkTV.network.errorDecode(a, c)); + }); + } + }; + var Pub = { + network: new Lampa.Reguest(), + baseurl: 'https://api.srvkp.com/', + tock: 'uirmqgdg5s3w9sq05udmjlca897oxrgk', + token: Lampa.Storage.get('pub_access_token', 'uirmqgdg5s3w9sq05udmjlca897oxrgk'), + openBrowser: function (url) { + if (Lampa.Platform.is('tizen')) { + var e = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/view", url); + tizen.application.launchAppControl(e, null, function (r) {}, function (e) { + Lampa.Noty.show(e); + }); + } else if (Lampa.Platform.is('webos')) { + webOS.service.request("luna://com.webos.applicationManager", { + method: "launch", + parameters: { + id: "com.webos.app.browser", + params: { + target: url + } + }, + onSuccess: function () {}, + onFailure: function (e) { + Lampa.Noty.show(e); + } + }); + } else window.open(url, '_blank'); + }, + Auth_pub: function () { + Pub.network.silent(Pub.baseurl + 'oauth2/device', function (json) { + Lampa.Storage.set('pub_user_code', json.user_code); + Lampa.Storage.set('pub_code', json.code); + Pub.checkAdd(); + }, function (a, c) { + Lampa.Noty.show(Pub.network.errorDecode(a, c)); + }, { + 'grant_type': 'device_code', + 'client_id': 'xbmc', + 'client_secret': 'cgg3gtifu46urtfp2zp1nqtba0k2ezxh' + }); + }, + checkAdd: function () { + var modal = $('
' + Lampa.Lang.translate('pub_modal_title') + '


' + Lampa.Lang.translate('pub_title_wait') + '
'); + Lampa.Modal.open({ + title: '', + html: modal, + size: 'small', + mask: true, + onBack: function onBack() { + Lampa.Modal.close(); + clearInterval(ping_auth); + Lampa.Controller.toggle('settings_component'); + }, + onSelect: function onSelect() { + if (!Lampa.Platform.tv()) { + Lampa.Utils.copyTextToClipboard(Lampa.Storage.get('pub_user_code'), function () { + Lampa.Noty.show(Lampa.Lang.translate('filmix_copy_secuses')); + }, function () { + Lampa.Noty.show(Lampa.Lang.translate('filmix_copy_fail')); + }); + } else Pub.openBrowser('http://kino.pub'); + } + }); + modal.find('a').on('click', function () { + Pub.openBrowser('http://kino.pub'); + }); + modal.find('.selector').text(Lampa.Storage.get('pub_user_code')); + var check = function check(url, call) { + Pub.network.clear(); + Pub.network.timeout(8000); + Pub.network.silent(url, function (json) { + Lampa.Storage.set('pub_access_token', json.access_token); + Lampa.Storage.set('pub_refresh_token', json.refresh_token); + Pub.token = Lampa.Storage.get('pub_access_token'); + if (!Lampa.Platform.is('android')) var uas = navigator.userAgent.match(/((.*?))/i)[1].split(';'); + Pub.network.silent(Pub.baseurl + 'v1/device/info?access_token=' + json.access_token, function (json) { + Pub.network.silent(Pub.baseurl + 'v1/device/notify?access_token=' + Pub.token, function (json) { + if (call) call(); + }, function (a, c) { + Lampa.Noty.show(Pub.network.errorDecode(a, c)); + }, { + 'title': Lampa.Platform.is('android') ? 'KinoPub Android-Lampa' : uas.length > 3 ? 'Kinopub TV-Lampa' : uas[0] + ' ' + Lampa.Platform.get().toUpperCase(), + 'hardware': Lampa.Platform.is('android') ? 'Android 10' : uas[2], + 'software': Lampa.Platform.is('android') ? 'Android' : uas.length > 3 ? uas[1] : uas[0] + }); + }); + }, false, { + 'grant_type': 'device_token', + 'client_id': 'xbmc', + 'client_secret': 'cgg3gtifu46urtfp2zp1nqtba0k2ezxh', + 'code': Lampa.Storage.get('pub_code') + }); + }; + ping_auth = setInterval(function () { + check(Pub.baseurl + 'oauth2/device', function () { + clearInterval(ping_auth); + Lampa.Modal.close(); + Lampa.Storage.set('logined_pub', true); + Lampa.Settings.update(); + }); + }, 5000); + }, + refreshTok: function () { + this.network.silent(Pub.baseurl + 'oauth2/token', function (json) { + Lampa.Storage.set('pub_access_token', json.access_token); + Lampa.Storage.set('pub_refresh_token', json.refresh_token); + Pub.token = Lampa.Storage.get('pub_access_token'); + Lampa.Noty.show('ТОКЕН обновлён'); + }, function (a, c) { + Lampa.Noty.show(Pub.network.errorDecode(a, c)); + }, { + 'grant_type': 'refresh_token', + 'refresh_token': Lampa.Storage.get('pub_refresh_token'), + 'client_id': 'xbmc', + 'client_secret': 'cgg3gtifu46urtfp2zp1nqtba0k2ezxh' + }); + }, + userInfo: function (itm, ur) { + var status = $('.settings-param__status', itm).removeClass('active error wait').addClass('wait'); + if (!Pub.token) status.removeClass('wait').addClass('error'); + else { + this.network.silent(Pub.baseurl + 'v1/user?access_token=' + Pub.token, function (json) { + $('.settings-param__' + (!ur ? 'name' : 'descr'), itm).html(' ' + json.user.username + ' - ' + Lampa.Lang.translate('pub_title_left_days') + '' + json.user.subscription.days + ' ' + Lampa.Lang.translate('pub_title_left_days_d') + ''); + $('.settings-param__' + (!ur ? 'descr' : ''), itm).html(Lampa.Lang.translate('pub_title_regdate') + ' ' + Lampa.Utils.parseTime(json.user.reg_date * 1000).full + '
' + (json.user.subscription.active ? Lampa.Lang.translate('pub_date_end_pro') + ' ' + Lampa.Utils.parseTime(json.user.subscription.end_time * 1000).full : '' + Lampa.Lang.translate('pub_title_not_pro') + '')); + status.removeClass('wait').addClass('active'); + Lampa.Storage.set('logined_pub', true); + Lampa.Storage.set('pro_pub', json.user.subscription.active); + }, function (a, c) { + status.removeClass('wait').addClass('error'); + Lampa.Storage.set('pro_pub', false); + Lampa.Storage.set('pub_access_token', ''); + Lampa.Storage.set('logined_pub', false); + Pub.token = Lampa.Storage.get('pub_access_token', Pub.tock); + Pub.userInfo(itm, ur); + }); + } + }, + info_device: function () { + this.network.silent(Pub.baseurl + 'v1/device/info?access_token=' + Pub.token, function (json) { + var enabled = Lampa.Controller.enabled().name; + var opt = json.device.settings; + var subtitle = { + supportSsl: { + title: 'Использовать SSL (https) для картинок и видео' + }, + supportHevc: { + title: 'HEVC или H.265 — формат Видеосжатия с применением более эффективных алгоритмов по сравнению с H.264/AVC. Убедитесь, что ваше устройство поддерживает Данный формат.' + }, + support4k: { + title: '4K или Ultra HD - фильм в сверхвысокой чёткости 2160p. Убедитесь, что ваше устройство и ТВ, поддерживает данный формат.' + }, + mixedPlaylist: { + title: 'Плейлист с AVC и HEVC потоками. В зависимости от настроек, устройство будет автоматически проигрывать нужный поток. Доступно только для 4К - фильмов. Убедитесь, что ваше устройство поддерживает данный формат плейлиста.' + }, + HTTP: { + title: 'Неадаптивный, качество через настройки (Настройки > плеер > качество видео), все аудио, нет сабов.' + }, + HLS: { + title: 'Неадаптивный, качество через настройки, одна аудиодорожка, нет сабов.' + }, + HLS2: { + title: 'Адаптивный, качество автоматом, одна аудиодорожка, нет сабов.' + }, + HLS4: { + title: 'Рекомендуется! - Адаптивный, качество автоматом, все аудио, сабы.' + } + }; + var item = [{ + title: 'Тип потока', + value: opt.streamingType, + type: 'streamingType' + }, { + title: 'Переключить сервер', + value: opt.serverLocation, + type: 'serverLocation' + }]; + Lampa.Arrays.getKeys(opt).forEach(function (key) { + var k = opt[key]; + if (!k.type && ['supportHevc', 'support4k'].indexOf(key) > - 1) item.push({ + title: k.label, + value: k.value, + type: key, + subtitle: subtitle[key] && subtitle[key].title, + checkbox: k.type ? false : true, + checked: k.value == 1 ? true : false + }); + }); + + function main(type, value) { + var edited = {}; + item.forEach(function (a) { + if (a.checkbox) edited[a.type] = a.checked ? 1 : 0; + }); + if (type) edited[type] = value; + Pub.network.silent(Pub.baseurl + 'v1/device/' + json.device.id + '/settings?access_token=' + Pub.token, function (json) { + Lampa.Noty.show(Lampa.Lang.translate('pub_device_options_edited')); + Lampa.Controller.toggle(enabled); + }, function (a, c) { + Lampa.Noty.show(Pub.network.errorDecode(a, c)); + }, edited); + } + Lampa.Select.show({ + items: item, + title: Lampa.Lang.translate('pub_device_title_options'), + onBack: main, + onSelect: function (i) { + var serv = []; + i.value.value.forEach(function (i) { + serv.push({ + title: i.label, + value: i.id, + subtitle: subtitle[i.label] && subtitle[i.label].title, + selected: i.selected + }); + }); + Lampa.Select.show({ + items: serv, + title: i.title, + onBack: main, + onSelect: function (a) { + main(i.type, a.value); + } + }); + } + }); + }, function (a, c) { + Lampa.Noty.show(Pub.network.errorDecode(a, c)); + }); + }, + delete_device: function (call) { + this.network.silent(Pub.baseurl + 'v1/device/unlink?access_token=' + Pub.token, function (json) { + Lampa.Noty.show(Lampa.Lang.translate('pub_device_dell_noty')); + Lampa.Storage.set('logined_pub', false); + Lampa.Storage.set('pub_access_token', ''); + Pub.token = Lampa.Storage.get('pub_access_token', Pub.tock); + if (call) call(); + }, function (a, c) { + Lampa.Noty.show(Lampa.Lang.translate('pub_device_dell_noty')); + Lampa.Storage.set('logined_pub', false); + Lampa.Storage.set('pub_access_token', ''); + Pub.token = Lampa.Storage.get('pub_access_token', Pub.tock); + if (call) call(); + Lampa.Noty.show(Pub.network.errorDecode(a, c)); + }, {}); + } + }; + + function videocdn(component, _object) { + var network = new Lampa.Reguest(); + var extract = {}; + var results = []; + var object = _object; + var get_links_wait = false; + var iframe_proxy = component.proxy('videocdn'); + var filter_items = {}; + var choice = { + season: 0, + voice: 0, + voice_name: '', + voice_id: 0, + order: 0 + }; + + function _typeof(obj) { + "@babel/helpers - typeof"; + return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { + return typeof obj; + } : function (obj) { + return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }, _typeof(obj); + } + + this.search = function (_object,data) { + object = _object; + var itm = data[0]; + var select_title = itm.title || object.movie.title; + var url = Protocol() +'videocdn.tv/api/'; + var type = itm.iframe_src.split('/').slice(-2)[0]; + if (type == 'movie') type = 'movies'; + if (type == 'anime') type = 'animes'; + url += type; + url = Lampa.Utils.addUrlComponent(url, 'api_token=3i40G5TSECmLF77oAqnEgbx61ZWaOYaE'); + url = Lampa.Utils.addUrlComponent(url, 'query=' + (itm.imdb_id ? encodeURIComponent(itm.imdb_id) : (itm.kinopoisk_id || itm.kinopoisk_ID) ? encodeURIComponent(itm.kinopoisk_id || itm.kinopoisk_ID) : encodeURIComponent(select_title))); + url = Lampa.Utils.addUrlComponent(url, 'field=' + (itm.imdb_id ? 'imdb_id' : (itm.kinopoisk_id || itm.kinopoisk_ID) ? 'kinopoisk_id' : 'title')); + network.clear(); + network.timeout(20000); + network.silent(url, function (found) { + results = found.data.filter(function (elem) { + return elem.id == itm.id; + }); + success(results); + component.loading(false); + if (!results.length) component.emptyForQuery(select_title); + }, function (a, c) { + component.empty(network.errorDecode(a, c)); + }); + }; + this.extendChoice = function (saved) { + Lampa.Arrays.extend(choice, saved, true); + }; + this.reset = function () { + component.reset(); + choice = { + season: 0, + voice: 0, + voice_name: '', + voice_id: 0, + order: 0 + }; + filter(); + append(filtred()); + }; + this.filter = function (type, a, b) { + choice[a.stype] = b.index; + + if (a.stype == 'voice') { + choice.voice_name = filter_items.voice[b.index]; + choice.voice_id = filter_items.voice_info[b.index] && filter_items.voice_info[b.index].id; + } + + component.reset(); + filter(); + append(filtred()); + }; + this.destroy = function () { + network.clear(); + results = null; + }; + function success(json) { + results = json; + extractData(json); + filter(); + append(filtred()); + } + function extractItems(str) { + try { + var items = component.parsePlaylist(str).map(function (item) { + var quality = item.label.match(/(\d\d\d+)p/); + var file = item.links[0]; + if (file) file = 'http:' + file; + return { + label: item.label, + quality: quality ? parseInt(quality[1]) : NaN, + file: file || '' + }; + }); + items.sort(function (a, b) { + if (b.quality > a.quality) return 1; + if (b.quality < a.quality) return -1; + if (b.label > a.label) return 1; + if (b.label < a.label) return -1; + return 0; + }); + return items; + } catch (e) {} + + return []; + } + function extractData(results) { + var movie = results.slice(0, 1)[0]; + extract = {}; + + if (movie) { + get_links_wait = true; + var src = 'http:' + movie.iframe_src; + + var call_success = function call_success(raw) { + get_links_wait = false; + component.render().find('.online_modss__scan-file').remove(); + var math = raw.replace(/\n/g, '').match(/id="files" value="(.*?)"/); + + if (!math) { + math = raw.replace(/\n/g, '').match(/id="files" value='(.*?)'/); + } + + if (math) { + var text = document.createElement("textarea"); + text.innerHTML = math[1]; + var json = Lampa.Arrays.decodeJson(text.value, {}); + for (var i in json) { + if (0 === i - 0) { + continue; + } + + extract[i] = { + json: _typeof(json[i]) === 'object' ? json[i] : Lampa.Arrays.decodeJson(json[i], {}), + items: extractItems(json[i]) + }; + + for (var a in extract[i].json) { + var elem = extract[i].json[a]; + + if (elem.folder) { + for (var f in elem.folder) { + var folder = elem.folder[f]; + folder.items = extractItems(folder.file); + } + } else elem.items = extractItems(elem.file); + } + } + } + }; + + var call_fail = function call_fail(data) { + get_links_wait = false; + component.render().find('.broadcast__scan').remove(); + }; + + if (iframe_proxy) { + component.proxyCall('GET', src, 20000, null, call_success, call_fail); + } else if (window.location.protocol !== 'http:') { + network.clear(); + network.timeout(20000); + network.silent('https://cors.lampa.stream/' + src, call_success, call_fail, false, { + dataType: 'text' + }); + } else { + var meta = $('head meta[name="referrer"]'); + var referrer = meta.attr('content') || 'never'; + meta.attr('content', 'origin'); + + try { + network.clear(); + network.timeout(20000); + console.log(src) + network.silent(src, call_success, call_fail, false, { + dataType: 'text' + }); + } finally { + meta.attr('content', referrer); + } + } + } + } + function extractData2(results) { + network.timeout(20000); + var movie = results.slice(0, 1)[0]; + extract = {}; + + if (movie) { + var src = movie.iframe_src; + var meta = $('head meta[name="referrer"]'); + var referrer = meta.attr('content') || 'never'; + meta.attr('content', 'unsafe-url'); + network.silent('http:' + src, function (raw) { + meta.attr('content', referrer); + get_links_wait = false; + component.render().find('.online_modss__scan-file').remove(); + var math = raw.replace(/\n/g, '').match(/id="files" value="(.*?)"/); + + if (!math) { + math = raw.replace(/\n/g, '').match(/id="files" value='(.*?)'/); + } + + if (math) { + var text = document.createElement("textarea"); + text.innerHTML = math[1]; + var json = Lampa.Arrays.decodeJson(text.value, {}); + + for (var i in json) { + if (0 === i - 0) { + continue; + } + + extract[i] = { + json: _typeof(json[i]) === 'object' ? json[i] : Lampa.Arrays.decodeJson(json[i], {}), + items: extractItems(json[i]) + }; + + for (var a in extract[i].json) { + var elem = extract[i].json[a]; + + if (elem.folder) { + for (var f in elem.folder) { + var folder = elem.folder[f]; + folder.items = extractItems(folder.file); + } + } else elem.items = extractItems(elem.file); + } + } + } + }, function () { + meta.attr('content', referrer); + get_links_wait = false; + component.render().find('.online_modss__scan-file').remove(); + }, false, { + dataType: 'text' + }); + } + } + function getFile(element, max_quality) { + var translat = extract[element.translation]; + var id = element.season + '_' + element.episode; + var file = ''; + var items = []; + var quality = false; + + if (translat) { + if (element.season) { + for (var i in translat.json) { + var elem = translat.json[i]; + + if (elem.folder) { + for (var f in elem.folder) { + var folder = elem.folder[f]; + + if (folder.id == id) { + items = folder.items; + break; + } + } + } else if (elem.id == id) { + items = elem.items; + break; + } + } + } else { + items = translat.items; + } + } + + if (items && items.length) { + quality = {}; + var mass = [1080, 720, 480, 360]; + mass.forEach(function (n) { + var exes = items.find(function (a) { + return a.quality == n; + }); + + if (exes) { + if (!file) file = exes.file; + quality[n + 'p'] = exes.file; + } + }); + var preferably = Lampa.Storage.get('video_quality_default', '1080') + 'p'; + if (quality[preferably]) file = quality[preferably]; + } + + return { + file: file, + quality: quality + }; + } + function filter() { + filter_items = { + season: [], + voice: [], + voice_info: [], + order: [] + }; + results.slice(0, 1).forEach(function (movie) { + if (movie.episodes) { + var season_count = 1; + movie.episodes.forEach(function (episode) { + if (episode.season_num > season_count) { + season_count = episode.season_num; + } + }); + var s = season_count; + + while (s--) { + filter_items.season.push(Lampa.Lang.translate('torrent_serial_season') + ' ' + (season_count - s)); + } + } + + if (!filter_items.season[choice.season]) choice.season = 0; + + if (movie.episodes) { + component.order.forEach(function (i){ + filter_items.order.push(i.title); + }); + movie.episodes.forEach(function (episode) { + if (episode.season_num == choice.season + 1) { + episode.media.forEach(function (media) { + if (!filter_items.voice_info.find(function (v) { + return v.id == media.translation.id; + })) { + filter_items.voice.push(media.translation.shorter_title || media.translation.short_title || media.translation.title); + filter_items.voice_info.push({ + id: media.translation.id + }); + } + }); + } + }); + } + }); + if (!filter_items.season[choice.season]) choice.season = 0; + if (!filter_items.voice[choice.voice]) choice.voice = 0; + + if (choice.voice_name) { + var inx = -1; + + if (choice.voice_id) { + var voice = filter_items.voice_info.find(function (v) { + return v.id == choice.voice_id; + }); + if (voice) inx = filter_items.voice_info.indexOf(voice); + } + + if (inx == -1) inx = filter_items.voice.indexOf(choice.voice_name); + if (inx == -1) choice.voice = 0;else if (inx !== choice.voice) { + choice.voice = inx; + } + } + + component.filter(filter_items, choice); + } + function filtred() { + var filtred = []; + results.slice(0, 1).forEach(function (movie) { + if (movie.episodes) { + movie.episodes.forEach(function (episode) { + if (episode.season_num == choice.season + 1) { + var temp = episode.media.filter(function (m) { + return filter_items.voice_info[choice.voice] && m.translation.id == filter_items.voice_info[choice.voice].id; + }); + temp.sort(function (a, b) { + return b.max_quality - a.max_quality; + }); + temp.slice(0, 1).forEach(function (media) { + var num = parseInt(episode.num); + if (isNaN(num)) num = episode.num; + filtred.push({ + episode: num, + season: episode.season_num, + title: episode.ru_title, + quality: media.max_quality + 'p' + (media.source_quality ? ' - ' + media.source_quality.toUpperCase() : ''), + translation: media.translation_id, + info: filter_items.voice[choice.voice], + voice_name: filter_items.voice[choice.voice] + }); + }); + filtred.sort(function (a, b) { + return a.episode - b.episode; + }); + } + }); + } else if(movie.media){ + movie.media.forEach(function (element) { + filtred.push({ + title: element.translation.shorter_title, + quality: element.max_quality + 'p' + (element.source_quality ? ' - ' + element.source_quality.toUpperCase() : ''), + translation: element.translation_id, + voice_name: element.translation.shorter_title + }); + }); + } + }); + return component.order[choice.order].id == 'invers' ? filtred.reverse() : filtred; + } + function toPlayElement(element) { + var extra = getFile(element, element.quality); + var play = { + title: element.title, + url: extra.file, + quality: extra.quality, + timeline: element.timeline, + callback: element.mark + }; + return play; + } + function append(items) { + component.reset(); + component.draw(items, { + onRender: function onRender(item, html) { + if (get_links_wait) html.find('.online_modss__body').append($('
')); + }, + onEnter: function onEnter(item, html) { + var extra = getFile(item, item.quality); + + if (extra.file) { + var playlist = []; + var first = toPlayElement(item); + + if (item.season) { + items.forEach(function (elem) { + playlist.push(toPlayElement(elem)); + }); + } else { + playlist.push(first); + } + + if (playlist.length > 1) first.playlist = playlist; + Lampa.Player.play(first); + Lampa.Player.playlist(playlist); + item.mark(); + } else Lampa.Noty.show(Lampa.Lang.translate(get_links_wait ? 'modss_waitlink' : 'modss_nolink')); + }, + onContextMenu: function onContextMenu(item, html, data, call) { + call(getFile(item, item.quality)); + } + }); + } + } + + function rezka(component, _object) { + var network = new Lampa.Reguest(); + var extract = {}; + var prox = component.proxy('hdrezka'); + var embed = prox ? prox + 'http://voidboost.tv/' : 'https://voidboost.tv/'; + var object = _object; + var select_id = ''; + var filter_items = {}; + var choice = { + season: 0, + voice: 0, + order: 0, + voice_name: '' + }; + this.searchByKinopoisk = function (_object, id) { + object = _object; + select_id = id; + getFirstTranlate(id, function (voice) { + getFilm(id, voice); + }); + }; + this.searchByImdbID = function (_object, id) { + object = _object; + select_id = id; + getFirstTranlate(id, function (voice) { + getFilm(id, voice); + }); + }; + this.extendChoice = function (saved) { + Lampa.Arrays.extend(choice, saved, true); + }; + this.reset = function () { + component.reset(); + choice = { + season: 0, + voice: 0, + voice_name: '' + }; + component.loading(true); + getFirstTranlate(select_id, function (voice) { + getFilm(select_id, voice); + }); + component.saveChoice(choice); + }; + this.filter = function (type, a, b) { + choice[a.stype] = b.index; + if (a.stype == 'voice') choice.voice_name = filter_items.voice[b.index]; + component.reset(); + filter(); + component.loading(true); + choice.voice_token = extract.voice[choice.voice].token; + getFilm(select_id, choice.voice_token); + component.saveChoice(choice); + setTimeout(component.closeFilter, 10); + }; + this.destroy = function () { + network.clear(); + extract = null; + }; + function getSeasons(voice, call) { + var url = embed + 'serial/' + voice + '/iframe?h=gidonline.io'; + network.clear(); + network.timeout(10000); + network["native"](url, function (str) { + extractData(str); + call(); + }, function (a, c) { + component.doesNotAnswer(); + }, false, { + dataType: 'text' + }); + } + function getChoiceVoice() { + var res = extract.voice[0]; + + if (choice.voice_token) { + extract.voice.forEach(function (voice) { + if (voice.token === choice.voice_token) res = voice; + }); + } + + return res; + } + function getFirstTranlate(id,call) { + network.clear(); + network.timeout(10000); + + network["native"](embed + 'embed/' + id, function (str) { + extractData(str); + if (extract.voice.length) call(getChoiceVoice().token); + else component.doesNotAnswer(object.movie.title); + }, function (a, c) { + component.doesNotAnswer(a.status == 404 && a.responseText && (a.responseText.indexOf('Видео не найдено') !== -1 || a.responseText.indexOf('Not Found') !== -1) ? object.movie.title : ''); + }, false, { + dataType: 'text' + }); + } + function getEmbed(url) { + network.clear(); + network.timeout(10000); + network.silent(url, function (str) { + component.loading(false); + extractData(str); + filter(); + append(); + }, function (a, c) { + component.doesNotAnswer(); + }, false, { + dataType: 'text' + }); + } + function getFilm(id, voice) { + var url = embed; + if (voice) { + if (extract.season.length) { + var ses = extract.season[Math.min(extract.season.length - 1, choice.season)].id; + url += 'serial/' + voice + '/iframe?s=' + ses + '&h=gidonline.io'; + return getSeasons(voice, function () { + var check = extract.season.filter(function (s) { + return s.id == ses; + }); + + if (!check.length) { + choice.season = extract.season.length - 1; + url = embed + 'serial/' + voice + '/iframe?s=' + extract.season[choice.season].id + '&h=gidonline.io'; + } + + getEmbed(url); + }); + } else { + url += 'movie/' + voice + '/iframe?h=gidonline.io'; + getEmbed(url); + } + } else { + url += 'embed/' + id; + getEmbed(url); + } + } + function filter() { + filter_items = { + season: extract.season.map(function (v) { + return v.name; + }), + voice: extract.season.length ? extract.voice.map(function (v) { + return v.name; + }) : [] + }; + + if (choice.voice_name) { + var inx = filter_items.voice.map(function (v) { + return v.toLowerCase(); + }).indexOf(choice.voice_name.toLowerCase()); + if (inx == -1) choice.voice = 0; + else if (inx !== choice.voice) { + choice.voice = inx; + } + } + + if(!extract.season[choice.season]) choice.season = 0; + else choice.seasons = filter_items.season.length; + + component.filter(filter_items, choice); + } + function parseSubtitles(str) { + var subtitles = []; + var subtitle = str.match("'subtitle': '(.*?)'"); + + if (subtitle) { + subtitles = component.parsePlaylist(subtitle[1]).map(function (item) { + return { + label: item.label, + url: item.links[0] + }; + }); + } + + return subtitles.length ? subtitles : false; + } + function extractItems(str) { + try { + var items = component.parsePlaylist(str).map(function (item) { + var quality = item.label.match(/(\d\d\d+)p/); + var links; + + links = item.links.filter(function (url) { + return /\.mp4$/i.test(url); + }); + + if (!links.length) links = item.links; + return { + label: item.label, + quality: quality ? parseInt(quality[1]) : NaN, + file: links[0] + }; + }); + items.sort(function (a, b) { + if (b.quality > a.quality) return 1; + if (b.quality < a.quality) return -1; + if (b.label > a.label) return 1; + if (b.label < a.label) return -1; + return 0; + }); + return items; + } catch (e) {} + + return []; + } + function getStream(element, call, error) { + if (element.stream) return call(element.stream); + var url = embed; + + if (element.season) { + url += 'serial/' + element.voice.token + '/iframe?s=' + element.season + '&e=' + element.episode + '&h=gidonline.io'; + } else { + url += 'movie/' + element.voice.token + '/iframe?h=gidonline.io'; + } + + network.clear(); + network.timeout(5000); + network["native"](url, function (str) { + var videos = str.match("'file': '(.*?)'"); + + if (videos) { + var video = decode(videos[1]), + file = '', + quality = false; + var items = extractItems(video); + + if (items && items.length) { + file = items[0].file; + quality = {}; + items.forEach(function (item) { + quality[item.label] = item.file; + }); + var preferably = Lampa.Storage.get('video_quality_default', '1080') + 'p'; + if (quality[preferably]) file = quality[preferably]; + } + + if (file) { + element.stream = file; + element.qualitys = quality; + element.subtitles = parseSubtitles(str); + call(element.stream); + } else error(); + } else error(); + }, error, false, { + dataType: 'text' + }); + } + function decode(data) { + if (data.charAt(0) !== '#') return data; + + var enc = function enc(str) { + return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) { + return String.fromCharCode('0x' + p1); + })); + }; + + var dec = function dec(str) { + return decodeURIComponent(atob(str).split('').map(function (c) { + return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); + }).join('')); + }; + + var trashList = TRASH_R; + + var x = data.substring(2); + trashList.forEach(function (trash) { + x = x.replace('//_//' + enc(trash), ''); + }); + + try { + x = dec(x); + } catch (e) { + x = ''; + } + + return x; + } + function extractData(str) { + extract.voice = []; + extract.season = []; + extract.episode = []; + str = str.replace(/\n/g, ''); + var voices = str.match(''); + var sesons = str.match(''); + var episod = str.match(''); + + if (sesons) { + var select = $(''); + $('option', select).each(function () { + extract.season.push({ + id: $(this).attr('value'), + name: $(this).text() + }); + }); + } + + if (voices) { + var _select = $(''); + + $('option', _select).each(function () { + var token = $(this).attr('data-token'); + + if (token) { + extract.voice.push({ + token: token, + name: $(this).text(), + id: $(this).val() + }); + } + }); + } + + if (episod) { + var _select2 = $(''); + + $('option', _select2).each(function () { + extract.episode.push({ + id: $(this).attr('value'), + name: $(this).text() + }); + }); + } + } + function append() { + component.reset(); + var items = []; + + if (extract.season.length) { + extract.episode.forEach(function (episode) { + items.push({ + title: episode.name, + quality: '720p ~ 1080p', + season: extract.season[Math.min(extract.season.length - 1, choice.season)].id, + episode: parseInt(episode.id), + info: extract.voice[choice.voice].name, + voice: extract.voice[choice.voice], + voice_name: extract.voice[choice.voice].name + }); + }); + } else { + extract.voice.forEach(function (voice) { + items.push({ + title: voice.name.length > 3 ? voice.name : object.movie.title, + quality: '720p ~ 1080p', + voice: voice, + info: '', + voice_name: voice.name + }); + }); + } + + component.draw(items, { + onEnter: function onEnter(item, html) { + getStream(item, function (stream) { + var first = { + url: stream, + timeline: item.timeline, + quality: item.qualitys, + subtitles: item.subtitles, + title: item.title + }; + Lampa.Player.play(first); + + if (item.season) { + var playlist = []; + items.forEach(function (elem) { + var cell = { + url: function url(call) { + getStream(elem, function (stream) { + cell.url = stream; + cell.quality = elem.qualitys; + call.subtitles = elem.subtitles; + elem.mark(); + call(); + }, function () { + cell.url = ''; + call(); + }); + }, + timeline: elem.timeline, + title: elem.title + }; + if (elem == item) cell.url = stream; + playlist.push(cell); + }); + Lampa.Player.playlist(playlist); + } else { + Lampa.Player.playlist([first]); + } + item.mark(); + }, function () { + Lampa.Noty.show(Lampa.Lang.translate('modss_nolink')); + }); + }, + onContextMenu: function onContextMenu(item, html, data, call) { + getStream(item, function (stream) { + call({ + file: stream, + quality: item.qualitys + }); + }); + } + }); + } + } + + function filmix(component, _object) { + var network = new Lampa.Reguest(); + var results = []; + var object = _object; + var embed = Filmix.api_url; + var select_title = ''; + var filter_items = {}; + var wait_similars; + var id_filmix; + var count = 0; + var choice = { + season: 0, + voice: 0, + order: 0, + voice_name: '' + }; + var dev_token = Filmix.user_dev + Filmix.token; + if (!window.FX) { + window.FX = { + max_qualitie: 480, + is_max_qualitie: false, + auth: false + }; + } + this.search = function (_object, sim) { + if (wait_similars) this.find(sim[0].id); + }; + this.searchByTitle = function (_object, query) { + var _this = this; + object = _object; + select_title = query || object.search; + if (object.movie.source == 'filmix') return this.find(object.movie.id); + var search_date = object.search_date || (object.movie.number_of_seasons ? object.movie.first_air_date : object.movie.release_date) || '0000'; + var search_year = parseInt((search_date + '').slice(0, 4)); + var orig = object.movie.original_title || object.movie.original_name; + var clean_title = component.cleanTitle(select_title).replace(/\b(\d\d\d\d+)\b/g, '+$1'); + if (search_year) clean_title = clean_title.replace(new RegExp(' +(' + search_year + ')'), ' $1'); + var url = embed + 'search'; + url = Lampa.Utils.addUrlComponent(url, 'story=' + encodeURIComponent(clean_title)); + url = Lampa.Utils.addUrlComponent(url, dev_token); + network.clear(); + network.timeout(15 * 1000); + network.silent(url, function (json) { + var is_sure = false; + if (count == 0 && json.length == 0) _this.searchByTitle(object, object.search_two)&count++; + else if (count == 1 && json.length == 0) component.doesNotAnswer(select_title); + else { + var cards = json.filter(function (c) { + if (!c.year && c.alt_name) c.year = parseInt(c.alt_name.split('-').pop()); + return !c.year || !search_year || c.year > search_year - 2 && c.year < search_year + 2; + }); + + if (orig) { + var tmp = cards.filter(function (c) { + return component.equalTitle(c.original_title, orig); + }); + if (tmp.length) { + cards = tmp; + is_sure = true; + } + } + + if (select_title) { + var _tmp = cards.filter(function (c) { + return component.equalTitle(c.title, select_title); + }); + if (_tmp.length) { + cards = _tmp; + is_sure = true; + } + } + + if (cards.length > 1 && search_year) { + var _tmp2 = cards.filter(function (c) { + return c.year == search_year; + }); + if (_tmp2.length) cards = _tmp2; + } + + /* + if (cards.length > 1) { + var tmp = cards.filter(function (c) { + return c.year == search_year; + }); + if (tmp.length) cards = tmp; + } + + if (cards.length > 1) { + var _tmp = cards.filter(function (c) { + return c.original_title == orig; + }); + + if (_tmp.length) cards = _tmp; + } + + if (cards.length > 1) { + var _tmp2 = cards.filter(function (c) { + return c.title == select_title; + }); + + if (_tmp2.length) cards = _tmp2; + } + */ + if (cards.length == 1 && is_sure) _this.find(cards[0].id); + else if (json.length) { + wait_similars = true; + json.forEach(function (c) { + c.type = c.last_episode?'serial':'film'; + c.seasons_count = c.last_episode.season; + c.episodes_count = c.last_episode.episode; + c.translations = c.last_episode.translation; + }); + component.similars(json); + component.loading(false); + } else component.doesNotAnswer(select_title); + } + }, function (a, c) { + component.doesNotAnswer(); + }); + }; + this.find = function (filmix_id) { + if (!window.FX.is_max_qualitie && !window.FX.auth) { + Filmix.checkPro(Filmix.token, function (found) { + window.FX.auth = false; + window.FX.is_max_qualitie = false; + if (found && found.user_data) { + window.FX.auth = true; + window.FX.date = found.user_data.pro_date; + window.FX.max_qualitie = 720; + if (found.user_data.is_pro || found.user_data.is_pro_plus) window.FX.is_max_qualitie = true; + if (found.user_data.is_pro) window.FX.max_qualitie = 1080; + if (found.user_data.is_pro_plus) window.FX.max_qualitie = 2160; + } + end_search(filmix_id); + }, function () { + window.FX.auth = false; + window.FX.max_qualitie = 480; + end_search(filmix_id); + }); + } else end_search(filmix_id); + + function end_search(filmix_id) { + id_filmix = filmix_id; + network.clear(); + network.timeout(20 * 1000); + network.silent(embed + 'post/' + filmix_id +'?'+ dev_token, function (found) { + if(found) { + found = { + playlist: found.player_links.playlist, + movie: found.player_links.movie, + max: found.quality, + quality: found.rip && found.rip.split(' ')[0] || found.rip + }; + if (found && Lampa.Arrays.getKeys(found).length && (found.movie.length || Lampa.Arrays.getKeys(found.playlist).length)) { + success(found); + component.loading(false); + } else component.doesNotAnswer(select_title); + } else component.doesNotAnswer(select_title); + }, function (a, c) { + component.doesNotAnswer(); + }); + } + }; + this.extendChoice = function (saved) { + Lampa.Arrays.extend(choice, saved, true); + }; + this.reset = function () { + component.reset(); + choice = { + season: 0, + voice: 0, + order: 0, + voice_name: '' + }; + filter(); + append(filtred()); + }; + this.filter = function (type, a, b) { + choice[a.stype] = b.index; + if (a.stype == 'voice') choice.voice_name = filter_items.voice[b.index]; + component.reset(); + filter(); + append(filtred()); + }; + this.destroy = function () { + network.clear(); + results = null; + }; + function success(json) { + results = json; + filter(); + append(filtred()); + } + function filter() { + filter_items = { + season: [], + season_id: [], + voice: [], + order: [], + voice_info: [] + }; + if (results.playlist && Object.keys(results.playlist).length > 0) { + component.order.forEach(function (i){ + filter_items.order.push(i.title); + }); + + for (var seasons in results.playlist){ + filter_items.season_id.push(seasons); + filter_items.season.push(Lampa.Lang.translate('torrent_serial_season') + ' ' + seasons); + } + Lampa.Arrays.getKeys(results.playlist[filter_items.season[choice.season].split(' ')[1]]).forEach(function (v){ + filter_items.voice.push(v); + }); + + if (!filter_items.voice[choice.voice]) choice.voice = 0; + choice.seasons = filter_items.season.length; + } + component.filter(filter_items, choice); + } + function getQuality(link){ + var qualities = link.match(/\[([\d,]*)\]\.mp4/i); + if (qualities) qualities = qualities[1].split(",").filter(function (elem) { + return parseInt(elem) <= window.FX.max_qualitie && parseInt(elem) !== 0; + }).sort(function (a, b) { + return b - a; + }); + var qualitie = qualities.length > 0 && Math.max.apply(null, qualities) || false; + return { + max: qualitie, + quals: qualities + }; + } + function filtred() { + var filtred = []; + if (results.playlist && Object.keys(results.playlist).length > 0) { + for (var seasons in results.playlist){ + if(seasons == filter_items.season_id[choice.season]){ + var season = results.playlist[seasons][filter_items.voice[choice.voice]]; + for (var episode in season) { + var eps = season[episode]; + var quality = season[episode].qualities.filter(function (elem) { + return parseInt(elem) <= window.FX.max_qualitie && parseInt(elem) !== 0; + }).sort(function(a, b) { + return b - a; + }); + filtred.push({ + episode: parseInt(episode), + season: parseInt(seasons), + link: season[episode].link, + title: Lampa.Lang.translate('torrent_serial_episode') + ' ' + episode, + qualityes: quality, + quality: results.quality + ' - ' + quality[0] + 'p ', + info: filter_items.voice[choice.voice], + voice_name: filter_items.voice[choice.voice] + }); + } + } + } + } else if (results.movie && results.movie.length > 0) { + for (var keyt in results.movie) { + var movie = results.movie[keyt]; + var q = getQuality(movie.link); + if(q.max) filtred.push({ + title: movie.translation, + link: movie.link, + qualityes: q.quals, + quality: results.quality + ' - ' + q.max + 'p ', + voice_name: movie.translation, + info: '' + }); + } + } + return component.order[choice.order].id == 'invers' ? filtred.reverse() : filtred; + } + function getFile(element) { + var quality = {}; + var files; + if (element.qualityes) { + var qualities = element.qualityes//JSON.parse(element.qualityes); + if (qualities) { + qualities.forEach(function (q) { + var files = object.movie.number_of_seasons || element.season ? element.link.replace(/%s(\.mp4)/i, q + "$1"): element.link.replace(/\[[\d,]*\](\.mp4)/i, q + "$1"); + quality[q + 'p'] = files; + }); + files = Lampa.Arrays.getValues(quality)[0]; + } + } + return { + file: files, + quality: quality + }; + } + function toPlayElement(element) { + var ex = getFile(element); + var play = { + title: element.title, + url: ex.file, + quality: ex.quality, + timeline: element.timeline, + callback: element.mark + }; + return play; + } + function append(items) { + component.reset(); + component.draw(items, { + onEnter: function onEnter(item, html) { + var ex = getFile(item); + if (ex.file) { + var playlist = []; + var first = toPlayElement(item); + + if (item.season) { + items.forEach(function (elem) { + playlist.push(toPlayElement(elem)); + }); + } else { + playlist.push(first); + } + + if (playlist.length > 1) first.playlist = playlist; + Lampa.Player.play(first); + Lampa.Player.playlist(playlist); + item.mark(); + } else Lampa.Noty.show(Lampa.Lang.translate(get_links_wait ? 'modss_waitlink' : 'online_nolink')); + }, + onContextMenu: function onContextMenu(item, html, data, call) { + call(getFile(item)); + } + }); + } + } + + function kinobase(component, _object) { + var network = new Lampa.Reguest(); + var extract = []; + var is_playlist = false; + var quality_type = ''; + var translation = ''; + var prox = component.proxy('kinobase'); + var embed = 'https://kinobase.org/'; + var object = _object; + var data; + var select_title = ''; + var select_id = ''; + var filter_items = {}; + var voic = ''; + var wait_similars; + var choice = { + season: 0, + voice: 0, + order: 0, + voice_name:'' + }; + + this.search = function (_object, sim) { + if (wait_similars && sim) return getPage(sim[0].link); + }; + this.searchByTitle = function (_object, query) { + object = _object; + select_title = object.search; + var url = embed + "search?query=" + encodeURIComponent(component.cleanTitle(select_title)); + network.clear(); + network.timeout(1000 * 10); + network["native"](url, function (str) { + str = str.replace(/\n/g, ''); + var links = object.movie.number_of_seasons ? str.match(/]*>(.*?)<\/a>/g) : str.match(/]*>(.*?)<\/a>/g); + var search_date = object.search_date || object.movie.release_date || object.movie.first_air_date || object.movie.last_air_date || '0000'; + var search_year = parseInt((search_date + '').slice(0, 4)); + + if (links) { + var is_sure = false; + + var items = links.map(function (l) { + var link = $(l), + titl = link.attr('title') || link.text() || ''; + var year; + var found = titl.match(/^(.*)\((\d{4})\)$/); + + if (found) { + year = parseInt(found[2]); + titl = found[1].trim(); + } + + return { + year: year, + title: titl, + link: link.attr('href') + }; + }); + var cards = items; + + if (cards.length) { + if (select_title) { + var _tmp = cards.filter(function (c) { + return component.containsTitle(c.title, select_title); + }); + + if (_tmp.length) { + cards = _tmp; + is_sure = true; + } + } + + if (cards.length > 1 && search_year) { + var _tmp2 = cards.filter(function (c) { + return c.year == search_year; + }); + + if (!_tmp2.length) _tmp2 = cards.filter(function (c) { + return c.year && c.year > search_year - 2 && c.year < search_year + 2; + }); + if (_tmp2.length) cards = _tmp2; + } + } + + if (cards.length == 1 && is_sure) { + if (search_year && cards[0].year) { + is_sure = cards[0].year > search_year - 2 && cards[0].year < search_year + 2; + } + + if (is_sure) { + is_sure = false; + + if (select_title) { + is_sure |= component.equalTitle(cards[0].title, select_title); + } + } + } + + if (cards.length == 1 && is_sure) getPage(cards[0].link); + else if (items.length) { + wait_similars = true; + var similars = []; + links.forEach(function (l) { + var link = $(l), + titl = link.attr('title') || link.text(); + type = link.attr('href').indexOf('film') > -1 ? 'film' : 'serial'; + similars.push({ + title: titl, + type: type, + link: link.attr('href') + }); + }); + component.similars(similars); + component.loading(false); + } else component.doesNotAnswer(select_title); + } else if (str.indexOf('/recaptcha/api.js') !== -1 || str.indexOf('form action="/check?') !== -1) { + component.empty(Lampa.Lang.translate('title_kb_captcha_address') + embed); + } else component.doesNotAnswer(select_title); + }, function (a, c) { + component.doesNotAnswer(); + }, false, { + dataType: 'text' + }); + }; + this.extendChoice = function (saved) { + Lampa.Arrays.extend(choice, saved, true); + }; + this.reset = function () { + component.reset(); + choice = { + season: 0, + voice: 0, + order: 0 + }; + filter(); + append(filtred()); + }; + this.filter = function (type, a, b) { + choice[a.stype] = b.index; + component.reset(); + filter(); + append(filtred()); + }; + this.destroy = function () { + network.clear(); + extract = null; + }; + function filter() { + filter_items = { + season: [], + voice: [], + order: [] + }; + + if (is_playlist) { + component.order.forEach(function (i){ + filter_items.order.push(i.title); + }); + extract.forEach(function (item) { + if (item.playlist || item.folder) { + filter_items.season.push(item.title || item.comment || ''); + } + }); + } + + if (!filter_items.season[choice.season]) choice.season = 0; + + if (is_playlist) { + extract.forEach(function (item, i) { + var playlist = item.playlist || item.folder; + + if (playlist) { + if (i == choice.season) { + playlist.forEach(function (eps) { + if (eps.file) { + component.parsePlaylist(eps.file).forEach(function (el) { + if (el.voice && filter_items.voice.indexOf(el.voice) == -1) { + filter_items.voice.push(el.voice); + } + }); + } + }); + } + } else if (item.file) { + component.parsePlaylist(item.file).forEach(function (el) { + if (el.voice && filter_items.voice.indexOf(el.voice) == -1) { + filter_items.voice.push(el.voice); + } + }); + } + }); + } + + if (!filter_items.voice[choice.voice]) choice.voice = 0; + component.filter(filter_items, choice); + } + function filtred() { + var filtred = []; + if (is_playlist) { + var playlist = extract; + var season = object.movie.number_of_seasons && 1; + if (extract[choice.season] && (extract[choice.season].playlist || extract[choice.season].folder)) { + playlist = extract[choice.season].playlist || extract[choice.season].folder; + season = parseInt(extract[choice.season].title || extract[choice.season].comment || ''); + if (isNaN(season)) season = 1; + } + playlist.forEach(function (eps, index) { + var items = extractItems(eps.file, filter_items.voice[choice.voice]); + if (items.length) { + var title = eps.title || eps.comment || ''; + var alt_voice = (eps.comment || eps.title).match(/\d+ серия (.*)$/i); + var info = items[0].voice || (alt_voice && alt_voice[1].trim()) || translation; + + if (info == title) info = ''; + if(season){ + var episode = parseInt(title); + if (isNaN(episode)) episode = index + 1; + filtred.push({ + file: eps.file, + title: title, + quality: (quality_type ? quality_type + ' - ' : '') + items[0].quality + 'p', + season: season, + episode: episode, + info: info ? info : '', + voice: info, + voice_name: info, + subtitles: parseSubs(eps.subtitle || '') + }); + } else { + filtred.push({ + file: eps.file, + title: title, + quality: (quality_type ? quality_type + ' - ' : '') + items[0].quality + 'p', + info: info ? ' / ' + info : '', + voice: items[0].voice, + voice_name: info, + subtitles: parseSubs(eps.subtitle || '') + }); + } + } + }); + } else { + filtred = extract; + } + return component.order[choice.order].id == 'invers' ? filtred.reverse() : filtred; + } + function parseSubs(vod) { + var subtitles = component.parsePlaylist(vod).map(function (item) { + return { + label: item.label, + url: item.links[0] + }; + }); + return subtitles.length ? subtitles : false; + } + function extractData(str, page) { + var quality_match = page.match(/
  • Качество:<\/b>([^<,]+)<\/li>/i); + var translation_match = page.match(/
  • Перевод:<\/b>([^<,]+)<\/li>/i); + quality_type = quality_match ? quality_match[1].trim() : ''; + translation = translation_match ? translation_match[1].trim() : ''; + var vod = str.split('|'); + if (vod[0] == 'file') { + var file = vod[1]; + var found = []; + var subtiles = parseSubs(vod[2]); + if (file) { + var voices = {}; + component.parsePlaylist(file).forEach(function (item) { + var prev = voices[item.voice || '']; + var quality_str = item.label.match(/(\d\d\d+)p/); + var quality = quality_str ? parseInt(quality_str[1]) : NaN; + if (!prev || quality > prev.quality) { + voices[item.voice || ''] = { + quality: quality + }; + } + }); + for (var voice in voices) { + var el = voices[voice]; + found.push({ + file: file, + title: voice || translation || object.movie.title, + quality: (quality_type ? quality_type + ' - ' : '') + el.quality + 'p', + info: '', + voice: voice, + voice_name: voice, + subtitles: subtiles + }); + } + } + extract = found; + is_playlist = false; + } else if (vod[0] == 'pl') { + extract = Lampa.Arrays.decodeJson(vod[1], []); + is_playlist = true; + } else component.doesNotAnswer(select_title); + } + function getPage(url) { + network.clear(); + network.timeout(1000 * 10); + network["native"](embed + url, function (str) { + str = str.replace(/\n/g, ''); + var voices = str.match('
      (.*?)
    '); + $(voices, 'li').each(function (r, a) { + var vsrt = a.match('
  • Перевод:(.*?)
  • '); + voic = vsrt && vsrt[1]; + }); + var MOVIE_ID = str.match('var MOVIE_ID = ([^;]+);'); + var IDENTIFIER = str.match('var IDENTIFIER = "([^"]+)"'); + var PLAYER_CUID = str.match('var PLAYER_CUID = "([^"]+)"'); + + if (MOVIE_ID && IDENTIFIER && PLAYER_CUID) { + select_id = MOVIE_ID[1]; + var identifier = IDENTIFIER[1]; + var player_cuid = PLAYER_CUID[1]; + + var user_url = "user_data"; + user_url = Lampa.Utils.addUrlComponent(user_url, "page=movie"); + user_url = Lampa.Utils.addUrlComponent(user_url, "movie_id=" + select_id); + user_url = Lampa.Utils.addUrlComponent(user_url, "cuid=" + player_cuid); + user_url = Lampa.Utils.addUrlComponent(user_url, "device=DESKTOP"); + user_url = Lampa.Utils.addUrlComponent(user_url, "_=" + Date.now()); + + var data_url = "videoplayer.js"; + data_url = Lampa.Utils.addUrlComponent(data_url, "movie_id=" + select_id); + data_url = Lampa.Utils.addUrlComponent(data_url, "IDENTIFIER=" + identifier); + data_url = Lampa.Utils.addUrlComponent(data_url, "player_type=new"); + data_url = Lampa.Utils.addUrlComponent(data_url, "file_type=mp4"); + data_url = Lampa.Utils.addUrlComponent(data_url, "_=" + Math.floor(Date.now() / 1e3)); + + network.clear(); + network.timeout(1000 * 10); + network["native"](embed + user_url, function () {}, function () {}, false, { + dataType: 'text', + withCredentials: !prox + }); + + network.clear(); + network.timeout(1000 * 10); + network["native"](embed + data_url, function (vod_script) { + var vod_data, vod_url; + try { + var tmp = $.get; + try { + vod_data = (0, eval)('"use strict"; (function () { var url, params, $ = {}; $.get = function (u, p) { if (u && u.startsWith("/vod/")) { url = u; params = p; } }; var XMLHttpRequest = function XMLHttpRequest() { this.open = function (m, u) { if (u && u.startsWith("/vod/")) { url = u; } }; this.send = function () {}; }; try { eval(' + JSON.stringify(vod_script) + '); } catch (e) {} return {url: url, params: params}; })();'); + } finally { + $.get = tmp; + } + } catch (e) {} + + if (vod_data && vod_data.url) { + vod_url = vod_data.url; + if (vod_data.params) { + for (var name in vod_data.params) { + vod_url = Lampa.Utils.addUrlComponent(vod_url, name + "=" + encodeURIComponent(vod_data.params[name])); + } + } + } + + if (vod_url) { + network.clear(); + network.timeout(1000 * 10); + network["native"](embed + vod_url, function (files) { + component.loading(false); + extractData(files, str); + filter(); + append(filtred()); + }, function (a, c) { + component.empty(network.errorDecode(a, c)); + }, false, { + dataType: 'text' + }); + } else component.empty(Lampa.Lang.translate('torrent_parser_no_hash')); + + }, function (a, c) { + component.doesNotAnswer(); + }, false, { + dataType: 'text' + }); + } else component.doesNotAnswer(); + }, function (a, c) { + component.doesNotAnswer(); + }, false, { + dataType: 'text' + }); + } + function extractItems(str, voice) { + try { + var list = component.parsePlaylist(str); + if (voice) { + var tmp = list.filter(function (el) { + return el.voice == voice; + }); + if (tmp.length) { + list = tmp; + } else { + list = list.filter(function (el) { + return typeof el.voice == 'undefined'; + }); + } + } + var items = list.map(function (item) { + var quality = item.label.match(/(\d\d\d+)p/); + return { + label: item.label, + voice: item.voice, + quality: quality ? parseInt(quality[1]) : NaN, + file: item.links[0] + }; + }); + items.sort(function (a, b) { + if (b.quality > a.quality) return 1; + if (b.quality < a.quality) return -1; + if (b.label > a.label) return 1; + if (b.label < a.label) return -1; + return 0; + }); + return items; + } catch (e) {} + return []; + } + function getFile(element) { + var file = '', + quality = false; + var items = extractItems(element.file, element.voice); + if (items && items.length) { + file = items[0].file; + quality = {}; + items.forEach(function (item) { + quality[item.label] = item.file; + }); + var preferably = Lampa.Storage.get('video_quality_default', '1080') + 'p'; + if (quality[preferably]) file = quality[preferably]; + } + element.stream = file; + element.qualitys = quality; + return { + file: file, + quality: quality + }; + } + function toPlayElement(element) { + getFile(element); + var play = { + url: element.stream, + timeline: element.timeline, + title: element.title, + subtitles: element.subtitles, + quality: element.qualitys, + callback: element.mark + }; + return play; + } + function append(items) { + component.reset(); + component.draw(items, { + similars: wait_similars, + onEnter: function onEnter(item, html) { + getFile(item); + + if (item.stream) { + var playlist = []; + var first = toPlayElement(item); + + if (item.season) { + items.forEach(function (elem) { + playlist.push(toPlayElement(elem)); + }); + } else { + playlist.push(first); + } + + if (playlist.length > 1) first.playlist = playlist; + Lampa.Player.play(first); + Lampa.Player.playlist(playlist); + item.mark(); + } else Lampa.Noty.show(Lampa.Lang.translate('modss_nolink')); + }, + onContextMenu: function onContextMenu(item, html, data, call) { + call(getFile(item)); + } + }); + } + } + + function collaps(component, _object) { + var network = new Lampa.Reguest(); + var extract = {}; + var prox = component.proxy('collaps'); + var embed = prox ? prox + 'https://api.topdbltj.ws/embed/' : 'https://api.strvid.ws/embed/'; + var select_title = ''; + var filter_items = {}; + var prefer_dash = Lampa.Storage.field('online_dash') === true; + var choice = { + season: 0, + voice: 0, + order: 0 + }; + this.searchByKinopoisk = function (_object, id) { + this.searchIn('kp', id); + }; + this.searchByImdbID = function (_object, id) { + this.searchIn('imdb', id); + }; + this.searchIn = function (where, id) { + select_title = _object.search; + var url = embed + where + '/' + id; + network.clear(); + network.timeout(10000); + network.silent(url, function (str) { + if (str) { + parse(str); + } else component.doesNotAnswer(select_title); + component.loading(false); + }, function (a, c) { + component.doesNotAnswer(a.status == 404 && a.responseText && a.responseText.indexOf('видео недоступно') !== -1 ? select_title : ''); + }, false, { + dataType: 'text' + }); + }; + this.extendChoice = function (saved) { + Lampa.Arrays.extend(choice, saved, true); + }; + this.reset = function () { + component.reset(); + choice = { + season: 0, + voice: 0, + order: 0 + }; + filter(); + append(filtred()); + component.saveChoice(choice); + }; + this.filter = function (type, a, b) { + choice[a.stype] = b.index; + component.reset(); + filter(); + append(filtred()); + component.saveChoice(choice); + }; + this.destroy = function () { + network.clear(); + extract = null; + }; + function parse(str) { + str = str.replace(/\n/g, ''); + var find = str.match('makePlayer\\({(.*?)}\\);'); + var json; + try { + json = find && eval('({' + find[1] + '})'); + } catch (e) {} + if (json) { + extract = json; + if (extract.playlist && extract.playlist.seasons) { + extract.playlist.seasons.sort(function (a, b) { + return a.season - b.season; + }); + } + filter(); + append(filtred()); + } else component.doesNotAnswer(select_title); + } + function filter() { + filter_items = { + season: [], + voice: [], + order: [] + }; + if (extract.playlist && extract.playlist.seasons) { + component.order.forEach(function (i){ + filter_items.order.push(i.title); + }); + extract.playlist.seasons.forEach(function (season) { + filter_items.season.push(Lampa.Lang.translate('torrent_serial_season') + ' ' + season.season); + }); + choice.seasons = filter_items.season.length; + } + + filter_items.season.sort(function(a,b){ + var n_a = parseInt(a.replace(/\D/g,'')); + var n_b = parseInt(b.replace(/\D/g,'')); + if(n_a > n_b) return 1; + else if(n_a < n_b) return -1; + else return 0; + }); + + if (!filter_items.season[choice.season]) choice.season = 0; + component.filter(filter_items, choice); + } + function filtred() { + var filtred = []; + if (extract.playlist) { + extract.playlist.seasons.forEach(function (season, i) { + var season_id = parseInt(filter_items.season[choice.season].split(' ').pop()); + if(season.season == season_id) { + season.episodes.forEach(function (episode) { + var resolution = Lampa.Arrays.getKeys(extract.qualityByWidth).pop(); + var max_quality = resolution ? extract.qualityByWidth[resolution] || 0 : ''; + var audio_tracks = episode.audio.names.map(function (name) { + return { + language: name + }; + }); + filtred.push({ + file: prefer_dash && episode.dash || episode.hls, + episode: parseInt(episode.episode), + season: parseInt(season.season), + title: episode.title, + quality: max_quality ? max_quality + 'p' : '', + voice: episode.audio.names.join('
    '), + info: episode.audio.names.slice(0, 5).join(', '), + subtitles: episode.cc ? episode.cc.map(function (c) { + return { + label: c.name, + url: c.url + }; + }) : false, + audio_tracks: audio_tracks.length ? audio_tracks : false + }); + }); + } + }); + } else if (extract.source) { + var resolution = Lampa.Arrays.getKeys(extract.qualityByWidth).pop(); + var max_quality = extract.qualityByWidth ? extract.qualityByWidth[resolution] || 0 : 0; + var audio_tracks = extract.source.audio.names.map(function (name) { + return { + language: name + }; + }); + filtred.push({ + file: prefer_dash && extract.source.dash || extract.source.hls, + title: extract.title, + quality: max_quality ? max_quality + 'p' : '', + info: extract.source.audio.names.slice(0, 5).join(', '), + voice: extract.source.audio.names.join('
    '), + subtitles: extract.source.cc ? extract.source.cc.map(function (c) { + return { + label: c.name, + url: c.url + }; + }) : false, + audio_tracks: audio_tracks.length ? audio_tracks : false + }); + } + return component.order[choice.order].id == 'invers' ? filtred.reverse() : filtred; + } + function append(items) { + component.reset(); + component.draw(items, { + onEnter: function onEnter(item, html) { + if (item.file) { + var playlist = []; + var first = { + url: item.file, + timeline: item.timeline, + title: item.title, + subtitles: item.subtitles, + translate: { + tracks: item.audio_tracks + } + }; + + if (item.season) { + items.forEach(function (elem) { + playlist.push({ + title: elem.title, + url: elem.file, + timeline: elem.timeline, + subtitles: elem.subtitles, + translate: { + tracks: elem.audio_tracks + }, + callback: function callback() { + elem.mark(); + } + }); + }); + } else { + playlist.push(first); + } + + if (playlist.length > 1) first.playlist = playlist; + Lampa.Player.play(first); + Lampa.Player.playlist(playlist); + item.mark(); + } else Lampa.Noty.show(Lampa.Lang.translate('modss_nolink')); + }, + onContextMenu: function onContextMenu(item, html, data, call) { + call({ + file: item.file + }); + } + }); + } + } + + function cdnmovies(component, _object) { + var network = new Lampa.Reguest(); + var extract = []; + var medias; + var object = _object; + var select_title = ''; + var filter_items = {}; + var wait_similars; + var prefer_old = false; + var iframe_proxy = false; + var choice = { + season: 0, + voice: 0, + order: 0 + }; + var old_embed = 'https://1f29036bcf55d.sarnage.cc/'; + var new_embed = 'https://cdnmovies-stream.online/'; + var prox = component.proxy('cdnmovies'); + var host = 'https://cdnmovies.net'; + var embed = prox + 'https://skinny-wilderness.cdnmovies-stream.online/'; + + function cdn_api_search(api, callback, error) { + var call_success = function call_success(str) { + if (callback) callback(str || ''); + }; + + var call_error = function call_error(a, c) { + if ((a.status == 404 || a.status == 403) && a.responseText && (a.responseText.indexOf('Not Found') !== -1 || a.responseText.indexOf('Не найдено!') !== -1 || a.responseText.indexOf('Контент не найден или недоступен в вашем регионе!') !== -1) || a.status == 0 && a.statusText !== 'timeout') { + if (callback) callback(''); + } else if (error) error(network.errorDecode(a, c)); + }; + + if (iframe_proxy) { + component.proxyCall('GET', embed + api, 10000, null, call_success, call_error); + } else { + var meta = $('head meta[name="referrer"]'); + var referrer = meta.attr('content') || 'never'; + meta.attr('content', 'origin'); + + try { + network.clear(); + network.timeout(10000); + network["native"](embed + api, call_success, call_error, false, { + dataType: 'text', + headers: Lampa.Platform.is('android') ? { + 'Origin': host, + 'Referer': host + '/' + } : {} + }); + } finally { + meta.attr('content', referrer); + } + } + } + + this.searchs = function (_object, kinopoisk_id) { + object = _object; + select_title = object.search || object.movie.title; + + var empty = function empty() { + component.doesNotAnswer(select_title); + }; + + var error = component.empty.bind(component); + var api = (+kinopoisk_id ? 'kinopoisk/' : 'imdb/') + kinopoisk_id + '/iframe'; + cdn_api_search(api, function (str) { + parse(str || '', function () { + if (!object.clarification && object.movie.imdb_id && kinopoisk_id != object.movie.imdb_id) { + cdn_api_search('imdb/' + object.movie.imdb_id + '/iframe', function (str) { + parse(str || '', empty); + }, error); + } else empty(); + }); + }, error); + }; + + this.extendChoice = function (saved) { + Lampa.Arrays.extend(choice, saved, true); + }; + this.reset = function () { + component.reset(); + choice = { + season: 0, + voice: 0, + order: 0, + voice_name: '' + }; + filter(); + append(filtred()); + component.saveChoice(choice); + }; + this.filter = function (type, a, b) { + choice[a.stype] = b.index; + if (a.stype == 'voice') choice.voice_name = filter_items.voice[b.index]; + component.reset(); + filter(); + append(filtred()); + component.saveChoice(choice); + }; + this.destroy = function () { + network.clear(); + }; + function parse(str, empty) { + + str = str.replace(/\n/g, ''); + + var video; + var app = str.match(/(
    ]*>)/); + + if (app) { + var page = $(app[1] + '
    ').attr('data-page') || ''; + var json; + + try { + json = page && JSON.parse(page); + } catch (e) {} + + var player = json && json.props && json.props.player && decode(json.props.player); + + try { + video = player && JSON.parse(player); + } catch (e) {} + } + + if (video) { + component.loading(false); + extract = video; + filter(); + append(filtred()); + } else empty(); + } + + function decode(data) { + if (data.charAt(0) !== '#') return data; + + var enc = function enc(str) { + return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) { + return String.fromCharCode('0x' + p1); + })); + }; + + var dec = function dec(str) { + return decodeURIComponent(atob(str).split('').map(function (c) { + return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); + }).join('')); + }; + + var trashList = ['-*frofpscprpamfpQ*45612.3256dfrgd', '54vjfhcgdbrydkcfkndz568436fred+*d', 'lvfycgndqcydrcgcfg+95147gfdgf-zd*', 'az+-erw*3457edgtjd-feqsptf/re*q*Y', 'df8vg69r9zxWdlyf+*fgx455g8fh9z-e*Q']; + var x = data.substring(2); + trashList.forEach(function (trash) { + x = x.replace('//' + enc(trash), ''); + }); + + try { + x = dec(x); + } catch (e) { + x = ''; + } + + return x; + } + + function extractItemsPlaylist(str, url) { + if (!str) return []; + + try { + var items = component.parsePlaylist(str).map(function (item) { + var quality = item.label.match(/(\d\d\d+)p/); + var link = item.links[0] || ''; + link = link.replace('/sundb.coldcdn.xyz/', '/sundb.nl/'); + return { + label: item.label, + quality: quality ? parseInt(quality[1]) : NaN, + file: link + }; + }); + items.sort(function (a, b) { + if (b.quality > a.quality) return 1; + if (b.quality < a.quality) return -1; + if (b.label > a.label) return 1; + if (b.label < a.label) return -1; + return 0; + }); + return items; + } catch (e) {} + + return []; + } + function parseStream(element, call, error, itemsExtractor, str, url) { + var file = ''; + var quality = false; + var items = itemsExtractor(str, url); + + if (items && items.length) { + file = items[0].file; + quality = {}; + items.forEach(function (item) { + quality[item.label] = item.file; + }); + } + if (file) { + element.stream = file; + element.qualitys = quality; + call(element.stream); + } else error(); + } + function getStream(element, call, error) { + if (element.stream) return call(element.stream); + var url = element.file || ''; + + if (url.charAt(0) === '[') { + parseStream(element, call, error, extractItemsPlaylist, url, ''); + return; + } + link = link.replace('/sundb.coldcdn.xyz/', '/sundb.nl/'); + + if (url) { + element.stream = url; + element.qualitys = false; + call(element.stream); + } else error(); + } + + function filter() { + filter_items = { + season: [], + voice: [], + order: [] + }; + extract.forEach(function (season) { + if (season.folder) filter_items.season.push(season.title); + }); + if (!filter_items.season[choice.season]) choice.season = 0; + + if (extract[choice.season] && extract[choice.season].folder) { + component.order.forEach(function (i){ + filter_items.order.push(i.title); + }); + extract[choice.season].folder.forEach(function (f) { + f.folder.forEach(function (t) { + if (filter_items.voice.indexOf(t.title) == -1) filter_items.voice.push(t.title); + }); + }); + } + + if (!filter_items.voice[choice.voice]) choice.voice = 0; + + if (choice.voice_name) { + var inx = filter_items.voice.indexOf(choice.voice_name); + if (inx == -1) choice.voice = 0;else if (inx !== choice.voice) { + choice.voice = inx; + } + } + + component.filter(filter_items, choice); + } + function parseSubs(str) { + var subtitles = component.parsePlaylist(str).map(function (item) { + link = link.replace('/sundb.coldcdn.xyz/', '/sundb.nl/'); + return { + label: item.label, + url: item.links[0] + }; + }); + return subtitles.length ? subtitles : false; + } + function filtred() { + var filtred = []; + extract.forEach(function (data) { + if (data.folder) { + if (data.title == filter_items.season[choice.season]) { + data.folder.forEach(function (se) { + se.folder.forEach(function (eps) { + if (eps.title == filter_items.voice[choice.voice]) { + var m = Lampa.Arrays.getValues(medias).filter(function (itm) { + return itm.translation == eps.title; + }); + filtred.push({ + file: eps.file, + title: Lampa.Lang.translate('full_episode') + ' ' + parseInt(se.title.match(/\d+/)), + episode: parseInt(se.title.match(/\d+/)), + season: parseInt(data.title.match(/\d+/)), + quality: m.length ? (m[0].source_quality + ' - ' + m[0].quality + 'p') : '', + info: Lampa.Utils.shortText(eps.title, 50) + }); + } + }); + }); + } + } else { + var m = Lampa.Arrays.getValues(medias).filter(function (itm) { + return itm.translation == data.title; + }); + filtred.push({ + file: data.file, + title: data.title, + quality: m.length ? (m[0].source_quality + ' - ' + m[0].quality + 'p') : '', + info: '', + subtitles: data.subtitle ? parseSubs(data.subtitle) : false + }); + } + }); + return component.order[choice.order].id == 'invers' ? filtred.reverse() : filtred; + } + function append(items) { + component.reset(); + component.draw(items, { + // similars: wait_similars, + onEnter: function onEnter(item, html) { + if (item.loading) return; + item.loading = true; + getStream(item, function (stream) { + item.loading = false; + var first = { + url: stream, + timeline: item.timeline, + quality: item.qualitys, + subtitle: item.subtitles, + title: item.title + }; + Lampa.Player.play(first); + + if (item.season) { + var playlist = []; + items.forEach(function (elem) { + var cell = { + url: function url(call) { + getStream(elem, function (stream) { + cell.url = stream; + cell.quality = elem.qualitys; + cell.subtitles = elem.subtitles; + elem.mark(); + call(); + }, function () { + cell.url = ''; + call(); + }); + }, + timeline: elem.timeline, + title: elem.title + }; + if (elem == item) cell.url = stream; + playlist.push(cell); + }); + Lampa.Player.playlist(playlist); + } else { + Lampa.Player.playlist([first]); + } + + if (item.subtitles && Lampa.Player.subtitles) Lampa.Player.subtitles(item.subtitles); + item.mark(); + }, function (data) { + item.loading = false; + Lampa.Noty.show(data ? network.errorDecode(data) : Lampa.Lang.translate('modss_nolink')); + }); + }, + onContextMenu: function onContextMenu(item, html, data, call) { + getStream(item, function (stream) { + call({ + file: stream, + quality: item.qualitys + }); + }, function (data) { + Lampa.Noty.show(data ? network.errorDecode(data) : Lampa.Lang.translate('modss_nolink')); + }); + } + }); + } + } + + function pub(component, _object) { + var network = new Lampa.Reguest(); + var extract = {}; + var results = []; + var object = _object; + var filter_items = {}; + var embed = Pub.baseurl + 'v1/items'; + var streamingType; + var supportHevc; + var wait_similars; + var choice = { + season: 0, + voice: 0, + order: 0, + type: 0 + }; + this.search = function (_object, sim) { + if (wait_similars && sim) return this.find(sim[0].id); + }; + this.searchByTitle = function (_object, query) { + object = _object; + var _this = this; + var title = object.search.trim(); + var relise = object.search_date || (object.movie.number_of_seasons ? object.movie.first_air_date : object.movie.release_date) || '0000'; + var year = parseInt((relise + '').slice(0, 4)); + var orig = object.movie.original_title || object.movie.original_name; + var imdb = object.movie.imdb_id && parseInt(object.movie.imdb_id.slice(2)); + var kpID = object.movie.kinopoisk_id || object.movie.kinopoisk_ID; + var url = embed + '/search'; + url = Lampa.Utils.addUrlComponent(url, 'q=' + encodeURIComponent(title)); + url = Lampa.Utils.addUrlComponent(url, 'access_token=' + Pub.token); + network.clear(); + network.timeout(10000); + network.silent(url, function (json) { + json = json.items; + if (json.length == 0) component.doesNotAnswer(title); + else { + var cards = json.filter(function (c) { + return c.imdb == imdb || c.kinopoisk == kpID; + }); + if (!cards.length) { + cards = json.filter(function (c) { + return c.year > year - 2 && c.year < year + 2; + }); + var tmp = cards.filter(function (c) { + return c.year == year; + }); + if (tmp.length) cards = tmp; + else return component.doesNotAnswer(title); + } + if (cards.length) { + var _tmp = cards.filter(function (c) { + c.title_ru = c.title.split(' / ')[0]; + return component.equalTitle(c.title_ru.replace(/\s/, ' '), title.replace(/\s/, ' ')); + }); + if (_tmp.length) cards = _tmp; + var _tmp2 = cards.filter(function (c) { + c.title_org = c.title.split(' / ')[1]; + if (!c.title_org) return; + return component.equalTitle(c.title_org.replace(/\s/, ' '), orig.replace(/\s/, ' ')); + }); + if (_tmp2.length) cards = _tmp2; + } + if (cards.length == 1) _this.find(cards[0].id); + else if (json.length > 1) { + wait_similars = true; + component.similars(json); + component.loading(false); + } else component.doesNotAnswer(title); + } + }, function (a, c) { + component.doesNotAnswer(); + }); + }; + this.find = function (id) { + network.clear(); + network.timeout(10000); + var url = embed + '/' + id; + url = Lampa.Utils.addUrlComponent(url, 'access_token=' + Pub.token); + network.silent(url, function (json) { + if (Lampa.Arrays.getKeys(json.item).length) { + network.silent(embed.slice(0, -6) + '/device/info?access_token=' + Pub.token, function (param) { + streamingType = param.device.settings.streamingType.value.find(function (t) { + return t.selected == 1; + }); + supportHevc = param.device.settings.supportHevc.value == 1; + choice.type = streamingType.id - 1; + success(json.item); + component.loading(false); + }, function (a, c) { + component.doesNotAnswer(); + }); + } else component.doesNotAnswer(object.search); + }, function (a, c) { + component.doesNotAnswer(); + }); + }; + this.extendChoice = function (saved) { + Lampa.Arrays.extend(choice, saved, true); + }; + this.reset = function () { + component.reset(); + choice = { + season: 0, + voice: 0, + order: 0, + type: 0 + }; + append(filtred()); + component.saveChoice(choice); + }; + this.filter = function (type, a, b) { + choice[a.stype] = b.index; + component.reset(); + filter(); + append(filtred()); + component.saveChoice(choice); + }; + this.destroy = function () { + network.clear(); + results = null; + }; + function success(json) { + results = json; + filter(); + append(filtred()); + } + function filter() { + filter_items = { + season: [], + voice: [], + type: [], + order: [] + }; + ['HTTP', 'HLS', 'HLS2', 'HLS4'].forEach(function (t) { + filter_items.type.push(t); + }); + if (results.seasons) { + component.order.forEach(function (i){ + filter_items.order.push(i.title); + }); + results.seasons.forEach(function (season) { + filter_items.season.push(parseInt(season.number) + ' ' + Lampa.Lang.translate('torrent_serial_season')); + }); + choice.seasons = filter_items.season.length; + } + if(!filter_items.type[choice.type]) choice.type = 2; + component.filter(filter_items, choice); + } + function filtred() { + var filtred = []; + var type = filter_items.type[choice.type]; + var CODEC = supportHevc ? 'HEVC' : 'AVC'; + if (results.seasons) { + results.seasons.forEach(function (season) { + if (season.number == parseInt(filter_items.season[choice.season])) { + season.episodes.forEach(function (ep) { + if(ep.files[0]) filtred.push({ + title: ep.title || Lampa.Lang.translate('full_episode')+' '+ep.number, + season: ep.snumber, + episode: ep.number, + quality: ep.files[0].quality + ' (' + CODEC + ')', + file: ep.files, + codec: CODEC, + voice: parseTrackss(ep.audios).join('
    '), + tracks: parseTracks(ep.audios || ''), + subtitles: parseSubs(ep.subtitles || ''), + info: type + }); + }); + } + }); + } else { + results.videos.forEach(function (movie) { + filtred.push({ + title: object.movie.title, + quality: movie.files[0].quality + ' (' + CODEC + ')', + file: movie.files, + codec: CODEC, + voice: parseTrackss(movie.audios).join('
    '), + tracks: parseTracks(movie.audios || ''), + subtitles: parseSubs(movie.subtitles || ''), + info: type + }); + }); + } + return component.order[choice.order].id == 'invers' ? filtred.reverse() : filtred; + } + function parseSubs(vod) { + var subtitles = vod.map(function (item) { + return { + label: item.lang.toUpperCase() + (item.forced && ' - [FORCED]' || ''), + url: item.url + }; + }); + return subtitles.length ? subtitles : false; + } + function parseTracks(vod) { + var tracks = vod.map(function (track) { + return { + language: track.lang.toUpperCase(), + label: track.codec.toUpperCase() + (track.channels && (' - ' + (track.channels == 6 ? '5.1' : track.channels)) || '') + (track.type && ' - ' + track.type.title || '') + (track.author && ' - ' + track.author.title || '') + }; + }); + return tracks.length ? tracks : false; + } + function parseTrackss(vod) { + var tracks = vod.map(function (track, i) { + return (i+1)+ (track.type && '. ' + track.type.title || '') + (track.author && ' - ' + track.author.title || '') + (track.lang && '(' + track.lang+')' || ''); + }); + return tracks.length ? tracks : false; + } + function getFile(element) { + var file = ''; + var quality = {}; + var preferably = Lampa.Storage.get('video_quality_default', '1080') + 'p'; + /* + var codec = element.file.filter(function (q) { + return q.codec == filter_items.codec[choice.codec].toLowerCase(); + }); + if (codec.length == 0) codec = element.file; + */ + element.file.forEach(function (item) { + quality[item.quality] = item.url[filter_items.type[choice.type].toLowerCase()]; + }); + var max_quality = Lampa.Arrays.getKeys(quality)[0]; + file = quality[max_quality]; + if (quality[preferably]) file = quality[preferably]; + return { + stream: file, + quality: ['HLS2', 'HLS4'].indexOf(filter_items.type[choice.type]) > - 1 ? '' : quality + }; + } + function toPlayElement(element) { + var ex = getFile(element); + var play = { + url: ex.stream, + timeline: element.timeline, + title: element.title, + subtitles: element.subtitles, + translate: { + tracks: element.tracks + }, + quality: ex.quality, + callback: element.mark + }; + return play; + } + function append(items) { + component.reset(); + component.draw(items, { + similars: wait_similars, + onEnter: function onEnter(item, html) { + var ex = getFile(item); + + if (ex.stream) { + var playlist = []; + var first = toPlayElement(item); + + if (item.season) { + items.forEach(function (elem) { + playlist.push(toPlayElement(elem)); + }); + } else { + playlist.push(first); + } + + if (playlist.length > 1) first.playlist = playlist; + Lampa.Player.play(first); + Lampa.Player.playlist(playlist); + item.mark(); + } else Lampa.Noty.show(Lampa.Lang.translate('modss_nolink')); + }, + onContextMenu: function onContextMenu(item, html, data, call) { + call(getFile(item)); + } + }); + } + } + + var proxyInitialized = false; + var proxyWindow; + var proxyCalls = {}; + + function component(object) { + var network = new Lampa.Reguest(); + var scroll = new Lampa.Scroll({ + mask: true, + over: true + }); + var files = new Lampa.Explorer(object); + var filter = new Lampa.Filter(object); + var last; + var extended; + var selected_id; + var sources = {}; + var source; + var balanser; + var initialized; + var balanser_timer; + var images = []; + var balansers = Modss.balansers(); + + var filter_sources = Lampa.Arrays.getKeys(balansers); + var filter_translate = { + season: Lampa.Lang.translate('torrent_serial_season'), + voice: Lampa.Lang.translate('torrent_parser_voice'), + source: Lampa.Lang.translate('settings_rest_source') + }; + this.initialize = function () { + var _this = this; + + try { + filter_sources.forEach(function(b){ + sources[b] = eval(b); + }); + } catch (e) {} + + source = this.createSource(); + + filter.onSearch = function (value) { + Lampa.Activity.replace({ + search: value, + clarification: true + }); + }; + + filter.onBack = function () { + _this.start(); + }; + + filter.render().find('.selector').on('hover:enter', function () { + clearInterval(balanser_timer); + }) + + filter.onSelect = function (type, a, b) { + if (a.bal) { + filter.render().find('.filter--sort').trigger('hover:enter'); + } else if (type == 'filter') { + if (a.reset) { + if (extended) source.reset();else _this.start(); + } else { + source.filter(type, a, b); + } + } else if (type == 'sort') { + Lampa.Select.close(); + if (Lampa.Arrays.getKeys(sources).indexOf(a.source) !== -1) { + if (!Lampa.Storage.get('pro_pub', false) && a.source == 'pub') + return Lampa.Noty.show('Доступно для VIP пользователей
    Через бот @modssmy_bot'); + _this.changeBalanser(a.source); + } else Lampa.Noty.show('Доступно для VIP пользователей
    Через бот @modssmy_bot'); + } + if (object.movie.number_of_seasons || balanser == 'pub' || balanser == 'bazon') filter.render().find('.filter--filter').show(); + else filter.render().find('.filter--filter').hide(); + }; + + if (object.movie.number_of_seasons || balanser == 'pub' || balanser == 'bazon') filter.render().find('.filter--filter').show(); + else filter.render().find('.filter--filter').hide(); + filter.render().find('.filter--sort').on('hover:enter', function () { + $('body').find('.selectbox__title').text(Lampa.Lang.translate('modss_balanser')); + }); + if (filter.addButtonBack) filter.addButtonBack(); + filter.render().find('.filter--sort span').text(Lampa.Lang.translate('modss_balanser')); + files.appendFiles(scroll.render()); + files.appendHead(filter.render()); + filter.render().find('.filter--filter').after(filter.render().find('.filter--search')); + scroll.body().addClass('torrent-list'); + scroll.minus(files.render().find('.explorer__files-head')); + this.search(); + }; + this.changeBalanser = 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); + 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.createSource = function () { + var priority_balanser = Lampa.Storage.get('priority_balanser', Modss.balansPrf); + if(priority_balanser == undefined) priority_balanser = Modss.balansPrf; + 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]; + Lampa.Storage.set('online_last_balanser', last_select_balanser); + } else balanser = priority_balanser; + + if (!sources[balanser]) balanser = priority_balanser; + + if (balanser == 'undefined') balanser = priority_balanser; + if (!sources[balanser]) balanser = Lampa.Arrays.getKeys(sources)[0]; + return new sources[balanser](this, object); + }; + this.proxy = function (name) { + var proxy = ''; + var need = Lampa.Storage.field('mods_proxy_' + name); + var need_url = Lampa.Storage.get('onl_mods_proxy_' + name); + var prox = Lampa.Storage.get('mods_proxy_all'); + var main = Lampa.Storage.get('mods_proxy_main', false); + var myprox = Protocol() +'prox.lampa.stream/'; + var proxys = 'https://cors.lampa.stream/' + (IP ? 'ip' + IP + '/' : ''); + + //if (Lampa.Storage.field('mods_proxy_main') === true || (need == 'on' && need_url.length == 0 && prox == '')) proxy = myprox; + if (need == 'on' && name == 'videocdn') return true; + if (need == 'on' && name == 'cdnmovies') return proxys; + if ((need == 'on' || main) && name == 'collaps' && need_url.length == 0) return myprox; + if ((need == 'on' || main) && name == 'hdrezka' && need_url.length == 0) return myprox; + if ((need == 'on' || main) && name == 'kinobase' && need_url.length == 0) return myprox; + else if (need == 'on' && need_url.length >= 0 && prox !== '') proxy = prox; + else if (need == 'url' || (need == 'on' && need_url.length > 0)) proxy = need_url; + else if (prox && need == 'on') proxy = prox; + //else if (main && need == 'on') proxy = myprox; + if (proxy && proxy.slice(-1) !== '/') { + proxy += '/'; + } + return proxy; + }; + this.create = function () { + return this.render(); + }; + this.search = function () { + this.activity.loader(true); + this.filter({ + source: filter_sources + }, this.getChoice()); + this.find(); + }; + this.find = function () { + var _this2 = this; + var query = (object.search || object.movie.title).trim(); + console.log(query) + + var search_date = object.search_date || object.movie.release_date || object.movie.first_air_date || object.movie.last_air_date || '0000'; + var search_year = parseInt((search_date + '').slice(0, 4)); + var orig = object.movie.original_title || object.movie.original_name; + + var display = function display(items) { + if (items && items.length) { + var is_sure = false; + if (object.movie.imdb_id) { + var tmp = items.filter(function (elem) { + return (elem.imdb_id || elem.imdbId) == object.movie.imdb_id; + }); + + if (tmp.length) { + items = tmp; + is_sure = true; + } + } + var cards = items.filter(function (c) { + var year = c.start_date || c.year || '0000'; + c.tmp_year = parseInt((year + '').slice(0, 4)); + return !c.tmp_year || !search_year || c.tmp_year > search_year - 2 && c.tmp_year < search_year + 2; + }); + + if(cards.length) { + if (orig) { + var _tmp = cards.filter(function (elem) { + return _this2.equalTitle(elem.orig_title || elem.nameOriginal || elem.en_title || elem.nameEn || elem.ru_title || elem.nameRu, orig); + }); + + if (_tmp.length) { + cards = _tmp; + is_sure = true; + } + } + + if (query) { + var _tmp2 = cards.filter(function (elem) { + return _this2.equalTitle(elem.title || elem.ru_title || elem.nameRu || elem.en_title || elem.nameEn || elem.orig_title || elem.nameOriginal, query); + }); + + if (_tmp2.length) { + cards = _tmp2; + is_sure = true; + } + } + + if (cards.length > 1 && search_year) { + var _tmp3 = cards.filter(function (c) { + return c.tmp_year == search_year; + }); + if (_tmp3.length) cards = _tmp3; + } + } else cards = items; + + if (cards.length == 1 && is_sure) { + _this2.extendChoice(); + var kinopoisk_id = cards[0].kinopoisk_id || cards[0].kinopoisk_ID || cards[0].kp_id || cards[0].kinopoiskId || cards[0].filmId; + + if (kinopoisk_id && source.searchByKinopoisk) { + source.searchByKinopoisk(object, kinopoisk_id); + } else if (cards[0].imdb_id && source.searchByImdbID) { + source.searchByImdbID(object, cards[0].imdb_id); + } else if (source.search) { + source.search(object, cards); + } else { + _this2.doesNotAnswer(); + } + } else { + _this2.similars(items); + _this2.loading(false); + } + } else _this2.doesNotAnswer(query); + }; + + var vcdn_search = function vcdn_search() { + var url; + if (balanser == 'videoapi') { + url = Protocol() +'5100.svetacdn.in/api/short'; + url = Lampa.Utils.addUrlComponent(url, 'api_token=qR0taraBKvEZULgjoIRj69AJ7O6Pgl9O'); + } else { + var prox = _this2.proxy('videocdn'); + url = Protocol() +'videocdn.tv/api/short'; + url = Lampa.Utils.addUrlComponent(url, 'api_token=3i40G5TSECmLF77oAqnEgbx61ZWaOYaE'); + } + var url_by_title = Lampa.Utils.addUrlComponent(url, 'title=' + encodeURIComponent(query)); + if (object.movie.imdb_id) url = Lampa.Utils.addUrlComponent(url, 'imdb_id=' + encodeURIComponent(object.movie.imdb_id)); + if (object.movie.kinopoisk_id || object.movie.kinopoisk_ID) url = Lampa.Utils.addUrlComponent(url, 'kinopoisk_id=' + encodeURIComponent(object.movie.kinopoisk_id || object.movie.kinopoisk_ID)); + else url = url_by_title; + network.timeout(1000 * 15); + network.silent(url, function (json) { + if (json.data && json.data.length) display(json.data); + else if (object.movie.imdb_id) { + network.timeout(1000 * 15); + network.silent(url_by_title, function (json) { + if (json.data && json.data.length) display(json.data); + else display([]); + }, function (a, c) { + _this2.doesNotAnswer(); + }); + } else display([]); + }, function (a, c) { + _this2.doesNotAnswer(); + }); + }; + + var kp_search = function kp_search() { + var url = API + 'KPfind/' + encodeURIComponent(query); + if(object.movie.imdb_id) url = API + 'KPimdb/' + encodeURIComponent(object.movie.imdb_id); + network.timeout(1000 * 15); + network.silent(url, function (json) { + if (json.items && json.items.length) display(json.items); + else if (json.films && json.films.length) display(json.films); + else display([]); + }, function (a, c) { + vcdn_search(); + }); + }; + + var letgo = function letgo(imdb_id) { + if (['videocdn', 'videoapi'].indexOf(balanser) >= 0) vcdn_search(); + else if(source.searchByKinopoisk) kp_search(); + else if (imdb_id && source.searchByImdbID) { + _this2.extendChoice(); + source.searchByImdbID(object, imdb_id); + } else { + var url = Protocol() +'videocdn.tv/api/short'; + url = Lampa.Utils.addUrlComponent(url, 'api_token=3i40G5TSECmLF77oAqnEgbx61ZWaOYaE'); + var url_end = Lampa.Utils.addUrlComponent(url, imdb_id ? 'imdb_id=' + encodeURIComponent(imdb_id) : 'title=' + encodeURIComponent(query)); + network.timeout(1000 * 15); + network["native"](url_end, function (json) { + if (json.data && json.data.length) display(json);else { + network["native"](Lampa.Utils.addUrlComponent(url, 'title=' + encodeURIComponent(query)), display.bind(_this2), kp_search()); + } + }, kp_search()); + } + }; + + if (source.searchByTitle) { + this.extendChoice(); + source.searchByTitle(object, query); + } else if (object.movie.imdb_id && source.searchByImdbID) { + this.extendChoice(); + source.searchByImdbID(object, object.movie.imdb_id); + } else if ((object.movie.kinopoisk_id || object.movie.kinopoisk_ID) && source.searchByKinopoisk) { + this.extendChoice(); + source.searchByKinopoisk(object, object.movie.kinopoisk_id || object.movie.kinopoisk_ID); + } else if (source.searchs) { + this.extendChoice(); + source.searchs(object, object.movie.kinopoisk_id || object.movie.kinopoisk_ID || object.movie.imdb_id); + } else if (object.movie.imdb_id) { + letgo(object.movie.imdb_id); + } else if (!object.movie.imdb_id && (object.movie.source == 'tmdb' || object.movie.source == 'cub')) { + var tmdburl = (object.movie.name ? 'tv' : 'movie') + '/' + object.movie.id + '/external_ids?api_key=4ef0d7355d9ffb5151e987764708ce96&language=ru'; + var baseurl = Lampa.TMDB.api(tmdburl); + network.timeout(1000 * 10); + network["native"](baseurl, function (ttid) { + object.movie.imdb_id = ttid.imdb_id; + letgo(ttid.imdb_id); + }, function (a, c) { + letgo(); + }); + } else letgo(); + }; + this.cleanTitle = function (str) { + return str.replace(/[\s.,:;’'`!?]+/g, ' ').trim(); + }; + this.normalizeTitle = function (str) { + return this.cleanTitle(str.toLowerCase().replace(/—/g, '-').replace(/ё/g, 'е')); + }; + this.equalTitle = function (t1, t2) { + return typeof t1 === 'string' && typeof t2 === 'string' && this.normalizeTitle(t1) === this.normalizeTitle(t2); + }; + this.containsTitle = function (str, title) { + return typeof str === 'string' && typeof title === 'string' && this.normalizeTitle(str).indexOf(this.normalizeTitle(title)) !== -1; + }; + this.parsePlaylist = function (str) { + var pl = []; + try { + if (str.charAt(0) === '[') { + str.substring(1).split(',[').forEach(function (item) { + if (item.endsWith(',')) item = item.substring(0, item.length - 1); + var label_end = item.indexOf(']'); + if (label_end >= 0) { + var label = item.substring(0, label_end); + if (item.charAt(label_end + 1) === '{') { + item.substring(label_end + 2).split(';{').forEach(function (voice_item) { + if (voice_item.endsWith(';')) voice_item = voice_item.substring(0, voice_item.length - 1); + var voice_end = voice_item.indexOf('}'); + if (voice_end >= 0) { + var voice = voice_item.substring(0, voice_end); + pl.push({ + label: label, + voice: voice, + links: voice_item.substring(voice_end + 1).split(' or ') + }); + } + }); + } else { + pl.push({ + label: label, + links: item.substring(label_end + 1).split(' or ') + }); + } + } + return null; + }); + } + } catch (e) {} + return pl; + }; + this.parseM3U = function (str) { + var pl = []; + + try { + var width = 0; + var height = 0; + str.split('\n').forEach(function (line) { + if (line.charAt(0) == '#') { + var resolution = line.match(/\bRESOLUTION=(\d+)x(\d+)\b/); + + if (resolution) { + width = parseInt(resolution[1]); + height = parseInt(resolution[2]); + } + } else if (line.trim().length) { + pl.push({ + width: width, + height: height, + link: line + }); + width = 0; + height = 0; + } + }); + } catch (e) {} + + return pl; + }; + this.proxyCall = function (method, url, timeout, post_data, call_success, call_fail) { + var process = function process() { + if (proxyWindow) { + timeout = timeout || 60 * 1000; + var message_id; + + try { + message_id = crypto.getRandomValues(new Uint8Array(16)).toString(); + } catch (e) {} + + if (!message_id) message_id = Math.random().toString(); + proxyCalls[message_id] = { + success: call_success, + fail: call_fail + }; + proxyWindow.postMessage({ + message: 'proxyMessage', + message_id: message_id, + method: method, + url: url, + timeout: timeout, + post_data: post_data + }, '*'); + setTimeout(function () { + var call = proxyCalls[message_id]; + + if (call) { + delete proxyCalls[message_id]; + if (call.fail) call.fail({ + status: 0, + statusText: 'timeout', + responseText: '' + }, 'timeout'); + } + }, timeout + 1000); + } else { + if (call_fail) call_fail({ + status: 0, + statusText: 'abort', + responseText: '' + }, 'abort'); + } + }; + + if (!proxyInitialized) { + proxyInitialized = true; + var proxyOrigin = API.replace('api.', '').slice(0,-1); + var proxyUrl = proxyOrigin + '/proxy.html'; + + var proxyIframe = document.createElement('iframe'); + proxyIframe.setAttribute('src', proxyUrl); + proxyIframe.setAttribute('width', '0'); + proxyIframe.setAttribute('height', '0'); + proxyIframe.setAttribute('tabindex', '-1'); + proxyIframe.setAttribute('title', 'empty'); + proxyIframe.setAttribute('style', 'display:none'); + proxyIframe.addEventListener('load', function () { + proxyWindow = proxyIframe.contentWindow; + window.addEventListener('message', function (event) { + var data = event.data; + + if (event.origin === proxyOrigin && data && data.message === 'proxyResponse' && data.message_id) { + var call = proxyCalls[data.message_id]; + + if (call) { + delete proxyCalls[data.message_id]; + + if (data.status === 200) { + if (call.success) call.success(data.responseText); + } else { + if (call.fail) call.fail({ + status: data.status, + statusText: data.statusText, + responseText: data.responseText + }); + } + } + } + }); + if (process) process(); + process = null; + }); + document.body.appendChild(proxyIframe); + setTimeout(function () { + if (process) process(); + process = null; + }, 10000); + } else { + process(); + } + }; + this.ReverseObject = function (Obj){ + var TempArr = []; + var NewObj = {}; + for (var Key in Obj){ + TempArr.push(Key); + } + for (var i = TempArr.length-1; i >= 0; i--){ + NewObj[TempArr[i]] = Obj[TempArr[i]]; + } + return NewObj; + }; + this.getChoice = function (for_balanser) { + var data = Lampa.Storage.cache('online_choice_' + (for_balanser || balanser), 3000, {}); + var save = data[selected_id || object.movie.id] || {}; + Lampa.Arrays.extend(save, { + season: 0, + voice: 0, + voice_name: '', + voice_id: 0, + episodes_view: {}, + movie_view: '' + }); + return save; + }; + this.extendChoice = function () { + extended = true; + source.extendChoice(this.getChoice()); + }; + this.saveChoice = function (choice, for_balanser) { + var data = Lampa.Storage.cache('online_choice_' + (for_balanser || balanser), 3000, {}); + data[selected_id || object.movie.id] = choice; + Lampa.Storage.set('online_choice_' + (for_balanser || balanser), data); + var last_select_balanser = Lampa.Storage.cache('online_last_balanser', 3000, {}); + last_select_balanser[object.movie.id] = (for_balanser || balanser); + Lampa.Storage.set('online_last_balanser', last_select_balanser); + }; + this.similars = function (json) { + var _this3 = this; + json.forEach(function (elem) { + var info = []; + var year = ((elem.start_date || elem.year || '') + '').slice(0, 4); + var transl = elem.translations ? String(elem.translations).split(',').slice(0, 2) : ''; + var count_s = elem.seasons_count ? elem.seasons_count + ' ' + Lampa.Lang.translate('torrent_serial_season').toLowerCase() + _this3.num_word(elem.seasons_count, ['', 'а', 'ов']) : ''; + var count_eps = elem.episodes_count ? elem.episodes_count + ' эпизод' + _this3.num_word(elem.episodes_count, ['', 'а', 'ов']) : ''; + if (year) info.push(year); + if (elem.type) info.push(elem.type == 'serial' || elem.type == 'MINI_SERIES' ? ('Cериал' + (count_s && ' - ' + count_s + ' из них ' + count_eps)) : + elem.type == 'TV_SHOW' ? 'Тв-Шоу' : + elem.type == ('movie' || 'film' || 'FILM') ? 'Фильм' : elem.type); + if (transl) info.push(transl); + if (elem.rating && elem.rating !== 'null' && elem.filmId) info.push(Lampa.Template.get('modss_online_rate', { + rate: elem.rating + }, true)); + if (elem.quality && elem.quality.length) info.push(elem.quality); + + if (elem.countries && elem.countries.length) { + info.push((elem.filmId ? elem.countries.map(function (c) { + return c.country; + }) : elem.countries.map(function(c){ + return c.title || c; + })).join(', ')); + } + + if (elem.categories && elem.categories.length) { + // info.push(elem.categories.slice(0, 4).join(', ')); + } + + var name = elem.title || elem.ru_title || elem.en_title || elem.nameRu || elem.nameEn; + var orig = elem.orig_title || elem.nameEn || ''; + elem.title = name + (orig && orig !== name ? ' / ' + orig : ''); + elem.time = elem.filmLength || ''; + elem.info = info.join(''); + var item = Lampa.Template.get('modss_online_folder', elem); + item.on('hover:enter', function () { + _this3.activity.loader(true); + + _this3.reset(); + + object.search_date = year; + selected_id = elem.id; + + _this3.extendChoice(); + + var kinopoisk_id = elem.kp_id || elem.filmId; + + if (kinopoisk_id && source.searchByKinopoisk) { + source.searchByKinopoisk(object, kinopoisk_id); + } else if (source.search) { + source.search(object, [elem]); + } else { + _this3.doesNotAnswer(); + } + }).on('hover:focus', function (e) { + last = e.target; + scroll.update($(e.target), true); + }); + scroll.append(item); + }); + }; + this.clearImages = function () { + images.forEach(function (img) { + img.onerror = function () {}; + + img.onload = function () {}; + + img.src = ''; + }); + images = []; + }; + this.reset = function () { + last = false; + clearInterval(balanser_timer); + network.clear(); + this.clearImages(); + scroll.render().find('.empty').remove(); + scroll.clear(); + }; + this.loading = function (status) { + if (status) this.activity.loader(true);else { + this.activity.loader(false); + this.activity.toggle(); + } + }; + this.filter = function (filter_items, choice) { + var _this4 = this; + var select = []; + + var add = function add(type, title) { + var need = _this4.getChoice(); + var items = filter_items[type]; + var subitems = []; + var value = need[type]; + items.forEach(function (name, i) { + subitems.push({ + title: name, + selected: value == i, + index: i + }); + }); + select.push({ + title: title, + subtitle: items[value], + items: subitems, + stype: type + }); + }; + + filter_items.source = filter_sources; + choice.source = filter_sources.indexOf(balanser); + select.push({ + title: Lampa.Lang.translate('torrent_parser_reset'), + reset: true + }, { + title: Lampa.Lang.translate('modss_balanser'), + subtitle: sources[balanser].name, + bal: true + }); + this.saveChoice(choice); + if (filter_items.voice && filter_items.voice.length) add('voice', Lampa.Lang.translate('torrent_parser_voice')); + if (filter_items.season && filter_items.season.length) add('season', Lampa.Lang.translate('torrent_serial_season')); + if (filter_items.type && filter_items.type.length) add('type', Lampa.Lang.translate('filter_video_stream') + ''); + if (filter_items.server && filter_items.server.length) add('server', Lampa.Lang.translate('filter_video_server') + ''); + if (filter_items.order && filter_items.order.length) add('order', Lampa.Lang.translate('filter_series_order') + ''); + + filter.set('filter', select); + filter.set('sort', filter_sources.map(function (e, i) { + var tpl = { + title: balansers[e], + source: e, + selected: e == balanser, + ghost: i >= (Lampa.Storage.get('pro_pub', false) ? 7 : 6) ? true : false + }; + if(i >= (Lampa.Storage.get('pro_pub', false) ? 7 : 6)) { + tpl.template = 'selectbox_icon'; + tpl.icon = '' + }; + return tpl; + })); + + this.selected(filter_items); + }; + this.closeFilter = function () { + if ($('body').hasClass('selectbox--open')) Lampa.Select.close(); + }; + this.selected = function (filter_items) { + var need = this.getChoice(), + select = []; + + for (var i in need) { + if (filter_items[i] && filter_items[i].length) { + if (i == 'voice') { + select.push(filter_translate[i] + ': ' + filter_items[i][need[i]]); + } else if (i !== 'source') { + if (filter_items.season.length >= 1) { + select.push(filter_translate.season + ': ' + filter_items[i][need[i]]); + } + } + } + } + + filter.chosen('filter', select); + filter.chosen('sort', [balanser]); + this.new_seria(); + }; + this.getEpisodes = function (season, call) { + var episodes = []; + if (typeof object.movie.id == 'number' && object.movie.name) { + var tmdburl = 'tv/' + object.movie.id + '/season/' + season + '?api_key=4ef0d7355d9ffb5151e987764708ce96&language=' + Lampa.Storage.get('language', 'ru'); + var baseurl = Lampa.TMDB.api(tmdburl); + if(object.movie.source == 'pub') baseurl = Pub.baseurl+'v1/items/'+object.movie.id+'?access_token='+ Pub.token; + network.timeout(1000 * 10); + network["native"](baseurl, function (data) { + if(object.movie.source == 'pub') { + episodes = data.item.seasons.find(function (s){ + return s.number == season; + }); + episodes = episodes && episodes.episodes || []; + } else episodes = data.episodes || []; + call(episodes); + }, function (a, c) { + call(episodes); + }); + } else call(episodes); + }; + this.append = function (item) { + item.on('hover:focus', function (e) { + last = e.target; + scroll.update($(e.target), true); + }); + scroll.append(item); + }; + this.draw = function (items) { + var _this4 = this; + var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var choice = _this4.getChoice(); + if (!items.length) return this.empty(); + + this.getEpisodes((object.movie.source == 'pub' || balanser == 'pub') || (object.movie.original_language !== 'ja' || object.movie.number_of_seasons >= choice.seasons) ? items[0].season : 1, function (episodes) { + var viewed = Lampa.Storage.cache('online_view', 5000, []); + var serial = object.movie.name ? true : false; + var fully = window.innerWidth > 480; + var scroll_to_element = false; + var scroll_to_mark = false; + + var more = object.movie.original_language == 'ja' && episodes.length > items.length && (object.movie.number_of_seasons < choice.seasons) + var ismore = true; + if (more){ + var ep = more ? episodes.slice(items.length) : episodes; + ismore = items[items.length-1].episode >= episodes[ep.length].episode_number; + if(ismore) ep = episodes.slice(items.length-((episodes.length-items.length) < items.length-1 ? 2 : 1)); + } + + items.forEach(function (element, index) { + var episode = serial && episodes.length && !params.similars ? ((ismore && more) ? ep : episodes).find(function (e, i) { + return (ismore && more) ? index == i : ((e.episode_number || e.number) == element.episode); + }) : false; + var episodee = serial && episodes.length && !params.similars ? episodes.find(function (e, i) { + return (e.episode_number || e.number) == element.episode; + }) : false; + + var episode_num = element.episode || index + 1; + var episode_last = choice.episodes_view[element.season]; + Lampa.Arrays.extend(element, { + serv: '', + info: '', + quality: '', + time: Lampa.Utils.secondsToTime((episode ? episode.runtime : object.movie.runtime) * 60, true) + }); + var hash_timeline = Lampa.Utils.hash(element.season ? [element.season, element.season > 10 ? ':' : '', element.episode, object.movie.original_title].join('') : object.movie.original_title); + var hash_behold = Lampa.Utils.hash(element.season ? [element.season, element.season > 10 ? ':' : '', element.episode, object.movie.original_title, element.voice_name].join('') : object.movie.original_title + element.voice_name); + var data = { + hash_timeline: hash_timeline, + hash_behold: hash_behold + }; + var info = []; + + if (element.season) { + element.translate_episode_end = _this4.getLastEpisode(items); + element.translate_voice = element.voice_name; + } + + element.timeline = Lampa.Timeline.view(hash_timeline); + + if (episode) { + element.title = (element.episode_name || episode.name || episode.title || element.title); + if (!element.info && episode.vote_average) info.push(Lampa.Template.get('modss_online_rate', { + rate: parseFloat(episode.vote_average + '').toFixed(1) + }, true)); + if (episode.air_date && fully) info.push(Lampa.Utils.parseTime(episode.air_date).full); + } else if (object.movie.release_date && object.movie.release_date.length > 4 && fully) { + info.push(Lampa.Utils.parseTime(object.movie.release_date).full); + } + + if (!serial && object.movie.tagline && element.info.length < 30) info.push(object.movie.tagline); + if (element.info) info.push(element.info); + if (info.length) element.info = info.map(function (i) { + return '' + i + ''; + }).join(''); + var html = Lampa.Template.get('modss_online_full', element); + var loader = html.find('.online_modss__loader'); + var image = html.find('.online_modss__img'); + + if (!serial) { + if (choice.movie_view == hash_behold) scroll_to_element = html; + } else if (typeof episode_last !== 'undefined' && episode_last == episode_num) { + scroll_to_element = html; + var cont = _this4.getChoice(); + if(Lampa.Storage.field('online_continued') && cont && cont.continued) { + cont.continued = false; + _this4.saveChoice(cont); + _this4.extendChoice(); + setTimeout(function(){ + $(html).trigger('hover:enter'); + }, balanser == 'videocdn' ? 2000 : 50); + } + } + + if (serial && element.episode) image.append('
    S' + (element.season || episode.snumber || episode.season_number || 0) + ':E' + (element.episode || episode.number || episode.episode_number || 0) + '
    '); + if (serial && !episode) { + image.append('
    ' + ('0' + (element.episode || index + 1)).slice(-2) + '
    '); + loader.remove(); + } else { + var img = html.find('img')[0]; + + img.onerror = function () { + img.src = './img/img_broken.svg'; + }; + + img.onload = function () { + image.addClass('online_modss__img--loaded'); + loader.remove(); + }; + img.src = object.movie.source == 'filmix' ? object.movie.img : object.movie.source == 'pub' ? (episode && episode.thumbnail || object.movie.background_image) : Lampa.TMDB.image('t/p/w300' + (episode ? episode.still_path : object.movie.backdrop_path)); + images.push(img); + } + + html.find('.online_modss__timeline').append(Lampa.Timeline.render(element.timeline)); + + if (Lampa.Timeline.details) { + html.find('.online_modss__timeline').append(Lampa.Timeline.details(element.timeline)); + } + + if (viewed.indexOf(hash_behold) !== -1) { + scroll_to_mark = html; + html.find('.online_modss__img').append('
    ' + Lampa.Template.get('icon_viewed', {}, true) + '
    '); + } + + element.mark = function () { + viewed = Lampa.Storage.cache('online_view', 5000, []); + + if (viewed.indexOf(hash_behold) == -1) { + viewed.push(hash_behold); + Lampa.Storage.set('online_view', viewed); + + if (html.find('.online_modss__viewed').length == 0) { + html.find('.online_modss__img').append('
    ' + Lampa.Template.get('icon_viewed', {}, true) + '
    '); + } + } + + choice = _this4.getChoice(); + + if (!serial) { + choice.movie_view = hash_behold; + } else { + choice.episodes_view[element.season] = episode_num; + } + + _this4.saveChoice(choice); + _this4.new_seria(); + }; + element.unmark = function () { + viewed = Lampa.Storage.cache('online_view', 5000, []); + + if (viewed.indexOf(hash_behold) !== -1) { + Lampa.Arrays.remove(viewed, hash_behold); + Lampa.Storage.set('online_view', viewed); + if(Lampa.Manifest.app_digital >= 177) Lampa.Storage.remove('online_view', hash_behold); + html.find('.online_modss__viewed').remove(); + _this4.new_seria(); + } + }; + element.timeclear = function () { + element.timeline.percent = 0; + element.timeline.time = 0; + element.timeline.duration = 0; + Lampa.Timeline.update(element.timeline); + _this4.new_seria(); + }; + + html.on('hover:enter', function () { + if (object.movie.id) Lampa.Favorite.add('history', object.movie, 100); + if (params.onEnter) params.onEnter(element, html, data); + }).on('hover:focus', function (e) { + last = e.target; + if(['pub', 'collaps'].indexOf(balanser) >= 0){ + $('.voices').remove(); + $('.explorer-card__descr').hide().after('
    '); + //$('.explorer-card__descr').html(Lampa.Lang.translate('#{torrent_parser_voice}:
    ' +element.voice)); + $('.voices').html(Lampa.Lang.translate('#{torrent_parser_voice}:
    ' +element.voice)); + } + + if (params.onFocus) params.onFocus(element, html, data); + scroll.update($(e.target), true); + }); + if (params.onRender) params.onRender(element, html, data); + + _this4.contextMenu({ + html: html, + element: element, + onFile: function onFile(call) { + if (params.onContextMenu) params.onContextMenu(element, html, data, call); + }, + onClearAllMark: function onClearAllMark() { + items.forEach(function (elem) { + elem.unmark(); + }); + }, + onClearAllTime: function onClearAllTime() { + items.forEach(function (elem) { + elem.timeclear(); + }); + } + }); + + scroll.append(html); + }); + + if (serial && object.movie.number_of_seasons >= choice.seasons && episodes.length > items.length && !params.similars) { + var left = episodes.slice(items.length); + left.forEach(function (episode) { + var info = []; + if (episode.vote_average) info.push(Lampa.Template.get('modss_online_rate', { + rate: parseFloat(episode.vote_average + '').toFixed(1) + }, true)); + if (episode.air_date) info.push(Lampa.Utils.parseTime(episode.air_date).full); + var air = new Date((episode.air_date + '').replace(/-/g, '/')); + var now = Date.now(); + var day = Math.round((air.getTime() - now) / (24 * 60 * 60 * 1000)); + var txt = Lampa.Lang.translate('full_episode_days_left') + ': ' + day; + var html = Lampa.Template.get('modss_online_full', { + time: Lampa.Utils.secondsToTime((episode ? episode.runtime : object.movie.runtime) * 60, true), + info: info.length ? info.map(function (i) { + return '' + i + ''; + }).join('') : '', + title: episode.name, + quality: day > 0 ? txt : '' + }); + html.css('opacity','0.3'); + + var loader = html.find('.online_modss__loader'); + var image = html.find('.online_modss__img'); + var season = items[0] ? items[0].season : 1; + html.find('.online_modss__timeline').append(Lampa.Timeline.render(Lampa.Timeline.view(Lampa.Utils.hash([season, episode.episode_number, object.movie.original_title].join(''))))); + var img = html.find('img')[0]; + + if (episode.still_path) { + img.onerror = function () { + img.src = './img/img_broken.svg'; + }; + + img.onload = function () { + image.addClass('online_modss__img--loaded'); + loader.remove(); + image.append('
    ' + ('0' + episode.episode_number).slice(-2) + '
    '); + }; + + img.src = Lampa.TMDB.image('t/p/w300' + episode.still_path); + images.push(img); + } else { + loader.remove(); + image.append('
    ' + ('0' + episode.episode_number).slice(-2) + '
    '); + } + + html.on('hover:focus', function (e) { + last = e.target; + scroll.update($(e.target), true); + }); + scroll.append(html); + }); + } + + if (scroll_to_element) { + last = scroll_to_element[0]; + } else if (scroll_to_mark) { + last = scroll_to_mark[0]; + } + + Lampa.Controller.enable('content'); + }); + }; + this.contextMenu = function (params) { + params.html.on('hover:long', function () { + function show(extra) { + var enabled = Lampa.Controller.enabled().name; + var menu = []; + + if (Lampa.Platform.is('webos')) { + menu.push({ + title: Lampa.Lang.translate('player_lauch') + ' - Webos', + player: 'webos' + }); + } + + if (Lampa.Platform.is('android')) { + menu.push({ + title: Lampa.Lang.translate('player_lauch') + ' - Android', + player: 'android' + }); + } + + + menu.push({ + title: Lampa.Lang.translate('player_lauch') + ' - Lampa', + player: 'lampa' + }); + menu.push({ + title: Lampa.Lang.translate('speedtest_button'), + speed: true + }); + menu.push({ + title: Lampa.Lang.translate('modss_video'), + separator: true + }); + menu.push({ + title: Lampa.Lang.translate('torrent_parser_label_title'), + mark: true + }); + menu.push({ + title: Lampa.Lang.translate('torrent_parser_label_cancel_title'), + unmark: true + }); + menu.push({ + title: Lampa.Lang.translate('time_reset'), + timeclear: true + }); + + if (extra) { + menu.push({ + title: Lampa.Lang.translate('copy_link'), + copylink: true + }); + } + + menu.push({ + title: Lampa.Lang.translate('more'), + separator: true + }); + + if (Lampa.Account.logged() && params.element && typeof params.element.season !== 'undefined' && params.element.translate_voice) { + menu.push({ + title: Lampa.Lang.translate('modss_voice_subscribe'), + subscribe: true + }); + } + + menu.push({ + title: Lampa.Lang.translate('modss_clear_all_marks'), + clearallmark: true + }); + menu.push({ + title: Lampa.Lang.translate('modss_clear_all_timecodes'), + timeclearall: true + }); + Lampa.Select.show({ + title: Lampa.Lang.translate('title_action'), + items: menu, + onBack: function onBack() { + Lampa.Controller.toggle(enabled); + }, + onSelect: function onSelect(a) { + if (a.mark) params.element.mark(); + if (a.unmark) params.element.unmark(); + if (a.timeclear) params.element.timeclear(); + if (a.clearallmark) params.onClearAllMark(); + if (a.timeclearall) params.onClearAllTime(); + Lampa.Controller.toggle(enabled); + + if (a.player) { + Lampa.Player.runas(a.player); + params.html.trigger('hover:enter'); + } + + if (a.speed) { + Modss.speedTest(extra.file, {title:object.search, info:[params.element.title, params.element.quality].join(' - '), balanser: (['pub', 'hdr'].indexOf(balanser) >= 0 && params.element.info && params.element.info.split('').pop() + ' - ' || '') + sources[balanser].name}); + } + + if (a.copylink) { + if (extra.quality) { + var qual = []; + + for (var i in extra.quality) { + qual.push({ + title: i, + file: extra.quality[i] + }); + } + + Lampa.Select.show({ + title: Lampa.Lang.translate('settings_server_links'), + items: qual, + onBack: function onBack() { + Lampa.Controller.toggle(enabled); + }, + onSelect: function onSelect(b) { + Lampa.Utils.copyTextToClipboard(b.file, function () { + Lampa.Noty.show(Lampa.Lang.translate('copy_secuses')); + }, function () { + Lampa.Noty.show(Lampa.Lang.translate('copy_error')); + }); + } + }); + } else { + Lampa.Utils.copyTextToClipboard(extra.file, function () { + Lampa.Noty.show(Lampa.Lang.translate('copy_secuses')); + }, function () { + Lampa.Noty.show(Lampa.Lang.translate('copy_error')); + }); + } + } + + if (a.subscribe) { + Lampa.Account.subscribeToTranslation({ + card: object.movie, + season: params.element.season, + episode: params.element.translate_episode_end, + voice: params.element.translate_voice + }, function () { + Lampa.Noty.show(Lampa.Lang.translate('modss_voice_success')); + }, function () { + Lampa.Noty.show(Lampa.Lang.translate('modss_voice_error')); + }); + } + } + }); + } + + params.onFile(show); + }).on('hover:focus', function () { + if (Lampa.Helper) Lampa.Helper.show('online_file', Lampa.Lang.translate('helper_online_file'), params.html); + }); + }; + this.empty = function (msg) { + var empty = Lampa.Template.get('list_empty'); + if (msg) empty.find('.empty__descr').text(msg); + scroll.append(empty); + this.loading(false); + }; + this.empty = function (er) { + var html = Lampa.Template.get('modss_does_not_answer', {}); + html.find('.online-empty__buttons').remove(); + html.find('.online-empty__title').text(er && er.vip ? er.vip.title : Lampa.Lang.translate('empty_title_two')); + html.find('.online-empty__time').text(er && er.vip ? er.vip.msg : er ? er: Lampa.Lang.translate('empty_text')); + scroll.append(html); + this.loading(false); + var balanser = files.render().find('.filter--sort'); + Navigator.focus(balanser[0]); + }; + this.doesNotAnswer = function (query) { + var _this6 = this; + this.reset(); + var html = Lampa.Template.get('modss_does_not_answer', { + title: (query && query.length) ? (Lampa.Lang.translate('online_query_start') + ' (' + query + ') ' + Lampa.Lang.translate('online_query_end') + Lampa.Lang.translate('modss_balanser_dont_work_from')) : Lampa.Lang.translate('modss_balanser_dont_work'), + balanser: balansers[balanser] + }); + var tic = 10; + html.find('.cancel').on('hover:enter', function () { + clearInterval(balanser_timer); + }); + html.find('.change').on('hover:enter', function () { + clearInterval(balanser_timer); + filter.render().find('.filter--sort').trigger('hover:enter'); + }); + balanser_timer = setInterval(function () { + tic--; + html.find('.timeout').text(tic); + + if (tic == 0) { + clearInterval(balanser_timer); + var keys = Lampa.Arrays.getKeys(sources); + var indx = keys.indexOf(balanser); + var next = keys[indx + 1]; + if (!next) next = keys[0]; + balanser = next; + if (Lampa.Activity.active().activity == _this6.activity) _this6.changeBalanser(balanser); + } + }, 1000); + scroll.append(html); + this.loading(false); + Lampa.Controller.enable('content'); + }; + this.emptyForQuery = function (query) { + this.empty(Lampa.Lang.translate('online_query_start') + ' (' + query + ') ' + Lampa.Lang.translate('online_query_end')); + }; + this.getLastEpisode = function (items) { + var last_episode = 0; + items.forEach(function (e) { + if (typeof e.episode !== 'undefined') last_episode = Math.max(last_episode, parseInt(e.episode)); + }); + return last_episode; + }; + this.new_seria = function () { + if (object.movie.number_of_seasons) { + setTimeout(function () { + $('.card--new_ser, .card--viewed, .full-start__right .time-line, .card--last_view').remove(); + if ($('body').find('.online').length !== 0) { + if ($('body').find('.online:last-child .torrent-item__viewed').length == 1 || $('body').find('.online:last-child .time-line.hide').length == 0) $('body').find('.full-start__poster').append("
    " + Lampa.Lang.translate('online_viewed') + "
    "); + else $('body').find('.full-start__poster').append("
    " + Lampa.Lang.translate('season_new') + " " + Lampa.Lang.translate('torrent_serial_episode') + "
    "); + } + Modss.last_view(object.movie); + }, 50); + } + }; + this.num_word = function (value, words) { + value = Math.abs(value) % 100; + var num = value % 10; + if (value > 10 && value < 20) return words[2]; + if (num > 1 && num < 5) return words[1]; + if (num == 1) return words[0]; + return words[2]; + }; + this.order = [{title: 'Стандартно', id: 'normal'}, {title: 'Инвертировать', id: 'invers'}]; + this.start = function () { + var _this7 = this; + if (Lampa.Activity.active().activity !== this.activity) return; + + if (!initialized) { + initialized = true; + this.initialize(); + } + + Lampa.Background.immediately(Lampa.Utils.cardImgBackgroundBlur(object.movie)); + Lampa.Controller.add('content', { + toggle: function toggle() { + Lampa.Controller.collectionSet(scroll.render(), files.render()); + Lampa.Controller.collectionFocus(last || false, scroll.render()); + }, + up: function up() { + if (Navigator.canmove('up')) { + Navigator.move('up'); + } else Lampa.Controller.toggle('head'); + }, + down: function down() { + Navigator.move('down'); + }, + right: function right() { + if (Navigator.canmove('right')) Navigator.move('right'); + else if (object.movie.number_of_seasons) filter.show(Lampa.Lang.translate('title_filter'), 'filter'); + else filter.show(Lampa.Lang.translate('modss_balanser'), 'sort'); + }, + left: function left(){ + var poster = files.render().find('.explorer-card__head-img'); + if(poster.hasClass('focus')) Lampa.Controller.toggle('menu'); + else if(Navigator.canmove('left')) Navigator.move('left'); + else Navigator.focus(poster[0]); + }, + gone: function gone() { + clearInterval(balanser_timer); + }, + back: this.back + }); + Lampa.Controller.toggle('content'); + }; + this.render = function () { + return files.render(); + }; + this.back = function () { + Lampa.Activity.backward(); + }; + this.pause = function () {}; + this.stop = function () {}; + this.destroy = function () { + network.clear(); + this.clearImages(); + files.destroy(); + scroll.destroy(); + clearInterval(balanser_timer); + if (source) source.destroy(); + }; + } + + function forktv(object) { + var network = new Lampa.Reguest(); + var scroll = new Lampa.Scroll({ + mask: true, + over: true, + step: 250 + }); + var items = []; + var contextmenu_all = []; + var html = $('
    '); + var body = $('
    '); + var last; + var waitload = false; + var active = 0; + this.create = function () { + var _this = this; + this.activity.loader(true); + if (object.submenu) _this.build(object.url); + else { + var u = object.url && object.url.indexOf('?') > -1 ? '&' : '?'; + network["native"](object.url + u + ForkTV.user_dev(), function (found) { + _this.build(found); + }, function (a, c) { + _this.build(a); + Lampa.Noty.show(network.errorDecode(a, c)); + }); + } + return this.render(); + }; + this.next = function (next_page_url) { + var _this2 = this; + if (waitload) return; + if (object.page < 90) { + waitload = true; + object.page++; + network["native"](next_page_url + '&' + ForkTV.user_dev(), function (result) { + _this2.append(result); + if (result.channels.length) waitload = false; + Lampa.Controller.enable('content'); + _this2.activity.loader(false); + }, function (a, c) { + Lampa.Noty.show(network.errorDecode(a, c)); + }); + } + }; + this.stream = function (data, title, youtube, subs, element, view) { + var _this = this; + if (data.indexOf('getstream') == -1 && (data.indexOf('rgfoot') > -1 || data.indexOf('torrstream') > -1 || data.indexOf('torrent') > -1)) { + this.activity.loader(true); + network.timeout(10000); + network["native"](data + '&' + ForkTV.user_dev(), function (json) { + _this.activity.loader(false); + if (json.channels.length > 0) { + var playlist = []; + var data = json.channels[0]; + if (data.stream_url) { + var first = { + title: data.title, + url: data.stream_url, + timeline: view + }; + if (json.channels.length > 1) { + json.channels.forEach(function (elem) { + playlist.push({ + title: elem.title, + url: elem.stream_url + }); + }); + } else playlist.push(first); + if (playlist.length > 1) first.playlist = playlist; + Lampa.Player.play(first); + Lampa.Player.playlist(playlist); + } else Lampa.Noty.show(data.title); + } else Lampa.Noty.show(Lampa.Lang.translate('online_nolink')); + }, function (a, e) { + _this.activity.loader(false); + Lampa.Noty.show(network.errorDecode(a, e)); + }, false, { + dataType: 'json' + }); + } else if (data && data.match(/magnet|videos|stream\?|mp4|mkv|m3u8/i)) { + if (object.title == 'IPTV') { + Lampa.Activity.push({ + url: data + '?' + ForkTV.user_dev(), + title: "MODS's TV", + component: 'modss_tv', + page: 1 + }); + } else { + var subtitles = []; + if (subs) { + subs.forEach(function (e) { + subtitles.push({ + label: e[0], + url: e[1] + }); + }); + } + var playlist = []; + var first = { + title: title, + url: data, + subtitles: subtitles, + timeline: view + }; + if (element.length > 1) { + JSON.parse(element).forEach(function (elem) { + if (elem.title.match('Описание|Торрент|Трейлер|Страны|Жанр|Похож|Модел|Студи|Катег|Превь|Тег|Порноз') == null) playlist.push({ + title: elem.title, + url: elem.stream_url + }); + }); + } else playlist.push(first); + if (playlist.length > 1) first.playlist = playlist; + Lampa.Player.play(first); + Lampa.Player.playlist(playlist); + } + } else if (youtube) { + var id = youtube.split('=')[1]; + if (Lampa.Platform.is('android')) Lampa.Android.openYoutube(id); + else _this.YouTube(id); + } + }; + this.append = function (data) { + var _this3 = this; + var viewed = Lampa.Storage.cache('online_view', 5000, []); + var bg_img = JSON.stringify(data).replace('background-image', 'background_image'); + bg_img = JSON.parse(bg_img); + bg_img.background_image && Lampa.Background.immediately(bg_img.background_image); + if (data.channels && data.channels.length == 0) { + Lampa.Noty.show('Ничего не найдено'); + } else { + var json = data.channels && data.menu && data.menu.length > 0 && data.menu[0].title != 'Трейлер' && data.next_page_url && data.next_page_url.indexOf('page=1') > -1 ? data.menu.concat(data.channels) : (object.title == 'SerialHD' && data.next_page_url && data.next_page_url.split('page=')[1] != 2) ? data.channels.slice(1) : data.channels; + json = JSON.stringify(json).replace('
    ', '
    ').replace(/\)|\(|%20/g, ''); + if (data.title == 'HDGO') { + [{ + name: 'Быстрый доступ', + id: [0, 1, 2, 3] + }, { + name: 'Фильмы', + id: [4, 14,15,16,17] + }, { + name: 'Сериалы', + id: [5, 18,19,20,21,22] + }, { + name: 'Мультфильмы', + id: [6, 23,24,25] + }, { + name: 'Мультсериалы', + id: [7, 26,27,28,29] + }, { + name: 'Аниме', + id: [8, 30,31,32,33] + }, { + name: 'Тв-Шоу', + id: [9, 34, 35,36] + }, { + name: 'Док. Сериалы', + id: [10, 37,38,39] + }, { + name: 'Док. Фильмы', + id: [11, 40,41] + }].map(function (i) { + _this3.appendHdgo({ + title: i.name, + results: JSON.parse(json).filter(function (element, id) { + if (i.id.indexOf(id) > -1) return element; + }) + }); + }); + } else { + var element = JSON.parse(json)[0]; + var infos = element.description ? element.description : element.template; + var voic = infos && infos.match(/Озвучка:(.*?)
    -1 || element.logo_30x30 && element.logo_30x30.match('mediafil') || element.logo_30x30 && element.logo_30x30.match('folder') && element.playlist_url && element.playlist_url.indexOf('torrstream?magnet') > -1) { + var image = element.before && element.before.indexOf('src') > -1 ? $('img', element.before).attr('src') : element.template && element.template.indexOf('src') > -1 ? $('img', element.template).attr('src') : element.description && element.description.indexOf('src') > -1 ? $('img', element.description).attr('src') : element.logo_30x30 && element.logo_30x30.indexOf('png') > -1 ? element.logo_30x30 : element.details && element.details.poster ? element.details.poster : './img/icons/film.svg'; + object.movie = { + img: image, + title: object.title, + original_title: '', + id: 1 + }; + var files = new Lampa.Files(object); + files.append(scroll.render()); + html.append(files.render()); + html.find('.selector').unbind('hover:enter').on('hover:enter', function () { + if (element.description || element.template) Lampa.Modal.open({ + title: element.title, + size: 'medium', + html: $(element.description ? $(element.description).attr('style', '') : element.template), + onBack: function onBack() { + Lampa.Modal.close(); + Lampa.Controller.toggle('content'); + } + }); + }); + } + JSON.parse(json).forEach(function (element) { + var stream = element.stream_url ? element.stream_url : element.playlist_url; + if (element.title.match('Описание|Трейлер') == null) { + if (element.template && element.template.indexOf('film.') > -1 || element.logo_30x30 && element.logo_30x30.match('mediafil') || element.logo_30x30 && element.logo_30x30.match('folder') && element.playlist_url && element.playlist_url.indexOf('torrstream?magnet') > -1) { + body.attr('class', ''); + scroll.body().addClass('torrent-list'); + element.quality = (voic && voic[0]) || ''; + element.info = ''; + if (element.logo_30x30 && element.logo_30x30.match(/folder|mediafil/) && stream && stream.match(/torrstream\?magnet|getstream|kinomix/)) { + var des = $(element.template || element.description).text(); + var vo = des.match(/Озвучка(.*?)Вид/) || des.match(/Перевод:(.*?)Разм/); + var vid = des.match(/Видео[:](.*?)[|]/) || des.match(/Видео[:](.*?)Длит/) || des.match(/Видео(.*?)$/); + var sed_per = des.match(/Раздают:(.*?)Качают:(.*?)(Обн|Кач|Длит)/) || des.match(/Раздают:(.*?)\s[|]\sКачают:(.*?)(Обн|Кач|Длит)/); + var size1 = des.match(/t\/s(.*?)Озв/) || des.match(/Размер:(.*?)Разд/) || $(element.template || element.description).find('.trt-size').text(); + var sizes = size1 && size1[1] || $(element.template || element.description).find('.trt-size').text(); + element.quality = ''; + if (sed_per || vid || sizes || vo) element.info = (sed_per ? '⇧' + parseInt(sed_per[1]) + '⇓' + parseInt(sed_per[2]) + ' - ' : '') + (vo ? vo[1] + ' / ' : '') + (sizes && ' ' + sizes + '

    ' || '') + (vid ? vid[0].replace(/Аудио|Звук/, ' | Аудио') : ''); + } + var card = Lampa.Template.get('onlines_v1', element); + var hash = Lampa.Utils.hash([element.title, element.ident, stream].join('')); + var view = Lampa.Timeline.view(hash); + var hash_file = Lampa.Utils.hash([element.title, element.ident, stream].join('')); + element.timeline = view; + card.append(Lampa.Timeline.render(view)); + if (Lampa.Timeline.details) card.find('.online__quality').append(Lampa.Timeline.details(view, ' / ')); + if (viewed.indexOf(hash_file) !== -1) card.append('
    ' + Lampa.Template.get('icon_star', {}, true) + '
    '); + } else { + var image = element.before && element.before.indexOf('src') > -1 ? $('img', element.before).attr('src') : element.template && element.template.indexOf('src') > -1 ? $('img', element.template).attr('src') : element.description && element.description.indexOf('src') > -1 ? $('img', element.description).attr('src') : element.logo_30x30 && element.logo_30x30.indexOf('png') > -1 ? element.logo_30x30 : element.details && element.details.poster ? element.details.poster : './img/icons/film.svg'; + if (!element.search_on) { + var time = $($(element.description).children()[0]).parent().text(); + time = time.match(/Продолжительность: (.*?)?./i); + time = time && time.shift() + ' - ' || ''; + var descr = !element.ident && element.description && $($(element.description).children()[1]) ? $($(element.description).children()[1]).text().slice(0, 130) || $($(element.description).children()[0]).parent().text().slice(0, 130) : ''; + var info = element.description ? element.description : element.template; + var voice = info && info.match(/Озвучка[:](.*?)(Субтит|<\/div><\/div>|')[2].trim().split(/,\s|\s/)[0] : ''; + var rating = $(element.template).find('.a-r').text(); + var peer = info && info.split(/]*>|<\/div>/).find(function (itm) { + if (itm.match(/Качают|Скачивают|Leechers/)) return itm; + }); + var seed = info && info.split(/]*>|<\/div>/).find(function (itm) { + if (itm.match('Раздают|Seeders')) return itm; + }); + } + var card = Lampa.Template.get('card', { + title: element.title || element.details && element.details.name, + release_year: (size && size[0] + ' | ') + voice && voice[1] ? (voice[1].indexOf(',') > -1 ? voice[1].split(',')[0] : voice[1]) : '' + }); + if (rating) card.find('.card__view').append('
    ' + rating + '
    '); + if (qual2) card.find('.card__view').append('
    ' + qual2 + '
    '); + if (seed) card.find('.card__view').append('
    ' + parseInt(seed.match(/ \d+/) ? seed.match(/ \d+/)[0] : seed.match(/\d+/)[0]) + '' + parseInt(peer.match(/ \d+/) ? peer.match(/ \d+/)[0] : peer.match(/\d+/)[0]) + '
    '); + card.addClass(isNaN(element.ident) && (element.home || typeof element.details != 'undefined' || element.title == 'Все' || element.title.match(/Всі|Обновлен|жанры|сезон|Наше|Зарубеж|Женск|Муж|Отеч|Фил|Сериал|Мул|Худ/g) !== null || element.template && element.template.indexOf('svg') > -1 || element.logo_30x30 && element.logo_30x30.match(/ttv|right|succes|server|info|cloud|translate|error|trailer|uhd|webcam|mediafile|viewed|new|top|country|genre|similarmenu|filter/g) != null || stream && (stream.indexOf('browse') > -1 || stream.indexOf('viewforum') > -1 || stream.indexOf('me/list?actor=') > -1 || stream.indexOf('genre=') > -1) || element.playlist_url && element.playlist_url.indexOf('actor') == -1 && element.playlist_url && element.playlist_url.indexOf('voice?') == -1 && element.playlist_url && element.playlist_url.match(/cat=|page=|year=|list\?direc|genre|list\?actor|country/g) !== null || element.playlist_url && element.playlist_url.indexOf('view?id') == -1 && element.playlist_url && element.playlist_url.indexOf('stream?id') == -1 && element.playlist_url && element.playlist_url.indexOf('details?') == -1 && object.title.indexOf('HDGO') > -1 || element.logo_30x30 && element.logo_30x30.indexOf('webcam') > -1) ? 'card--collection' : 'card--category'); + if (!data.landscape && !data.details && ((/iPhone|android/i.test(navigator.userAgent) || Lampa.Platform.is('android')))) card.addClass('mobile'); + if (/iPhone|x11|nt/i.test(navigator.userAgent) && !Lampa.Platform.is('android')) card.addClass('pc'); + if (/Mozilla/i.test(navigator.userAgent) && !/Android/i.test(navigator.userAgent) || Lampa.Platform.tv()) card.addClass('tv'); + if (data.details && !data.details.images && stream && stream.match(/subcategory|submenu|page=|year=|list\?direc|genre|list\?actor|country/g) !== null) card.addClass('mobiles'); + if (element.description && element.description.indexOf('linear-gradientto') > -1 || data.landscape || data.next_page_url && data.next_page_url.indexOf('girl') > -1) card.addClass('nuam'); + if (data.next_page_url && data.next_page_url.indexOf('girl') > -1 && stream.indexOf('vporn/list?cat')) card.addClass('card--category').removeClass('card--collection'); + if (element.logo_30x30 && element.logo_30x30.match(/country|genre|filter|mediafolder/g) != null) card.addClass('hdgo'); + if (element.logo_30x30 && element.logo_30x30.match(/\/folder\./g) && stream.match(/stream|magnet|view\?|view=|\/details/g)) card.addClass('mobile card--category').removeClass('card--collection'); + if (element.logo_30x30 && element.logo_30x30.indexOf('/folder.') > -1 && stream.match(/view=/g)) card.addClass('card--category hdgo').removeClass('card--collection nuam mobile'); + if (element.logo_30x30 && element.logo_30x30.match(/mediafolder/g)) card.addClass('card--category').removeClass('card--collection'); + if (bg_img.background_image && bg_img.background_image.indexOf('18') > -1 && ((data.next_page_url && data.next_page_url.indexOf('girl') > -1) && stream.match(/pornst|models/g) !== null)) card.addClass('card--category').removeClass('nuam hdgo mobile card--collection'); + if (image && image.indexOf('film.svg') > -1) card.addClass('card--collection nuam'); + if (bg_img.background_image && bg_img.background_image.indexOf('18') > -1 && stream.match(/view\?|hdporn|channel=/g)) card.addClass('card--collection').removeClass('nuam hdgo mobile card--category'); + if (object.title.match(/Торренты|ForkTV|18\+/g)) card.addClass('home'); + if (element.logo_30x30 && element.logo_30x30.match(/country|genre|filter/g)) card.addClass('sort'); + if ((stream && stream.match(/filmix\?subcategory|rutor/) || element.submenu && element.submenu[0] && element.submenu[0].playlist_url && element.submenu[0].playlist_url.indexOf('rutor') > -1) && element.logo_30x30 && element.logo_30x30.match(/filter/g)) card.addClass('two'); + if (element.title == 'Поиск' && (stream && stream.match(/coldfilm/) || object.title == 'SerialHD')) card.addClass('searc'); + var img = card.find('img')[0]; + img.onload = function () { + card.addClass('card--loaded'); + }; + img.onerror = function (e) { + img.src = './img/img_broken.svg'; + }; + var picture = image && image.indexOf('yandex') > -1 ? 'https://cors.eu.org/' + image : image && image.indexOf('svg') > -1 ? image : image; + img.src = image; + } + //console.log ('class', card[0].className, window.innerWidth) + card.on('hover:focus hover:touch', function () { + if (this.className.indexOf('card--category') > -1) { + if (Lampa.Helper) Lampa.Helper.show('online_file', 'Удерживайте клавишу (ОК) для просмотра описания', card); + //Lampa.Background.immediately(image); + } + last = card[0]; + scroll.update(card, true); + var maxrow = Math.ceil(items.length / 7) - 1; + if (Math.ceil(items.indexOf(card) / 7) >= maxrow) + if (data.next_page_url) _this3.next(data.next_page_url); + }).on('hover:enter', function () { + if (stream || data.channels.length > 0) { + if (element.event || (stream && stream.match(/youtube|stream\?|mp4|mkv|m3u8/i))) { + _this3.stream(stream, element.title, element.infolink || element.stream_url, element.subtitles, json, view); + if (viewed.indexOf(hash_file) == -1) { + viewed.push(hash_file); + card.append('
    ' + Lampa.Template.get('icon_star', {}, true) + '
    '); + Lampa.Storage.set('online_view', viewed); + } + } else if (element.search_on) { + Lampa.Input.edit({ + value: element.playlist_url.indexOf('newserv') > -1 && Lampa.Storage.get('server_ip') ? Lampa.Storage.get('server_ip') : '', + free: true + }, function (new_value) { + if (new_value == '') { + Lampa.Controller.toggle('content'); + return; + } + if (element.playlist_url.indexOf('newserv') > -1) Lampa.Storage.set('server_ip', new_value); + var query = element.playlist_url.indexOf('newserv') > -1 ? Lampa.Storage.get('server_ip') : new_value; + var u = element.playlist_url && element.playlist_url.indexOf('?') > -1 ? '&' : '/?'; + network["native"](element.playlist_url + u + 'search=' + query + '&' + ForkTV.user_dev(), function (json) { + if (json.channels && json.channels[0].title.indexOf('по запросу') > -1) { + if (json.channels.length == 0) { + Lampa.Controller.toggle('content'); + return; + } + Lampa.Modal.open({ + title: '', + size: 'medium', + html: Lampa.Template.get('error', { + title: 'Ошибка', + text: json.channels[0].title + }), + onBack: function onBack() { + Lampa.Modal.close(); + Lampa.Controller.toggle('content'); + } + }); + } else { + Lampa.Activity.push({ + title: element.title, + url: json, + submenu: true, + component: 'forktv', + page: 1 + }); + } + }); + }); + } else if (stream == '' || image.indexOf('info.png') > -1) { + Lampa.Modal.open({ + title: element.title, + size: 'medium', + html: $('
    ' + $(element.description)[0].innerHTML + '
    '), + onBack: function onBack() { + Lampa.Modal.close(); + Lampa.Controller.toggle('content'); + } + }); + } else if (stream) { + var goto = function goto() { + var title = /*stream == 'submenu' ? element.submenu && element.submenu[0].title : */ element.details && element.details.title ? element.details.title : element.title && element.title.indexOf('l-count') > -1 ? element.title.split(' ').shift() : element.details && element.details.name ? element.details.name : element.title; + //console.log (element.submenu) + var url = stream == 'submenu' ? { + channels: element.submenu + } : stream; + Lampa.Activity.push({ + title: title, + url: url, + submenu: stream == 'submenu', + component: 'forktv', + page: 1 + }); + }; + if (element.title == '18+' && Lampa.Storage.get('mods_password')) { + Lampa.Input.edit({ + value: "", + title: "Введите пароль доступа", + free: true, + nosave: true + }, function (t) { + if (Lampa.Storage.field('mods_password') == t) goto(); + else { + Lampa.Noty.show('Неверный пароль.'); + Lampa.Controller.toggle('content'); + } + }); + } else goto(); + } else if (element.description && element.description.indexOf('доступа') > -1) { + ForkTV.checkAdd('content'); + } + } + }).on('hover:long', function () { + if (stream && stream.match('bonga|chatur|rgfoot') == null && stream.match(/stream\?|mp4|mkv|m3u8/i)) { + _this3.contextmenu({ + item: card, + view: view, + viewed: viewed, + hash_file: hash_file, + file: stream + }); + } + if ((element.template || element.description) && stream && stream.match('torrstream|getstream|mp4|kinomix') == null && stream.match(/viewtube|details|season|view\?|voice|magnet|stream\?id|mp4|m3u8/i) && (element.description || element.template)) { + Lampa.Modal.open({ + title: element.title, + size: 'medium', + html: $(element.description ? $(element.description).attr('style', '') : element.template), + onBack: function onBack() { + Lampa.Modal.close(); + Lampa.Controller.toggle('content'); + } + }); + } + }); + body.append(card); + items.push(card); + } + }); + } + } + }; + this.build = function (data) { + if (data.channels && data.channels.length) { + scroll.minus(); + html.append(scroll.render()); + this.append(data); + scroll.append(body); + this.activity.toggle(); + } else { + this.activity.toggle(); + html.append(scroll.render()); + this.empty(); + } + this.activity.loader(false); + }; + this.createHdGO = function (data) { + var content = Lampa.Template.get('items_line', { + title: data.title + }); + var body = content.find('.items-line__body'); + var scroll = new Lampa.Scroll({ + horizontal: true, + step: 300 + }); + var items = []; + var active = 0; + var last; + this.create = function () { + scroll.render().find('.scroll__body').addClass('items-cards'); + content.find('.items-line__title').text(data.title); + data.results.forEach(this.append.bind(this)); + body.append(scroll.render()); + }; + this.item = function (data) { + var item = Lampa.Template.get('hdgo_item', { + title: data.title + }); + if (/iPhone|x11|nt|Mozilla/i.test(navigator.userAgent) || Lampa.Platform.tv()) item.addClass('card--collection').find('.card__age').remove(); + if (/iPhone|x11|nt/i.test(navigator.userAgent) && !Lampa.Platform.is('android')) item.addClass('hdgo pc'); + if (Lampa.Platform.tv()) item.addClass('hdgo tv'); + var logo = data.logo_30x30 ? data.logo_30x30 : data.template && data.template.indexOf('src') > -1 ? $('img', data.template).attr('src') : 'img/actor.svg'; + var img = item.find('img')[0]; + img.onerror = function () { + img.src = './img/img_broken.svg'; + }; + img.src = logo; + this.render = function () { + return item; + }; + this.destroy = function () { + img.onerror = function () {}; + img.onload = function () {}; + img.src = ''; + item.remove(); + }; + }; + this.append = function (element) { + var _this = this; + var item$1 = new _this.item(element); + item$1.render().on('hover:focus hover:touch', function () { + scroll.render().find('.last--focus').removeClass('last--focus'); + item$1.render().addClass('last--focus'); + + last = item$1.render()[0]; + active = items.indexOf(item$1); + scroll.update(items[active].render(), true); + }).on('hover:enter', function () { + if (element.search_on) { + Lampa.Input.edit({ + value: '', + free: true + }, function (new_value) { + var query = new_value; + var u = element.playlist_url && element.playlist_url.indexOf('?') > -1 ? '&' : '/?'; + network["native"](element.playlist_url + u + 'search=' + query + '&' + ForkTV.user_dev(), function (json) { + if (json.channels[0].title.indexOf('Нет результатов') == -1) { + Lampa.Activity.push({ + title: element.title, + url: json, + submenu: true, + component: 'forktv', + page: 1 + }); + } else { + Lampa.Modal.open({ + title: '', + size: 'medium', + html: Lampa.Template.get('error', { + title: 'Ошибка', + text: json.channels[0].title + }), + onBack: function onBack() { + Lampa.Modal.close(); + Lampa.Controller.toggle('content'); + } + }); + } + }); + }); + } else { + Lampa.Activity.push({ + title: element.title, + url: element.playlist_url, + submenu: false, + component: 'forktv', + page: 1 + }); + } + }); + scroll.append(item$1.render()); + items.push(item$1); + }; + this.toggle = function () { + var _this = this; + Lampa.Controller.add('hdgo_line', { + toggle: function toggle() { + Lampa.Controller.collectionSet(scroll.render()); + Lampa.Controller.collectionFocus(last || false, scroll.render()); + }, + right: function right() { + Navigator.move('right'); + Lampa.Controller.enable('hdgo_line'); + }, + left: function left() { + if (Navigator.canmove('left')) Navigator.move('left'); + else if (_this.onLeft) _this.onLeft(); + else Lampa.Controller.toggle('menu'); + }, + down: this.onDown, + up: this.onUp, + gone: function gone() {}, + back: this.onBack + }); + Lampa.Controller.toggle('hdgo_line'); + }; + this.render = function () { + return content; + }; + this.destroy = function () { + Lampa.Arrays.destroy(items); + scroll.destroy(); + content.remove(); + items = null; + }; + }; + this.appendHdgo = function (data) { + var _this = this; + var item = new _this.createHdGO(data); + item.create(); + item.onDown = this.down.bind(this); + item.onUp = this.up.bind(this); + item.onBack = this.back.bind(this); + scroll.append(item.render()); + items.push(item); + }; + this.YouTube = function (id) { + var player, html$7, timer$1; + + function create$f(id) { + html$7 = $('
    '); + $('body').append(html$7); + player = new YT.Player('youtube-player', { + height: window.innerHeight, + width: window.innerWidth, + playerVars: { + 'controls': 0, + 'showinfo': 0, + 'autohide': 1, + 'modestbranding': 1, + 'autoplay': 1 + }, + videoId: id, + events: { + onReady: function onReady(event) { + event.target.playVideo(); + update$2(); + }, + onStateChange: function onStateChange(state) { + if (state.data == 0) { + Lampa.Controller.toggle('content'); + } + } + } + }); + } + + function update$2() { + timer$1 = setTimeout(function () { + var progress = player.getCurrentTime() / player.getDuration() * 100; + $('#youtube-player__progress').css('width', progress + '%'); + update$2(); + }, 400); + } + + function play(id) { + create$f(id); + Lampa.Controller.add('youtube', { + invisible: true, + toggle: function toggle() {}, + right: function right() { + player.seekTo(player.getCurrentTime() + 10, true); + }, + left: function left() { + player.seekTo(player.getCurrentTime() - 10, true); + }, + enter: function enter() {}, + gone: function gone() { + destroy$2(); + }, + back: function back() { + Lampa.Controller.toggle('content'); + } + }); + Lampa.Controller.toggle('youtube'); + } + + function destroy$2() { + clearTimeout(timer$1); + player.destroy(); + html$7.remove(); + html$7 = null; + } + play(id); + }; + this.contextmenu = function (params) { + var _this = this; + contextmenu_all.push(params); + var enabled = Lampa.Controller.enabled().name; + var menu = [{ + title: Lampa.Lang.translate('torrent_parser_label_title'), + mark: true + }, { + title: Lampa.Lang.translate('torrent_parser_label_cancel_title'), + clearmark: true + }, { + title: Lampa.Lang.translate('online_title_clear_all_mark'), + clearmark_all: true + }, { + title: Lampa.Lang.translate('time_reset'), + timeclear: true + }, { + title: Lampa.Lang.translate('online_title_clear_all_timecode'), + timeclear_all: true + }, { + title: Lampa.Lang.translate('copy_link'), + copylink: true + }]; + if (Lampa.Platform.is('webos')) { + menu.push({ + title: Lampa.Lang.translate('player_lauch') + ' - Webos', + player: 'webos' + }); + } + if (Lampa.Platform.is('android')) { + menu.push({ + title: Lampa.Lang.translate('player_lauch') + ' - Android', + player: 'android' + }); + } + menu.push({ + title: Lampa.Lang.translate('player_lauch') + ' - Lampa', + player: 'lampa' + }); + Lampa.Select.show({ + title: Lampa.Lang.translate('title_action'), + items: menu, + onBack: function onBack() { + Lampa.Controller.toggle(enabled); + }, + onSelect: function onSelect(a) { + if (a.clearmark) { + Lampa.Arrays.remove(params.viewed, params.hash_file); + Lampa.Storage.set('online_view', params.viewed); + params.item.find('.torrent-item__viewed').remove(); + } + if (a.clearmark_all) { + contextmenu_all.forEach(function (params) { + Lampa.Arrays.remove(params.viewed, params.hash_file); + Lampa.Storage.set('online_view', params.viewed); + params.item.find('.torrent-item__viewed').remove(); + }); + } + if (a.mark) { + if (params.viewed.indexOf(params.hash_file) == -1) { + params.viewed.push(params.hash_file); + params.item.append('
    ' + Lampa.Template.get('icon_star', {}, true) + '
    '); + Lampa.Storage.set('online_view', params.viewed); + } + } + if (a.timeclear) { + params.view.percent = 0; + params.view.time = 0; + params.view.duration = 0; + Lampa.Timeline.update(params.view); + Lampa.Arrays.remove(params.viewed, params.hash_file); + params.item.find('.torrent-item__viewed').remove(); + Lampa.Storage.set('online_view', params.viewed); + } + if (a.timeclear_all) { + contextmenu_all.forEach(function (params) { + params.view.percent = 0; + params.view.time = 0; + params.view.duration = 0; + Lampa.Timeline.update(params.view); + Lampa.Arrays.remove(params.viewed, params.hash_file); + params.item.find('.torrent-item__viewed').remove(); + Lampa.Storage.set('online_view', params.viewed); + }); + } + Lampa.Controller.toggle(enabled); + if (a.player) { + Lampa.Player.runas(a.player); + params.item.trigger('hover:enter'); + } + if (a.copylink) { + Lampa.Utils.copyTextToClipboard(params.file, function () { + Lampa.Noty.show(Lampa.Lang.translate('copy_secuses')); + }, function () { + Lampa.Noty.show(Lampa.Lang.translate('copy_error')); + }); + } + } + }); + }; + this.empty = function () { + var empty = new Lampa.Empty(); + scroll.append(empty.render()); + this.start = empty.start; + this.activity.loader(false); + this.activity.toggle(); + }; + this.start = function () { + Lampa.Controller.add('content', { + toggle: function toggle() { + if (object.title == 'HDGO' && items.length) { + items[active].toggle(); + } else { + Lampa.Controller.collectionSet(scroll.render(), html); + Lampa.Controller.collectionFocus(last || false, scroll.render()); + } + }, + left: function left() { + if (Navigator.canmove('left')) { + Navigator.move('left'); + } else Lampa.Controller.toggle('menu'); + }, + right: function right() { + Navigator.move('right'); + }, + up: function up() { + if (Navigator.canmove('up')) Navigator.move('up'); + else Lampa.Controller.toggle('head'); + }, + down: function down() { + if (Navigator.canmove('down')) Navigator.move('down'); + }, + back: this.back + }); + Lampa.Controller.toggle('content'); + }; + this.down = function () { + active++; + active = Math.min(active, items.length - 1); + items[active].toggle(); + scroll.update(items[active].render()); + }; + this.up = function () { + active--; + if (active < 0) { + active = 0; + Lampa.Controller.toggle('head'); + } else { + items[active].toggle(); + } + scroll.update(items[active].render()); + }; + this.back = function () { + Lampa.Activity.backward(); + }; + this.pause = function () {}; + this.stop = function () {}; + this.render = function () { + return html; + }; + this.destroy = function () { + network.clear(); + scroll.destroy(); + html.remove(); + body.remove(); + network = null; + items = null; + html = null; + body = null; + }; + } + + function collection(object) { + var network = new Lampa.Reguest(); + var scroll = new Lampa.Scroll({ + mask: true, + over: true, + step: 250 + }); + var items = []; + var html = $('
    '); + var body = $('
    '); + var cors = object.sour == 'rezka' || object.sourc == 'rezka' ? Lampa.Utils.protocol() + 'prox.lampa.stream/' : object.sour == 'filmix' || object.sourc == 'filmix' ? 'http://corsanywhere.herokuapp.com/' : ''; + var cache = Lampa.Storage.cache('my_col', 5000, {}); + var info; + var last; + var waitload = false; + var relises = []; + var total_pages; + var _this1 = this; + this.create = function () { + var _this = this; + var url; + if (object.sourc == 'my_coll') { + _this.build({ + card: cache + }); + } else { + if (object.card && isNaN(object.id)) url = object.id; + else if (object.sourc == 'pub') { + if (object.search) url = object.url + '?title=' + object.search + '&sort=views-&access_token=' + Pub.token; + else url = object.url + '?sort=' + (object.sort ? object.sort : 'views-') + '&access_token=' + Pub.token; + } else if (object.sourc == 'rezka') url = object.url + '?filter=last'; + else url = object.url; + + if ((object.page == 1 && object.card_cat) || object.cards || (!object.card && !Lampa.Storage.field('light_version') && object.card_cat)) { + this.activity.loader(true); + network.silent(cors + url, function (str) { + var data = _this.card(str); + _this.build(data); + if (object.card) $('.head__title').append(' - ' + data.card.length); + }, function (a, c) { + _this.empty(network.errorDecode(a, c)); + }, false, { + dataType: 'text' + }); + } else _this.build(object.data); + } + return this.render(); + }; + this.next = function (page) { + var _this2 = this; + var url; + if (total_pages == 0 || total_pages == page) waitload = true; + if (waitload) return; + waitload = true; + object.page++; + network.clear(); + network.timeout(1000 * 40); + if (typeof page == 'undefined') return; + if (object.sourc == 'pub' && object.sour !== 'rezka') url = object.url + '?page=' + object.page + '&sort=' + (object.sort ? object.sort : 'views-') + '&access_token=' + Pub.token; + else if ((object.sourc == 'rezka' || object.sour == 'rezka') && object.data && object.data.page) url = object.data.page; + else url = page.replace(/(\d+)\/\?filter/,object.page+'/?filter'); + network.silent(cors + url, function (result) { + var data = _this2.card(result); + object.data = data; + _this2.append(data, true); + if (data.card.length) waitload = false; + //Lampa.Controller.toggle('content'); + _this2.activity.loader(false); + }, function (a, c) { + Lampa.Noty.show(network.errorDecode(a, c)); + }, false, { + dataType: 'text' + }); + }; + this.append = function (data, append) { + var _this1 = this; + var datas = Lampa.Arrays.isArray(data.card) ? data.card : Lampa.Arrays.getValues(data.card).reverse(); + datas.forEach(function (element) { + var card = new Lampa.Card(element, { + card_category: object.sourc == 'my_coll' || object.sourc == 'pub' || object.sourc == 'filmix' || !object.card_cat || object.cards ? true : false, + card_collection: object.sourc == 'my_coll' || object.sourc == 'pub' || object.sourc == 'filmix' || !object.card_cat || object.cards ? false : true, + object: object + }); + card.create(); + if(object.category && (element.watch || element.quantity)) card.render().find('.card__view').append('
    ' + (element.watch || element.quantity) + '
    '); + card.onFocus = function (target, card_data) { + last = target; + scroll.update(card.render(), true); + Lampa.Background.change(card_data.img); + if (scroll.isEnd()) _this1.next(data.page); + if (!Lampa.Platform.tv() || !Lampa.Storage.field('light_version')) { + var maxrow = Math.ceil(items.length / 7) - 1; + //if (Math.ceil(items.indexOf(card) / 7) >= maxrow) _this1.next(data.page); + } + }; + card.onEnter = function (target, card_data) { + last = target; + if (object.sour == 'rezka' || object.sour == 'filmix' || (Lampa.Storage.field('light_version') && !object.cards) && !object.card_cat || object.cards) { + Lampa.Api.search({ + query: encodeURIComponent(element.title_org) + }, function (find) { + var finded = _this1.finds(element, find); + if (finded) { + Lampa.Activity.push({ + url: '', + component: 'full', + id: finded.id, + method: finded.name ? 'tv' : 'movie', + card: finded + }); + } else { + Lampa.Noty.show(Lampa.Lang.translate('nofind_movie')); + Lampa.Controller.toggle('content'); + } + }, function () { + Lampa.Noty.show(Lampa.Lang.translate('nofind_movie')); + Lampa.Controller.toggle('content'); + }); + } else if (object.sourc == 'pub' || object.sourc == 'my_coll') { + Lampa.Activity.push({ + title: element.title, + url: object.url + '/view?id=' + (object.sourc == 'my_coll' ? element.id : element.url) + '&access_token=' + Pub.token, + sourc: 'pub', + sour: element.source, + source: 'pub', + id: element.url, + card: element, + card_cat: true, + component: !object.category ? 'full' : 'collection', + page: 1 + }); + } else { + Lampa.Activity.push({ + title: element.title, + url: element.url, + component: 'collection', + cards: true, + sourc: object.sourc, + source: object.source, + page: 1 + }); + } + }; + card.onMenu = function (target, data) { + var _this2 = this; + var enabled = Lampa.Controller.enabled().name; + var status = Lampa.Favorite.check(data); + var items = []; + if (object.category) { + items.push({ + title: cache['id_' + data.id] ? Lampa.Lang.translate('card_my_clear') : Lampa.Lang.translate('card_my_add'), + subtitle: Lampa.Lang.translate('card_my_descr'), + where: 'book' + }); + } else { + items.push({ + title: status.book ? Lampa.Lang.translate('card_book_remove') : Lampa.Lang.translate('card_book_add'), + subtitle: Lampa.Lang.translate('card_book_descr'), + where: 'book' + }, { + title: status.like ? Lampa.Lang.translate('card_like_remove') : Lampa.Lang.translate('card_like_add'), + subtitle: Lampa.Lang.translate('card_like_descr'), + where: 'like' + }, { + title: status.wath ? Lampa.Lang.translate('card_wath_remove') : Lampa.Lang.translate('card_wath_add'), + subtitle: Lampa.Lang.translate('card_wath_descr'), + where: 'wath' + }, { + title: status.history ? Lampa.Lang.translate('card_history_remove') : Lampa.Lang.translate('card_history_add'), + subtitle: Lampa.Lang.translate('card_history_descr'), + where: 'history' + }); + } + if (object.sourc == 'my_coll') { + items.push({ + title: Lampa.Lang.translate('card_my_clear_all'), + subtitle: Lampa.Lang.translate('card_my_clear_all_descr'), + where: 'clear' + }); + } + Lampa.Select.show({ + title: Lampa.Lang.translate('title_action'), + items: items, + onBack: function onBack() { + Lampa.Controller.toggle(enabled); + }, + onSelect: function onSelect(a) { + if (a.where == 'clear') { + Lampa.Storage.set('my_col', ''); + Lampa.Activity.push({ + url: object.url, + sourc: object.sourc, + source: object.source, + title: object.title, + card_cat: true, + category: true, + component: 'collection', + page: 1 + }); + Lampa.Noty.show(Lampa.Lang.translate('saved_collections_clears')); + } else if (object.category) { + data.source = object.sourc; + _this1.favorite(data, card.render()); + } else { + if (object.sour == 'filmix' || object.sour == 'rezka' || object.sourc == 'rezka' || object.sourc == 'filmix') { + Lampa.Api.search({ + query: encodeURIComponent(data.title_org) + }, function (find) { + var finded = _this1.finds(data, find); + if (finded) { + finded.url = (finded.name ? 'tv' : 'movie') + '/' + finded.id; + Lampa.Favorite.toggle(a.where, finded); + } else { + Lampa.Noty.show(Lampa.Lang.translate('nofind_movie')); + Lampa.Controller.toggle('content'); + } + }, function () { + Lampa.Noty.show(Lampa.Lang.translate('nofind_movie')); + Lampa.Controller.toggle('content'); + }); + } else { + data.source = object.source; + Lampa.Favorite.toggle(a.where, data); + } + _this2.favorite(); + } + Lampa.Controller.toggle(enabled); + } + }); + }; + card.visible(); + body.append(card.render()); + if (cache['id_' + element.id]) _this1.addicon('book', card.render()); + if (append) Lampa.Controller.collectionAppend(card.render()); + items.push(card); + }); + }; + this.addicon = function (name, card) { + card.find('.card__icons-inner').append('
    '); + }; + this.favorite = function (data, card) { + var _this = this; + if (!cache['id_' + data.id]) { + cache['id_' + data.id] = data; + Lampa.Storage.set('my_col', cache); + } else { + delete cache['id_' + data.id]; + Lampa.Storage.set('my_col', cache); + Lampa.Activity.push({ + url: object.url, + sourc: object.sourc, + source: object.source, + title: object.title, + card_cat: true, + category: true, + component: 'collection', + page: 1 + }); + } + card.find('.card__icon').remove(); + if (cache['id_' + data.id]) _this.addicon('book', card); + }; + this.build = function (data) { + var _this1 = this; + if (data.card.length || Lampa.Arrays.getKeys(data.card).length) { + Lampa.Template.add('info_coll', Lampa.Lang.translate('
    #{pub_search_coll}
    #{title_filter}
    ')); + info = Lampa.Template.get('info_coll'); + info.find('.view--category').on('hover:enter hover:click', function () { + Lampa.Input.edit({ + value: '', + free: true + }, function (name) { + if (name == '') { + Lampa.Controller.toggle('content'); + return; + } + Lampa.Activity.push({ + title: 'Поиск по - ' + name, + url: Pub.baseurl + 'v1/collections', + component: 'collection', + search: name, + card_cat: true, + category: true, + sourc: 'pub', + source: 'pub', + page: 1 + }); + }); + }); + info.find('.view--filter').on('hover:enter hover:click', function () { + var enabled = Lampa.Controller.enabled().name; + var items = [{ + title: Lampa.Lang.translate('pub_sort_views'), + id: 'views-' + }, { + title: Lampa.Lang.translate('pub_sort_watchers'), + id: 'watchers-' + }, { + title: Lampa.Lang.translate('pub_sort_updated'), + id: 'updated-' + }, { + title: Lampa.Lang.translate('pub_sort_created'), + id: 'created-' + }].filter(function (el, i) { + if (object.sort == el.id) el.selected = true; + return el; + }); + Lampa.Select.show({ + title: Lampa.Lang.translate('title_filter'), + items: items, + onBack: function onBack() { + Lampa.Controller.toggle(enabled); + }, + onSelect: function onSelect(a) { + Lampa.Activity.push({ + title: Lampa.Lang.translate('title_filter') + ' ' + a.title.toLowerCase(), + url: Pub.baseurl + 'v1/collections', + component: 'collection', + sort: a.id, + card_cat: true, + category: true, + sourc: 'pub', + source: 'pub', + page: 1 + }); + } + }); + }); + scroll.render().addClass('layer--wheight').data('mheight', info); + if (object.sourc == 'pub' && object.category) html.append(info); + html.append(scroll.render()); + scroll.onEnd = function(){ + _this1.next(data.page); + } + this.append(data); + + // if (Lampa.Platform.tv() && Lampa.Storage.field('light_version')) this.more(data); + scroll.append(body); + this.activity.loader(false); + this.activity.toggle(); + } else { + html.append(scroll.render()); + this.empty(object.search ? Lampa.Lang.translate('online_query_start') + ' (' + object.search + ') ' + Lampa.Lang.translate('online_query_end') : ''); + } + }; + this.empty = function (msg) { + var empty = msg == undefined ? new Lampa.Empty() : new Lampa.Empty({ + title: '', + descr: msg + }); + html.append(empty.render()); + _this1.start = empty.start; + _this1.activity.loader(false); + _this1.activity.toggle(); + }; + this.more = function (data) { + var _this = this; + // var more = $('
    ' + Lampa.Lang.translate('show_more') + '
    '); + // more.on('hover:focus hover:touch', function (e) { + Lampa.Controller.collectionFocus(last || false, scroll.render()); + var next = Lampa.Arrays.clone(object); + if (data.total_pages == 0 || data.total_pages == undefined) { + more.remove(); + return; + } + network.clear(); + network.timeout(1000 * 20); + var url; + if (object.sourc == 'pub') url = object.url + '?page=' + data.page + '&sort=' + (object.sort ? object.sort : 'views-') + '&access_token=' + Pub.token; + else url = data.page; + network.silent(cors + url, function (result) { + var card = _this.card(result); + next.data = card; + if (object.cards) next.cards = false; + delete next.activity; + next.page++; + if (card.card.length == 0) more.remove(); + else Lampa.Activity.push(next); + }, function (a, c) { + Lampa.Noty.show(network.errorDecode(a, c)); + }, false, { + dataType: 'text' + }); + // }); + body.append(more); + }; + this.back = function () { + last = items[0].render()[0]; + var more = $('
    '); + more.on('hover:focus', function (e) { + if (object.page > 1) { + Lampa.Activity.backward(); + } else { + Lampa.Controller.toggle('head'); + } + }); + body.prepend(more); + }; + this.card = function (str) { + var card = []; + var page; + if (object.sourc != 'pub') str = str.replace(/\n/g, ''); + if (object.card && object.card.source == 'rezka' || object.sourc == 'rezka') { + var h = $('.b-content__inline_item', str).length ? $('.b-content__inline_item', str) : $('.b-content__collections_item', str); + total_pages = $('.b-navigation', str).find('a:last-child').length; + page = $('.b-navigation', str).find('a:last-child').attr('href'); + $(h).each(function (i, html) { + card.push({ + id: $('a', html).attr('href').split('-')[0].split('/').pop(), + title: $('a:eq(1)', html).text().split(' / ').shift() || $('.title', html).text(), + title_org: $('a:eq(1)', html).text().split(' / ').shift(), + url: $('a', html).attr('href'), + img: $('img', html).attr('src'), + quantity: $('.num', html).text() + ' видео', + year: $('div:eq(2)', html).text().split(' - ').shift() + }); + }); + } else if (object.card && object.card.source == 'filmix' || object.sourc == 'filmix') { + var d = $('.playlist-articles', str); + var str = d.length ? d.html() : $('.m-list-movie', str).html(); + $(str).each(function (i, html) { + if (html.tagName == 'DIV') { + page = $(html).find('.next').attr('href'); + total_pages = $(html).find('a:last-child').length; + } + if (html.tagName == 'ARTICLE') card.push({ + id: $('a', html).attr('href').split('-')[0].split('/').pop(), + title: $('.m-movie-title', html).text() || ($('.poster', html).attr('alt') && $('.poster', html).attr('alt').split(',').shift()), + title_org: $('.m-movie-original', html).text() || $('.origin-name', html).text(), + url: $('a', html).attr('href'), + img: $('img', html).attr('src'), + quantity: $('.m-movie-quantity', html).text() || $('.count', html).text(), + year: $('.grid-item', html).text() || ($('.poster', html).attr('alt') && $('.poster', html).attr('alt').split(',').pop()) + }); + }); + } else if (object.card && object.card.source == 'pub' || object.sourc == 'pub') { + str = JSON.parse(str); + if (str.pagination) { + total_pages = str.pagination.total + 1; + page = str.pagination.current + 1; + } + if (str.items) str.items.forEach(function (element) { + card.push({ + url: element.id, + id: element.id, + watch: element.views + '/' + element.watchers, + title: element.title.split('/')[0], + original_title: element.title.split('/')[1] || element.title, + release_date: (element.year ? element.year + '' : element.years ? element.years[0] + '' : '0000'), + first_air_date: element.type && (element.type.match('serial|docuserial|tvshow') ? 'tv' : '') || '', + vote_average: element.imdb_rating || 0, + img: element.posters.big, + year: element.year, + years: element.years + }); + }); + } + return { + card: card, + page: page, + total_pages: total_pages + }; + }; + this.finds = function (element, find) { + var finded; + var filtred = function filtred(items) { + for (var i = 0; i < items.length; i++) { + var item = items[i]; + if ((element.title_org == (item.original_title || item.original_name) || element.title == (item.title || item.name)) && (item.first_air_date || item.release_date) && parseInt(element.year) == (item.first_air_date || item.release_date).split('-').shift()) { + finded = item; + break; + } + } + }; + if (find.movie && find.movie.results.length) filtred(find.movie.results); + if (find.tv && find.tv.results.length && !finded) filtred(find.tv.results); + return finded; + }; + this.start = function () { + Lampa.Controller.add('content', { + toggle: function toggle() { + Lampa.Controller.collectionSet(scroll.render(), info); + Lampa.Controller.collectionFocus(last || false, scroll.render()); + }, + left: function left() { + if (Navigator.canmove('left')) Navigator.move('left'); + else Lampa.Controller.toggle('menu'); + }, + right: function right() { + Navigator.move('right'); + }, + up: function up() { + if (Navigator.canmove('up')) Navigator.move('up'); + else Lampa.Controller.toggle('head'); + }, + down: function down() { + if (Navigator.canmove('down')) Navigator.move('down'); + }, + back: function back() { + Lampa.Activity.backward(); + } + }); + Lampa.Controller.toggle('content'); + }; + this.pause = function () {}; + this.stop = function () {}; + this.render = function () { + return html; + }; + this.destroy = function () { + network.clear(); + Lampa.Arrays.destroy(items); + scroll.destroy(); + html.remove(); + body.remove(); + network = null; + items = null; + html = null; + body = null; + info = null; + }; + } + + function Radio_n(object) { + var audio = new Audio(); + var network = new Lampa.Reguest(); + var scroll = new Lampa.Scroll({ + mask: true, + over: true, + step: 250 + }); + var items = []; + var html = $('
    '); + var body = $('
    '); + var info; + var last; + var song; + var playing = false; + this.create = function () { + var _this = this; + this.activity.loader(true); + network.silent(object.url.replace('api.',''), this.build.bind(this), function () { + var empty = new Lampa.Empty(); + html.append(empty.render()); + _this.start = empty.start; + _this.activity.loader(false); + _this.activity.toggle(); + }); + return this.render(); + }; + this.append = function (data) { + var _this3 = this; + var name = null; + var playlist = []; + data.forEach(function (element) { + var url_song = element.video; + var name_song = element.name; + if (name == null) name = name_song, song = url_song; + var card = Lampa.Template.get('card', { + title: name_song, + release_year: '' + }); + playlist.push({ + title: name_song, + url: url_song + }); + card.addClass('card--radio'); + card.find('.card__img').css({ + 'cursor': 'pointer', + 'background-color': '#353535a6' + }).attr('src', element.picture ? element.picture : './img/welcome.jpg'); + card.on('hover:focus', function () { + last = card[0]; + scroll.update(card, true); + info.find('.info__title').text(name_song); + info.find('.info__title-original').text(element.time + (element.quality ? ' / ' + element.quality : '')); + }); + card.on('hover:enter', function () { + //$(this).addClass('focus'); + $('.title_plaing').text(name_song); + card.find('.card--category').addClass('focus'); + if (url_song.indexOf('.m3u8') !== -1) { + var video = { + title: name_song, + url: url_song + }; + Lampa.Player.play(video); + Lampa.Player.playlist(playlist); + } else _this3.Player(url_song); + }); + body.append(card); + items.push(card); + }); + if (info.find('.title_plaing').text() == '') info.find('.title_plaing').text(name); + }; + this.build = function (data) { + var _this2 = this; + Lampa.Background.change(API.replace('api.','') + 'r/back.jpg'); + info = Lampa.Template.get('info_radio'); + info.find('#plbut').on('hover:enter hover:click', function () { + _this2.Player(audio.src ? audio.src : song); + }); + info.find('#stbut').on('hover:enter hover:click', function () { + _this2.showStancia(); + }); + scroll.render().addClass('layer--wheight').data('mheight', info); + html.append(info.append()); + html.append(scroll.render()); + this.append(data); + scroll.append(body); + this.activity.loader(false); + this.activity.toggle(); + }; + this.showStancia = function () { + var catalogs = [{ + title: 'Radio Record', + url: API + 'r/record/' + }, { + title: 'Ukraine', + url: API + 'r/ukraine/' + }, { + title: 'Russia', + url: API + 'r/russia/' + }, { + title: 'Rock', + url: API + 'r/rock/' + }, { + title: 'Dance', + url: API + 'r/dance/' + }, { + title: 'Rap', + url: API + 'r/rap/' + }, { + title: 'Background', + url: API + 'r/fon/' + }, { + title: 'Jazz blues', + url: API + 'r/jazz/' + }]; + Lampa.Select.show({ + title: Lampa.Lang.translate('radio_style'), + items: catalogs, + onBack: function onBack() { + Lampa.Controller.toggle('content'); + }, + onSelect: function onSelect(a) { + Lampa.Activity.push({ + url: a.url.replace('api.',''), + title: a.title, + component: 'Radio_n', + page: 1 + }); + } + }); + }; + this.Player = function (file) { + if (audio.paused || (audio.src !== file || audio.src == null)) { + audio.src = file; + audio.play(); + info.find('.title_plaing').removeClass('blink2'); + info.find('#plbut').removeClass('play').addClass('pause'); + } else { + audio.pause(); + info.find('.title_plaing').addClass('blink2'); + info.find('#plbut').removeClass('pause').addClass('play'); + } + }; + this.start = function () { + var _this = this; + Lampa.Controller.add('content', { + toggle: function toggle() { + Lampa.Controller.collectionSet(scroll.render(), info); + Lampa.Controller.collectionFocus(last || false, scroll.render()); + }, + left: function left() { + if (Navigator.canmove('left')) Navigator.move('left'); + else Lampa.Controller.toggle('menu'); + }, + right: function right() { + if (Navigator.canmove('right')) Navigator.move('right'); + else _this.showStancia(); + }, + up: function up() { + if (Navigator.canmove('up')) { + Navigator.move('up'); + } else { + if (!$('body').find('#stbut').hasClass('focus') && !$('body').find('#plbut').hasClass('focus')) { + if (!$('body').find('#stbut').hasClass('focus')) { + Lampa.Controller.collectionSet(info); + Navigator.move('right'); + } + } else Lampa.Controller.toggle('head'); + } + }, + down: function down() { + if (Navigator.canmove('down')) Navigator.move('down'); + else Lampa.Controller.toggle('content'); + }, + back: function back() { + Lampa.Activity.backward(); + } + }); + Lampa.Controller.toggle('content'); + }; + this.pause = function () { + audio.pause(); + }; + this.stop = function () {}; + this.render = function () { + return html; + }; + this.destroy = function () { + audio.pause(); + network.clear(); + scroll.destroy(); + info.remove(); + html.remove(); + body.remove(); + audio = null; + network = null; + items = null; + html = null; + body = null; + info = null; + }; + } + + function startPlugin() { + window.plugin_modss = true; + Lampa.Component.add('forktv', forktv); + Lampa.Component.add('Radio_n', Radio_n); + + Lampa.Component.add('modss_online', component); + Lampa.Component.add('collection', collection); + + Lampa.Template.add('onlines_v1', "
    {title}
    {quality}{info}
    "); + Lampa.Template.add('modss_online_css', ""); + Lampa.Template.add('modss_online_full', "
    \"\"
    {title}
    {serv} {time}
    {info}
    {quality}
    "); + Lampa.Template.add('modss_does_not_answer', "
    {title}
    #{modss_balanser_timeout}
    #{cancel}
    #{modss_change_balanser}
    "); + Lampa.Template.add('modss_online_rate', "
    {rate}
    "); + Lampa.Template.add('modss_online_folder', "
    {title}
    {time}
    {info}
    "); + Lampa.Template.add('modss_online_watched', "
    "); + Lampa.Template.add('epg_modss', "
    {title}
    {time}
    {descr}
    "); + Lampa.Template.add('icon_subs', '\n\n'); + Lampa.Template.add('modss_style', ""); + + Lampa.Template.add('hdgo_item', '
    {title}
    '); + Lampa.Template.add('hdgo_style', ''); + Lampa.Template.add('mods_radio_style', ""); + Lampa.Template.add('info_radio', '
    СТАНЦИИ
    '); + Lampa.Template.add('mods_iptv_details', '
    '); + Lampa.Template.add('mods_iptv_list', "
    #{iptv_select_playlist}
    "); + + /* + var plugins = Lampa.Storage.get('plugins','[]'); + plugins.forEach(function(plug) { + plug.url = (plug.url + '').replace('http://modss.online', 'https://lampa.stream/modss'); + }); + Lampa.Storage.set('plugins',plugins); + */ + + manifest = { + type: 'video', + version: version_modss, + name: "Онлайн - MODS's v" + version_modss, + description: 'Плагин для просмотра онлайн сериалов и фильмов', + component: 'modss_online', + onContextMenu: function onContextMenu(object) { + return { + name: Lampa.Lang.translate('online_watch'), + description: '' + }; + }, + onContextLauch: function onContextLauch(object) { + Lampa.Activity.push({ + url: '', + title: Lampa.Lang.translate('modss_title_online') + " - MODS's v" + version_modss, + component: 'modss_online', + search: object.title, + search_one: object.title, + search_two: object.original_title, + movie: object, + page: 1 + }); + } + }; + Lampa.Manifest.plugins = manifest; + if (!Lampa.Lang) { + var lang_data = {}; + Lampa.Lang = { + add: function (data) { + lang_data = data; + }, + translate: function (key) { + return lang_data[key] ? lang_data[key].ru : key; + } + } + } + Lampa.Lang.add({ + iptv_select_playlist: { + ru: 'Выберите плейлист', + uk: 'Виберіть плейлист', + en: 'Choose a playlist' + }, + iptv_add_fav: { + ru: 'Добавить в избранное', + uk: 'Додати в обране', + en: 'Add to favourites' + }, + iptv_remove_fav: { + ru: 'Убрать из избранного', + uk: 'Прибрати з вибраного', + en: 'Remove from favorites' + }, + iptv_later: { + ru: 'Потом', + uk: 'Потім', + en: 'Later' + }, + iptv_now: { + ru: 'Сейчас на:', + uk: 'Зараз на:', + en: 'Now on:' + }, + pub_sort_views: { + ru: 'По просмотрам', + uk: 'По переглядах', + en: 'By views' + }, + pub_sort_watchers: { + ru: 'По подпискам', + uk: 'За підписками', + en: 'Subscriptions' + }, + pub_sort_updated: { + ru: 'По обновлению', + uk: 'За оновленням', + en: 'By update' + }, + pub_sort_created: { + ru: 'По дате добавления', + uk: 'За датою додавання', + en: 'By date added' + }, + pub_search_coll: { + ru: 'Поиск по подборкам', + uk: 'Пошук по добіркам', + en: 'Search by collections' + }, + pub_title_all: { + ru: 'Все', + uk: 'Все', + en: 'All' + }, + pub_title_popular: { + ru: 'Популярные', + uk: 'Популярнi', + en: 'Popular' + }, + pub_title_new: { + ru: 'Новые', + uk: 'Новi', + en: 'New' + }, + pub_title_hot: { + ru: 'Горячие', + uk: 'Гарячi', + en: 'Hot' + }, + pub_title_fresh: { + ru: 'Свежие', + uk: 'Свiжi', + en: 'Fresh' + }, + pub_title_rating: { + ru: 'Рейтинговые', + uk: 'Рейтинговi', + en: 'Rating' + }, + pub_title_allingenre: { + ru: 'Всё в жанре', + uk: 'Все у жанрі', + en: 'All in the genre' + }, + pub_title_popularfilm: { + ru: 'Популярные фильмы', + uk: 'Популярні фільми', + en: 'Popular movies' + }, + pub_title_popularserial: { + ru: 'Популярные сериалы', + uk: 'Популярні сериали', + en: 'Popular series' + }, + pub_title_newfilm: { + ru: 'Новые фильмы', + uk: 'Новi фiльми', + en: 'New movies' + }, + pub_title_newserial: { + ru: 'Новые сериалы', + uk: 'Новi серiали', + en: 'New series' + }, + pub_title_newconcert: { + ru: 'Новые концерты', + uk: 'Новi концерти', + en: 'New concerts' + }, + pub_title_newdocfilm: { + ru: 'Новые док. фильмы', + uk: 'Новi док. фiльми', + en: 'New document movies' + }, + pub_title_newdocserial: { + ru: 'Новые док. сериалы', + uk: 'Новi док. серiали', + en: 'New document series' + }, + pub_title_newtvshow: { + ru: 'Новое ТВ шоу', + uk: 'Нове ТБ шоу', + en: 'New TV show' + }, + pub_modal_title: { + ru: '1. Авторизируйтесь на сайте:
    https://kino.pub/device
    2. В поле "Активация устройства" введите код.', + uk: '1. Авторизуйтесь на сайті: https://kino.pub/device
    2. Введіть код у полі "Активація пристрою".', + en: '1. Log in to the site: https://kino.pub/device
    2. Enter the code in the "Device activation" field.' + }, + pub_title_wait: { + ru: 'Ожидание идентификации кода', + uk: 'Очікування ідентифікації коду', + en: 'Waiting for code identification' + }, + pub_title_left_days: { + ru: 'Осталось: ', + uk: 'Залишилось: ', + en: 'Left days: ' + }, + pub_title_left_days_d: { + ru: 'дн.', + uk: 'дн.', + en: 'd.' + }, + pub_title_regdate: { + ru: 'Дата регистрации:', + uk: 'Дата реєстрації:', + en: 'Date of registration:' + }, + pub_date_end_pro: { + ru: 'ПРО заканчивается:', + uk: 'ПРО закінчується:', + en: 'PRO ends:' + }, + pub_auth_add_descr: { + ru: 'Добавить в свой профиль устройство', + uk: 'Додати у свій профіль пристрій', + en: 'Add a device to your profile' + }, + pub_title_not_pro: { + ru: 'ПРО не активирован', + uk: 'ПРО не активований', + en: 'PRO is not activated' + }, + pub_device_dell_noty: { + ru: 'Устройство успешно удалено', + uk: 'Пристрій успішно видалено', + en: 'Device deleted successfully' + }, + pub_device_title_options: { + ru: 'Настройки устройства', + uk: 'Налаштування пристрою', + en: 'Device Settings' + }, + pub_device_options_edited: { + ru: 'Настройки устройства изменены', + uk: 'Установки пристрою змінено', + en: 'Device settings changed' + }, + params_pub_clean_tocken: { + ru: 'Очистить токен', + uk: 'Очистити токен', + en: 'Clear token' + }, + saved_collections_clears: { + ru: 'Сохранённые подборки очищены', + uk: 'Збірки очищені', + en: 'Saved collections cleared' + }, + card_my_clear: { + ru: 'Убрать с моих подборок', + uk: 'Прибрати з моїх добірок', + en: 'Remove from my collections' + }, + card_my_add: { + ru: 'Добавить в мои подборки', + uk: 'Додати до моїх добірок', + en: 'Add to my collections' + }, + card_my_descr: { + ru: 'Смотрите в меню (Подборки)', + uk: 'Дивитесь в меню (Підбірки)', + en: 'Look in the menu (Collections)' + }, + card_my_clear_all: { + ru: 'Удалить всё', + uk: 'Видалити все', + en: 'Delete all' + }, + card_my_clear_all_descr: { + ru: 'Очистит все сохранённые подборки', + uk: 'Очистити всі збережені збірки', + en: 'Clear all saved selections' + }, + radio_style: { + ru: 'Стиль', + uk: 'Стиль', + en: 'Style' + }, + title_on_the: { + ru: 'на', + uk: 'на', + en: 'on' + }, + title_my_collections: { + ru: 'Мои подборки', + uk: 'Мої добiрки', + en: 'My collections' + }, + modss_watch: { + ru: 'Смотреть онлайн', + en: 'Watch online', + ua: 'Дивитися онлайн', + zh: '在线观看' + }, + online_no_watch_history: { + ru: 'Нет истории просмотра', + en: 'No browsing history', + ua: 'Немає історії перегляду', + zh: '没有浏览历史' + }, + modss_video: { + ru: 'Видео', + en: 'Video', + ua: 'Відео', + zh: '视频' + }, + modss_nolink: { + ru: 'Не удалось извлечь ссылку', + uk: 'Неможливо отримати посилання', + en: 'Failed to fetch link' + }, + modss_waitlink: { + ru: 'Работаем над извлечением ссылки, подождите...', + uk: 'Працюємо над отриманням посилання, зачекайте...', + be: 'Працуем над выманнем спасылкі, пачакайце...', + en: 'Working on extracting the link, please wait...', + zh: '正在提取链接,请稍候...' + }, + modss_viewed: { + ru: 'Просмотрено', + uk: 'Переглянуто', + en: 'Viewed' + }, + modss_balanser: { + ru: 'Источник', + uk: 'Джерело', + en: 'Source' + }, + helper_online_file: { + ru: 'Удерживайте клавишу "ОК" для вызова контекстного меню', + uk: 'Утримуйте клавішу "ОК" для виклику контекстного меню', + en: 'Hold the "OK" key to bring up the context menu' + }, + filter_series_order: { + ru: 'Порядок серий', + uk: 'Порядок серій', + en: 'Series order' + }, + filter_video_stream: { + ru: 'Видео поток', + uk: 'Відео потік', + en: 'Video stream' + }, + filter_video_codec: { + ru: 'Кодек', + uk: 'Кодек', + en: 'Codec' + }, + filter_video_server: { + ru: 'Сервер', + uk: 'Сервер', + en: 'Server' + }, + modss_title_online: { + ru: 'Онлайн', + uk: 'Онлайн', + en: 'Online' + }, + modss_change_balanser: { + ru: 'Изменить источник', + uk: 'Змінити источник', + en: 'Change source', + zh: '更改平衡器' + }, + modss_clear_all_marks: { + ru: 'Очистить все метки', + uk: 'Очистити всі мітки', + en: 'Clear all labels', + zh: '清除所有标签' + }, + modss_clear_all_timecodes: { + ru: 'Очистить все тайм-коды', + uk: 'Очистити всі тайм-коди', + en: 'Clear all timecodes', + zh: '清除所有时间代码' + }, + modss_title_clear_all_mark: { + ru: 'Снять отметку у всех', + uk: 'Зняти відмітку у всіх', + en: 'Unmark all' + }, + modss_title_clear_all_timecode: { + ru: 'Сбросить тайм-код у всех', + uk: 'Скинути тайм-код у всіх', + en: 'Reset timecode for all' + }, + modss_title_links: { + ru: 'Качество', + uk: 'Якість', + en: 'Quality' + }, + title_proxy: { + ru: 'Прокси', + uk: 'Проксі', + en: 'Proxy' + }, + online_proxy_title: { + ru: 'Личный прокси', + uk: 'Особистий проксі', + en: 'Your proxy' + }, + online_proxy_title_descr: { + ru: 'Если источник недоступен или не отвечает, требуется в выбранном Вами источнике "Включить" прокси, или указать ссылку на "Свой URL"', + uk: 'Якщо джерело недоступний або не відповідає, потрібно у вибраному Вами джерелі "Увімкнути" проксі, або вказати посилання на "Свій URL"', + en: 'If the source is not available or does not respond, you need to "Enable" the proxy in the source you have chosen, or specify a link to "Custom URL"' + }, + online_proxy_title_main: { + ru: 'Встроенный прокси', + uk: 'Вбудований проксі', + en: 'Built-in proxy' + }, + online_proxy_title_main_descr: { + ru: 'Позволяет использовать встроенный в систему прокси для всех', + uk: 'Дозволяє використовувати вбудований у систему проксі для всіх', + en: 'Allows you to use the built-in proxy for all' + }, + online_proxy_descr: { + ru: 'Позволяет задать личный прокси для всех', + uk: 'Дозволяє встановити особистий проксі для всіх', + en: 'Allows you to set a personal proxy for all' + }, + online_proxy_placeholder: { + ru: 'Например: http://proxy.com', + uk: 'Наприклад: http://proxy.com', + en: 'For example: http://proxy.com' + }, + online_proxy_url: { + ru: 'Свой URL', + uk: 'Свiй URL', + en: 'Mine URL' + }, + modss_voice_subscribe: { + ru: 'Подписаться на перевод', + uk: 'Підписатися на переклад', + en: 'Subscribe to translation' + }, + modss_voice_success: { + ru: 'Вы успешно подписались', + uk: 'Ви успішно підписалися', + en: 'You have successfully subscribed' + }, + modss_voice_error: { + ru: 'Возникла ошибка', + uk: 'Виникла помилка', + en: 'An error has occurred' + }, + modss_balanser_dont_work: { + ru: 'Источник ({balanser}) не отвечает на запрос.', + uk: 'Джерело ({balanser}) не відповідає на запит.', + en: 'Source ({balanser}) does not respond to the request.', + zh: '平衡器({balanser})未响应请求。' + }, + modss_balanser_timeout: { + ru: 'Источник будет переключен автоматически через 10 секунд.', + uk: 'Джерело буде переключено автоматично через 10 секунд.', + en: 'Source will be switched automatically in 10 seconds.', + zh: '平衡器将在10秒内自动切换。' + }, + modss_does_not_answer_text: { + ru: 'Сервер не отвечает на запрос.', + uk: 'Сервер не відповідає на запит.', + en: 'Server does not respond to the request.', + zh: '服务器未响应请求。' + }, + modss_balanser_dont_work_from: { + ru: ' на источнике {balanser}', + uk: ' на джерелі {balanser}', + en: ' at the source {balanser}', + }, + online_dash: { + ru: 'Предпочитать DASH вместо HLS', + uk: 'Віддавати перевагу DASH замість HLS', + be: 'Аддаваць перавагу DASH замест HLS', + en: 'Prefer DASH over HLS', + zh: '比 HLS 更喜欢 DASH' + }, + online_query_start: { + ru: 'По запросу', + uk: 'На запит', + en: 'On request' + }, + online_query_end: { + ru: 'нет результатов', + uk: 'немає результатів', + en: 'no results' + }, + title_online_continue: { + ru: 'Продолжить', + uk: 'Продовжити', + en: 'Continue' + }, + title_kb_captcha_address: { + ru: 'Требуется пройти капчу по адресу: ', + uk: 'Потрібно пройти капчу за адресою: ', + en: 'It is required to pass the captcha at: ', + }, + title_online_first_but: { + ru: 'Кнопка онлайн всегда первая', + uk: 'Кнопка онлайн завжди перша', + en: 'Online button always first' + }, + title_online_continued: { + ru: 'Продолжить просмотр', + uk: 'Продовжити перегляд', + en: 'Continue browsing' + }, + title_online_descr: { + ru: 'Позволяет запускать плеер сразу на том месте, где остановили просмотр. Работает только в ВСТРОЕННОМ плеере.', + uk: 'Дозволяє запускати плеєр одразу на тому місці, де зупинили перегляд. Працює тільки у Вбудованому плеєрі.', + en: 'Allows you to start the player immediately at the place where you stopped browsing. Works only in the INTEGRATED player.' + }, + title_online_hevc: { + ru: 'Включить поддержку HDR', + uk: 'Включити підтримку HDR', + en: 'Enable HDR Support', + }, + title_online__hevc_descr: { + ru: 'Использовать HEVC / HDR если он доступен', + uk: 'Використовувати HEVC / HDR якщо він доступний', + en: 'Use HEVC / HDR if available', + }, + title_prioriry_balanser: { + ru: 'Источник по умолчанию', + uk: 'Джерело за замовчуванням', + en: 'Default source', + }, + title_prioriry_balanser_descr: { + ru: 'Источник фильмов по умолчанию', + uk: 'Джерело фільмів за замовчуванням', + en: 'Default movie source', + }, + filmix_param_add_title: { + ru: 'Добавить ТОКЕН от Filmix', + uk: 'Додати ТОКЕН від Filmix', + en: 'Add TOKEN from Filmix' + }, + filmix_param_add_descr: { + ru: 'Добавьте ТОКЕН для подключения подписки', + uk: 'Додайте ТОКЕН для підключення передплати', + en: 'Add a TOKEN to connect a subscription' + }, + filmix_param_placeholder: { + ru: 'Например: nxjekeb57385b..', + uk: 'Наприклад: nxjekeb57385b..', + en: 'For example: nxjekeb57385b..' + }, + filmix_params_add_device: { + ru: 'Добавить устройство на ', + uk: 'Додати пристрій на ', + en: 'Add Device to ' + }, + filmix_modal_text: { + ru: 'Введите его на странице https://filmix.ac/consoles в вашем авторизованном аккаунте!', + uk: 'Введіть його на сторінці https://filmix.ac/consoles у вашому авторизованому обліковому записі!', + en: 'Enter it at https://filmix.ac/consoles in your authorized account!' + }, + filmix_modal_wait: { + ru: 'Ожидаем код', + uk: 'Очікуємо код', + en: 'Waiting for the code' + }, + filmix_copy_secuses: { + ru: 'Код скопирован в буфер обмена', + uk: 'Код скопійовано в буфер обміну', + en: 'Code copied to clipboard' + }, + filmix_copy_fail: { + ru: 'Ошибка при копировании', + uk: 'Помилка при копіюванні', + en: 'Copy error' + }, + filmix_nodevice: { + ru: 'Устройство не авторизовано', + uk: 'Пристрій не авторизований', + en: 'Device not authorized' + }, + filmix_auth_onl: { + ru: 'Для просмотра в качестве 720p нужно добавить устройство в свой аккаунт на сайте filmix иначе будет заставка на видео.

    Перейти в настройки и добавить?', + uk: 'Для перегляду в якостi 720p потрібно додати пристрій до свого облікового запису на сайті filmix інакше буде заставка на відео.

    Перейти до налаштувань і додати?', + en: 'To view in 720p quality, you need to add a device to your account on the filmix website, otherwise there will be a splash screen on the video.

    Go to settings and add?' + }, + fork_auth_modal_title: { + ru: '1. Авторизируйтесь на: http://forktv.me
    2. Потребуется оформить подписку
    3. В поле "Ваш ID/MAC" добавьте код', + uk: '1. Авторизуйтесь на: http://forktv.me
    2. Потрібно оформити передплату
    3. У полі "Ваш ID/MAC" додайте код', + en: '1. Log in to: http://forktv.me
    2. Subscription required
    3. In the "Your ID / MAC" field, add the code' + }, + fork_modal_wait: { + ru: 'Ожидание идентификации кода
    После завершения идентификации произойдет перенаправление в обновленный раздел ForkTV', + uk: 'Очiкуемо ідентифікації коду
    Після завершення ідентифікації відбудеться перенаправлення в оновлений розділ ForkTV', + en: 'Waiting for code identification
    After identification is completed, you will be redirected to the updated ForkTV section' + }, + title_status: { + ru: 'Статус', + uk: 'Статус', + en: 'Status' + }, + season_ended: { + ru: 'сезон завершён', + uk: 'сезон завершено', + en: 'season ended' + }, + season_from: { + ru: 'из', + uk: 'з', + en: 'from' + }, + season_new: { + ru: 'Новая', + uk: 'Нова', + en: 'New' + }, + info_attention: { + ru: 'Внимание', + uk: 'Увага', + en: 'Attention' + }, + info_pub_descr: { + ru: 'KinoPub платный ресурс, просмотр онлайн с тсточника, а так же спортивные ТВ каналы будут доступны после покупки PRO в аккаунте на сайте', + uk: 'KinoPub платний ресурс, перегляд онлайн з джерела, а також спортивні ТБ канали будуть доступні після покупки PRO в обліковому записі на сайті', + en: 'KinoPub a paid resource, online viewing from a source, as well as sports TV channels will be available after purchasing PRO in your account on the site' + }, + info_filmix_descr: { + ru: 'Максимально доступное качество для просмотра без подписки - 720p. Для того, чтобы смотреть фильмы и сериалы в качестве - 1080р-2160р требуется подписка PRO или PRO-PLUS на сайте', + uk: 'Максимально доступна якість для перегляду без підписки – 720p. Для того, щоб дивитися фільми та серіали як - 1080р-2160р потрібна підписка PRO або PRO-PLUS на сайтi', + en: 'The maximum available quality for viewing without a subscription is 720p. In order to watch movies and series in quality - 1080p-2160p, you need a PRO or PRO-PLUS subscription to the site' + }, + params_pub_on: { + ru: 'Включить', + uk: 'Увiмкнути', + en: 'Enable' + }, + params_pub_off: { + ru: 'Выключить', + uk: 'Вимкнути', + en: 'Disable' + }, + params_pub_on_descr: { + ru: 'Отображает источник "KinoPub", а так же подборки. Для просмотра с тсточника, а так же ТВ спорт каналов требуется подписка', + uk: 'Відображає джерело "KinoPub", а також добірки. Для перегляду з балансера, а також ТБ спорт каналів потрібна підписка', + en: 'Displays the "KinoPub" source as well as collections. To view from the source, as well as TV sports channels subscription is required' + }, + params_pub_add_source: { + ru: 'Установить источник', + uk: 'Встановити джерело', + en: 'Set source' + }, + pub_source_add_noty: { + ru: 'KinoPub установлен источником по умолчанию', + uk: 'KinoPub встановлений стандартним джерелом', + en: 'KinoPub set as default source' + }, + descr_pub_settings: { + ru: 'Настройки сервера, типа потока...', + uk: 'Налаштування сервера типу потоку...', + en: 'Server settings, stream type...' + }, + params_pub_add_source_descr: { + ru: 'Установить источник по умолчанию на KinoPub', + uk: 'Встановити стандартне джерело на KinoPub', + en: 'Set Default Source to KinoPub' + }, + params_pub_update_tocken: { + ru: 'Обновить токен', + uk: 'Оновити токен', + en: 'Update token' + }, + params_pub_dell_device: { + ru: 'Удалить привязку устройства', + uk: 'Видалити прив\'язку пристрою', + en: 'Remove device link' + }, + params_pub_dell_descr: { + ru: 'Будет удалено устройство с прывязаных устройств в аккаунте', + uk: 'Буде видалено пристрій із прив\'язаних пристроїв в обліковому записі', + en: 'The device will be removed from linked devices in the account' + }, + params_radio_enable: { + ru: 'Включить радио', + uk: 'Увiмкнути радiо', + en: 'Enable radio' + }, + params_radio_enable_descr: { + ru: 'Отображает пункт "Радио" в главном меню с популярными радио-станциями', + uk: 'Відображає пункт "Радіо" в головному меню з популярними радіостанціями', + en: 'Displays the item "Radio" in the main menu with popular radio stations' + }, + params_tv_enable: { + ru: 'Включить ТВ', + uk: 'Увiмкнути ТВ', + en: 'Enable TV' + }, + params_tv_enable_descr: { + ru: 'Отображает пункт "Modss-TV" в главном меню с популярными каналами', + uk: 'Відображає пункт "Modss-TV" в головному меню з популярними каналами', + en: 'Displays the item "Modss-TV" in the main menu with popular channels' + }, + params_collections_descr: { + ru: 'Добавляет в пункт "Подборки" популярные разделы, такие как Rezka, Filmix, KinoPub', + uk: 'Додає до пункту "Підбірки" популярні розділи, такі як Rezka, Filmix, KinoPub', + en: 'Adds to "Collections" popular sections such as Rezka, Filmix, KinoPub' + }, + params_styles_title: { + ru: 'Стилизация', + uk: 'Стилізація', + en: 'Stylization' + }, + placeholder_password: { + ru: 'Введите пароль', + uk: 'Введіть пароль', + en: 'Enter password' + }, + title_parent_contr: { + ru: 'Родительский контроль', + uk: 'Батьківський контроль', + en: 'Parental control' + }, + title_addons: { + ru: 'Дополнения', + uk: 'Додатки', + en: 'Add-ons' + }, + onl_enable_descr: { + ru: 'Позволяет просматривать фильмы, сериалы в режиме Stream', + uk: 'Дозволяє переглядати фільми, серіали в режимі Stream', + en: 'Allows you to watch movies, series in Stream mode' + }, + fork_enable_descr: { + ru: 'Отображает пункт "ForkTV" в главном меню с популярными источниками, торрентами', + uk: 'Відображає пункт "ForkTV" у головному меню з популярними джерелами, торрентами', + en: 'Displays "ForkTV" item in main menu with popular sources, torrents' + }, + title_fork_edit_cats: { + ru: 'Изменить разделы', + uk: 'Змінити розділи', + en: 'Edit Sections' + }, + title_fork_add_cats: { + ru: 'Добавить разделы', + uk: 'Додати розділи', + en: 'Add Sections' + }, + title_fork_clear: { + ru: 'Очистить разделы', + uk: 'Очистити розділи', + en: 'Clear Sections' + }, + title_fork_clear_descr: { + ru: 'Будет выполнена очистка всех выбранных разделов', + uk: 'Буде виконано очищення всіх вибраних розділів', + en: 'All selected partitions will be cleared' + }, + title_fork_clear_noty: { + ru: 'Разделы успешно очищены', + uk: 'Розділи успішно очищені', + en: 'Partitions cleared successfully' + }, + title_fork_reload_code: { + ru: 'Обновить код', + uk: 'Оновити код', + en: 'Update Code' + }, + title_fork_current: { + ru: 'Текущий', + uk: 'Поточний', + en: 'Current' + }, + title_fork_new: { + ru: 'Новый', + uk: 'Новий', + en: 'New' + }, + title_tv_clear_fav: { + ru: 'Очистить избранное', + uk: 'Очистити вибране', + en: 'Clear Favorites' + }, + title_tv_clear__fav_descr: { + ru: 'Будет выполнена очистка избранных каналов', + uk: 'Буде виконано очищення обраних каналів', + en: 'Favorite channels will be cleared' + }, + title_tv_clear_fav_noty: { + ru: 'Все избранные каналы удалены', + uk: 'Усі вибрані канали видалені', + en: 'All favorite channels have been deleted' + }, + succes_update_noty: { + ru: 'успешно обновлён', + uk: 'успішно оновлено', + en: 'successfully updated' + }, + title_enable_rating: { + ru: 'Включить рейтинг', + uk: 'Увiмкнути рейтинг', + en: 'Enable rating' + }, + title_enable_rating_descr: { + ru: 'Отображает в карточке рейтинг Кинопоиск и IMDB', + uk: 'Відображає у картці рейтинг Кінопошук та IMDB', + en: 'Displays the Kinopoisk and IMDB rating in the card' + }, + title_info_serial: { + ru: 'Информация о карточке', + uk: 'Інформація про картку', + en: 'Card Information' + }, + title_info_serial_descr: { + ru: 'Отображает информацию о количестве серий в карточке, в том числе последнею серию на постере', + uk: 'Відображає інформацію про кількість серій у картці, у тому числі останню серію на постері', + en: 'Displays information about the number of episodes in the card, including the last episode on the poster' + }, + title_add_butback: { + ru: 'Включить кнопку "Назад"', + uk: 'Увiмкнути кнопку "Назад"', + en: 'Enable back button' + }, + title_add_butback_descr: { + ru: 'Отображает внешнюю кнопку "Назад" для удобной навигации в полноэкраном режиме на различных смартфона', + uk: 'Відображає зовнішню кнопку "Назад" для зручної навігації в повноекранному режимі на різних смартфонах', + en: 'Displays an external back button for easy full-screen navigation on various smartphones' + }, + title_butback_pos: { + ru: 'Положение кнопки "Назад"', + uk: 'Розташування кнопки "Назад"', + en: 'Back button position' + }, + buttback_right: { + ru: 'Справа', + uk: 'Праворуч', + en: 'Right' + }, + buttback_left: { + ru: 'Слева', + uk: 'Лiворуч', + en: 'Left' + }, + title_close_app: { + ru: 'Закрыть приложение', + uk: 'Закрити додаток', + en: 'Close application' + }, + title_radio: { + ru: 'Радио', + uk: 'Радiо', + en: 'Radio' + } + }); + function FreeJaketOpt() { + Lampa.Arrays.getKeys(Modss.jack).map(function (el){ + jackets[el] = el.replace(/_/g,'.'); + }); + var params = Lampa.SettingsApi.getParam('parser') + if(params){ + var param = params.find(function (p){ + return p.param.name == 'jackett_url2'; + }); + if(param) Lampa.Arrays.remove(params, param); + } + Lampa.SettingsApi.addParam({ + component: 'parser', + param: { + name: 'jackett_url2', + type: 'select', + values: jackets, + default: 'jacred_ru' + }, + field: { + name: 'Публичные JACKett Ⓜ️', + description: 'Обновится после выхода из настроек' + }, + onChange: function (value) { + Lampa.Storage.set('jackett_url', Modss.jack[value].url); + Lampa.Storage.set('jackett_key', Modss.jack[value].key); + Lampa.Storage.set('jackett_interview',Modss.jack[value].interv); + Lampa.Storage.set('parse_in_search', false); + Lampa.Storage.set('parse_lang', Modss.jack[value].lang); + Lampa.Settings.update(); + }, + onRender: function (item) { + setTimeout(function() { + $('div[data-children="parser"]').on('hover:enter', function(){ + Lampa.Settings.update(); + }); + if(!API || !API.length) window.location.reload(); + $('[data-name="jackett_url2"]').on('hover:enter', function (el){ + Lampa.Select.render().find('.selectbox-item__title').map(function(i, item){ + Modss.check($(item).text().toLowerCase().replace(/\./g,'_'), function(e){ + $(item).css('color', e ? '#23ff00' : '#d10000'); + }); + }); + }); + if(Lampa.Storage.field('parser_use')) { + item.show(); + if(Boolean(Modss.jack[Lampa.Storage.get('jackett_url2')])) $('.settings-param__name', item).before('
    '); + $('[data-name="jackett_url"] .settings-param__name').before('
    '); + $('.settings-param__name', item).css('color','#f3d900'); + $('div[data-name="jackett_url2"]').insertAfter('div[data-children="parser"]'); + Modss.check($('.settings-param__value', item).text().toLowerCase().replace(/\./g,'_'), function(e){ + Modss.check(Lampa.Storage.get('jackett_url')); + $($('.settings-param__status', item)).removeClass('active error wait').addClass(e ? 'active' : 'error'); + }); + } else item.hide(); + }, 50); + } + }); + } + Lampa.Listener.follow('full', function (e) { + if (e.type == 'complite') { + cards = e.data.movie; + Modss.serialInfo(e.data.movie); + Modss.online(); + Modss.rating_kp_imdb(e.data.movie).then(function (e) { + + })['catch'](function(e){ + {START_PRELOAD} + }); + $('.view--torrent').addClass('selector').empty().append('' + Lampa.Lang.translate('full_torrents') + ''); + $('.view--trailer').empty().append("" + Lampa.Lang.translate('full_trailers') + ""); + } + }); + Lampa.Listener.follow('activity', function (e) { + if (e.component == 'full' && e.type == 'start') { + var button = Lampa.Activity.active().activity.render().find('.view--modss_online'); + if(button.length){ + cards = e.object.card; + Modss.online(button); + Modss.last_view(e.object.card); + } + } + }); + Lampa.Storage.listener.follow('change', function (e) { + //if(e.name == 'jackett_key' || e.name == 'jackett_url') Modss.check(e.value); + }); + Lampa.Settings.listener.follow('open', function (e) { + if (e.name == 'main') { + if (Lampa.Settings.main().render().find('[data-component="pub_param"]').length == 0) { + Lampa.SettingsApi.addComponent({ + component: 'pub_param', + name: 'KinoPub', + icon: '' + }); + } + if (Lampa.Settings.main().render().find('[data-component="fork_param"]').length == 0) { + Lampa.SettingsApi.addComponent({ + component: 'fork_param', + name: 'ForkTV', + icon: '' + }); + } + if (Lampa.Settings.main().render().find('[data-component="rezka_param"]').length == 0) { + Lampa.SettingsApi.addComponent({ + component: 'rezka_param', + name: 'HDRezka', + icon: '' + }); + } + if (Lampa.Settings.main().render().find('[data-component="filmix_param"]').length == 0) { + Lampa.SettingsApi.addComponent({ + component: 'filmix_param', + name: 'Filmix', + icon: '' + }); + } + if (Lampa.Settings.main().render().find('[data-component="modss_tv_param"]').length == 0) { + Lampa.SettingsApi.addComponent({ + component: 'modss_tv_param', + name: 'Modss-TV', + icon: '' + }); + } + if (Lampa.Settings.main().render().find('[data-component="modss_online_param"]').length == 0) { + Lampa.SettingsApi.addComponent({ + component: 'modss_online_param', + name: 'Modss-Online', + icon: '' + }); + } + Lampa.Settings.main().update(); + Lampa.Settings.main().render().find('[data-component="modss_online_param"], [data-component="filmix"], [data-component="rezka_param"], [data-component="pub_param"], [data-component="filmix_param"], [data-component="fork_param"], [data-component="modss_tv_param"]').addClass('hide'); + } + if (e.name == 'mods_proxy') { + $('.settings__title').text(Lampa.Lang.translate('title_proxy') + " MODS's"); + var ads = ['
    ', '
    ', '
    #{info_attention} ⚠
    ', '
    #{online_proxy_title_descr}
    ', '
    ', '
    '].join(''); + e.body.find('[data-name="mods_proxy_all"]').before(Lampa.Lang.translate(ads)); + } else $('.settings__title').text(Lampa.Lang.translate('menu_settings')); + if (e.name == 'fork_param') $('.settings__title').append(" ForkTV"); + if (e.name == 'filmix_param') { + var ads = ['
    ', '
    ', '
    #{info_attention} ⚠
    ', '
    #{info_filmix_descr} filmix.ac
    ', '
    ', '
    '].join(''); + e.body.find('[data-static="true"]:eq(0)').after(Lampa.Lang.translate(ads)); + $('.settings__title').append(" Filmix"); + } + if (e.name == 'pub_param') { + var ads = ['
    ', '
    ', '
    #{info_attention} ⚠
    ', '
    #{info_pub_descr} kino.pub
    ', '
    ', '
    '].join(''); + e.body.find('[data-static="true"]:eq(0)').after(Lampa.Lang.translate(ads)); + $('.settings__title').append(" KinoPub"); + } + if (e.name == 'modss_online_param') { + $('.settings__title').text("MODS's Online"); + var title = $('[data-name="priority_balanser"] .settings-param__value', e.body); + title.text(title.text().split('<').shift()); + } + if (e.name == 'settings_modss') { + $('.settings__title').text("MODS's "); + var title = $('[data-name="priority_balanser"] .settings-param__value', e.body); + title.text(title.text().split('<').shift()); + } + if (e.name == 'parser') FreeJaketOpt(); + }); + if (Lampa.Manifest.app_digital >= 177) { + Lampa.Storage.sync('my_col', 'object_object'); + Lampa.Storage.sync('fav_chns', 'object_object'); + Lampa.Storage.sync('online_watched_last', 'object_object'); + var balansers_sync = ["filmix", "kinobase", "hdrezka", "rezka", "videocdn", "videodb", "collaps", "hdvb", "kodik", "uakino", "kinotochka", "cdnmovies", "anilibria", "videoapi", "bazon", "pub"]; + balansers_sync.forEach(function (name) { + Lampa.Storage.sync('online_choice_' + name, 'object_object'); + }); + } + function add() { + Modss.init(); + $('body').append(Lampa.Template.get('hdgo_style', {}, true)); + $('body').append(Lampa.Template.get('mods_radio_style', {}, true)); + $('body').append(Lampa.Template.get('modss_style', {}, true)); + $('body').append(Lampa.Template.get('modss_online_css', {}, true)); + // Lampa.Storage.set('guide', ''); + setTimeout(function () { + //if (window.innerHeight > 700 && Lampa.Storage.field('guide') == 'undefined') guide(); + }, 3000); + Lampa.SettingsApi.addComponent({ + component: 'settings_modss', + name: "MODS's ", + icon: "" + }); + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_status', + type: 'static' + }, + field: { + name: '
    Не подключён
    ', + description: '' + } + }); + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_info', + type: 'title' + }, + field: { + name: '', + description: 'Для активации Vip статуса перейдите в телеграм бот @modssmy_bot
    ' + } + }); + + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_device', + type: 'title' + }, + field: { + name: ' 💻 Wget/1.21.4' + } + }); + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_password', + type: 'static', //доступно select,input,trigger,title,static + placeholder: Lampa.Lang.translate('placeholder_password'), + values: '', + default: '' + }, + field: { + name: Lampa.Lang.translate('title_parent_contr'), + description: Lampa.Lang.translate('placeholder_password') + }, + onRender: function (item) { + function pass() { + Lampa.Input.edit({ + value: '' + Lampa.Storage.get('mods_password') + '', + free: true, + nosave: true + }, function (t) { + Lampa.Storage.set('mods_password', t); + Lampa.Settings.update(); + }); + } + item.on('hover:enter', function () { + if (Lampa.Storage.get('mods_password')) Lampa.Input.edit({ + value: '', + title: 'Введите старый пароль', + free: true, + nosave: true + }, function (t) { + if (t == Lampa.Storage.get('mods_password')) pass(); + else Lampa.Noty.show('Неверный пароль'); + }); + else pass(); + }); + if (Lampa.Storage.get('mods_password')) item.find('.settings-param__descr').text('Изменить пароль'); + else item.find('.settings-param__descr').text(Lampa.Lang.translate('placeholder_password')); + }, + onChange: function (value) { + if (value) $('body').find('.settings-param__descr').text('Изменить пароль'); + else $('body').find('.settings-param__descr').text(Lampa.Lang.translate('placeholder_password')); + } + }); + //Add-ons + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_onl', + type: 'trigger', //доступно select,input,trigger,title,static + default: true + }, + field: { + name: Lampa.Lang.translate('params_pub_on') + ' ' + Lampa.Lang.translate('modss_title_online').toLowerCase(), + description: Lampa.Lang.translate('onl_enable_descr') + }, + onChange: function (value) { + if(cards) Modss.online('delete'); + Lampa.Settings.update(); + } + }); + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'modss_online_param', + type: 'static', //доступно select,input,trigger,title,static + default: true + }, + field: { + name: '
    Online
    ' + }, + onRender: function (item) { + if (Lampa.Storage.field('mods_onl')) { + item.show(); + } else item.hide(); + item.on('hover:enter', function () { + Lampa.Settings.create('modss_online_param'); + Lampa.Controller.enabled().controller.back = function(){ + Lampa.Settings.create('settings_modss'); + } + }); + } + }); + Lampa.SettingsApi.addParam({ + component: 'modss_online_param', + param: { + name: 'priority_balanser', + type: 'select', //доступно select,input,trigger,title,static + values: Modss.balansers(), + default: Modss.balansPrf + }, + field: { + name: Lampa.Lang.translate('title_prioriry_balanser'), + description: Lampa.Lang.translate('title_prioriry_balanser_descr') + }, + onRender: function (item) { + if (Lampa.Storage.field('mods_onl')) item.show(); + else item.hide(); + }, + onChange: function (values) { + var title = $('body').find('[data-name="priority_balanser"] .settings-param__value'); + title.text(title.text().split('<').shift()); + } + }); + Lampa.SettingsApi.addParam({ + component: 'modss_online_param', + param: { + name: 'online_but_first', + type: 'trigger', //доступно select,input,trigger,title,static + default: true + }, + field: { + name: Lampa.Lang.translate('title_online_first_but'), + }, + onChange: function (item) { + Lampa.Storage.set('full_btn_priority', ''); + }, + onRender: function (item) { + if (Lampa.Storage.field('mods_onl')) item.show(); + else item.hide(); + } + }); + Lampa.SettingsApi.addParam({ + component: 'modss_online_param', + param: { + name: 'online_continued', + type: 'trigger', //доступно select,input,trigger,title,static + default: true + }, + field: { + name: Lampa.Lang.translate('title_online_continued'), + description: Lampa.Lang.translate('title_online_descr') + }, + onRender: function (item) { + if (Lampa.Storage.field('mods_onl')) item.show(); + else item.hide(); + } + }); + Lampa.SettingsApi.addParam({ + component: 'modss_online_param', + param: { + name: 'online_dash', + type: 'trigger', //доступно select,input,trigger,title,static + default: false + }, + field: { + name: Lampa.Lang.translate('online_dash'), + description: Lampa.Lang.translate('modss_balanser') + ' Collaps' + }, + onRender: function (item) { + if (Lampa.Storage.field('mods_onl')) item.show(); + else item.hide(); + } + }); + //Filmix + Lampa.SettingsApi.addParam({ + component: 'modss_online_param', + param: { + name: 'filmix_param', + type: 'static', //доступно select,input,trigger,title,static + default: true + }, + field: { + name: '
    Filmix
    ', + description: ' ' + }, + onRender: function (item) { + if (Lampa.Storage.field('mods_onl')) { + item.show(); + $('.settings-param__name', item).before('
    '); + Filmix.checkPro(Filmix.token); + Filmix.showStatus(item); + } else item.hide(); + item.on('hover:enter', function () { + Lampa.Settings.create('filmix_param'); + Lampa.Controller.enabled().controller.back = function(){ + Lampa.Settings.create('modss_online_param'); + } + }); + } + }); + Lampa.SettingsApi.addParam({ + component: 'filmix_param', + param: { + name: 'filmix_status', + type: 'title', //доступно select,input,trigger,title,static + default: '' + }, + field: { + name: '' + Lampa.Lang.translate('title_status') + '', + description: ' ' + }, + onRender: function (item) { + $('.settings-param__descr', item).before('
    '); + Filmix.showStatus(item); + } + }); + Lampa.SettingsApi.addParam({ + component: 'filmix_param', + param: { + name: 'filmix_token', + type: 'input', //доступно select,input,trigger,title,static + values: '', + placeholder: Lampa.Lang.translate('filmix_param_placeholder'), + default: '' + }, + field: { + name: Lampa.Lang.translate('filmix_param_add_title'), + description: Lampa.Lang.translate('filmix_param_add_descr') + }, + onChange: function (value) { + if (value) { + Filmix.checkPro(value, true); + Filmix.token = value; + } else { + Lampa.Storage.set("filmix_status", {}); + Filmix.token = value; + Filmix.showStatus(); + } + } + }); + Lampa.SettingsApi.addParam({ + component: 'filmix_param', + param: { + name: 'filmix_add', + type: 'static', //доступно select,input,trigger,title,static + default: '' + }, + field: { + name: Lampa.Lang.translate('filmix_params_add_device') + ' Filmix', + description: '' + }, + onRender: function (item) { + item.on('hover:enter', function () { + Filmix.add_new(); + }); + } + }); + //Pub + Lampa.SettingsApi.addParam({ + component: 'modss_online_param', + param: { + name: 'pub_param', + type: 'static', //доступно select,input,trigger,title,static + default: true + }, + field: { + name: '
    KinoPub
    ', + description: Lampa.Lang.translate('filmix_nodevice') + }, + onRender: function (item) { + if (Lampa.Storage.field('mods_onl')) { + item.show(); + $('.settings-param__name', item).before('
    '); + Pub.userInfo(item, true); + } else item.hide(); + item.on('hover:enter', function () { + Lampa.Settings.create('pub_param'); + Lampa.Controller.enabled().controller.back = function(){ + Lampa.Settings.create('modss_online_param'); + }; + }); + } + }); + Lampa.SettingsApi.addParam({ + component: 'pub_param', + param: { + name: 'pub_auth', + type: 'static' //доступно select,input,trigger,title,static + }, + field: { + name: ' ', + description: ' ', + }, + onRender: function (item) { + $('.settings-param__name', item).before('
    '); + Pub.userInfo(item); + } + }); + Lampa.SettingsApi.addParam({ + component: 'pub_param', + param: { + name: 'pub_auth_add', + type: 'static' //доступно select,input,trigger,title,static + }, + field: { + name: Lampa.Lang.translate('filmix_params_add_device') + ' KinoPub', + description: Lampa.Lang.translate('pub_auth_add_descr') + }, + onRender: function (item) { + item.on('hover:enter', function () { + Pub.Auth_pub(); + }); + } + }); + Lampa.SettingsApi.addParam({ + component: 'modss_online_param', + param: { + name: 'pub_speed', + type: 'static', //доступно select,input,trigger,title,static + }, + field: { + name: 'SpeedTest', + description: 'Выбор лучшего сервера Pub' + }, + onRender: function (item) { + item.on('hover:enter', function(){ + Lampa.Iframe.show({ + url: 'http://zamerka.com/', + onBack: function onBack() { + Lampa.Controller.toggle('settings_component'); + } + }); + }); + if (!Lampa.Storage.field('mods_onl')) item.hide(); + } + }); + Lampa.SettingsApi.addParam({ + component: 'pub_param', + param: { + name: 'pub_parametrs', + type: 'static' //доступно select,input,trigger,title,static + }, + field: { + name: Lampa.Lang.translate('title_settings'), + description: Lampa.Lang.translate('descr_pub_settings') + }, + onRender: function (item) { + if (!Lampa.Storage.get('logined_pub')) item.hide(); + item.on('hover:enter', function () { + Pub.info_device(); + }); + } + }); + Lampa.SettingsApi.addParam({ + component: 'pub_param', + param: { + name: 'pub_source', + type: 'static' //доступно select,input,trigger,title,static + }, + field: { + name: Lampa.Lang.translate('params_pub_add_source'), + description: Lampa.Lang.translate('params_pub_add_source_descr') + }, + onRender: function (item) { + item.on('hover:enter', function () { + Lampa.Noty.show(Lampa.Lang.translate('pub_source_add_noty')); + Lampa.Storage.set('source', 'pub'); + }); + } + }); + Lampa.SettingsApi.addParam({ + component: 'pub_param', + param: { + name: 'pub_del_device', + type: 'static' //доступно select,input,trigger,title,static + }, + field: { + name: Lampa.Lang.translate('params_pub_dell_device'), + description: Lampa.Lang.translate('params_pub_dell_descr') + }, + onRender: function (item) { + item.on('hover:enter', function () { + Pub.delete_device(function () { + Lampa.Storage.set('pro_pub', false); + Lampa.Settings.create('pub_param'); + }); + }); + if (!Lampa.Storage.get('pro_pub', false)) item.hide(); + } + }); + Lampa.SettingsApi.addParam({ + component: 'pub_param', + param: { + name: 'pub_clear_tocken', + type: 'static' //доступно select,input,trigger,title,static + }, + field: { + name: Lampa.Lang.translate('params_pub_clean_tocken') + }, + onRender: function (item) { + item.on('hover:enter', function () { + Lampa.Storage.set('pub_access_token', Pub.token); + Lampa.Storage.set('logined_pub', false); + Lampa.Noty.show('Cleared'); + Lampa.Settings.update(); + }); + } + }); + + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_title', + type: 'title', //доступно select,input,trigger,title,static + default: true + }, + field: { + name: Lampa.Lang.translate('title_addons') + } + }); + + //ForkTV + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_fork', + type: 'trigger', //доступно select,input,trigger,title,static + default: false + }, + field: { + name: Lampa.Lang.translate('params_pub_on') + ' ForkTV', + description: Lampa.Lang.translate('fork_enable_descr') + }, + onChange: function (value) { + if (value) ForkTV.check_forktv('', true); + Lampa.Settings.update(); + } + }); + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'fork_param', + type: 'static', //доступно select,input,trigger,title,static + default: true + }, + field: { + name: '
    ForkTV
    ', + description: Lampa.Lang.translate('filmix_nodevice') + }, + onRender: function (item) { + if (Lampa.Storage.field('mods_fork')) { + item.show(); + $('.settings-param__name', item).before('
    '); + ForkTV.check_forktv(item, true); + } else item.hide(); + item.on('hover:enter', function () { + Lampa.Settings.create('fork_param'); + Lampa.Controller.enabled().controller.back = function(){ + Lampa.Settings.create('settings_modss'); + } + }); + } + }); + Lampa.SettingsApi.addParam({ + component: 'fork_param', + param: { + name: 'forktv_url', + type: 'static' //доступно select,input,trigger,title,static + }, + field: { + name: ForkTV.url, + description: Lampa.Lang.translate('filmix_nodevice') + }, + onRender: function (item) { + $('.settings-param__name', item).before('
    '); + ForkTV.check_forktv(item); + } + }); + Lampa.SettingsApi.addParam({ + component: 'fork_param', + param: { + name: 'ForkTV_add', + type: 'static', //доступно select,input,trigger,title,static + default: '' + }, + field: { + name: Lampa.Storage.get('ForkTv_cat') ? Lampa.Lang.translate('title_fork_edit_cats') : Lampa.Lang.translate('title_fork_add_cats'), + description: '' + }, + onRender: function (item) { + if (Lampa.Storage.get('forktv_auth')) { + item.show(); + } else item.hide(); + item.on('hover:enter', function () { + ForkTV.check_forktv(item); + }); + } + }); + Lampa.SettingsApi.addParam({ + component: 'fork_param', + param: { + name: 'ForkTV_clear', + type: 'static', //доступно select,input,trigger,title,static + default: '' + }, + field: { + name: Lampa.Lang.translate('title_fork_clear'), + description: Lampa.Lang.translate('title_fork_clear_descr') + }, + onRender: function (item) { + if (Lampa.Storage.get('forktv_auth')) { + item.show(); + } else item.hide(); + item.on('hover:enter', function () { + Lampa.Storage.set('ForkTv_cat', ''); + Lampa.Noty.show(Lampa.Lang.translate('title_fork_clear_noty')); + }); + } + }); + Lampa.SettingsApi.addParam({ + component: 'fork_param', + param: { + name: 'ForkTV_clearMac', + type: 'static', //доступно select,input,trigger,title,static + default: '' + }, + field: { + name: Lampa.Lang.translate('title_fork_reload_code'), + description: ' ' + }, + onRender: function (item) { + item.on('hover:enter', function () { + ForkTV.updMac(item); + }); + } + }); + //Radio + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_radio', + type: 'trigger', //доступно select,input,trigger,title,static + default: false + }, + field: { + name: Lampa.Lang.translate('params_radio_enable'), + description: Lampa.Lang.translate('params_radio_enable_descr') + }, + onChange: function (value) { + Modss.radio(); + } + }); + //Collection + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_collection', + type: 'trigger', //доступно select,input,trigger,title,static + default: false + }, + field: { + name: Lampa.Lang.translate('params_pub_on') + ' ' + Lampa.Lang.translate('menu_collections').toLowerCase(), + description: Lampa.Lang.translate('params_collections_descr') + }, + onChange: function (value) { + if (value == 'true') Modss.collections(); + else $('body').find('.menu [data-action="collection"]').remove(); + } + }); + //Styles + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_title', + type: 'title', //доступно select,input,trigger,title,static + default: true + }, + field: { + name: Lampa.Lang.translate('params_styles_title') + } + }); + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_snow', + type: 'trigger', //доступно select,input,trigger,title,static + default: false + }, + field: { + name: 'Снег' + }, + onChange: function (value) { + Modss.snow(); + } + }); + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_rating', + type: 'trigger', //доступно select,input,trigger,title,static + default: true + }, + field: { + name: Lampa.Lang.translate('title_enable_rating'), + description: Lampa.Lang.translate('title_enable_rating_descr') + }, + onChange: function (value) { + if (value == 'true') { + $('body').find('.rate--kp, .rate--imdb').removeClass('hide'); + Modss.rating_kp_imdb(cards); + } else $('body').find('.rate--kp, .rate--imdb').addClass('hide'); + } + }); + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_serial_info', + type: 'trigger', //доступно select,input,trigger,title,static + default: true + }, + field: { + name: Lampa.Lang.translate('title_info_serial'), + description: Lampa.Lang.translate('title_info_serial_descr') + }, + onChange: function (value) { + if (value == 'true' && $('body').find('.full-start__poster').length) Modss.serialInfo(cards); + else $('body').find('.files__left .time-line, .card--last_view, .card--new_seria').remove(); + } + }); + if (/iPhone|iPad|iPod|android|x11/i.test(navigator.userAgent) || (Lampa.Platform.is('android') && window.innerHeight < 1080)) { + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_butt_back', + type: 'trigger', //доступно select,input,trigger,title,static + default: false + }, + field: { + name: Lampa.Lang.translate('title_add_butback'), + description: Lampa.Lang.translate('title_add_butback_descr') + }, + onChange: function (value) { + Lampa.Settings.update(); + if (value == 'true') Modss.buttBack(); + else $('body').find('.elem-mobile-back').remove(); + } + }); + Lampa.SettingsApi.addParam({ + component: 'settings_modss', + param: { + name: 'mods_butt_pos', + type: 'select', //доступно select,input,trigger,title,static + values: { + right: Lampa.Lang.translate('buttback_right'), + left: Lampa.Lang.translate('buttback_left') + }, + default: 'right' + }, + field: { + name: Lampa.Lang.translate('title_butback_pos'), + }, + onRender: function (item) { + if (Lampa.Storage.field('mods_butt_back')) item.show(); + else item.hide(); + }, + onChange: function (value) { + Modss.buttBack(value); + } + }); + } + //Proxy mods + Lampa.SettingsApi.addComponent({ + component: 'mods_proxy', + name: Lampa.Lang.translate('title_proxy') + " MODS's", + icon: '' + }); + Lampa.SettingsApi.addParam({ + component: 'mods_proxy', + param: { + name: 'mods_proxy_all', + type: 'input', //доступно select,input,trigger,title,static + values: '', + default: '', + placeholder: Lampa.Lang.translate('online_proxy_placeholder') + }, + field: { + name: Lampa.Lang.translate('online_proxy_title'), + description: Lampa.Lang.translate('online_proxy_descr') + } + }); + ['VideoCDN', 'HDRezka', 'CDNmovies', 'Collaps'].forEach(function (itm) { + Lampa.SettingsApi.addParam({ + component: 'mods_proxy', + param: { + name: 'mods_proxy_' + itm.toLowerCase(), + type: 'select', //доступно select,input,trigger,title,static + values: { + on: Lampa.Lang.translate('params_pub_on'), + off: Lampa.Lang.translate('params_pub_off'), + url: Lampa.Lang.translate('online_proxy_url') + }, + default: 'off' + }, + field: { + name: itm, + description: Lampa.Storage.get('onl_mods_proxy_' + itm.toLowerCase()) || ' ' + }, + onRender: function (item) { + var url = Lampa.Storage.get('onl_mods_proxy_' + itm.toLowerCase()); + if (url.length > 0) item.find('.settings-param__descr').text(url); + if (url.length == 0) item.find('.settings-param__descr').addClass('hide'); + //вызывается когда срабатывает рендер параметра + }, + onChange: function (value) { + if (value == 'url') { + var name = itm.toLowerCase(); + Lampa.Input.edit({ + value: Lampa.Storage.get('onl_mods_proxy_' + name) || '', + }, function (t) { + if (t !== '') { + Lampa.Storage.set('onl_mods_proxy_' + name, t); + $('[data-name="mods_proxy_' + name).find('.settings-param__descr').removeClass('hide').text(t); + } else if (t == '') { + Lampa.Storage.set('mods_proxy_' + name, 'off'); + Lampa.Storage.set('onl_mods_proxy_' + name, ''); + $('[data-name="mods_proxy_' + name + '"]').find('.settings-param__descr').addClass('hide').text(''); + } + }); + } + } + }); + }); + + //Close_app + if (Lampa.Platform.is('android')) { + Lampa.SettingsApi.addComponent({ + component: 'mods_exit', + name: Lampa.Lang.translate('title_close_app'), + icon: '' + }); + Lampa.SettingsApi.addParam({ + component: 'mods_exit', + param: { + name: 'close_app', + type: 'static', //доступно select,input,trigger,title,static + default: true + }, + field: { + name: '' + }, + onRender: function (item) { + Lampa.Android.exit(); + } + }); + } + FreeJaketOpt(); + } + + if (window.appready) add();else { + Lampa.Listener.follow('app', function (e) { + if (e.type == 'ready') add(); + }); + } + + function url$1(u) { + var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + if (params.genres) u = add$4(u, 'genre=' + params.genres); + if (params.page) u = add$4(u, 'page=' + params.page); + if (params.query) u = add$4(u, 'q=' + params.query); + if (params.type) u = add$4(u, 'type=' + params.type); + if (params.field) u = add$4(u, 'field=' + params.field); + if (params.id) u = add$4(u, 'actor=' + params.id); + if (params.perpage) u = add$4(u, 'perpage=' + params.perpage); + u = add$4(u, 'access_token=' + Pub.token); + if (params.filter) { + for (var i in params.filter) { + u = add$4(u, i + '=' + params.filter[i]); + } + } + return Pub.baseurl + u; + } + function add$4(u, params) { + return u + (/\?/.test(u) ? '&' : '?') + params; + } + function get$6(method, call) { + var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var oncomplite = arguments.length > 2 ? arguments[2] : undefined; + var onerror = arguments.length > 3 ? arguments[3] : undefined; + var u = url$1(method, params); + Pub.network.silent(u, function (json) { + json.url = method; + oncomplite(json); + }, onerror); + } + function tocard(element) { + return { + url: '', + id: element.id, + type: element.type, + title: element.title.split('/')[0], + promo_title: element.title.split('/')[0], + original_title: element.title.split('/')[1] || element.title, + release_date: (element.year ? element.year + '' : element.years ? element.years[0] + '' : '0000'), + first_air_date: element.type == 'serial' || element.type == 'docuserial' || element.type == 'tvshow' ? element.year : '', + vote_averagey: parseFloat((element.imdb_rating || 0) + '').toFixed(1), + vote_average: element.imdb_rating || 0, + poster: element.posters.big, + cover: element.posters.wide, + background_image: element.posters.wide, + imdb_rating: parseFloat(element.imdb_rating || '0.0').toFixed(1), + kp_rating: parseFloat(element.kinopoisk_rating || '0.0').toFixed(1), + year: element.year, + years: element.years + }; + } + function list$2(params, oncomplite, onerror) { + var url = url$1('v1/items', params, params.type = type); + if (!params.genres) url = url$1(params.url, params); + Pub.network["native"](url, function (json) { + var items = []; + if (json.items) { + json.items.forEach(function (element) { + items.push(tocard(element)); + }); + } + oncomplite({ + results: items, + page:json.pagination.current, + total_pages: json.pagination.total + }); + }, onerror); + } + function main$2(params, oncomplite, onerror) { + var status = new Lampa.Status(9); + status.onComplite = function () { + var fulldata = []; + var data = status.data; + for (var i = 1; i <= 9; i++) { + var ipx = 's' + i; + if (data[ipx] && data[ipx].results.length) fulldata.push(data[ipx]); + } + if (fulldata.length) oncomplite(fulldata); + else onerror(); + }; + var append = function append(title, name, json) { + json.title = title; + var data = []; + json.items.forEach(function (element) { + data.push(tocard(element)); + }); + if(name == 's1' || name == 's6') { + json.wide = true; + json.small = true; + } + if(name == 's2') { + data.forEach(function (el){ + el.poster = el.cover; + }); + json.collection = true; + json.line_type = 'collection'; + } + json.results = data; + status.append(name, json); + }; + get$6('v1/items/popular?type=movie&sort=views', params, function (json) { + append(Lampa.Lang.translate('pub_title_popularfilm'), 's1', json); + Lampa.VideoQuality.add(json.results); + }, status.error.bind(status)); + get$6('v1/items?type=movie&sort=updated-', params, function (json) { + append(Lampa.Lang.translate('pub_title_newfilm'), 's2', json); + }, status.error.bind(status)); + get$6('v1/items/popular?type=serial&sort=views', params, function (json) { + append(Lampa.Lang.translate('pub_title_popularserial'), 's3', json); + Lampa.VideoQuality.add(json.results); + }, status.error.bind(status)); + get$6('v1/items?type=serial&sort=updated-', params, function (json) { + append(Lampa.Lang.translate('pub_title_newserial'), 's4', json); + }, status.error.bind(status)); + get$6('v1/items?type=concert&sort=updated-', params, function (json) { + append(Lampa.Lang.translate('pub_title_newconcert'), 's5', json); + }, status.error.bind(status)); + get$6('v1/items?type=&quality=4', params, function (json) { + append('4K', 's6', json); + }, status.error.bind(status)); + get$6('v1/items?type=documovie&sort=updated-', params, function (json) { + append(Lampa.Lang.translate('pub_title_newdocfilm'), 's7', json); + }, status.error.bind(status)); + get$6('v1/items?type=docuserial&sort=updated-', params, function (json) { + append(Lampa.Lang.translate('pub_title_newdocserial'), 's8', json); + }, status.error.bind(status)); + get$6('v1/items?type=tvshow&sort=updated-', params, function (json) { + append(Lampa.Lang.translate('pub_title_newtvshow'), 's9', json); + }, status.error.bind(status)); + } + function category$1(params, oncomplite, onerror) { + var books = Lampa.Favorite.continues(params.url); + var status = new Lampa.Status(5); + status.onComplite = function () { + var fulldata = []; + if (books.length) fulldata.push({ + results: books, + title: params.url == 'tv' ? Lampa.Lang.translate('title_continue') : Lampa.Lang.translate('title_watched') + }); + var data = status.data; + for (var i = 1; i <= 5; i++) { + var ipx = 's' + i; + if (data[ipx] && data[ipx].results.length) fulldata.push(data[ipx]); + } + if (fulldata.length) oncomplite(fulldata); + else onerror(); + }; + var append = function append(title, name, json) { + json.title = title; + var data = []; + json.items.forEach(function (element) { + data.push(tocard(element)); + }); + json.results = data; + status.append(name, json); + }; + var type = params.url == 'tv' ? 'serial' : params.url; + var Name = params.genres ? params.typeName.toLowerCase() : params.url == 'tv' ? Lampa.Lang.translate('menu_tv').toLowerCase() : Lampa.Lang.translate('menu_movies').toLowerCase(); + if (params.genres) { + get$6('v1/items?type=' + type + (params.genres ? '&sort=created-' : ''), params, function (json) { + append(Lampa.Lang.translate('pub_title_new') + ' ' + params.janr.toLowerCase(), 's1', json); + }, status.error.bind(status)); + get$6('v1/items?type=' + type + 'sort=rating-', params, function (json) { + append(Lampa.Lang.translate('pub_title_rating') + ' ' + Name, 's2', json); + }, status.error.bind(status)); + get$6('v1/items?type=' + type + '&sort=updated-', params, function (json) { + append(Lampa.Lang.translate('pub_title_fresh') + ' ' + Name, 's3', json); + }, status.error.bind(status)); + get$6('v1/items?type=' + type + '&sort=views-', params, function (json) { + append(Lampa.Lang.translate('pub_title_hot') + ' ' + Name, 's4', json); + }, status.error.bind(status)); + get$6('v1/items?type=' + type + '&quality=4', params, function (json) { + append('4K ' + Name, 's5', json); + }, status.error.bind(status)); + } else { + get$6('v1/items?type=' + type + (params.genres ? '&sort=created-' : ''), params, function (json) { + append(Lampa.Lang.translate('pub_title_new') + ' ' + Name, 's1', json); + }, status.error.bind(status)); + get$6('v1/items/popular?type=' + type + '&sort=views-&conditions=' + encodeURIComponent("year=" + Date.now('Y')), params, function (json) { + append(Lampa.Lang.translate('pub_title_popular') + ' ' + Name, 's2', json); + }, status.error.bind(status)); + get$6('v1/items/fresh?type=' + type + '&sort=views-&conditions=' + encodeURIComponent("year=" + Date.now('Y')), params, function (json) { + append(Lampa.Lang.translate('pub_title_fresh') + ' ' + Name, 's3', json); + }, status.error.bind(status)); + get$6('v1/items/hot?type=' + type + '&sort=created-&conditions=' + encodeURIComponent("year=" + Date.now('Y')), params, function (json) { + append(Lampa.Lang.translate('pub_title_hot') + ' ' + Name, 's4', json); + }, status.error.bind(status)); + get$6('v1/items?type=' + type + '&quality=4', params, function (json) { + append('4K ' + Name, 's5', json); + }, status.error.bind(status)); + } + } + function full$1(params, oncomplite, onerror) { + var status = new Lampa.Status(Lampa.Storage.get('pro_pub', false) ? 5 : 4); + status.onComplite = oncomplite; + var url = 'v1/items/' + params.id; + get$6(url, params, function (json) { + json.source = 'pub'; + var data = {}; + var element = json.item; + get$6('v1/items/similar?id=' + element.id, params, function (json) { + var similars = []; + if (json.items) { + for (var i in json.items) { + var item = json.items[i]; + similars.push(tocard(item)); + } + status.append('simular', { + results: similars + }); + } + }, onerror); + get$6('v1/items/comments?id=' + element.id, params, function (json) { + var comments = []; + if (json.comments) { + for (var i in json.comments) { + var com = json.comments[i]; + com.text = com.message.replace(/\[n|r|t]/g, ''); + com.like_count = com.rating; + comments.push(com); + } + status.append('comments', comments); + } + }, onerror); + data.movie = { + id: element.id, + url: url, + type: element.type, + source: 'pub', + title: element.title.split('/')[0], + original_title: element.title.split('/')[1] ? element.title.split('/')[1] : element.title.split('/')[0], + name: element.seasons ? element.title.split('/')[0] : '', + original_name: element.seasons ? element.title.split('/')[1] : '', + original_language: element.genres.find(function (e){return e.id == 25}) !== undefined ? 'ja' : '', + overview: element.plot.replace(/\[n|r|t]/g, ''), + img: element.posters.big, + runtime: (element.duration.average || 0) / 1000 / 6 * 100, + genres: genres$1(element, json.item), + vote_average: parseFloat(element.imdb_rating || element.kinopoisk_rating || '0'), + production_companies: [], + production_countries: countries(element.countries, json.item), + budget: element.budget || 0, + seasons: element.seasons && element.seasons.filter(function (el){ + el.episode_count = 1; + return el + }) || '', + release_date: element.year || Lampa.Utils.parseTime(element.created_at).full || '0000', + number_of_seasons: seasonsCount(element).seasons, + number_of_episodes: seasonsCount(element).episodes, + first_air_date: element.type == 'serial' || element.type == 'docuserial' || element.type == 'tvshow' ? element.year || Lampa.Utils.parseTime(element.created_at).full || '0000' : '', + background_image: element.posters.wide, + imdb_rating: parseFloat(element.imdb_rating || '0.0').toFixed(1), + kp_rating: parseFloat(element.kinopoisk_rating || '0.0').toFixed(1), + imdb_id:'tt' +element.imdb, + kinopoisk_id:element.kinopoisk + }; + status.append('persons', persons(json)); + status.append('movie', data.movie); + if(Lampa.Storage.get('pro_pub', false)) status.append('videos', videos(element)); + }, onerror); + } + function menu$1(params, oncomplite) { + var u = url$1('v1/types', params); + var typeName = ''; + Pub.network["native"](u, function (json) { + Lampa.Select.show({ + title: Lampa.Lang.translate('title_category'), + items: json.items, + onBack: this.onBack, + onSelect: function onSelect(a) { + type = a.id; + typeName = a.title; + get$6('v1/genres?type=' + a.id, params, function (jsons) { + Lampa.Select.show({ + title: Lampa.Lang.translate('full_genre'), + items: jsons.items, + onBack: function onBack() { + menu$1(params, oncomplite); + }, + onSelect: function onSelect(a) { + Lampa.Activity.push({ + url: type, + title: Lampa.Lang.translate('title_catalog') + ' - ' + typeName + ' - ' + a.title + ' - KinoPUB', + component: 'category', + typeName: typeName, + janr: a.title, + genres: a.id, + id: a.id, + source: 'pub', + card_type: true, + page: 1 + }); + } + }); + }, onerror); + } + }); + }); + } + function seasons$2(tv, from, oncomplite) { + Lampa.Api.sources.tmdb.seasons(tv, from, oncomplite); + } + function person$2(params, oncomplite, onerror) { + var u = url$1('v1/items', params); + Pub.network["native"](u, function (json, all) { + var data = {}; + if (json.items) { + data.person = { + name: params.id, + biography: '', + img: '', + place_of_birth: '', + birthday: '----' + }; + var similars = []; + for (var i in json.items) { + var item = json.items[i]; + similars.push(tocard(item)); + } + data.credits = { + movie: similars, + knownFor: [{ + name: '', + credits: similars + }] + }; + } + oncomplite(data); + }, onerror); + } + function clear$3() { + Pub.network.clear(); + } + function seasonsCount(element) { + var data = { + seasons: 0, + episodes: 0 + }; + if (element.seasons) { + data.seasons = element.seasons.length; + element.seasons.forEach(function (ep) { + data.episodes += ep.episodes.length; + }) + } + return data; + } + function videos(element) { + var data = []; + if (element.trailer) { + data.push({ + name: element.trailer.title || 'Trailer name', + url: element.trailer.url, + youtube: false, + iso_639_1: 'ru' + }); + } + return data.length ? { + results: data + } : false; + } + function persons(json) { + var data = []; + if (json.item.cast) { + json.item.cast.split(',').forEach(function (name) { + data.push({ + name: name, + id: name, + character: Lampa.Lang.translate('title_actor'), + }); + }); + } + return data.length ? { + cast: data + } : false; + } + function genres$1(element, json) { + var data = []; + element.genres.forEach(function (id) { + if (id) { + data.push({ + id: id.id, + name: id.title + }); + } + }); + return data; + } + function countries(element, json) { + var data = []; + if (element && json.countries) { + data.push({ + name: element[0].title + }); + } + return data; + } + function search$3() { + var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var oncomplite = arguments.length > 1 ? arguments[1] : undefined; + var status = new Lampa.Status(2); + status.onComplite = function (data) { + var items = []; + if (data.movie && data.movie.results.length) items.push(data.movie); + if (data.tv && data.tv.results.length) items.push(data.tv); + oncomplite(items); + }; + var mov = params; + mov.type = ''; + mov.field = 'title'; + mov.perpage = 20; + get$6('v1/items/search', mov, function (json) { + var items = []; + var itemss = []; + if (json.items) { + json.items.forEach(function (element) { + if(element.type == 'movie') items.push(tocard(element)); + else itemss.push(tocard(element)); + }); + var movie = { + results: items, + page: json.pagination.current, + total_pages: json.pagination.total, + total_results: json.pagination.total_items, + title: Lampa.Lang.translate('menu_movies') +' ('+items.length+')', + type: 'movie' + }; + status.append('movie', movie); + var tv = { + results: itemss, + page: json.pagination.current, + total_pages: json.pagination.total, + total_results: json.pagination.total_items, + title: Lampa.Lang.translate('menu_tv') +' ('+itemss.length+')', + type: 'tv' + }; + status.append('tv', tv); + } + }, function(){ + status.need = 1; + status.error(); + }); + } + function discovery() { + return { + title: 'PUB', + search: search$3, + params: { + align_left: true, + object: { + source: 'pub' + } + }, + onMore: function onMore(params) { + Lampa.Activity.push({ + url: 'v1/items/search?field=title&type=' + params.data.type, + title: Lampa.Lang.translate('search') + ' - ' + params.query, + component: 'category_full', + page: 2, + query: encodeURIComponent(params.query), + source: 'pub' + }); + }, + onCancel: Pub.network.clear.bind(Pub.network) + }; + } + var PUB = { + main: main$2, + menu: menu$1, + full: full$1, + search: search$3, + person: person$2, + list: list$2, + seasons: seasons$2, + category: category$1, + clear: clear$3, + discovery: discovery + }; + Lampa.Api.sources.pub = PUB; + + function url$2(u) { + var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + u = (u == 'undefined' ? '' : u) + if (params.genres) u = 'catalog' +add$5(u, 'orderby=date&orderdir=desc&filter=s996-' + params.genres.replace('f','g')); + if (params.page) u = add$5(u, 'page=' + params.page); + if (params.query) u = add$5(u, 'story=' + params.query); + if (params.type) u = add$5(u, 'type=' + params.type); + if (params.field) u = add$5(u, 'field=' + params.field); + if (params.perpage) u = add$5(u, 'perpage=' + params.perpage); + u = add$5(u, Filmix.user_dev + Filmix.token); + if (params.filter) { + for (var i in params.filter) { + u = add$5(u, i + '=' + params.filter[i]); + } + } + return Filmix.api_url + u; + } + function add$5(u, params) { + return u + (/\?/.test(u) ? '&' : '?') + params; + } + function get$7(method, call) { + var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var oncomplite = arguments.length > 2 ? arguments[2] : undefined; + var onerror = arguments.length > 3 ? arguments[3] : undefined; + var u = url$2(method, params); + Filmix.network["native"](u, function (json) { + json.url = method; + oncomplite(json); + }, onerror); + } + function tocardf(element, type) { + return { + url: '', + id: element.id, + type: type || (((element.serial_stats && element.serial_stats.post_id) || (element.last_episode && element.last_episode.post_id)) ? 'tv' : 'movie'), + source: 'filmix', + quality: element.quality && element.quality.split(' ').shift() || '', + title: element.title, + original_title: element.original_title || element.title, + release_date: (element.year || element.date && element.date.split(' ')[2] || '0000'), + first_air_date: (type == 'tv' || ((element.serial_stats && element.serial_stats.post_id) || (element.last_episode && element.last_episode.post_id))) ? element.year : '', + img: element.poster, + cover: element.poster, + background_image: element.poster, + vote_average: parseFloat(element.kp_rating || '0.0').toFixed(1), + imdb_rating: parseFloat(element.imdb_rating || '0.0').toFixed(1), + kp_rating: parseFloat(element.kp_rating || '0.0').toFixed(1), + year: element.year + }; + } + function list$3(params, oncomplite, onerror) { + var page = 2; + var url = url$2(params.url, params); + Filmix.network["native"](url, function (json) { + var items = []; + if (json) { + json.forEach(function (element) { + items.push(tocardf(element)); + }); + } + oncomplite({ + results: items, + page: page, + total_pages: 50 + }); + page++ + }, onerror); + } + function main$1(params, oncomplite, onerror) { + var source = [{ + title: 'title_now_watch', + url: 'top_views' + }, { + title: 'title_new', + url: 'catalog?orderby=date&orderdir=desc' + }, { + title: 'title_new_this_year', + url: 'catalog?orderby=year&orderdir=desc' + }, { + title: 'pub_title_newfilm', + url: 'catalog?orderby=date&orderdir=desc&filter=s0' + }, { + title: '4K', + url: 'catalog?orderby=date&orderdir=desc&filter=s0-q4' + }, { + title: 'pub_title_popularfilm', + url: 'popular' + }, { + title: 'pub_title_popularserial', + url: 'popular?section=7' + }, { + title: 'title_in_top', + url: 'catalog?orderby=rating&orderdir=desc' + }]; + var status = new Lampa.Status(Lampa.Arrays.getKeys(source).length); + status.onComplite = function () { + var fulldata = []; + var data = status.data; + source.forEach(function (q) { + if (status.data[q.title] && status.data[q.title].results.length) { + fulldata.push(status.data[q.title]); + } + }); + if (fulldata.length) oncomplite(fulldata); + else onerror(); + }; + var append = function append(title, name, json) { + json.title = title; + var data = []; + json.forEach(function (element) { + data.push(tocardf(element)); + }); + json.results = data; + status.append(name, json); + }; + source.forEach(function (q) { + get$7(q.url, params, function (json) { + append(Lampa.Lang.translate(q.title), q.title, json); + }, status.error.bind(status)); + }); + } + function category$2(params, oncomplite, onerror) { + var books = Lampa.Favorite.continues(params.url); + var type = params.url == 'tv' ? 7 : 0; + var source = [{ + title: 'title_new_this_year', + url: 'catalog?orderby=year&orderdir=desc&filter=s'+type + }, { + title: 'title_new', + url: 'catalog?orderby=date&orderdir=desc&filter=s'+type + }, { + title: 'title_popular', + url: 'popular?section='+type + }, { + title: 'title_in_top', + url: 'catalog?orderby=rating&orderdir=desc&filter=s'+type + }]; + var status = new Lampa.Status(Lampa.Arrays.getKeys(source).length); + status.onComplite = function () { + var fulldata = []; + var data = status.data; + if (books.length) fulldata.push({ + results: books, + title: params.url == 'tv' ? Lampa.Lang.translate('title_continue') : Lampa.Lang.translate('title_watched') + }); + source.forEach(function (q) { + if (data[q.title] && data[q.title].results.length) { + fulldata.push(data[q.title]); + } + }); + if (fulldata.length) oncomplite(fulldata); + else onerror(); + }; + var append = function append(title, name, json) { + json.title = title; + var data = []; + json.forEach(function (element) { + data.push(tocardf(element, params.url)); + }); + json.results = data; + status.append(name, json); + }; + source.forEach(function (q) { + get$7(q.url, params, function (json) { + append(Lampa.Lang.translate(q.title), q.title, json); + }, status.error.bind(status)); + }); + } + function full$2(params, oncomplite, onerror) { + var status = new Lampa.Status(5); + status.onComplite = oncomplite; + var url = 'post/' + params.id; + get$7(url, params, function (json) { + json.source = 'filmix'; + var data = {}; + var element = json; + + var similars = []; + if (json.relates) { + for (var i in json.relates) { + var item = json.relates[i]; + similars.push(tocardf(item)); + } + status.append('simular', { + results: similars + }); + } + + data.movie = { + id: element.id, + url: url, + type: Lampa.Arrays.getValues(element.player_links.playlist).length ? 'tv' : 'movie', + source: 'filmix', + title: element.title, + original_title: element.original_title, + name: Lampa.Arrays.getValues(element.player_links.playlist).length ? element.title : '', + original_name: Lampa.Arrays.getValues(element.player_links.playlist).length ? element.original_title : '', + overview: element.short_story.replace(/\[n|r|t]/g, ''), + img: element.poster, + runtime: (element.duration || 0), + genres: genres$2(element), + vote_average: parseFloat(element.imdb_rating || element.kp_rating || '0'), + production_companies: [], + production_countries: countries2(element.countries), + budget: element.budget || 0, + release_date: element.year || element.date.split(' ')[2] || '0000', + seasons: Lampa.Arrays.getValues(element.player_links.playlist).filter(function (el){ + el.episode_count = 1; + return el + }), + quality: element.rip && element.rip.split(' ').shift() || '', + number_of_seasons: Lampa.Arrays.getValues(element.player_links.playlist).length || '', + number_of_episodes: element.last_episode && element.last_episode.episode || '', + first_air_date: Lampa.Arrays.getValues(element.player_links.playlist).length ? element.year || element.date_atom || '0000' : '', + background_image: element.poster, + imdb_rating: parseFloat(element.imdb_rating || '0.0').toFixed(1), + kp_rating: parseFloat(element.kp_rating || '0.0').toFixed(1), + }; + get$7('comments/' + element.id, params, function (json) { + var comments = []; + if (json) { + json.forEach(function(com) { + com.text = com.text.replace(/\[n|r|t]/g, ''); + com.like_count = ''; + comments.push(com); + }); + status.append('comments', comments); + $('.full-review__footer', Lampa.Activity.active().activity.render()).hide(); + } + }, onerror); + status.append('persons', persons2(json)); + status.append('movie', data.movie); + status.append('videos', videos2(element.player_links)); + }, onerror); + } + function menu$2(params, oncomplite) { + var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var oncomplite = arguments.length > 1 ? arguments[1] : undefined; + if (menu_list.length) oncomplite(menu_list);else { + var us = url$2('filter_list', params); + var u = url$2('category_list', params); + Filmix.network["native"](u, function (j) { + Lampa.Arrays.getKeys(j).forEach(function (g) { + menu_list.push({ + title: j[g], + id: g + }); + }); + //console.log (menu_list) + oncomplite(menu_list); + }); + } + } + function seasons$1(tv, from, oncomplite) { + Lampa.Api.sources.tmdb.seasons(tv, from, oncomplite); + } + function formatDate(dateString) { + var months = [ + { name: 'января', number: '01' }, + { name: 'февраля', number: '02' }, + { name: 'марта', number: '03' }, + { name: 'апреля', number: '04' }, + { name: 'мая', number: '05' }, + { name: 'июня', number: '06' }, + { name: 'июля', number: '07' }, + { name: 'августа', number: '08' }, + { name: 'сентября', number: '09' }, + { name: 'октября', number: '10' }, + { name: 'ноября', number: '11' }, + { name: 'декабря', number: '12' } + ]; + + var parts = dateString.split(' '); + var day = parts[0]; + var monthName = parts[1]; + var year = parts[2]; + + var monthNumber; + for (var i = 0; i < months.length; i++) { + if (months[i].name === monthName) { + monthNumber = months[i].number; + break; + } + } + + var formattedDate = year + '-' + monthNumber + '-' + day; + return formattedDate; + } + function person$3(params, oncomplite, onerror) { + var u = url$2('person/'+params.id, params); + Filmix.network["native"](u, function (json, all) { + var data = {}; + if (json) { + data.person = { + id: params.id, + name: json.name, + biography: json.about, + img: json.poster, + place_of_birth: json.birth_place, + birthday: formatDate(json.birth) + }; + var similars = []; + for (var i in json.movies) { + var item = json.movies[i]; + similars.push(tocardf(item)); + } + data.credits = { + movie: similars, + knownFor: [{ + name: json.career, + credits: similars + }] + }; + } + oncomplite(data); + }, onerror); + } + function clear$4() { + Filmix.network.clear(); + } + function videos2(element) { + var data = []; + if (element.trailer.length) { + element.trailer.forEach(function (el){ + var qualities = el.link.match(/\[(.*?)\]/); + qualities = qualities[1].split(',').filter(function (quality){ + if (quality === '') return false + return true + }).sort(function (a, b) { + return b - a + }).map(function (quality) { + data.push({ + name: el.translation+' '+quality+'p', + url: el.link.replace(/\[(.*?)\]/, quality), + player: true + }); + }); + }); + } + return data.length ? { + results: data + } : false; + } + function persons2(json) { + var data = []; + if (json.actors) { + json.found_actors.filter(function (act){ + data.push({ + name: act.name, + id: act.id, + character: Lampa.Lang.translate('title_actor'), + }); + }); + } + return data.length ? { + cast: data + } : false; + } + function genres$2(element) { + var data = []; + var u = url$2('category_list'); + Filmix.network["native"](u, function (j) { + element.categories.forEach(function (name, i) { + if (name) { + var _id = Object.entries(j).find(function (g) { + return g[1] == name + }); + data.push({ + id: _id && _id[0] || '', + name: name + }); + } + }); + }); + return data; + } + function countries2(element) { + var data = []; + if (element) { + element.forEach(function (el) { + data.push({ + name: el + }); + }); + } + return data; + } + function search$4() { + var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var oncomplite = arguments.length > 1 ? arguments[1] : undefined; + var status = new Lampa.Status(2); + status.onComplite = function (data) { + var items = []; + if (data.movie && data.movie.results.length) items.push(data.movie); + if (data.tv && data.tv.results.length) items.push(data.tv); + oncomplite(items); + }; + get$7('search', params, function (json) { + var items = []; + var itemss = []; + //console.log('fx',json) + if (json) { + json.forEach(function (element) { + if(element, element.last_episode && element.last_episode.season || element.serial_stats && element.serial_stats.status) itemss.push(tocardf(element, element.last_episode && element.last_episode.season || element.serial_stats && element.serial_stats.status ? 'tv' : 'movie')); + else items.push(tocardf(element, element.last_episode && element.last_episode.season || element.serial_stats && element.serial_stats.status ? 'tv' : 'movie')); + }); + var movie = { + results: items, + page: 1, + total_pages: 1, + total_results: json.length, + title: Lampa.Lang.translate('menu_movies') +' ('+items.length+')', + type: 'movie' + }; + status.append('movie', movie); + var tv = { + results: itemss, + page: 1, + total_pages: 1, + total_results: json.length, + title: Lampa.Lang.translate('menu_tv') +' ('+itemss.length+')', + type: 'tv' + }; + status.append('tv', tv); + } + }, function(){ + status.need = 1; + status.error(); + }); + } + function discovery$1() { + return { + title: 'FILMIX', + search: search$4, + params: { + align_left: true, + object: { + source: 'filmix' + } + }, + onMore: function onMore(params) { + Lampa.Activity.push({ + url: 'search', + title: Lampa.Lang.translate('search') + ' - ' + params.query, + component: 'category_full', + query: encodeURIComponent(params.query), + source: 'filmix' + }); + }, + onCancel: Filmix.network.clear.bind(Filmix.network) + }; + } + var FILMIX = { + main: main$1, + menu: menu$2, + full: full$2, + search: search$4, + person: person$3, + list: list$3, + seasons: seasons$1, + category: category$2, + clear: clear$4, + discovery: discovery$1 + }; + Lampa.Api.sources.filmix = FILMIX; + + function include(url) { + var script = document.createElement('script'); + script.src = url; + document.getElementsByTagName('head')[0].appendChild(script); + } + include('https://cdn.jsdelivr.net/npm/gaugeJS/dist/gauge.min.js'); + include('https://www.googletagmanager.com/gtag/js?id=G-8LVPC3VETR'); + window.dataLayer = window.dataLayer || []; + function gtag() { + dataLayer.push(arguments); + } + gtag('js', new Date()); + gtag('config', 'G-8LVPC3VETR'); + + function guide() { + var guide = '
    Вас приветствует Guide по использованию и настройке приложения Lampa.
    Мы пройдём с Вами краткую инструкцию по основным этапам приложения.
    Пройдено 0 из 0
    • Парсер
    • Включение парсера
    • Плагины
    • Добавление плагина
    • Установка плагина
    • Балансер
    • Смена балансера
    • Фильтр
    • Применение фильтра
    Откройте Настройки, после перейдите в раздел "Парсер".
    В пункте "Использовать парсер" переведите функцию в положение "Да", после чего в карточке фильма или сериала появится кнопка "Торренты".
    Установка плагинов
    Для добавления плагинов воспользуйтесь следующими вариантами.
    Для добавления плагина, воспользуйтесь списком плагинов
    Для смены "Онлайн" источника, воспользуйтесь кнопкой Балансер.
    В случае, если источник не работает (нет подключения к сети) выберете в разделе "Балансер" другой источник.
    Используйте "Фильтры" для смены перевода и сезона.
    Для смены сезона или озвучки воспользуйтесь пунктами
    1. Перевод
    2. Сезон
    Поздравляем! После прохождения краткого гайда, Вы знаете как пользоваться приложением и у Вас должно возникать меньше вопросов
    '; + Lampa.Template.add('guide', guide); + var temp = Lampa.Template.get('guide'); + var descr = temp.find('.torrent-checklist__descr'); + var list = temp.find('.torrent-checklist__list > li'); + var info = temp.find('.torrent-checklist__infoS > div'); + var next = temp.find('.torrent-checklist__next-step'); + var prog = temp.find('.torrent-checklist__progress-bar > div'); + var comp = temp.find('.torrent-checklist__progress-steps'); + var btn = temp.find('.next'); + var btn_back = temp.find('.back'); + var position = -2; + + function makeStep(step) { + step ? position-- : position++; + var total = list.length; + comp.text('Пройдено ' + Math.max(0, position) + ' из ' + total); + if (position > list.length) { + Lampa.Modal.close(); + Lampa.Controller.toggle('content'); + Lampa.Storage.set('guide', true); + } else if (position >= 0) { + Lampa.Storage.set('guide', ''); + info.addClass('hide'); + descr.addClass('hide'); + info.eq(position).removeClass('hide'); + var next_step = list.eq(position + 1); + prog.css('width', Math.round(position / total * 100) + '%'); + btn.text(position < total ? 'Далее' : 'Завершить'); + if (position > 0) btn_back.removeClass('hide'); + next.text(next_step.length ? '- ' + next_step.text() : ''); + } + } + makeStep(); + btn.on('hover:enter', function () { + makeStep(); + }); + btn_back.on('hover:enter', function () { + if (position == 1) { + // btn_back.removeClass('focus')//.addClass('hide'); + // btn.addClass('focus'); + //Lampa.Controller.collectionSet() ; + // Lampa.Controller.collectionFocus(btn); + } + if (position > 0) makeStep(true); + }); + Lampa.Modal.open({ + title: 'Гайд по использованию', + html: temp, + size: 'medium', + mask: true + }); + } + + } + if (!window.plugin_modss) startPlugin(); + +})(); + \ No newline at end of file