mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 00:32:04 +00:00
some major changes
This commit is contained in:
parent
f36a9a9780
commit
de07a4620b
4 changed files with 32 additions and 3 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 10a18e6867d4600851c8b263a2d82665298b3990
|
Subproject commit a251769bedb4ab2f1f983e2c2a216041c664780a
|
||||||
|
|
@ -40,6 +40,7 @@ export interface AppSettings {
|
||||||
scraperRepositoryUrl: string; // URL to the scraper repository
|
scraperRepositoryUrl: string; // URL to the scraper repository
|
||||||
enableLocalScrapers: boolean; // Enable/disable local scraper functionality
|
enableLocalScrapers: boolean; // Enable/disable local scraper functionality
|
||||||
scraperTimeout: number; // Timeout for scraper execution in seconds
|
scraperTimeout: number; // Timeout for scraper execution in seconds
|
||||||
|
enableScraperUrlValidation: boolean; // Enable/disable URL validation for scrapers
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_SETTINGS: AppSettings = {
|
export const DEFAULT_SETTINGS: AppSettings = {
|
||||||
|
|
@ -62,6 +63,7 @@ export const DEFAULT_SETTINGS: AppSettings = {
|
||||||
scraperRepositoryUrl: '',
|
scraperRepositoryUrl: '',
|
||||||
enableLocalScrapers: true,
|
enableLocalScrapers: true,
|
||||||
scraperTimeout: 60, // 60 seconds timeout
|
scraperTimeout: 60, // 60 seconds timeout
|
||||||
|
enableScraperUrlValidation: true, // Enable URL validation by default
|
||||||
};
|
};
|
||||||
|
|
||||||
const SETTINGS_STORAGE_KEY = 'app_settings';
|
const SETTINGS_STORAGE_KEY = 'app_settings';
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,10 @@ const ScraperSettingsScreen: React.FC = () => {
|
||||||
await updateSetting('enableLocalScrapers', enabled);
|
await updateSetting('enableLocalScrapers', enabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleToggleUrlValidation = async (enabled: boolean) => {
|
||||||
|
await updateSetting('enableScraperUrlValidation', enabled);
|
||||||
|
};
|
||||||
|
|
||||||
const renderScraperItem = (scraper: ScraperInfo) => (
|
const renderScraperItem = (scraper: ScraperInfo) => (
|
||||||
<View key={scraper.id} style={styles.scraperItem}>
|
<View key={scraper.id} style={styles.scraperItem}>
|
||||||
<View style={styles.scraperInfo}>
|
<View style={styles.scraperInfo}>
|
||||||
|
|
@ -232,6 +236,22 @@ const ScraperSettingsScreen: React.FC = () => {
|
||||||
thumbColor={settings.enableLocalScrapers ? '#ffffff' : '#f4f3f4'}
|
thumbColor={settings.enableLocalScrapers ? '#ffffff' : '#f4f3f4'}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
{/* URL Validation Toggle */}
|
||||||
|
<View style={styles.settingRow}>
|
||||||
|
<View style={styles.settingInfo}>
|
||||||
|
<Text style={styles.settingTitle}>Enable URL Validation</Text>
|
||||||
|
<Text style={styles.settingDescription}>
|
||||||
|
Validate streaming URLs before returning them (may slow down results but improves reliability)
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<Switch
|
||||||
|
value={settings.enableScraperUrlValidation}
|
||||||
|
onValueChange={handleToggleUrlValidation}
|
||||||
|
trackColor={{ false: '#767577', true: '#007AFF' }}
|
||||||
|
thumbColor={settings.enableScraperUrlValidation ? '#ffffff' : '#f4f3f4'}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Repository Configuration */}
|
{/* Repository Configuration */}
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,11 @@ class LocalScraperService {
|
||||||
private async executeSandboxed(code: string, params: any): Promise<LocalScraperResult[]> {
|
private async executeSandboxed(code: string, params: any): Promise<LocalScraperResult[]> {
|
||||||
// This is a simplified sandbox - in production, you'd want more security
|
// This is a simplified sandbox - in production, you'd want more security
|
||||||
try {
|
try {
|
||||||
|
// Get URL validation setting from AsyncStorage
|
||||||
|
const settingsData = await AsyncStorage.getItem('app_settings');
|
||||||
|
const settings = settingsData ? JSON.parse(settingsData) : {};
|
||||||
|
const urlValidationEnabled = settings.enableScraperUrlValidation ?? true;
|
||||||
|
|
||||||
// Create a limited global context
|
// Create a limited global context
|
||||||
const moduleExports = {};
|
const moduleExports = {};
|
||||||
const moduleObj = { exports: moduleExports };
|
const moduleObj = { exports: moduleExports };
|
||||||
|
|
@ -373,7 +378,9 @@ class LocalScraperService {
|
||||||
// Node.js compatibility
|
// Node.js compatibility
|
||||||
module: moduleObj,
|
module: moduleObj,
|
||||||
exports: moduleExports,
|
exports: moduleExports,
|
||||||
global: {} // Empty global object
|
global: {}, // Empty global object
|
||||||
|
// URL validation setting
|
||||||
|
URL_VALIDATION_ENABLED: urlValidationEnabled
|
||||||
};
|
};
|
||||||
|
|
||||||
// Execute the scraper code with timeout
|
// Execute the scraper code with timeout
|
||||||
|
|
@ -385,7 +392,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, require, axios, fetch, module, exports, global } = sandbox;
|
const { console, setTimeout, clearTimeout, Promise, JSON, Date, Math, parseInt, parseFloat, encodeURIComponent, decodeURIComponent, require, axios, fetch, module, exports, global, URL_VALIDATION_ENABLED } = sandbox;
|
||||||
${code}
|
${code}
|
||||||
|
|
||||||
// Call the main function (assuming it's exported)
|
// Call the main function (assuming it's exported)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue