fix: url encode extra values

This commit is contained in:
Viren070
2025-07-30 14:28:15 +01:00
parent a07ec7a0c9
commit 2eea0a9ed5
4 changed files with 19 additions and 7 deletions
+11 -1
View File
@@ -644,12 +644,22 @@ export const AddonCatalogResponseSchema = z.object({
export type AddonCatalogResponse = z.infer<typeof AddonCatalogResponseSchema>;
export type AddonCatalog = z.infer<typeof AddonCatalogSchema>;
export const ExtrasTypesSchema = z.enum(['skip', 'genre', 'search']);
export const ExtrasTypesSchema = z.enum([
'skip',
'genre',
'search',
'filename',
'videoHash',
'videoSize',
]);
export type ExtrasTypes = z.infer<typeof ExtrasTypesSchema>;
export const ExtrasSchema = z.object({
skip: z.coerce.number().optional(),
genre: z.string().optional(),
search: z.string().optional(),
filename: z.string().optional(),
videoHash: z.string().optional(),
videoSize: z.coerce.number().optional(),
});
export type Extras = z.infer<typeof ExtrasSchema>;
+5 -3
View File
@@ -13,7 +13,7 @@ import {
getTimeTakenSincePoint,
maskSensitiveInfo,
Cache,
CatalogExtras,
ExtrasParser,
TMDBMetadata,
Metadata,
makeUrlLogSafe,
@@ -318,7 +318,7 @@ export class AIOStreams {
// reset the type from the request (which is the overriden type) to the actual type
type = modification.type;
}
const parsedExtras = new CatalogExtras(extras);
const parsedExtras = new ExtrasParser(extras);
logger.debug(`Parsed extras: ${JSON.stringify(parsedExtras)}`);
if (parsedExtras.genre === 'None') {
logger.debug(`Genre extra is None, removing genre extra`);
@@ -592,6 +592,8 @@ export class AIOStreams {
}
}
}
const parsedExtras = new ExtrasParser(extras);
logger.debug(`Parsed extras: ${JSON.stringify(parsedExtras)}`);
// Request subtitles from all supported addons in parallel
let errors: AIOStreamsError[] = this.addonInitialisationErrors.map(
@@ -608,7 +610,7 @@ export class AIOStreams {
const subtitles = await new Wrapper(addon).getSubtitles(
type,
id,
extras
parsedExtras.toString()
);
if (subtitles) {
allSubtitles.push(...subtitles);
@@ -1,6 +1,6 @@
import { Extras, ExtrasSchema, ExtrasTypesSchema } from '../db/schemas';
export class CatalogExtras {
export class ExtrasParser {
private extras: Partial<Extras>;
constructor(extras?: string) {
@@ -13,7 +13,7 @@ export class CatalogExtras {
}
const mapped = extras.split('&').map((e) => {
const [key, value] = e.split('=');
return { key, value };
return { key, value: encodeURIComponent(value) };
});
const extrasObject = Object.fromEntries(
mapped.map(({ key, value }) => {
+1 -1
View File
@@ -12,5 +12,5 @@ export * from './config';
export * from './languages';
export * from './dsu';
export * from './startup';
export * from './catalogExtras';
export * from './extras';
export * from './rpdb';