Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/FoxxMD/multi-scrobbler. Scrobble plays from multiple sources to multiple clients docs.multi-scrobbler.app
deezer docker jellyfin koito lastfm listenbrainz maloja mopidy mpris music music-assistant plex scrobble self-hosted spotify subsonic tautulli youtube-music
Something went wrong. Try again.
2.5 kB · 60 lines
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061import * as z from "zod";import {commonSourceConfigSchema, commonSourceDataSchema, commonSourceOptionsSchema, type EnvSourceSchema} from "./index.ts";
// all of the required data for the Build Data and Test Auth stages (from Common Development docs)// should go hereexport const coolPlayerData = z.object({ // make sure to include common source data ...commonSourceDataSchema.shape, token: z.string().meta({ description: 'The user-generated token for Cool Player auth created in Cool Player -> Settings -> User -> Tokens', examples: ['f243331e-cf5b-49d7-846b-0845bdc965b4'] }), baseUrl: z.string().meta({ description: 'The host and port where Cool Player is hosted', examples: ['http://192.168.0.100:6969'] })});export type CoolPlayeryData = z.infer<typeof coolPlayerData>;
// a default options shape is created from common options// if you have optional (non-mandatory) behavior or data for configuration// it should go hereexport const coolPlayerOptionsSchema = z.object({ ...commonSourceOptionsSchema.shape,});export type CoolPlayerOptions = z.infer<typeof coolPlayerOptionsSchema>;
// the full Source config is created from the above data/optionsexport const coolPlayerSourceConfigSchema = z.object({ ...commonSourceConfigSchema.shape, data: coolPlayerData, options: coolPlayerOptionsSchema.optional(),});export type CoolPlayerSourceConfig = z.infer<typeof coolPlayerSourceConfigSchema>;
// if your Source should accept ENVs create them as a separate schemaconst envDataSchema = z.object({ COOL_TOKEN: coolPlayerData.shape.token, COOL_URL: coolPlayerData.shape.baseUrl,});// and then export an `envSchemas` that returns a normal data schema based on the ENVsexport const envSchemas: EnvSourceSchema<typeof envDataSchema, CoolPlayerSourceConfig> = { env: envDataSchema, // prefix is used for generic settings that can be applied to this source prefix: 'COOL', toConfig: (partial) => ({ data: { token: partial.COOL_TOKEN, baseUrl: partial.COOL_URL, } })};
// finally, the AIO config shape is created with the required `type` constantexport const coolPlayerSourceAIOConfigSchema = z.object({ ...coolPlayerSourceConfigSchema.shape, type: z.literal('coolplayer'),}).meta({title: 'CoolPlayer'});
export type CoolPlayerSourceAIOConfig = z.infer<typeof coolPlayerSourceAIOConfigSchema>;