mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 00:32:04 +00:00
Remove hardcoded addon config URL guesses
This commit is contained in:
parent
0b82682dd9
commit
ba909a4aec
1 changed files with 7 additions and 21 deletions
|
|
@ -761,28 +761,14 @@ const handleConfigureAddon = (addon: ExtendedManifest, transportUrl?: string) =>
|
||||||
logger.info(`Using addon.url property: ${configUrl}`);
|
logger.info(`Using addon.url property: ${configUrl}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. com.stremio.*.addon
|
|
||||||
else if (addon.id && addon.id.match(/^com\.stremio\.(.*?)\.addon$/)) {
|
|
||||||
const match = addon.id.match(/^com\.stremio\.(.*?)\.addon$/);
|
|
||||||
if (match && match[1]) {
|
|
||||||
const addonName = match[1];
|
|
||||||
if (addonName === 'torrentio') {
|
|
||||||
configUrl = 'https://torrentio.strem.fun/configure';
|
|
||||||
} else {
|
|
||||||
configUrl = `https://${addonName}.strem.fun/configure`;
|
|
||||||
}
|
|
||||||
logger.info(`Constructed URL from addon name: ${configUrl}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. addon.id is a URL
|
|
||||||
else if (addon.id && addon.id.startsWith('http')) {
|
else if (addon.id && addon.id.startsWith('http')) {
|
||||||
const baseUrl = addon.id.replace(/\/[^\/]+\.json$/, '/');
|
const baseUrl = addon.id.replace(/\/[^\/]+\.json$/, '/');
|
||||||
configUrl = `${ensureSlash(baseUrl)}configure`;
|
configUrl = `${ensureSlash(baseUrl)}configure`;
|
||||||
logger.info(`Using addon.id as HTTP URL: ${configUrl}`);
|
logger.info(`Using addon.id as HTTP URL: ${configUrl}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. stremio:// containing http/https
|
// 5. stremio:// containing http/https
|
||||||
else if (addon.id && (addon.id.includes('https://') || addon.id.includes('http://'))) {
|
else if (addon.id && (addon.id.includes('https://') || addon.id.includes('http://'))) {
|
||||||
const match = addon.id.match(/(https?:\/\/[^\/]+)(\/[^\s]*)?/);
|
const match = addon.id.match(/(https?:\/\/[^\/]+)(\/[^\s]*)?/);
|
||||||
if (match) {
|
if (match) {
|
||||||
|
|
@ -793,7 +779,7 @@ const handleConfigureAddon = (addon: ExtendedManifest, transportUrl?: string) =>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. stremio://domain.com
|
// 6. stremio://domain.com
|
||||||
if (!configUrl && addon.id && addon.id.startsWith('stremio://')) {
|
if (!configUrl && addon.id && addon.id.startsWith('stremio://')) {
|
||||||
const match = addon.id.match(/stremio:\/\/([^\/]+)(\/[^\s]*)?/);
|
const match = addon.id.match(/stremio:\/\/([^\/]+)(\/[^\s]*)?/);
|
||||||
if (match) {
|
if (match) {
|
||||||
|
|
@ -804,21 +790,21 @@ const handleConfigureAddon = (addon: ExtendedManifest, transportUrl?: string) =>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. addon.transport
|
// 7. addon.transport
|
||||||
if (!configUrl && addon.transport && addon.transport.includes('http')) {
|
if (!configUrl && addon.transport && addon.transport.includes('http')) {
|
||||||
const baseUrl = addon.transport.replace(/\/[^\/]+\.json$/, '/');
|
const baseUrl = addon.transport.replace(/\/[^\/]+\.json$/, '/');
|
||||||
configUrl = `${ensureSlash(baseUrl)}configure`;
|
configUrl = `${ensureSlash(baseUrl)}configure`;
|
||||||
logger.info(`Using addon.transport for config URL: ${configUrl}`);
|
logger.info(`Using addon.transport for config URL: ${configUrl}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9. originalUrl
|
// 8. originalUrl
|
||||||
if (!configUrl && (addon as any).originalUrl) {
|
if (!configUrl && (addon as any).originalUrl) {
|
||||||
const baseUrl = (addon as any).originalUrl.replace(/\/[^\/]+\.json$/, '/');
|
const baseUrl = (addon as any).originalUrl.replace(/\/[^\/]+\.json$/, '/');
|
||||||
configUrl = `${ensureSlash(baseUrl)}configure`;
|
configUrl = `${ensureSlash(baseUrl)}configure`;
|
||||||
logger.info(`Using originalUrl property: ${configUrl}`);
|
logger.info(`Using originalUrl property: ${configUrl}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10. Failure
|
// 9. Failure
|
||||||
if (!configUrl) {
|
if (!configUrl) {
|
||||||
logger.error(`Failed to determine config URL for addon: ${addon.name}, ID: ${addon.id}`);
|
logger.error(`Failed to determine config URL for addon: ${addon.name}, ID: ${addon.id}`);
|
||||||
setAlertTitle(t('addons.config_unavailable_title'));
|
setAlertTitle(t('addons.config_unavailable_title'));
|
||||||
|
|
@ -1254,4 +1240,4 @@ const handleConfigureAddon = (addon: ExtendedManifest, transportUrl?: string) =>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AddonsScreen;
|
export default AddonsScreen;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue