mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 00:32:04 +00:00
crucial changes
This commit is contained in:
parent
9006d312b8
commit
f36a9a9780
4 changed files with 930 additions and 6 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6be646d6702a809b28eac63b7d04a453f756c402
|
Subproject commit 10a18e6867d4600851c8b263a2d82665298b3990
|
||||||
894
package-lock.json
generated
894
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -29,7 +29,7 @@
|
||||||
"@types/react-native-video": "^5.0.20",
|
"@types/react-native-video": "^5.0.20",
|
||||||
"axios": "^1.10.0",
|
"axios": "^1.10.0",
|
||||||
"base64-js": "^1.5.1",
|
"base64-js": "^1.5.1",
|
||||||
"cheerio": "^1.1.0",
|
"cheerio-without-node-native": "^0.20.2",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"eventemitter3": "^5.0.1",
|
"eventemitter3": "^5.0.1",
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ export interface ScraperInfo {
|
||||||
|
|
||||||
export interface LocalScraperResult {
|
export interface LocalScraperResult {
|
||||||
title: string;
|
title: string;
|
||||||
|
name?: string;
|
||||||
url: string;
|
url: string;
|
||||||
quality?: string;
|
quality?: string;
|
||||||
size?: string;
|
size?: string;
|
||||||
|
|
@ -297,6 +298,18 @@ class LocalScraperService {
|
||||||
const moduleExports = {};
|
const moduleExports = {};
|
||||||
const moduleObj = { exports: moduleExports };
|
const moduleObj = { exports: moduleExports };
|
||||||
|
|
||||||
|
// Try to load cheerio-without-node-native
|
||||||
|
let cheerio = null;
|
||||||
|
try {
|
||||||
|
cheerio = require('cheerio-without-node-native');
|
||||||
|
} catch (error) {
|
||||||
|
try {
|
||||||
|
cheerio = require('react-native-cheerio');
|
||||||
|
} catch (error2) {
|
||||||
|
// Cheerio not available, scrapers will fall back to regex
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const sandbox = {
|
const sandbox = {
|
||||||
console: {
|
console: {
|
||||||
log: (...args: any[]) => logger.log('[Scraper]', ...args),
|
log: (...args: any[]) => logger.log('[Scraper]', ...args),
|
||||||
|
|
@ -313,6 +326,19 @@ class LocalScraperService {
|
||||||
parseFloat,
|
parseFloat,
|
||||||
encodeURIComponent,
|
encodeURIComponent,
|
||||||
decodeURIComponent,
|
decodeURIComponent,
|
||||||
|
// Add require function for specific modules
|
||||||
|
require: (moduleName: string) => {
|
||||||
|
switch (moduleName) {
|
||||||
|
case 'cheerio-without-node-native':
|
||||||
|
if (cheerio) return cheerio;
|
||||||
|
throw new Error('cheerio-without-node-native not available');
|
||||||
|
case 'react-native-cheerio':
|
||||||
|
if (cheerio) return cheerio;
|
||||||
|
throw new Error('react-native-cheerio not available');
|
||||||
|
default:
|
||||||
|
throw new Error(`Module '${moduleName}' is not available in sandbox`);
|
||||||
|
}
|
||||||
|
},
|
||||||
// Add fetch for HTTP requests (using axios as polyfill)
|
// Add fetch for HTTP requests (using axios as polyfill)
|
||||||
fetch: async (url: string, options: any = {}) => {
|
fetch: async (url: string, options: any = {}) => {
|
||||||
const axiosConfig = {
|
const axiosConfig = {
|
||||||
|
|
@ -359,7 +385,7 @@ class LocalScraperService {
|
||||||
try {
|
try {
|
||||||
// Create function from code
|
// Create function from code
|
||||||
const func = new Function('sandbox', 'params', `
|
const func = new Function('sandbox', 'params', `
|
||||||
const { console, setTimeout, clearTimeout, Promise, JSON, Date, Math, parseInt, parseFloat, encodeURIComponent, decodeURIComponent, axios, fetch, module, exports, global } = sandbox;
|
const { console, setTimeout, clearTimeout, Promise, JSON, Date, Math, parseInt, parseFloat, encodeURIComponent, decodeURIComponent, require, axios, fetch, module, exports, global } = sandbox;
|
||||||
${code}
|
${code}
|
||||||
|
|
||||||
// Call the main function (assuming it's exported)
|
// Call the main function (assuming it's exported)
|
||||||
|
|
@ -404,8 +430,9 @@ class LocalScraperService {
|
||||||
|
|
||||||
return results.map((result, index) => {
|
return results.map((result, index) => {
|
||||||
const stream: Stream = {
|
const stream: Stream = {
|
||||||
name: result.title || `${scraper.name} Stream ${index + 1}`,
|
// Preserve scraper's name and title if provided, otherwise use fallbacks
|
||||||
title: result.title || `${scraper.name} Stream ${index + 1}`,
|
name: result.name || result.title || `${scraper.name} Stream ${index + 1}`,
|
||||||
|
title: result.title || result.name || `${scraper.name} Stream ${index + 1}`,
|
||||||
url: result.url,
|
url: result.url,
|
||||||
addon: scraper.id,
|
addon: scraper.id,
|
||||||
addonId: scraper.id,
|
addonId: scraper.id,
|
||||||
|
|
@ -422,6 +449,11 @@ class LocalScraperService {
|
||||||
stream.infoHash = result.infoHash;
|
stream.infoHash = result.infoHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Preserve any additional fields from the scraper result
|
||||||
|
if (result.quality && !stream.quality) {
|
||||||
|
stream.quality = result.quality;
|
||||||
|
}
|
||||||
|
|
||||||
return stream;
|
return stream;
|
||||||
}).filter(stream => stream.url); // Filter out streams without URLs
|
}).filter(stream => stream.url); // Filter out streams without URLs
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue