Compare commits
10 commits
83b8c86cac
...
e1dbe4d7e4
Author | SHA1 | Date | |
---|---|---|---|
e1dbe4d7e4 | |||
47ccc86b75 | |||
f4425c941f | |||
a3646e51d5 | |||
b7255bd6c5 | |||
afce2994bd | |||
d6731d1676 | |||
ce604b3626 | |||
ea78b4a6b5 | |||
6ad2721831 |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
be/config.ts
|
||||
database.json
|
||||
|
||||
# Logs
|
||||
logs
|
||||
|
|
7
be/src/fsHelper.ts
Normal file
7
be/src/fsHelper.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import * as fs from "fs";
|
||||
|
||||
export const saveJsonToDisk = (content: {}) => {
|
||||
const outputPath = `../database.json`;
|
||||
|
||||
fs.writeFileSync(outputPath, JSON.stringify(content));
|
||||
}
|
59
be/src/itemHelper.ts
Normal file
59
be/src/itemHelper.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
interface ItemProvidedByJellyfin {
|
||||
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,
|
||||
};
|
||||
|
||||
interface ItemForWishlistUsage {
|
||||
name: string,
|
||||
hasSubtitles: boolean,
|
||||
ageRating: string,
|
||||
productionYear: number,
|
||||
itemType: "Movie" | "Series",
|
||||
imdbId: string,
|
||||
};
|
||||
|
||||
export const transformItems = (items: []) => (
|
||||
items.map((item: ItemProvidedByJellyfin) => {
|
||||
const {
|
||||
Name,
|
||||
HasSubtitles,
|
||||
OfficialRating,
|
||||
ProductionYear,
|
||||
Type,
|
||||
ProviderIds,
|
||||
} = item;
|
||||
const { Imdb } = ProviderIds;
|
||||
|
||||
const newItem: ItemForWishlistUsage = {
|
||||
name: Name,
|
||||
hasSubtitles: HasSubtitles,
|
||||
ageRating: OfficialRating,
|
||||
productionYear: ProductionYear,
|
||||
itemType: Type,
|
||||
imdbId: Imdb,
|
||||
};
|
||||
|
||||
return newItem;
|
||||
})
|
||||
);
|
|
@ -5,7 +5,7 @@ import { API_BASE, API_TOKEN } from "../config.ts";
|
|||
const API_ENDPOINT_WITH_PARAMS = "/Items?isMovie=true&isSeries=true&recursive=true&fields=ProviderIds&filters=&mediaTypes=Video&enableTotalRecordCount=true&enableImages=false";
|
||||
const API_URL = API_BASE + API_ENDPOINT_WITH_PARAMS;
|
||||
|
||||
export const fetchFromApi = async () => {
|
||||
export const fetchFromJellyfinApi = async () => {
|
||||
const init = {
|
||||
method: "GET",
|
||||
headers: {
|
|
@ -1,4 +1,6 @@
|
|||
import { fetchFromApi } from "./fetchItemsFromJellyfin.ts";
|
||||
import { fetchFromJellyfinApi } from "./jellyfinApiHelper.ts";
|
||||
import { saveJsonToDisk } from "./fsHelper.ts";
|
||||
import { transformItems } from "./itemHelper.ts";
|
||||
|
||||
interface JellyfinApiResponse {
|
||||
Items?: [],
|
||||
|
@ -6,11 +8,20 @@ interface JellyfinApiResponse {
|
|||
StartIndex?: number,
|
||||
};
|
||||
|
||||
const init = async () => {
|
||||
const response: JellyfinApiResponse = await fetchFromApi();
|
||||
const { Items: items, TotalRecordCount: totalItemCount } = response;
|
||||
console.log("items:", items);
|
||||
console.log("totalItemCount:", totalItemCount);
|
||||
const run = async () => {
|
||||
const {
|
||||
Items: items,
|
||||
TotalRecordCount: totalItemCount
|
||||
}: JellyfinApiResponse = await fetchFromJellyfinApi();
|
||||
|
||||
const transformedItems = transformItems(items);
|
||||
saveJsonToDisk({ totalItemCount, jellyfinItems: transformedItems });
|
||||
|
||||
// save as something else than json lol
|
||||
|
||||
// express API
|
||||
// GET endpoint
|
||||
// POST endpoint
|
||||
}
|
||||
|
||||
init();
|
||||
run();
|
||||
|
|
Loading…
Reference in a new issue