recycleactor commited on
Commit
9be0bcb
·
verified ·
1 Parent(s): c2a7aff

Delete alloha.js

Browse files
Files changed (1) hide show
  1. alloha.js +0 -165
alloha.js DELETED
@@ -1,165 +0,0 @@
1
- /**
2
- * Alloha stream extractor using Puppeteer
3
- * Opens the player page in a real browser, intercepts the /bnsi request
4
- */
5
- const puppeteer = require('puppeteer');
6
-
7
- // Alloha domains config
8
- const ALLOHA_DOMAINS = [
9
- {
10
- domain: 'https://streamalloha.live',
11
- token: '7fda2b04f6ae5e0e228bda812b0dee',
12
- referer: 'https://kinokrad.my/',
13
- },
14
- {
15
- domain: 'https://alloha.videozal.club',
16
- token: '7245bc6ce2604536b78f128f818b06',
17
- referer: 'https://videozal.club/',
18
- },
19
- {
20
- domain: 'https://no.nextpool.online',
21
- token: 'a4ae37fcdff5014cc929230cb83da5',
22
- referer: 'https://kinojump.com/',
23
- },
24
- ];
25
-
26
- let browserInstance = null;
27
-
28
- async function getBrowser() {
29
- if (browserInstance && browserInstance.connected) {
30
- return browserInstance;
31
- }
32
- console.log('[puppeteer] Launching browser...');
33
-
34
- const launchOptions = {
35
- headless: true,
36
- args: [
37
- '--no-sandbox',
38
- '--disable-setuid-sandbox',
39
- '--disable-dev-shm-usage',
40
- '--disable-gpu',
41
- '--no-first-run',
42
- '--no-zygote',
43
- '--single-process',
44
- '--disable-extensions',
45
- '--disable-background-networking',
46
- '--disable-default-apps',
47
- '--disable-sync',
48
- '--disable-translate',
49
- '--hide-scrollbars',
50
- '--metrics-recording-only',
51
- '--mute-audio',
52
- '--safebrowsing-disable-auto-update',
53
- ],
54
- };
55
-
56
- // Use system Chromium if specified (Docker/Railway)
57
- if (process.env.PUPPETEER_EXECUTABLE_PATH) {
58
- launchOptions.executablePath = process.env.PUPPETEER_EXECUTABLE_PATH;
59
- console.log('[puppeteer] Using system Chromium:', launchOptions.executablePath);
60
- }
61
-
62
- browserInstance = await puppeteer.launch(launchOptions);
63
- console.log('[puppeteer] Browser launched');
64
- return browserInstance;
65
- }
66
-
67
- /**
68
- * Try one domain — returns result or throws
69
- */
70
- async function tryDomain(browser, { domain, token, referer }, token_movie, timeout_ms) {
71
- const page = await browser.newPage();
72
- try {
73
- await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36');
74
- await page.setExtraHTTPHeaders({ 'Accept-Language': 'ru-RU,ru;q=0.9,en;q=0.8' });
75
-
76
- const playerUrl = `${domain}/?token_movie=${token_movie}&token=${encodeURIComponent(token)}`;
77
- console.log(`[puppeteer] Trying: ${domain}`);
78
-
79
- const bnsiPromise = new Promise((resolve, reject) => {
80
- const timer = setTimeout(() => reject(new Error(`timeout ${timeout_ms}ms`)), timeout_ms);
81
-
82
- page.on('response', async (response) => {
83
- const url = response.url();
84
- if (url.includes('/bnsi/')) {
85
- clearTimeout(timer);
86
- try {
87
- const status = response.status();
88
- const text = await response.text();
89
- console.log(`[puppeteer] bnsi ${status} ${url.substring(0, 80)}`);
90
- if (status === 200) {
91
- const json = JSON.parse(text);
92
- resolve({ ok: true, domain, url, ...json });
93
- } else {
94
- const decoded = text.replace(/\\u([0-9a-f]{4})/gi, (_, h) => String.fromCharCode(parseInt(h, 16)));
95
- reject(new Error(`bnsi ${status}: ${decoded.substring(0, 100)}`));
96
- }
97
- } catch (e) {
98
- reject(e);
99
- }
100
- }
101
- });
102
- });
103
-
104
- // Navigate with referer
105
- await page.goto(playerUrl, {
106
- waitUntil: 'domcontentloaded',
107
- timeout: timeout_ms,
108
- referer: referer,
109
- });
110
-
111
- return await bnsiPromise;
112
-
113
- } finally {
114
- await page.close();
115
- }
116
- }
117
-
118
- /**
119
- * Get streams for a movie using Puppeteer
120
- * Tries all domains in order, returns first success
121
- */
122
- async function getStreams({ token_movie, partner_token, referer, timeout_ms = 20000 }) {
123
- const browser = await getBrowser();
124
-
125
- // Build domain list — if partner_token provided, try to match or prepend custom
126
- let domains = [...ALLOHA_DOMAINS];
127
- if (partner_token) {
128
- // Find matching domain or add custom entry at front
129
- const match = domains.find(d => d.token === partner_token);
130
- if (!match) {
131
- domains.unshift({ domain: 'https://streamalloha.live', token: partner_token, referer: referer || 'https://kinokrad.my/' });
132
- } else {
133
- // Move matching domain to front
134
- domains = [match, ...domains.filter(d => d !== match)];
135
- }
136
- }
137
-
138
- let lastError = null;
139
- for (const domainConfig of domains) {
140
- try {
141
- const result = await tryDomain(browser, domainConfig, token_movie, timeout_ms);
142
- if (result && result.ok) {
143
- console.log(`[puppeteer] SUCCESS on ${domainConfig.domain}`);
144
- return result;
145
- }
146
- } catch (e) {
147
- console.log(`[puppeteer] ${domainConfig.domain} failed: ${e.message}`);
148
- lastError = e;
149
- }
150
- }
151
-
152
- throw lastError || new Error('all domains failed');
153
- }
154
-
155
- /**
156
- * Close the browser (call on shutdown)
157
- */
158
- async function closeBrowser() {
159
- if (browserInstance) {
160
- await browserInstance.close();
161
- browserInstance = null;
162
- }
163
- }
164
-
165
- module.exports = { getStreams, closeBrowser, getBrowser };