From 14893f1db28590849ede630480657a5a0f0efcb8 Mon Sep 17 00:00:00 2001 From: nb557 <> Date: Mon, 2 Dec 2024 02:33:34 +0300 Subject: [PATCH] Fix --- online_mod.js | 432 +++++++++++++++++++++++++++++--------------------- 1 file changed, 250 insertions(+), 182 deletions(-) diff --git a/online_mod.js b/online_mod.js index 4b8fed4..d7980f6 100644 --- a/online_mod.js +++ b/online_mod.js @@ -1,4 +1,4 @@ -//30.11.2024 - Fix +//01.12.2024 - Fix (function () { 'use strict'; @@ -95,16 +95,14 @@ var ip = getMyIp() || ''; var param_ip = Lampa.Storage.field('online_mod_proxy_find_ip') === true ? 'ip' + ip + '/' : ''; var proxy1 = 'https://cors.nb557.workers.dev:8443/'; - var proxy2 = (window.location.protocol === 'https:' ? 'https://' : 'http://') + 'iqslgbok.deploy.cx/?'; + var proxy2 = (window.location.protocol === 'https:' ? 'https://' : 'http://') + 'iqslgbok.deploy.cx/'; var proxy3 = 'https://cors557.deno.dev/'; - var proxy_apn0 = ''; var proxy_apn = ''; var proxy_secret = ''; var proxy_secret_ip = ''; if (isDebug()) { - proxy_apn0 = (window.location.protocol === 'https:' ? 'https://' : 'http://') + decodeSecret([83, 85, 76, 77, 71, 82, 76, 65, 26, 92, 85, 73, 88, 92, 64, 26, 83, 76, 23]); - proxy_apn = proxy_apn0 + '?'; + proxy_apn = (window.location.protocol === 'https:' ? 'https://' : 'http://') + decodeSecret([83, 85, 76, 77, 71, 82, 76, 65, 26, 92, 85, 73, 88, 92, 64, 26, 83, 76, 23]); proxy_secret = decodeSecret([80, 68, 77, 68, 64, 3, 27, 31, 85, 72, 94, 20, 89, 81, 12, 1, 6, 26, 83, 95, 64, 81, 81, 23, 85, 64, 68, 23]); proxy_secret_ip = proxy_secret + (param_ip || 'ip/'); } @@ -127,7 +125,7 @@ if (name === 'rezka') return user_proxy2; if (name === 'rezka2') return user_proxy2; if (name === 'kinobase') return proxy_apn; - if (name === 'collaps') return proxy_other ? proxy_secret : proxy_apn0; + if (name === 'collaps') return proxy_other ? proxy_secret : proxy_apn; if (name === 'cdnmovies') return proxy_other ? proxy_secret : proxy_apn; if (name === 'filmix') return proxy_secret_ip || user_proxy1; if (name === 'videodb') return user_proxy2; @@ -143,6 +141,61 @@ return ''; } + function fixLink(link, referrer) { + if (link) { + if (!referrer || link.indexOf('://') !== -1) return link; + var url = new URL(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.href.substring(0, url.href.lastIndexOf('/') + 1); + return base + link; + } + + 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') { + 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) : ''; + return proxy + 'enc2/' + encodeURIComponent(btoa(proxy_enc + link)) + '/' + name; + } + + return proxy + proxy_enc + link; + } + + return link; + } + function randomWords(words, len) { words = words || []; len = len || 0; @@ -198,6 +251,8 @@ setMyIp: setMyIp, getMyIp: getMyIp, proxy: proxy, + fixLink: fixLink, + proxyLink: proxyLink, randomWords: randomWords, randomChars: randomChars, randomHex: randomHex, @@ -370,17 +425,18 @@ 'Cookie': '', 'x-csrf-token': '' } : {}; + var prox_enc = ''; if (prox) { - prox += 'param/Origin=' + encodeURIComponent(host) + '/'; - prox += 'param/Referer=' + encodeURIComponent(ref) + '/'; - prox += 'param/User-Agent=' + encodeURIComponent(user_agent) + '/'; - prox += 'param/Sec-Fetch-Dest=empty/'; - prox += 'param/Sec-Fetch-Mode=cors/'; - prox += 'param/Sec-Fetch-Site=same-site/'; + 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 prox2 = prox; + var prox_enc2 = prox_enc; var embed = atob('aHR0cHM6Ly9hcGkubHVtZXgucHcv'); var suffix = atob('Y2xpZW50SWQ9Q1dmS1hMYzFhaklkJmRvbWFpbj1tb3ZpZWxhYi5vbmUmdXJsPW1vdmllbGFiLm9uZQ=='); var filter_items = {}; @@ -399,10 +455,10 @@ }; var returnHeaders = true; - var cookie_prox = prox; + var prox_enc_cookie = prox_enc; - if (cookie_prox) { - cookie_prox += 'cookie_plus/param/Cookie=/'; + if (prox) { + prox_enc_cookie += 'cookie_plus/param/Cookie=/'; returnHeaders = false; } @@ -438,7 +494,7 @@ network.clear(); network.timeout(10000); - network["native"](cookie_prox + api, success_check, error_check, false, { + network["native"](component.proxyLink(api, prox, prox_enc_cookie), success_check, error_check, false, { headers: headers, returnHeaders: returnHeaders }); @@ -459,7 +515,7 @@ if (data[0] && data[0].content_type && data[0].id) { found = true; - src = Lampa.Utils.addUrlComponent(src, 'contentType=' + encodeURIComponent(data[0].content_type)); + 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'); @@ -535,11 +591,11 @@ component.loading(false); if (json && json.player && json.player.media && json.player.media.length) { - prox2 = prox; + prox_enc2 = prox_enc; - if (prox2) { - prox2 += 'param/Cookie=' + encodeURIComponent(cookie) + '/'; - prox2 += 'param/x-csrf-token=' + encodeURIComponent(json.meta || '') + '/'; + if (prox) { + prox_enc2 += 'param/Cookie=' + encodeURIComponent(cookie) + '/'; + prox_enc2 += 'param/x-csrf-token=' + encodeURIComponent(json.meta || '') + '/'; } if (Lampa.Platform.is('android')) { @@ -553,8 +609,11 @@ json.player.media.forEach(function (media) { if (media.episodes) { season_count++; - seasons.push(media); - season_num.push(media.season_id != null ? media.season_id : 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({ @@ -710,7 +769,7 @@ return { label: quality ? quality + 'p' : '360p ~ 1080p', quality: quality, - file: component.proxyStream(component.fixLink(link, '', url), 'lumex') + file: component.proxyStream(component.fixLink(link, url), 'lumex') }; }); items.sort(function (a, b) { @@ -782,19 +841,19 @@ function getSubtitles(res, subtitles, call) { if (subtitles && subtitles.length) { - var url = component.fixLink(subtitles.shift(), '', embed); + var url = component.fixLink(subtitles.shift(), embed); if (url) { network.clear(); network.timeout(10000); - network["native"](prox2 + url, function (json) { + network["native"](component.proxyLink(url, prox, prox_enc2), function (json) { var url = json && json.url ? (prefer_http ? 'http:' : 'https:') + json.url : ''; if (url) { var pos = url.lastIndexOf('/', url.length); res.push({ label: pos !== -1 ? url.substring(pos + 1) : url, - url: component.convertVttToSrt(url) + url: component.proxyStreamSubs(url, 'lumex') }); } @@ -816,10 +875,10 @@ function getStream(element, call, error) { if (element.stream) return call(element); if (!element.media.playlist) error(); - var url = component.fixLink(element.media.playlist, '', embed); + var url = component.fixLink(element.media.playlist, embed); network.clear(); network.timeout(10000); - network["native"](prox2 + url, function (json) { + network["native"](component.proxyLink(url, prox, prox_enc2), function (json) { var url = json && json.url ? (prefer_http ? 'http:' : 'https:') + json.url : ''; if (url) { @@ -1038,7 +1097,7 @@ if (voice.d) url += '&d=' + encodeURIComponent(voice.d); network.clear(); network.timeout(10000); - network["native"](prox + url, function (str) { + network["native"](component.proxyLink(url, prox), function (str) { extractData(str); call(); }, function (a, c) { @@ -1067,7 +1126,7 @@ function getFirstTranlate(id, call) { network.clear(); network.timeout(10000); - network["native"](prox + embed + 'embed/' + id, function (str) { + network["native"](component.proxyLink(embed + 'embed/' + id, prox), function (str) { extractData(str); if (extract.voice.length) { @@ -1088,7 +1147,7 @@ function getEmbed(url) { network.clear(); network.timeout(10000); - network["native"](prox + url, function (str) { + network["native"](component.proxyLink(url, prox), function (str) { component.loading(false); extractData(str); filter(); @@ -1180,7 +1239,7 @@ return { label: item.label, - url: component.convertVttToSrt(link) + url: component.processSubs(link) }; }); } @@ -1292,7 +1351,7 @@ } else { network.clear(); network.timeout(5000); - network["native"](prox + url, call_success, call_error, false, { + network["native"](component.proxyLink(url, prox), call_success, call_error, false, { dataType: 'text' }); } @@ -1528,11 +1587,12 @@ 'Referer': ref, 'User-Agent': user_agent } : {}; + var prox_enc = ''; if (prox) { - prox += 'param/Origin=' + encodeURIComponent(host) + '/'; - prox += 'param/Referer=' + encodeURIComponent(ref) + '/'; - prox += 'param/User-Agent=' + encodeURIComponent(user_agent) + '/'; + prox_enc += 'param/Origin=' + encodeURIComponent(host) + '/'; + prox_enc += 'param/Referer=' + encodeURIComponent(ref) + '/'; + prox_enc += 'param/User-Agent=' + encodeURIComponent(user_agent) + '/'; } var cookie = Lampa.Storage.get('online_mod_rezka2_cookie', '') + ''; @@ -1544,7 +1604,7 @@ } if (prox) { - prox += 'param/Cookie=' + encodeURIComponent(cookie) + '/'; + prox_enc += 'param/Cookie=' + encodeURIComponent(cookie) + '/'; } } @@ -1587,7 +1647,7 @@ var url = more_url + '&q=' + encodeURIComponent(query) + '&page=' + encodeURIComponent(page); network.clear(); network.timeout(10000); - network["native"](prox + url, function (str) { + network["native"](component.proxyLink(url, prox, prox_enc, prox_enc), function (str) { str = (str || '').replace(/\n/g, ''); var login_form = str.match(/