//31.01.2024 - Fix proxy (function () { 'use strict'; var myIp = ''; function decodeSecret(input) { var result = ''; var password = Lampa.Storage.get('online_mod_secret_password', ''); if (input && password) { var hash = Lampa.Utils.hash(password); while (hash.length < input.length) { hash += hash; } var i = 0; while (i < input.length) { result += String.fromCharCode(input[i] ^ hash.charCodeAt(i)); i++; } } return result; } function isDebug() { var secret = decodeSecret([92, 85, 91, 65, 84]); return secret === 'debug'; } function rezka2Mirror() { var url = Lampa.Storage.get('online_mod_rezka2_mirror', ''); if (!url) return 'https://hdrezka.ag'; if (url.indexOf('://') == -1) url = 'https://' + url; if (url.charAt(url.length - 1) === '/') url = url.substring(0, url.length - 1); return url; } function kinobaseMirror() { var url = Lampa.Storage.get('online_mod_kinobase_mirror', ''); if (!url) return 'https://kinobase.org'; if (url.indexOf('://') == -1) url = 'https://' + url; if (url.charAt(url.length - 1) === '/') url = url.substring(0, url.length - 1); return url; } function setMyIp(ip) { myIp = ip; } function getMyIp() { return myIp; } function proxy(name) { var ip = getMyIp(); var proxy1 = (window.location.protocol === 'https:' ? 'https://' : 'http://') + 'prox.lampa.stream/'; var proxy2 = 'https://cors.nb557.workers.dev:8443/'; var proxy3 = 'https://cors557.deno.dev/'; var proxy_other = Lampa.Storage.field('online_mod_proxy_other') === true ? Lampa.Storage.field('online_mod_proxy_other_url') : ''; var user_proxy2 = (proxy_other || proxy2) + (ip ? 'ip' + ip + '/' : ''); var user_proxy3 = (proxy_other || proxy3) + (ip ? 'ip' + ip + '/' : ''); var alt_proxy = Lampa.Storage.field('online_mod_proxy_other') === true ? user_proxy2 : proxy1; if (name === 'filmix') return window.location.protocol === 'https:' ? user_proxy2 : ''; if (name === 'svetacdn') return ''; if (name === 'allohacdn') return Lampa.Platform.is('android') ? '' : user_proxy3; if (Lampa.Storage.field('online_mod_proxy_' + name) === true) { if (name === 'rezka') return alt_proxy; if (name === 'rezka2') return user_proxy2; if (name === 'kinobase') return user_proxy3; if (name === 'cdnmovies') return user_proxy3; if (name === 'videodb') return user_proxy2; if (name === 'zetflix') return user_proxy2; if (name === 'redheadsound') return user_proxy2; if (name === 'anilibria') return alt_proxy; if (name === 'kodik') return user_proxy3; if (name === 'kinopub') return user_proxy2; } return ''; } var Utils = { decodeSecret: decodeSecret, isDebug: isDebug, rezka2Mirror: rezka2Mirror, kinobaseMirror: kinobaseMirror, setMyIp: setMyIp, getMyIp: getMyIp, proxy: proxy }; var network$1 = new Lampa.Reguest(); var cache = {}; var total_cnt = 0; var proxy_cnt = 0; var good_cnt = 0; var CACHE_SIZE = 100; var CACHE_TIME = 1000 * 60 * 60; function get(method, oncomplite, onerror) { var use_proxy = total_cnt >= 10 && good_cnt > total_cnt / 2; if (!use_proxy) total_cnt++; var kp_prox = 'https://cors.kp556.workers.dev:8443/'; var url = 'https://kinopoiskapiunofficial.tech/'; url += method; network$1.timeout(15000); network$1.silent((use_proxy ? kp_prox : '') + url, function (json) { oncomplite(json); }, function (a, c) { use_proxy = !use_proxy && (proxy_cnt < 10 || good_cnt > proxy_cnt / 2); if (use_proxy && (a.status == 429 || a.status == 0 && a.statusText !== 'timeout')) { proxy_cnt++; network$1.timeout(15000); network$1.silent(kp_prox + url, function (json) { good_cnt++; oncomplite(json); }, onerror, false, { headers: { 'X-API-KEY': '2a4a0808-81a3-40ae-b0d3-e11335ede616' } }); } else onerror(a, c); }, false, { headers: { 'X-API-KEY': '2a4a0808-81a3-40ae-b0d3-e11335ede616' } }); } function getComplite(method, oncomplite) { get(method, oncomplite, function () { oncomplite(null); }); } function getCompliteIf(condition, method, oncomplite) { if (condition) getComplite(method, oncomplite);else { setTimeout(function () { oncomplite(null); }, 10); } } function getCache(key) { var res = cache[key]; if (res) { var cache_timestamp = new Date().getTime() - CACHE_TIME; if (res.timestamp > cache_timestamp) return res.value; for (var ID in cache) { var node = cache[ID]; if (!(node && node.timestamp > cache_timestamp)) delete cache[ID]; } } return null; } function setCache(key, value) { var timestamp = new Date().getTime(); var size = Object.keys(cache).length; if (size >= CACHE_SIZE) { var cache_timestamp = timestamp - CACHE_TIME; for (var ID in cache) { var node = cache[ID]; if (!(node && node.timestamp > cache_timestamp)) delete cache[ID]; } size = Object.keys(cache).length; if (size >= CACHE_SIZE) { var timestamps = []; for (var _ID in cache) { var _node = cache[_ID]; timestamps.push(_node && _node.timestamp || 0); } timestamps.sort(function (a, b) { return a - b; }); cache_timestamp = timestamps[Math.floor(timestamps.length / 2)]; for (var _ID2 in cache) { var _node2 = cache[_ID2]; if (!(_node2 && _node2.timestamp > cache_timestamp)) delete cache[_ID2]; } } } cache[key] = { timestamp: timestamp, value: value }; } function getFromCache(method, oncomplite, onerror) { var json = getCache(method); if (json) { setTimeout(function () { oncomplite(json, true); }, 10); } else get(method, oncomplite, onerror); } function clear() { network$1.clear(); } var KP = { get: get, getComplite: getComplite, getCompliteIf: getCompliteIf, getCache: getCache, setCache: setCache, getFromCache: getFromCache, clear: clear }; 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); } function videocdn(component, _object) { var network = new Lampa.Reguest(); var extract = {}; var results = []; var object = _object; var get_links_wait = false; var select_title = ''; var prefer_http = Lampa.Storage.field('online_mod_prefer_http') === true; var prefer_mp4 = Lampa.Storage.field('online_mod_prefer_mp4') === true; var prox = component.proxy('videocdn'); var prox2 = component.proxy('svetacdn'); var host = (prefer_http || prox ? 'http:' : 'https:') + '//videocdn.tv'; var embed = prox + host + '/api/'; var filter_items = {}; var choice = { season: 0, voice: 0, voice_name: '', voice_id: 0 }; /** * Начать поиск * @param {Object} _object * @param {String} kinopoisk_id */ this.search = function (_object, kinopoisk_id, data) { object = _object; var itm = data[0]; select_title = itm.title || itm.ru_title || itm.en_title || itm.orig_title || object.movie.title; if (itm.episodes || itm.media) { success([itm]); return; } var url = embed; 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.kp_id || itm.kinopoisk_id ? encodeURIComponent(itm.kp_id || itm.kinopoisk_id) : encodeURIComponent(select_title))); url = Lampa.Utils.addUrlComponent(url, 'field=' + (itm.imdb_id ? 'imdb_id' : itm.kp_id || itm.kinopoisk_id ? 'kinopoisk_id' : 'title')); network.clear(); network.timeout(20000); network.silent(url, function (found) { var results = found.data.filter(function (elem) { return elem.id == itm.id; }); if (results.length) success(results);else 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 }; filter(); append(filtred()); component.saveChoice(choice); }; /** * Применить фильтр * @param {*} type * @param {*} a * @param {*} b */ 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()); component.saveChoice(choice); }; /** * Уничтожить */ this.destroy = function () { network.clear(); results = null; extract = null; }; /** * Успешно, есть данные * @param {Object} json */ function success(json) { component.loading(false); results = json; extractData(json); filter(); append(filtred()); } /** * Получить потоки * @param {String} str * @returns array */ function extractItems(str) { if (!str) return []; 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 = (prefer_http ? 'http:' : 'https:') + file; if (prefer_mp4) file = file.replace(/(\.mp4):hls:manifest\.m3u8$/i, '$1'); 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 []; } /** * Получить информацию о фильме * @param {Arrays} results */ function extractData(results) { var movie = results.slice(0, 1)[0]; extract = {}; if (movie) { get_links_wait = true; var src = (window.location.protocol === 'https:' && !prox2 ? 'https:' : 'http:') + movie.iframe_src; var call_success = function call_success(raw) { get_links_wait = false; component.render().find('.broadcast__scan').remove(); var math = raw.replace(/\n/g, '').match(/id="fs" value='([^']*)'/); if (math) { var json = Lampa.Arrays.decodeJson(component.decodeHtml(math[1]), {}); 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() { get_links_wait = false; component.render().find('.broadcast__scan').remove(); }; if (prox2 && window.location.protocol !== 'http:') { network.clear(); network.timeout(20000); network.silent(prox2 + 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); network["native"](src, call_success, call_fail, false, { dataType: 'text', headers: Lampa.Platform.is('android') ? { 'Origin': host, 'Referer': host + '/' } : {} }); } finally { meta.attr('content', referrer); } } } } /** * Найти поток * @param {Object} element * @param {Int} max_quality * @returns string */ 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) { max_quality = parseInt(max_quality); if (max_quality) { items = items.filter(function (item) { return item.quality <= max_quality; }); } if (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]; } } return { file: file, quality: quality }; } /** * Построить фильтр */ function filter() { filter_items = { season: [], season_num: [], voice: [], voice_info: [] }; results.slice(0, 1).forEach(function (movie) { if (movie.episodes) { movie.episodes.forEach(function (episode) { if (filter_items.season_num.indexOf(episode.season_num) == -1) filter_items.season_num.push(episode.season_num); }); if (!filter_items.season_num.length) filter_items.season_num.push(1); filter_items.season_num.sort(function (a, b) { return a - b; }); filter_items.season_num.forEach(function (s) { filter_items.season.push(Lampa.Lang.translate('torrent_serial_season') + ' ' + s); }); } if (!filter_items.season[choice.season]) choice.season = 0; if (movie.episodes) { var season_num = filter_items.season_num[choice.season]; movie.episodes.forEach(function (episode) { if (episode.season_num == season_num) { 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); } /** * Отфильтровать файлы * @returns array */ function filtred() { var filtred = []; results.slice(0, 1).forEach(function (movie) { if (movie.episodes) { var season_num = filter_items.season_num[choice.season]; movie.episodes.forEach(function (episode) { if (episode.season_num == season_num) { 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) { var cmp = b.max_quality - a.max_quality; if (!cmp) return cmp; return b.id - a.id; }); temp.slice(0, 1).forEach(function (media) { var num = parseInt(episode.num); if (isNaN(num)) num = episode.num; filtred.push({ title: 'S' + episode.season_num + ' / ' + Lampa.Lang.translate('torrent_serial_episode') + ' ' + num + ' - ' + (episode.title || episode.ru_title || episode.en_title || episode.orig_title), quality: media.max_quality + 'p', info: ' / ' + filter_items.voice[choice.voice], season: episode.season_num, episode: num, max_quality: media.max_quality, translation: media.translation_id }); }); } }); filtred.sort(function (a, b) { return a.episode - b.episode; }); } else if (movie.media) { var temp = {}; var translations = []; movie.media.forEach(function (element) { var old = temp[element.translation_id]; if (old) { if (old.max_quality > element.max_quality) return; if (old.id > element.id) return; } else { translations.push(element.translation_id); } temp[element.translation_id] = element; }); translations.forEach(function (translation_id) { var element = temp[translation_id]; filtred.push({ title: element.translation.title || element.translation.short_title || element.translation.shorter_title || select_title, quality: element.max_quality + 'p' + (element.source_quality ? ' - ' + element.source_quality.toUpperCase() : ''), info: '', max_quality: element.max_quality, translation: element.translation_id }); }); } }); return filtred; } /** * Добавить видео * @param {Array} items */ function append(items) { component.reset(); if (get_links_wait) component.append($('
')); var viewed = Lampa.Storage.cache('online_view', 5000, []); var last_episode = component.getLastEpisode(items); items.forEach(function (element) { if (element.season) { element.translate_episode_end = last_episode; element.translate_voice = filter_items.voice[choice.voice]; } var hash = Lampa.Utils.hash(element.season ? [element.season, element.season > 10 ? ':' : '', element.episode, object.movie.original_title].join('') : object.movie.original_title); var view = Lampa.Timeline.view(hash); var item = Lampa.Template.get('online_mod', element); var hash_file = Lampa.Utils.hash(element.season ? [element.season, element.season > 10 ? ':' : '', element.episode, object.movie.original_title, filter_items.voice[choice.voice]].join('') : object.movie.original_title + element.title); element.timeline = view; item.append(Lampa.Timeline.render(view)); if (Lampa.Timeline.details) { item.find('.online__quality').append(Lampa.Timeline.details(view, ' / ')); } if (viewed.indexOf(hash_file) !== -1) item.append('
' + Lampa.Template.get('icon_star', {}, true) + '
'); item.on('hover:enter', function () { if (object.movie.id) Lampa.Favorite.add('history', object.movie, 100); var extra = getFile(element, element.max_quality); if (extra.file) { var playlist = []; var first = { url: extra.file, quality: extra.quality, timeline: element.timeline, title: element.season ? element.title : select_title + (element.title == select_title ? '' : ' / ' + element.title) }; if (element.season) { items.forEach(function (elem) { var ex = getFile(elem, elem.max_quality); playlist.push({ url: ex.file, quality: ex.quality, timeline: elem.timeline, title: elem.title }); }); } else { playlist.push(first); } if (playlist.length > 1) first.playlist = playlist; Lampa.Player.play(first); Lampa.Player.playlist(playlist); if (viewed.indexOf(hash_file) == -1) { viewed.push(hash_file); item.append('
' + Lampa.Template.get('icon_star', {}, true) + '
'); Lampa.Storage.set('online_view', viewed); } } else Lampa.Noty.show(Lampa.Lang.translate(get_links_wait ? 'online_mod_waitlink' : 'online_mod_nolink')); }); component.append(item); component.contextmenu({ item: item, view: view, viewed: viewed, hash_file: hash_file, element: element, file: function file(call) { call(getFile(element, element.max_quality)); } }); }); component.start(true); } } function rezka(component, _object) { var network = new Lampa.Reguest(); var extract = {}; var object = _object; var select_title = ''; var select_id = ''; var prefer_http = Lampa.Storage.field('online_mod_prefer_http') === true; var prefer_mp4 = Lampa.Storage.field('online_mod_prefer_mp4') === true; var prox = component.proxy('rezka'); var embed = prox + (prox ? 'http:' : 'https:') + '//voidboost.tv/'; var iframe_proxy = !prox && Lampa.Storage.field('online_mod_iframe_proxy') === true && window.location.protocol.startsWith('http') && !Lampa.Platform.is('android'); var filter_items = {}; var choice = { season: 0, voice: 0, voice_name: '' }; /** * Поиск * @param {Object} _object */ this.search = function (_object, kinopoisk_id) { object = _object; select_id = kinopoisk_id; select_title = object.search || object.movie.title; if (!object.clarification && object.movie.imdb_id && select_id != object.movie.imdb_id) { select_id += ',' + object.movie.imdb_id; } getFirstTranlate(select_id, function (voice) { getFilm(select_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); }; /** * Применить фильтр * @param {*} type * @param {*} a * @param {*} b */ 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(); component.loading(true); var voice = extract.voice[choice.voice]; choice.voice_id = voice.id; getFilm(select_id, voice); component.saveChoice(choice); setTimeout(component.closeFilter, 10); }; /** * Уничтожить */ this.destroy = function () { network.clear(); extract = null; }; function getSeasons(voice, call) { var url = embed + 'serial/' + voice.token + '/iframe?h=gidonline.io'; if (voice.d) url += '&d=' + encodeURIComponent(voice.d); network.clear(); network.timeout(10000); network["native"](url, function (str) { extractData(str); call(); }, function (a, c) { component.empty(network.errorDecode(a, c)); }, false, { dataType: 'text' }); } function getChoiceVoice() { var res = extract.voice[0]; if (choice.voice_id) { extract.voice.forEach(function (voice) { if (voice.id === choice.voice_id) res = voice; }); } else if (choice.voice_name) { extract.voice.forEach(function (voice) { if (voice.name === choice.voice_name) 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) { var voice = getChoiceVoice(); choice.voice_id = voice.id; choice.voice_name = voice.name; call(voice); } else component.emptyForQuery(select_title); }, function (a, c) { if (a.status == 404 && a.responseText && a.responseText.indexOf('Видео не найдено') !== -1 || a.status == 0 && a.statusText !== 'timeout') { component.emptyForQuery(select_title); } else component.empty(network.errorDecode(a, c)); }, false, { dataType: 'text' }); } function getEmbed(url) { network.clear(); network.timeout(10000); network["native"](url, function (str) { component.loading(false); extractData(str); filter(); append(); }, function (a, c) { component.empty(network.errorDecode(a, c)); }, false, { dataType: 'text' }); } /** * Запросить фильм * @param {Int} id * @param {String} voice */ function getFilm(id, voice) { var url = embed; if (voice && voice.token) { if (extract.season.length) { var ses = extract.season[Math.min(extract.season.length - 1, choice.season)].id; url += 'serial/' + voice.token + '/iframe?s=' + ses + '&h=gidonline.io'; if (voice.d) url += '&d=' + encodeURIComponent(voice.d); 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.token + '/iframe?s=' + extract.season[choice.season].id + '&h=gidonline.io'; if (voice.d) url += '&d=' + encodeURIComponent(voice.d); } getEmbed(url); }); } else { url += 'movie/' + voice.token + '/iframe?h=gidonline.io'; if (voice.d) url += '&d=' + encodeURIComponent(voice.d); 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 (!filter_items.season[choice.season]) choice.season = 0; 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 parseSubtitles(str) { var subtitles = []; var subtitle = str.match("'subtitle': '(.*?)'"); if (subtitle) { subtitles = component.parsePlaylist(subtitle[1]).map(function (item) { var link = item.links[0] || ''; if (prefer_http) { link = link.replace('https://', 'http://'); } else { link = link.replace('http://', 'https://'); } return { label: item.label, url: link }; }); } return subtitles.length ? subtitles : false; } /** * Получить потоки * @param {String} str * @returns array */ function extractItems(str) { if (!str) return []; try { var items = component.parsePlaylist(str).map(function (item) { var quality = item.label.match(/(\d\d\d+)p/); var links; if (prefer_mp4) { links = item.links.filter(function (url) { return /\.mp4$/i.test(url); }); } else { links = item.links.filter(function (url) { return /\.m3u8$/i.test(url); }); } if (!links.length) links = item.links; var link = links[0] || ''; if (prefer_http) { link = link.replace('https://', 'http://'); } else { link = link.replace('http://', 'https://'); } 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 []; } /** * Получить поток * @param {*} element */ function getStream(element, call, error) { if (element.stream) return call(element); 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'; } if (element.voice.d) url += '&d=' + encodeURIComponent(element.voice.d); var call_success = function call_success(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); } else error(); } else error(); }; if (iframe_proxy) { component.proxyCall3('GET', url, 5000, null, call_success, error); } else { network.clear(); network.timeout(5000); network["native"](url, call_success, 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 = ['$$$####!!!!!!!', '^^^^^^##@', '@!^^!@#@@$$$$$', '^^#@@!!@#!$', '@#!@@@##$$@@']; var x = data.substring(2); trashList.forEach(function (trash) { x = x.replace('//_//' + enc(trash), ''); }); try { x = dec(x); } catch (e) { x = ''; } return x; } /** * Получить данные о фильме * @param {String} str */ 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, d: $(this).attr('data-d'), 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 = []; var viewed = Lampa.Storage.cache('online_view', 5000, []); if (extract.season.length) { var ses = extract.season[Math.min(extract.season.length - 1, choice.season)].id; var voice = getChoiceVoice(); extract.episode.forEach(function (episode) { items.push({ title: 'S' + ses + ' / ' + episode.name, quality: '360p ~ 1080p', info: ' / ' + voice.name, season: parseInt(ses), episode: parseInt(episode.id), voice: voice }); }); } else { extract.voice.forEach(function (voice) { items.push({ title: voice.name || select_title, quality: '360p ~ 1080p', info: '', voice: voice }); }); } var last_episode = component.getLastEpisode(items); items.forEach(function (element) { if (element.season) { element.translate_episode_end = last_episode; element.translate_voice = element.voice.name; } var hash = Lampa.Utils.hash(element.season ? [element.season, element.season > 10 ? ':' : '', element.episode, object.movie.original_title].join('') : object.movie.original_title); var view = Lampa.Timeline.view(hash); var item = Lampa.Template.get('online_mod', element); var hash_file = 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); element.timeline = view; item.append(Lampa.Timeline.render(view)); if (Lampa.Timeline.details) { item.find('.online__quality').append(Lampa.Timeline.details(view, ' / ')); } if (viewed.indexOf(hash_file) !== -1) item.append('
' + Lampa.Template.get('icon_star', {}, true) + '
'); item.on('hover:enter', function () { if (element.loading) return; if (object.movie.id) Lampa.Favorite.add('history', object.movie, 100); element.loading = true; getStream(element, function (element) { element.loading = false; var first = { url: element.stream, quality: element.qualitys, subtitles: element.subtitles, timeline: element.timeline, title: element.season ? element.title : select_title + (element.title == select_title ? '' : ' / ' + element.title) }; Lampa.Player.play(first); if (element.season && Lampa.Platform.version) { var playlist = []; items.forEach(function (elem) { if (elem == element) { playlist.push(first); } else { var cell = { url: function url(call) { getStream(elem, function (elem) { cell.url = elem.stream; cell.quality = elem.qualitys; cell.subtitles = elem.subtitles; call(); }, function () { cell.url = ''; call(); }); }, timeline: elem.timeline, title: elem.title }; playlist.push(cell); } }); Lampa.Player.playlist(playlist); } else { Lampa.Player.playlist([first]); } if (viewed.indexOf(hash_file) == -1) { viewed.push(hash_file); item.append('
' + Lampa.Template.get('icon_star', {}, true) + '
'); Lampa.Storage.set('online_view', viewed); } }, function () { element.loading = false; Lampa.Noty.show(Lampa.Lang.translate('online_mod_nolink')); }); }); component.append(item); component.contextmenu({ item: item, view: view, viewed: viewed, hash_file: hash_file, element: element, file: function file(call) { getStream(element, function (element) { call({ file: element.stream, quality: element.qualitys }); }, function () { Lampa.Noty.show(Lampa.Lang.translate('online_mod_nolink')); }); } }); }); component.start(true); } } function rezka2(component, _object) { var network = new Lampa.Reguest(); var extract = {}; var object = _object; var select_title = ''; var prefer_http = Lampa.Storage.field('online_mod_prefer_http') === true; var prefer_mp4 = Lampa.Storage.field('online_mod_prefer_mp4') === true; var proxy_mirror = Lampa.Storage.field('online_mod_proxy_rezka2_mirror') === true; var prox = component.proxy('rezka2'); var host = prox && !proxy_mirror ? 'https://hdrezka.ag' : Utils.rezka2Mirror(); var embed = prox + host + '/'; var logged_in = Lampa.Storage.field('online_mod_rezka2_status') === true && !prox; var network_call = logged_in ? network.silent : network["native"]; var headers = Lampa.Platform.is('android') && !logged_in ? { 'Origin': host, 'Referer': host + '/', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36', 'Cookie': atob('ZGxlX3VzZXJfdGFrZW49MTsgZGxlX3VzZXJfdG9rZW49NWEwN2IwNzFhYjNjMzIwMWUxMjYxZTlhYTM0ODAyOTM7IGRsZV91c2VyX2lkPTk3NTE5NTsgZGxlX3Bhc3N3b3JkPTM0M2FkOTAxYzBmMTY4MTk1OTU1NTY5MjY3NmM1YmU5') } : {}; var filter_items = {}; var choice = { season: 0, voice: 0, voice_name: '' }; /** * Поиск * @param {Object} _object */ this.search = function (_object, kinopoisk_id, data) { var _this = this; object = _object; select_title = object.search || object.movie.title; if (this.wait_similars && data && data[0].is_similars) return getPage(data[0].link); var search_date = object.search_date || !object.clarification && (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 url = embed + 'engine/ajax/search.php'; var display = function display(links) { if (links && links.length) { var is_sure = false; var items = links.map(function (l) { var li = $(l); var link = $('a', li); var enty = $('.enty', link); var rating = $('.rating', link); var titl = enty.text().trim() || ''; enty.remove(); rating.remove(); var alt_titl = link.text().trim() || ''; var orig_title = ''; var year; var found = alt_titl.match(/\((.*,\s*)?\b(\d{4})(\s*-\s*[\d.]*)?\)$/); if (found) { if (found[1]) { var found_alt = found[1].match(/^([^а-яА-ЯёЁ]+),/); if (found_alt) orig_title = found_alt[1].trim(); } year = parseInt(found[2]); } return { year: year, title: titl, orig_title: orig_title, link: link.attr('href') || '' }; }); var cards = items; if (cards.length) { if (orig) { var tmp = cards.filter(function (c) { return component.containsTitle(c.orig_title, orig) || component.containsTitle(c.title, orig); }); if (tmp.length) { cards = tmp; is_sure = true; } } if (select_title) { var _tmp = cards.filter(function (c) { return component.containsTitle(c.title, select_title) || component.containsTitle(c.orig_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 (orig) { is_sure |= component.equalTitle(cards[0].orig_title, orig) || component.equalTitle(cards[0].title, orig); } if (select_title) { is_sure |= component.equalTitle(cards[0].title, select_title) || component.equalTitle(cards[0].orig_title, select_title); } } } if (cards.length == 1 && is_sure) getPage(cards[0].link);else if (items.length) { _this.wait_similars = true; items.forEach(function (c) { c.is_similars = true; }); component.similars(items); component.loading(false); } else component.emptyForQuery(select_title); } else component.emptyForQuery(select_title); }; var query_search = function query_search(query, data, callback) { var postdata = 'q=' + encodeURIComponent(query); network.clear(); network.timeout(10000); network_call(url, function (str) { str = str.replace(/\n/g, ''); var links = str.match(/
  • /g); if (links && links.length) data = data.concat(links); if (callback) callback(data); }, function (a, c) { component.empty(network.errorDecode(a, c)); }, postdata, { dataType: 'text', withCredentials: logged_in, headers: headers }); }; var query_title_search = function query_title_search() { query_search(component.cleanTitle(select_title), [], function (data) { if (data && data.length) display(data);else display([]); }); }; if (!object.clarification && (object.movie.imdb_id || +object.movie.kinopoisk_id)) { query_search('+' + (object.movie.imdb_id || +object.movie.kinopoisk_id), [], function (data) { if (data && data.length) display(data);else if (object.movie.imdb_id && +object.movie.kinopoisk_id) { query_search('+' + +object.movie.kinopoisk_id, [], function (data) { if (data && data.length) display(data);else query_title_search(); }); } else query_title_search(); }); } else query_title_search(); }; 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); getEpisodes(success); component.saveChoice(choice); }; /** * Применить фильтр * @param {*} type * @param {*} a * @param {*} b */ 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(); component.loading(true); getEpisodes(success); component.saveChoice(choice); setTimeout(component.closeFilter, 10); }; /** * Уничтожить */ this.destroy = function () { network.clear(); extract = null; }; function getPage(url) { url = url.indexOf('://') == -1 ? embed + (url.startsWith('/') ? url.substring(1) : url) : prox + url; network.clear(); network.timeout(10000); network_call(url, function (str) { extractData(str); if (extract.film_id) { getEpisodes(success); } else component.emptyForQuery(select_title); }, function (a, c) { component.empty(network.errorDecode(a, c)); }, false, { dataType: 'text', withCredentials: logged_in, headers: headers }); } function success() { component.loading(false); filter(); append(filtred()); } /** * Получить данные о фильме * @param {String} str */ function extractData(str) { extract.voice = []; extract.season = []; extract.episode = []; extract.voice_data = {}; extract.is_series = false; extract.film_id = ''; extract.favs = ''; str = str.replace(/\n/g, ''); var translation = str.match(/

    В переводе<\/h2>:<\/td>\s*(.*?<\/td>)/); var cdnSeries = str.match(/\.initCDNSeriesEvents\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,/); var cdnMovie = str.match(/\.initCDNMoviesEvents\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,/); var devVoiceName; if (translation) { devVoiceName = $(translation[1]).text().trim(); } if (!devVoiceName) devVoiceName = 'Оригинал'; var defVoice, defSeason, defEpisode; if (cdnSeries) { extract.is_series = true; extract.film_id = cdnSeries[1]; defVoice = { name: devVoiceName, id: cdnSeries[2] }; defSeason = { name: 'Сезон ' + cdnSeries[3], id: cdnSeries[3] }; defEpisode = { name: 'Серия ' + cdnSeries[4], season_id: cdnSeries[3], episode_id: cdnSeries[4] }; } else if (cdnMovie) { extract.film_id = cdnMovie[1]; defVoice = { name: devVoiceName, id: cdnMovie[2], is_camrip: cdnMovie[3], is_ads: cdnMovie[4], is_director: cdnMovie[5] }; } var voices = str.match(/(