mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
feat: add previous type as suffix to queryType e.g. anime.series and migrate existing SEL
This commit is contained in:
@@ -60,21 +60,25 @@ class StreamFetcher {
|
||||
const start = Date.now();
|
||||
let queryType = type;
|
||||
if (AnimeDatabase.getInstance().isAnime(id)) {
|
||||
queryType = 'anime';
|
||||
queryType = `anime.${type}`;
|
||||
}
|
||||
|
||||
addons = addons.filter((addon) => {
|
||||
if (
|
||||
addon.mediaTypes &&
|
||||
addon.mediaTypes.length > 0 &&
|
||||
['movie', 'series', 'anime'].includes(queryType)
|
||||
['movie', 'series', 'anime.series', 'anime.movie'].includes(queryType)
|
||||
) {
|
||||
let mappedType = queryType;
|
||||
if (queryType === 'anime.series' || queryType === 'anime.movie') {
|
||||
mappedType = 'anime';
|
||||
}
|
||||
const result = addon.mediaTypes.includes(
|
||||
queryType as 'movie' | 'series' | 'anime'
|
||||
mappedType as 'movie' | 'series' | 'anime'
|
||||
);
|
||||
if (!result) {
|
||||
logger.debug(
|
||||
`Skipping ${getAddonName(addon)} because its specified media types do not include ${queryType}`
|
||||
`Skipping ${getAddonName(addon)} because its specified media types do not include ${mappedType}`
|
||||
);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1566,7 +1566,7 @@ class StreamFilterer {
|
||||
let queryType = type;
|
||||
|
||||
if (AnimeDatabase.getInstance().isAnime(id)) {
|
||||
queryType = 'anime';
|
||||
queryType = `anime.${queryType}`;
|
||||
}
|
||||
const selector = new StreamSelector(queryType);
|
||||
const streamsToKeep = new Set<string>();
|
||||
@@ -1596,7 +1596,7 @@ class StreamFilterer {
|
||||
let queryType = type;
|
||||
|
||||
if (AnimeDatabase.getInstance().isAnime(id)) {
|
||||
queryType = 'anime';
|
||||
queryType = `anime.${queryType}`;
|
||||
}
|
||||
|
||||
const passthroughStreams = streams
|
||||
|
||||
@@ -23,7 +23,7 @@ class StreamPrecomputer {
|
||||
public async precompute(streams: ParsedStream[], type: string, id: string) {
|
||||
let queryType = type;
|
||||
if (AnimeDatabase.getInstance().isAnime(id)) {
|
||||
queryType = 'anime';
|
||||
queryType = `anime.${type}`;
|
||||
}
|
||||
const preferredRegexPatterns =
|
||||
(await FeatureControl.isRegexAllowed(
|
||||
|
||||
@@ -584,6 +584,60 @@ export function applyMigrations(config: any): UserData {
|
||||
migrateHOSBS('excluded');
|
||||
migrateHOSBS('included');
|
||||
|
||||
// migrate comparisons of queryType to 'anime' to 'anime.series' or 'anime.movie'
|
||||
const migrateAnimeQueryTypeInExpression = (expr?: string) => {
|
||||
if (typeof expr !== 'string') return expr as any;
|
||||
// Replace equality comparisons
|
||||
let updated = expr.replace(
|
||||
/queryType\s*==\s*(["'])anime\1/g,
|
||||
"(queryType == 'anime.series' or queryType == 'anime.movie')"
|
||||
);
|
||||
updated = updated.replace(
|
||||
/(["'])anime\1\s*==\s*queryType/g,
|
||||
"(queryType == 'anime.series' or queryType == 'anime.movie')"
|
||||
);
|
||||
// Replace inequality comparisons
|
||||
updated = updated.replace(
|
||||
/queryType\s*!=\s*(["'])anime\1/g,
|
||||
"(queryType != 'anime.series' and queryType != 'anime.movie')"
|
||||
);
|
||||
updated = updated.replace(
|
||||
/(["'])anime\1\s*!=\s*queryType/g,
|
||||
"(queryType != 'anime.series' and queryType != 'anime.movie')"
|
||||
);
|
||||
return updated;
|
||||
};
|
||||
|
||||
const expressionLists = [
|
||||
'excludedStreamExpressions',
|
||||
'requiredStreamExpressions',
|
||||
'includedStreamExpressions',
|
||||
'preferredStreamExpressions',
|
||||
] as const;
|
||||
|
||||
for (const key of expressionLists) {
|
||||
if (Array.isArray((config as any)[key])) {
|
||||
(config as any)[key] = (config as any)[key].map((expr: unknown) =>
|
||||
typeof expr === 'string'
|
||||
? migrateAnimeQueryTypeInExpression(expr)
|
||||
: expr
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.dynamicAddonFetching?.condition) {
|
||||
config.dynamicAddonFetching.condition = migrateAnimeQueryTypeInExpression(
|
||||
config.dynamicAddonFetching.condition
|
||||
);
|
||||
}
|
||||
|
||||
if (config.groups?.groupings) {
|
||||
config.groups.groupings = config.groups.groupings.map((group: any) => ({
|
||||
...group,
|
||||
condition: migrateAnimeQueryTypeInExpression(group.condition),
|
||||
}));
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,58 @@ export function applyMigrations(config: any): UserData {
|
||||
migrateHOSBS('excluded');
|
||||
migrateHOSBS('included');
|
||||
|
||||
// migrate comparisons of queryType to 'anime' to 'anime.series' or 'anime.movie'
|
||||
const migrateAnimeQueryTypeInExpression = (expr?: string) => {
|
||||
if (typeof expr !== 'string') return expr as any;
|
||||
let updated = expr.replace(
|
||||
/queryType\s*==\s*(["'])anime\1/g,
|
||||
"(queryType == 'anime.series' or queryType == 'anime.movie')"
|
||||
);
|
||||
updated = updated.replace(
|
||||
/(["'])anime\1\s*==\s*queryType/g,
|
||||
"(queryType == 'anime.series' or queryType == 'anime.movie')"
|
||||
);
|
||||
updated = updated.replace(
|
||||
/queryType\s*!=\s*(["'])anime\1/g,
|
||||
"(queryType != 'anime.series' and queryType != 'anime.movie')"
|
||||
);
|
||||
updated = updated.replace(
|
||||
/(["'])anime\1\s*!=\s*queryType/g,
|
||||
"(queryType != 'anime.series' and queryType != 'anime.movie')"
|
||||
);
|
||||
return updated;
|
||||
};
|
||||
|
||||
const expressionLists = [
|
||||
'excludedStreamExpressions',
|
||||
'requiredStreamExpressions',
|
||||
'includedStreamExpressions',
|
||||
'preferredStreamExpressions',
|
||||
] as const;
|
||||
|
||||
for (const key of expressionLists) {
|
||||
if (Array.isArray((config as any)[key])) {
|
||||
(config as any)[key] = (config as any)[key].map((expr: unknown) =>
|
||||
typeof expr === 'string'
|
||||
? migrateAnimeQueryTypeInExpression(expr)
|
||||
: expr
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.dynamicAddonFetching?.condition) {
|
||||
config.dynamicAddonFetching.condition = migrateAnimeQueryTypeInExpression(
|
||||
config.dynamicAddonFetching.condition
|
||||
);
|
||||
}
|
||||
|
||||
if (config.groups?.groupings) {
|
||||
config.groups.groupings = config.groups.groupings.map((group: any) => ({
|
||||
...group,
|
||||
condition: migrateAnimeQueryTypeInExpression(group.condition),
|
||||
}));
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
const DefaultUserData: UserData = {
|
||||
|
||||
Reference in New Issue
Block a user