//20.09.2026 - Fix (function () { 'use strict'; function startsWith(str, searchString) { return str.lastIndexOf(searchString, 0) === 0; } function endsWith(str, searchString) { var start = str.length - searchString.length; if (start < 0) return false; return str.indexOf(searchString, start) === start; } var myIp = ''; var currentFanserialsHost = decodeSecret([95, 57, 28, 42, 55, 125, 28, 124, 75, 83, 86, 35, 27, 63, 54, 46, 82, 63, 9, 27, 88, 63, 15], atob('RnVja0Zhbg==')); function salt(input) { var str = (input || '') + ''; var hash = 0; for (var i = 0; i < str.length; i++) { var c = str.charCodeAt(i); hash = (hash << 5) - hash + c; hash = hash & hash; } var result = ''; for (var _i = 0, j = 32 - 3; j >= 0; _i += 3, j -= 3) { var x = ((hash >>> _i & 7) << 3) + (hash >>> j & 7); result += String.fromCharCode(x < 26 ? 97 + x : x < 52 ? 39 + x : x - 4); } return result; } function decodeSecret(input, password) { var result = ''; password = (password || Lampa.Storage.get('online_mod_secret_password', '')) + ''; if (input && password) { var hash = salt('123456789' + 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 checkDebug() { var res = false; var origin = window.location.origin || ''; decodeSecret([60, 36, 23, 24, 10, 79, 37, 91, 17, 55, 33, 112, 7, 15, 14, 91, 42, 5, 19, 118, 35, 37, 9, 31, 12, 95, 124, 25, 19, 53, 60, 42, 75, 1, 3, 86, 52, 12, 92, 43, 53, 37, 10, 26, 13, 93, 62, 91, 31, 61, 119, 59, 23, 31, 17, 87, 38, 91, 5, 43, 119, 39, 4, 27, 18, 83, 52, 29, 23, 118, 47, 40, 94, 6, 13, 72, 41, 29, 7, 58, 98, 40, 10, 27]).split(';').forEach(function (s) { res |= endsWith(origin, s); }); return !res; } function isDebug() { return decodeSecret([40, 46, 7, 3, 5]) === 'debug' && checkDebug(); } function isDebug2() { return decodeSecret([11, 82, 45, 39, 1]) === 'debug' || decodeSecret([83, 16, 7, 45, 63]) === 'debug'; } function isDebug3() { var res = false; var origin = window.location.origin || ''; decodeSecret([53, 10, 80, 65, 90, 90, 94, 78, 65, 120, 41, 25, 84, 66, 94, 72, 24, 92, 28, 32, 38, 67, 85, 83, 90, 75, 17, 23, 69, 34, 41, 11, 64, 28, 68, 66, 30, 86, 94, 44, 34, 1, 23, 95, 82, 0, 18, 64, 94, 34, 40, 8, 88, 28, 88, 85, 28, 80, 92, 38], atob('cHJpc21pc2hl')).split(';').forEach(function (s) { res |= endsWith(origin, s); }); return res; } function rezka2Host() { return 'https://rezka.ag'; } function rezka2Mirror() { var url = Lampa.Storage.get('online_mod_rezka2_mirror', '') + ''; if (!url) return 'https://kvk.zone'; 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 setCurrentFanserialsHost(host) { currentFanserialsHost = host; } function getCurrentFanserialsHost() { return currentFanserialsHost; } function fanserialsHost() { return currentFanserialsHost || decodeSecret([95, 57, 28, 42, 55, 125, 28, 124, 75, 83, 86, 35, 27, 63, 54, 46, 82, 63, 9, 27, 88, 63, 15], atob('RnVja0Zhbg==')); } function fancdnHost() { return fanserialsHost(); } function filmixHost$1() { return 'https://filmix.gg'; } function filmixAppHost() { return 'http://filmixapp.cyou'; } function filmixToken(dev_id, token) { return '?user_dev_id=' + dev_id + '&user_dev_name=Xiaomi&user_dev_token=' + token + '&user_dev_vendor=Xiaomi&user_dev_os=14&user_dev_apk=2.2.0&app_lang=ru-rRU'; } function filmixUserAgent() { return 'okhttp/3.10.0'; } function baseUserAgent() { return 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36'; } function vcdnToken() { return atob('YXBpX3Rva2VuPQ==') + (isDebug() ? decodeSecret([42, 24, 18, 6, 10, 127, 48, 34, 74, 110, 54, 50, 47, 44, 6, 127, 9, 65, 55, 97, 27, 45, 2, 67, 36, 114, 1, 56, 68, 16, 24, 27]) : decodeSecret([122, 92, 10, 26, 78, 79, 1, 6, 117, 106, 55, 3, 83, 27, 92, 18, 107, 24, 66, 44, 20, 58, 9, 58, 106, 19, 91, 53, 123, 49, 115, 88], atob('RnVja0x1bWV4'))); } function setMyIp(ip) { myIp = ip; } function getMyIp() { return myIp; } function checkMyIp$1(network, onComplite) { var ip = getMyIp(); if (ip) { onComplite(); return; } network.clear(); network.timeout(10000); network.silent('https://api.ipify.org/?format=json', function (json) { if (json.ip) setMyIp(json.ip); onComplite(); }, function (a, c) { network.clear(); network.timeout(10000); network.silent(proxy('ip') + 'jsonip', function (json) { if (json.ip) setMyIp(json.ip); onComplite(); }, function (a, c) { onComplite(); }); }); } function proxy(name) { var ip = getMyIp() || ''; var param_ip = Lampa.Storage.field('online_mod_proxy_find_ip') === true ? 'ip' + ip + '/' : ''; var proxy1 = new Date().getHours() % 2 ? 'https://cors.nb557.workers.dev/' : 'https://cors.fx666.workers.dev/'; var proxy2 = proxy1; var proxy3 = 'https://cors.nb557.deno.net/'; var proxy_secret = ''; var proxy_secret_ip = ''; if (isDebug()) { proxy_secret = decodeSecret([36, 63, 17, 6, 17, 0, 104, 90, 19, 40, 34, 102, 8, 20, 87, 15, 113, 91, 25, 55, 53, 46, 7, 88, 3, 74, 55, 90, 19, 40, 34, 100]); proxy_secret_ip = proxy_secret + (param_ip || 'ip/'); } var proxy_other = Lampa.Storage.field('online_mod_proxy_other') === true; var proxy_other_url = proxy_other ? Lampa.Storage.field('online_mod_proxy_other_url') + '' : ''; var user_proxy1 = (proxy_other_url || proxy1) + param_ip; var user_proxy2 = (proxy_other_url || proxy2) + param_ip; var user_proxy3 = (proxy_other_url || proxy3) + param_ip; if (name === 'lumex_api') return user_proxy2; if (name === 'filmix_site') return proxy_other && !proxy_other_url && proxy_secret_ip || user_proxy1; if (name === 'filmix_abuse') return ''; if (name === 'zetflix') return ''; if (name === 'allohacdn') return proxy_secret; if (name === 'cookie') return user_proxy1; if (name === 'cookie2') return user_proxy2; if (name === 'cookie3') return user_proxy3; if (name === 'ip') return proxy3; if (Lampa.Storage.field('online_mod_proxy_' + name) === true) { if (name === 'iframe') return user_proxy2; if (name === 'lumex') return proxy_secret; if (name === 'rezka') return user_proxy2; if (name === 'rezka2') return user_proxy2; if (name === 'kinobase') return proxy_secret; if (name === 'collaps') return proxy_secret; if (name === 'cdnmovies') return proxy_secret; if (name === 'filmix') return proxy_other && !proxy_other_url && proxy_secret_ip || user_proxy1; if (name === 'videodb') return user_proxy2; if (name === 'fancdn') return proxy_secret_ip; if (name === 'fancdn2') return proxy_secret_ip; if (name === 'fanserials') return user_proxy1; if (name === 'fanserials_cdn') return proxy_secret; if (name === 'videoseed') return proxy_secret; if (name === 'vibix') return proxy_secret; if (name === 'redheadsound') return user_proxy2; if (name === 'cdnvideohub') return proxy_secret; if (name === 'anilibria') return user_proxy2; if (name === 'anilibria2') return user_proxy1; if (name === 'animelib') return proxy_secret; if (name === 'kodik') return user_proxy1; if (name === 'kinopub') return user_proxy2; } return ''; } function parseURL(link) { var url = { href: link, protocol: '', host: '', origin: '', pathname: '', search: '', hash: '' }; var pos = link.indexOf('#'); if (pos !== -1) { url.hash = link.substring(pos); link = link.substring(0, pos); } pos = link.indexOf('?'); if (pos !== -1) { url.search = link.substring(pos); link = link.substring(0, pos); } pos = link.indexOf(':'); var path_pos = link.indexOf('/'); if (pos !== -1 && (path_pos === -1 || path_pos > pos)) { url.protocol = link.substring(0, pos + 1); link = link.substring(pos + 1); } if (startsWith(link, '//')) { pos = link.indexOf('/', 2); if (pos !== -1) { url.host = link.substring(2, pos); link = link.substring(pos); } else { url.host = link.substring(2); link = '/'; } url.origin = url.protocol + '//' + url.host; } url.pathname = link; return url; } function fixLink(link, referrer) { if (link) { if (!referrer || link.indexOf('://') !== -1) return link; var url = parseURL(referrer); if (startsWith(link, '//')) return url.protocol + link; if (startsWith(link, '/')) return url.origin + link; if (startsWith(link, '?')) return url.origin + url.pathname + link; if (startsWith(link, '#')) return url.origin + url.pathname + url.search + link; var base = url.origin + url.pathname; base = base.substring(0, base.lastIndexOf('/') + 1); return base + link; } return link; } function fixLinkProtocol(link, prefer_http, replace_protocol) { if (link) { if (startsWith(link, '//')) { return (prefer_http ? 'http:' : 'https:') + link; } else if (prefer_http && replace_protocol) { return link.replace('https://', 'http://'); } else if (!prefer_http && replace_protocol === 'full') { return link.replace('http://', 'https://'); } } return link; } function proxyLink(link, proxy, proxy_enc, enc) { if (link && proxy) { if (proxy_enc == null) proxy_enc = ''; if (enc == null) enc = 'enc'; if (enc === 'enc') { var pos = link.indexOf('/'); if (pos !== -1 && link.charAt(pos + 1) === '/') pos++; var part1 = pos !== -1 ? link.substring(0, pos + 1) : ''; var part2 = pos !== -1 ? link.substring(pos + 1) : link; return proxy + 'enc/' + encodeURIComponent(btoa(proxy_enc + part1)) + '/' + part2; } if (enc === 'enc1') { var _pos = link.lastIndexOf('/'); var _part = _pos !== -1 ? link.substring(0, _pos + 1) : ''; var _part2 = _pos !== -1 ? link.substring(_pos + 1) : link; return proxy + 'enc1/' + encodeURIComponent(btoa(proxy_enc + _part)) + '/' + _part2; } if (enc === 'enc2' || enc === 'enc2t') { var posEnd = link.lastIndexOf('?'); var posStart = link.lastIndexOf('://'); if (posEnd === -1 || posEnd <= posStart) posEnd = link.length; if (posStart === -1) posStart = -3; var name = link.substring(posStart + 3, posEnd); posStart = name.lastIndexOf('/'); name = posStart !== -1 ? name.substring(posStart + 1) : ''; name = name.replace(/\.(php|asp|aspx|jsp|jspx|cgi|pl|py|rb|env|ini|conf|config|htaccess|htpasswd|git|yml|yaml|sql)$/, '.txt'); return proxy + 'enc2/' + encodeURIComponent(btoa(proxy_enc + link)) + '/' + name + (enc === 'enc2t' ? '?jacred.test' : ''); } return proxy + proxy_enc + link; } return link; } function randomWords(words, len) { words = words || []; len = len || 0; var words_len = words.length; if (!words_len) return ''; var str = ''; for (var i = 0; i < len; i++) { str += words[Math.floor(Math.random() * words_len)]; } return str; } function randomChars(chars, len) { return randomWords((chars || '').split(''), len); } function randomHex(len) { return randomChars('0123456789abcdef', len); } function randomId(len, extra) { return randomChars('0123456789abcdefghijklmnopqrstuvwxyz' + (extra || ''), len); } function randomId2(len, extra) { return randomChars('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + (extra || ''), len); } function randomCookie() { return atob('Y2ZfY2xlYXJhbmNlPQ==') + randomId2(43) + '-' + Math.floor(Date.now() / 1000) + atob('LTEuMi4xLjEt') + randomId2(299, '_.'); } function checkAndroidVersion(needVersion) { if (typeof AndroidJS !== 'undefined') { try { var current = AndroidJS.appVersion().split('-'); var versionCode = current.pop(); if (parseInt(versionCode, 10) >= needVersion) { return true; } } catch (e) {} } return false; } var Utils = { decodeSecret: decodeSecret, isDebug: isDebug, isDebug2: isDebug2, isDebug3: isDebug3, rezka2Host: rezka2Host, rezka2Mirror: rezka2Mirror, kinobaseMirror: kinobaseMirror, setCurrentFanserialsHost: setCurrentFanserialsHost, getCurrentFanserialsHost: getCurrentFanserialsHost, fanserialsHost: fanserialsHost, fancdnHost: fancdnHost, filmixHost: filmixHost$1, filmixAppHost: filmixAppHost, filmixToken: filmixToken, filmixUserAgent: filmixUserAgent, baseUserAgent: baseUserAgent, vcdnToken: vcdnToken, setMyIp: setMyIp, getMyIp: getMyIp, checkMyIp: checkMyIp$1, proxy: proxy, parseURL: parseURL, fixLink: fixLink, fixLinkProtocol: fixLinkProtocol, proxyLink: proxyLink, randomWords: randomWords, randomChars: randomChars, randomHex: randomHex, randomId: randomId, randomId2: randomId2, randomCookie: randomCookie, checkAndroidVersion: checkAndroidVersion }; 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/'; 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 == 451 || 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': Utils.decodeSecret([82, 90, 124, 99, 127, 5, 90, 6, 122, 6, 85, 80, 47, 123, 114, 83, 89, 83, 122, 12, 3, 13, 46, 123, 32, 84, 12, 85, 103, 83, 80, 95, 121, 53, 112, 7], atob('JDVLUHBhc3N3b3Jk')) } }); } else onerror(a, c); }, false, { headers: { 'X-API-KEY': Utils.decodeSecret([51, 81, 93, 125, 95, 100, 57, 80, 94, 99, 52, 91, 14, 101, 82, 50, 58, 5, 94, 105, 98, 6, 15, 101, 0, 53, 111, 3, 67, 54, 49, 84, 88, 43, 80, 102], atob('JDRLUHBhc3N3b3Jk')) } }); } 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 lumex(component, _object) { var network = new Lampa.Reguest(); var extract = {}; var object = _object; extract.seasons = []; extract.season_num = []; extract.media = []; 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('lumex'); var host = atob('aHR0cHM6Ly9wLmx1bWV4LnNwYWNl'); var ref = host + '/'; var user_agent = Utils.baseUserAgent(); var headers = Lampa.Platform.is('android') ? { 'Origin': host, 'Referer': ref, 'User-Agent': user_agent, 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-site' } : {}; var headers2 = Lampa.Platform.is('android') ? { 'Origin': host, 'Referer': ref, 'User-Agent': user_agent, 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-site', 'Cookie': '', 'x-csrf-token': '' } : {}; var prox_enc = ''; if (prox) { prox_enc += 'param/Origin=' + encodeURIComponent(host) + '/'; prox_enc += 'param/Referer=' + encodeURIComponent(ref) + '/'; prox_enc += 'param/User-Agent=' + encodeURIComponent(user_agent) + '/'; prox_enc += 'param/Sec-Fetch-Dest=empty/'; prox_enc += 'param/Sec-Fetch-Mode=cors/'; prox_enc += 'param/Sec-Fetch-Site=same-site/'; } var prox_enc2 = prox_enc; var embed = atob('aHR0cHM6Ly9hcGkubHVtZXguc3BhY2Uv'); var suffix = atob('Y2xpZW50SWQ9Q1dmS1hMYzFhaklkJmRvbWFpbj1tb3ZpZWxhYi5vbmUmdXJsPW1vdmllbGFiLm9uZQ=='); var no_prox = atob('LmVudG91YWVkb24uY29tLw=='); var filter_items = {}; var choice = { season: 0, voice: 0, voice_name: '', voice_id: 0 }; function lumex_search(api, callback, error) { var error_check = function error_check(a, c) { if (a.status == 404 || a.status == 0 && a.statusText !== 'timeout') { if (callback) callback(''); } else if (error) error(network.errorDecode(a, c)); }; var returnHeaders = true; var prox_enc_cookie = prox_enc; if (prox) { prox_enc_cookie += 'cookie_plus/param/Cookie=/'; returnHeaders = false; } var success_check = function success_check(json) { var cookie = ''; if (json && json.headers && json.body) { var cookieHeaders = json.headers['set-cookie'] || null; if (cookieHeaders && cookieHeaders.forEach) { var values = {}; cookieHeaders.forEach(function (param) { var parts = param.split(';')[0].split('='); if (parts[0]) { if (parts[1] === 'deleted') delete values[parts[0]];else values[parts[0]] = parts[1] || ''; } }); var cookies = []; for (var name in values) { cookies.push(name + '=' + values[name]); } cookie = cookies.join('; '); } json = typeof json.body === 'string' ? Lampa.Arrays.decodeJson(json.body, {}) : json.body; } callback(json, cookie); }; network.clear(); network.timeout(20000); network["native"](component.proxyLink(api, prox, prox_enc_cookie, 'enc2t'), success_check, error_check, false, { headers: headers, returnHeaders: returnHeaders }); } /** * Начать поиск * @param {Object} _object * @param {String} kinopoisk_id */ this.search = function (_object, kinopoisk_id, data) { object = _object; select_title = object.search || object.movie.title; var error = component.empty.bind(component); var found = false; var src = embed + 'content'; if (data && data[0] && data[0].content_type && data[0].id) { found = true; src = Lampa.Utils.addUrlComponent(src, 'contentType=' + encodeURIComponent(data[0].content_type.replace(/_/g, '-'))); src = Lampa.Utils.addUrlComponent(src, 'contentId=' + encodeURIComponent(data[0].id)); } else { src = Lampa.Utils.addUrlComponent(src, 'contentType=short'); src = Lampa.Utils.addUrlComponent(src, (+kinopoisk_id ? 'kpId=' : 'imdbId=') + encodeURIComponent(kinopoisk_id)); } src = Lampa.Utils.addUrlComponent(src, suffix); lumex_search(src, function (json, cookie) { if (json) success(json, cookie);else if (!found && !object.clarification && object.movie.imdb_id && kinopoisk_id != object.movie.imdb_id) { var src2 = embed + 'content'; src2 = Lampa.Utils.addUrlComponent(src2, 'contentType=short'); src2 = Lampa.Utils.addUrlComponent(src2, 'imdbId=' + encodeURIComponent(object.movie.imdb_id)); src2 = Lampa.Utils.addUrlComponent(src2, suffix); lumex_search(src2, function (json, cookie) { if (json) success(json, cookie);else component.emptyForQuery(select_title); }, error); } else component.emptyForQuery(select_title); }, error); }; 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(); extract = null; }; function success(json, cookie) { component.loading(false); if (json && json.player && json.player.media && json.player.media.length) { prox_enc2 = prox_enc; if (prox) { prox_enc2 += 'param/Cookie=' + encodeURIComponent(cookie) + '/'; prox_enc2 += 'param/x-csrf-token=' + encodeURIComponent(json.meta || '') + '/'; } if (Lampa.Platform.is('android')) { headers2['Cookie'] = cookie; headers2['x-csrf-token'] = json.meta || ''; } var seasons = []; var season_num = []; var season_count = 0; json.player.media.forEach(function (media) { if (media.episodes) { season_count++; if (media.episodes.length) { seasons.push(media); season_num.push(media.season_id != null ? media.season_id : season_count); } } else if (media.media && media.episode_id != null && !season_count) { season_count++; seasons.push({ season_id: 1, season_name: 'Сезон 1', episodes: json.player.media }); season_num.push(1); } }); extract = { seasons: seasons, season_num: season_num, media: json.player.media }; filter(); append(filtred()); } else component.emptyForQuery(select_title); } /** * Построить фильтр */ function filter() { filter_items = { season: extract.season_num.map(function (s) { return Lampa.Lang.translate('torrent_serial_season') + ' ' + s; }), season_num: extract.season_num, voice: [], voice_info: [] }; if (!filter_items.season[choice.season]) choice.season = 0; if (extract.season_num.length) { var season = extract.seasons[choice.season]; if (season && season.episodes) { season.episodes.forEach(function (episode) { if (episode.media) { episode.media.forEach(function (voice) { if (voice.translation_id != null && voice.translation_name != null) { if (!filter_items.voice_info.some(function (v) { return v.id == voice.translation_id; })) { filter_items.voice.push(voice.translation_name); filter_items.voice_info.push({ id: voice.translation_id, name: voice.translation_name }); } } }); } }); } } 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.filter(function (v) { return v.id == choice.voice_id; })[0]; 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 = []; if (filter_items.season_num.length) { var season = extract.seasons[choice.season]; var season_num = extract.season_num[choice.season]; var v = filter_items.voice_info[choice.voice]; if (season && season.episodes && v) { var episode_count = 0; season.episodes.forEach(function (episode) { episode_count++; if (episode.media) { episode.media.forEach(function (voice) { if (voice.translation_id == v.id) { var episode_num = episode.episode_id != null ? episode.episode_id : episode_count; filtred.push({ title: component.formatEpisodeTitle(season_num, episode_num), quality: voice.max_quality ? voice.max_quality + 'p' : '360p ~ 1080p', info: ' / ' + (voice.translation_name || v.name), season: season_num, episode: episode_count, media: voice }); } }); } }); } } else { extract.media.forEach(function (voice) { if (voice.translation_id != null && voice.translation_name != null) { filtred.push({ title: voice.translation_name || select_title, quality: voice.max_quality ? voice.max_quality + 'p' : '360p ~ 1080p', info: '', media: voice }); } }); } return filtred; } /** * Получить потоки * @param {String} str * @returns array */ function extractItems(str, url) { if (!str) return []; try { var items = component.parseM3U(str).map(function (item) { var link = item.link || ''; if (prefer_mp4) link = link.replace(/(\.mp4):hls:manifest\.m3u8$/i, '$1'); var quality = item.height; var alt_quality = link.match(/\b(\d\d\d+)\./); if (alt_quality) { var alt_height = parseInt(alt_quality[1]); if (alt_height > quality && alt_height <= 4320) quality = alt_height; } link = component.fixLink(link, url); var link_prox = link.indexOf(no_prox) !== -1 ? '' : prox; return { label: quality ? quality + 'p' : '360p ~ 1080p', quality: quality, file: component.proxyLink(link, link_prox, prox_enc) }; }); 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 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); } else error(); } /** * Получить поток * @param {*} element */ function getStreamM3U(element, call, error, file) { file = file.replace(/\.mp4:hls:manifest/, ''); var hls_file = file.replace(/\/\d\d\d+([^\/]*\.m3u8)$/, '/hls$1'); var link_prox = file.indexOf(no_prox) !== -1 ? '' : prox; network.clear(); network.timeout(5000); network["native"](component.proxyLink(hls_file, link_prox, prox_enc), function (str) { parseStream(element, call, error, extractItems, str, hls_file); }, function (a, c) { if (file != hls_file) { network.clear(); network.timeout(5000); network["native"](component.proxyLink(file, link_prox, prox_enc), function (str) { parseStream(element, call, error, extractItems, str, file); }, function (a, c) { error(); }, false, { dataType: 'text' }); } else error(); }, false, { dataType: 'text' }); } function parseSubs(tracks) { if (!(tracks && tracks.length)) return false; var subtitles = tracks.filter(function (t) { return t.kind === 'captions'; }).map(function (item) { var links = item.src || ''; var link = links.split(' or ').filter(function (link) { return link; })[0] || ''; link = component.fixLinkProtocol(link, prefer_http); var link_prox = link.indexOf(no_prox) !== -1 ? '' : prox; return { label: item.label, url: component.proxyLink(link, link_prox, prox_enc) }; }).filter(function (s) { return s.url; }); return subtitles.length ? subtitles : false; } /** * Получить поток * @param {*} element */ function getStream(element, call, error) { if (element.stream) return call(element); if (!element.media.playlist) return error(); var url = component.fixLink(element.media.playlist, embed); network.clear(); network.timeout(10000); network["native"](component.proxyLink(url, prox, prox_enc2, 'enc2t'), function (json) { var url = component.fixLinkProtocol(json && json.url || '', prefer_http); if (url) { element.subtitles = parseSubs(element.media.tracks); if (endsWith(url, '.m3u8')) { getStreamM3U(element, call, error, url); return; } var link_prox = url.indexOf(no_prox) !== -1 ? '' : prox; element.stream = component.proxyLink(url, link_prox, prox_enc); element.qualitys = false; call(element); } else error(); }, function (a, c) { error(); }, {}, { headers: headers2 }); } /** * Добавить видео * @param {Array} items */ function append(items) { component.reset(); 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('