mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 00:32:04 +00:00
showbox support
This commit is contained in:
parent
92973c1c7b
commit
9ae0a7010c
2 changed files with 59 additions and 52 deletions
|
|
@ -849,8 +849,9 @@ const PluginsScreen: React.FC = () => {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||||
const [hasRepository, setHasRepository] = useState(false);
|
const [hasRepository, setHasRepository] = useState(false);
|
||||||
const [showboxCookie, setShowboxCookie] = useState<string>('');
|
const [showboxUiToken, setShowboxUiToken] = useState<string>('');
|
||||||
const [showboxRegion, setShowboxRegion] = useState<string>('');
|
const [showboxSavedToken, setShowboxSavedToken] = useState<string>('');
|
||||||
|
const [showboxScraperId, setShowboxScraperId] = useState<string | null>(null);
|
||||||
|
|
||||||
// Multiple repositories state
|
// Multiple repositories state
|
||||||
const [repositories, setRepositories] = useState<RepositoryInfo[]>([]);
|
const [repositories, setRepositories] = useState<RepositoryInfo[]>([]);
|
||||||
|
|
@ -1071,12 +1072,22 @@ const PluginsScreen: React.FC = () => {
|
||||||
|
|
||||||
|
|
||||||
setInstalledScrapers(scrapers);
|
setInstalledScrapers(scrapers);
|
||||||
// preload showbox settings if present
|
// Detect ShowBox scraper dynamically and preload settings
|
||||||
const sb = scrapers.find(s => s.id === 'showboxog');
|
const sb = scrapers.find(s => {
|
||||||
|
const id = (s.id || '').toLowerCase();
|
||||||
|
const name = (s.name || '').toLowerCase();
|
||||||
|
const filename = (s.filename || '').toLowerCase();
|
||||||
|
return id.includes('showbox') || name.includes('showbox') || filename.includes('showbox');
|
||||||
|
});
|
||||||
if (sb) {
|
if (sb) {
|
||||||
const s = await localScraperService.getScraperSettings('showboxog');
|
setShowboxScraperId(sb.id);
|
||||||
setShowboxCookie(s.cookie || '');
|
const s = await localScraperService.getScraperSettings(sb.id);
|
||||||
setShowboxRegion(s.region || '');
|
setShowboxUiToken(s.uiToken || '');
|
||||||
|
setShowboxSavedToken(s.uiToken || '');
|
||||||
|
} else {
|
||||||
|
setShowboxScraperId(null);
|
||||||
|
setShowboxUiToken('');
|
||||||
|
setShowboxSavedToken('');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('[ScraperSettings] Failed to load scrapers:', error);
|
logger.error('[ScraperSettings] Failed to load scrapers:', error);
|
||||||
|
|
@ -1615,59 +1626,49 @@ const PluginsScreen: React.FC = () => {
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* ShowBox Settings */}
|
{/* ShowBox Settings - only visible when ShowBox scraper is available */}
|
||||||
{scraper.id === 'showboxog' && settings.enableLocalScrapers && (
|
{showboxScraperId && scraper.id === showboxScraperId && settings.enableLocalScrapers && (
|
||||||
<View style={{ marginTop: 16, paddingTop: 16, borderTopWidth: 1, borderTopColor: colors.elevation3 }}>
|
<View style={{ marginTop: 16, paddingTop: 16, borderTopWidth: 1, borderTopColor: colors.elevation3 }}>
|
||||||
<Text style={[styles.settingTitle, { marginBottom: 8 }]}>ShowBox Cookie</Text>
|
<Text style={[styles.settingTitle, { marginBottom: 8 }]}>ShowBox UI Token</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={[styles.textInput, { marginBottom: 12 }]}
|
style={[styles.textInput, { marginBottom: 12 }]}
|
||||||
value={showboxCookie}
|
value={showboxUiToken}
|
||||||
onChangeText={setShowboxCookie}
|
onChangeText={setShowboxUiToken}
|
||||||
placeholder="Paste FebBox ui cookie value"
|
placeholder="Paste your ShowBox UI token"
|
||||||
placeholderTextColor={colors.mediumGray}
|
placeholderTextColor={colors.mediumGray}
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
multiline={true}
|
multiline={true}
|
||||||
numberOfLines={3}
|
numberOfLines={3}
|
||||||
/>
|
/>
|
||||||
<Text style={[styles.settingTitle, { marginBottom: 8 }]}>Region</Text>
|
<View style={styles.buttonRow}>
|
||||||
<View style={[styles.qualityChipsContainer, { marginBottom: 16 }]}>
|
{showboxUiToken !== showboxSavedToken && (
|
||||||
{regionOptions.map(opt => {
|
<TouchableOpacity
|
||||||
const selected = showboxRegion === opt.value;
|
style={[styles.button, styles.primaryButton]}
|
||||||
return (
|
onPress={async () => {
|
||||||
<TouchableOpacity
|
if (showboxScraperId) {
|
||||||
key={opt.value}
|
await localScraperService.setScraperSettings(showboxScraperId, { uiToken: showboxUiToken });
|
||||||
style={[styles.qualityChip, selected && styles.qualityChipSelected]}
|
}
|
||||||
onPress={() => setShowboxRegion(opt.value)}
|
setShowboxSavedToken(showboxUiToken);
|
||||||
>
|
openAlert('Saved', 'ShowBox settings updated');
|
||||||
<Text style={[styles.qualityChipText, selected && styles.qualityChipTextSelected]}>
|
}}
|
||||||
{opt.label}
|
>
|
||||||
</Text>
|
<Text style={styles.buttonText}>Save</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
)}
|
||||||
})}
|
<TouchableOpacity
|
||||||
</View>
|
style={[styles.button, styles.secondaryButton]}
|
||||||
<View style={styles.buttonRow}>
|
onPress={async () => {
|
||||||
<TouchableOpacity
|
setShowboxUiToken('');
|
||||||
style={[styles.button, styles.primaryButton]}
|
setShowboxSavedToken('');
|
||||||
onPress={async () => {
|
if (showboxScraperId) {
|
||||||
await localScraperService.setScraperSettings('showboxog', { cookie: showboxCookie, region: showboxRegion });
|
await localScraperService.setScraperSettings(showboxScraperId, {});
|
||||||
openAlert('Saved', 'ShowBox settings updated');
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text style={styles.buttonText}>Save</Text>
|
<Text style={styles.secondaryButtonText}>Clear</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity
|
</View>
|
||||||
style={[styles.button, styles.secondaryButton]}
|
|
||||||
onPress={async () => {
|
|
||||||
setShowboxCookie('');
|
|
||||||
setShowboxRegion('');
|
|
||||||
await localScraperService.setScraperSettings('showboxog', {});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text style={styles.secondaryButtonText}>Clear</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
|
||||||
|
|
@ -1117,7 +1117,7 @@ class LocalScraperService {
|
||||||
try {
|
try {
|
||||||
// Create function from code
|
// Create function from code
|
||||||
const func = new Function('sandbox', 'params', 'PRIMARY_KEY', 'TMDB_API_KEY', `
|
const func = new Function('sandbox', 'params', 'PRIMARY_KEY', 'TMDB_API_KEY', `
|
||||||
const { console, setTimeout, clearTimeout, Promise, JSON, Date, Math, parseInt, parseFloat, encodeURIComponent, decodeURIComponent, require, axios, fetch, module, exports, global, URL_VALIDATION_ENABLED } = sandbox;
|
const { console, setTimeout, clearTimeout, Promise, JSON, Date, Math, parseInt, parseFloat, encodeURIComponent, decodeURIComponent, require, axios, fetch, module, exports, global, URL_VALIDATION_ENABLED, SCRAPER_SETTINGS, SCRAPER_ID } = sandbox;
|
||||||
|
|
||||||
// Inject MovieBox constants into global scope
|
// Inject MovieBox constants into global scope
|
||||||
global.PRIMARY_KEY = PRIMARY_KEY;
|
global.PRIMARY_KEY = PRIMARY_KEY;
|
||||||
|
|
@ -1125,6 +1125,12 @@ class LocalScraperService {
|
||||||
window.PRIMARY_KEY = PRIMARY_KEY;
|
window.PRIMARY_KEY = PRIMARY_KEY;
|
||||||
window.TMDB_API_KEY = TMDB_API_KEY;
|
window.TMDB_API_KEY = TMDB_API_KEY;
|
||||||
|
|
||||||
|
// Expose per-scraper context to plugin globals
|
||||||
|
global.SCRAPER_SETTINGS = SCRAPER_SETTINGS;
|
||||||
|
global.SCRAPER_ID = SCRAPER_ID;
|
||||||
|
window.SCRAPER_SETTINGS = SCRAPER_SETTINGS;
|
||||||
|
window.SCRAPER_ID = SCRAPER_ID;
|
||||||
|
|
||||||
${code}
|
${code}
|
||||||
|
|
||||||
// Call the main function (assuming it's exported)
|
// Call the main function (assuming it's exported)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue