From ea78b4a6b52c6247df59231b773981630d158513 Mon Sep 17 00:00:00 2001 From: Nikhil Nawgiri Date: Sat, 26 Oct 2024 17:46:58 +0200 Subject: [PATCH] Create itemHelper --- be/src/itemHelper.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 be/src/itemHelper.ts diff --git a/be/src/itemHelper.ts b/be/src/itemHelper.ts new file mode 100644 index 0000000..9da4d03 --- /dev/null +++ b/be/src/itemHelper.ts @@ -0,0 +1,48 @@ +interface Item { + Name: string, + ServerId: string, + Id: string, + HasSubtitles?: boolean, + Container: string, + PremiereDate: string, + CriticRating: number, + OfficialRating: string, + ChannelId: null, + CommunityRating: number, + RunTimeTicks: number, + ProductionYear: number, + ProviderIds: { + Tmdb: string, + Imdb: string, + TmdbCollection?: string, + }, + IsFolder: boolean, + Type: "Movie" | "Series", + VideoType: string, + ImageBlurHashes: {}, + LocationType: string, + MediaType: string, +}; + +export const transformItems = (items: []) => ( + items.map((item: Item) => { + // omit unnecessary props + const { + ServerId, + Id, + Container, + PremiereDate, + CriticRating, + ChannelId, + CommunityRating, + RunTimeTicks, + IsFolder, + VideoType, + ImageBlurHashes, + LocationType, + MediaType, + ...remainingProps + } = item; + return remainingProps; + }) +);