recommitting after removing lfs files
This commit is contained in:
parent
f198d98437
commit
6a209f8698
22 changed files with 593 additions and 197 deletions
|
@ -1,19 +1,20 @@
|
|||
"use server";
|
||||
|
||||
import type { Category, Entry } from "./types";
|
||||
import { query } from "@solidjs/router";
|
||||
import { listItemIds, getContinueWatching, getItemStream, getRandomItems } from "./apis/jellyfin";
|
||||
import { query, revalidate } from "@solidjs/router";
|
||||
import { listItemIds, getContinueWatching, getItemStream, getRandomItems, getItemUserData } from "./apis/jellyfin";
|
||||
import {
|
||||
getDiscovery,
|
||||
getRecommendations,
|
||||
getEntry as getTmdbEntry,
|
||||
searchMulti,
|
||||
} from "./apis/tmdb";
|
||||
import { listIds as listSerieIds } from "./apis/sonarr";
|
||||
import { listIds as listMovieIds } from "./apis/radarr";
|
||||
import { listIds as listSerieIds, addSeries } from "./apis/sonarr";
|
||||
import { listIds as listMovieIds, addMovie } from "./apis/radarr";
|
||||
import { merge } from "~/utilities";
|
||||
|
||||
const jellyfinUserId = "a9c51af84bf54578a99ab4dd0ebf0763";
|
||||
// const jellyfinUserId = "9aa9bde73fe8429ca387134579a803d0";
|
||||
|
||||
const lookupTable = query(async () => {
|
||||
'use server';
|
||||
|
@ -27,9 +28,15 @@ export const getHighlights = () => getContinueWatching(jellyfinUserId);
|
|||
export const getStream = query(async (id: string, range: string) => {
|
||||
const table = await lookupTable();
|
||||
const ids = table[id];
|
||||
const manager = id[0] === 'm' ? 'radarr' : 'sonarr'
|
||||
|
||||
if (ids.jellyfin) {
|
||||
return getItemStream(ids.jellyfin, range);
|
||||
if (ids?.jellyfin) {
|
||||
return getItemStream(jellyfinUserId, ids.jellyfin, range);
|
||||
}
|
||||
|
||||
if (ids?.[manager]) {
|
||||
console.log('id is known, but jellyfin does not (yet) have the file');
|
||||
return;
|
||||
}
|
||||
|
||||
// - If the lookup table has no entry
|
||||
|
@ -42,7 +49,11 @@ export const getStream = query(async (id: string, range: string) => {
|
|||
// - If we have the radarr or sonarr id,
|
||||
// than we are tracking the entry,
|
||||
// but it is not available for use yet
|
||||
console.log(ids);
|
||||
console.log(`request the item '${id}' at ${manager}`);
|
||||
|
||||
const res = await ((manager === 'radarr' ? addMovie : addSeries)(id.slice(1)));
|
||||
|
||||
revalidate(lookupTable.keyFor())
|
||||
|
||||
}, 'content.stream');
|
||||
|
||||
|
@ -59,24 +70,44 @@ export const listCategories = query(async (): Promise<Category[]> => {
|
|||
}, "content.categories.list");
|
||||
|
||||
export const getEntryFromSlug = query(
|
||||
async (slug: string): Promise<Entry | undefined> => {
|
||||
const id = slug.match(/\w+$/)![0];
|
||||
|
||||
return getTmdbEntry(id);
|
||||
},
|
||||
async (slug: string): Promise<Entry | undefined> => getEntry(slug.match(/\w+$/)![0]),
|
||||
"content.getFromSlug",
|
||||
);
|
||||
|
||||
export const getEntry = query(
|
||||
async (id: Entry["id"]): Promise<Entry | undefined> => {
|
||||
return getTmdbEntry(id);
|
||||
const [entry, userData] = await Promise.all([
|
||||
getTmdbEntry(id),
|
||||
getEntryUserData(id)
|
||||
] as const);
|
||||
|
||||
if (entry && userData) {
|
||||
entry['offset'] = ticksToSeconds(userData.playbackPositionTicks ?? 0);
|
||||
}
|
||||
|
||||
return entry;
|
||||
},
|
||||
"content.get",
|
||||
);
|
||||
|
||||
export const getEntryUserData = query(
|
||||
async (id: string): ReturnType<typeof getItemUserData> => {
|
||||
const table = await lookupTable();
|
||||
const { jellyfin } = table[id] ?? {};
|
||||
|
||||
const userData = await getItemUserData(jellyfinUserId, jellyfin);
|
||||
|
||||
return userData;
|
||||
},
|
||||
"content.getFromSlug",
|
||||
);
|
||||
|
||||
export const search = query(async (query: string, page: number = 1) => {
|
||||
"use server";
|
||||
return searchMulti(query, page);
|
||||
}, 'content.search');
|
||||
|
||||
export { listUsers, getContinueWatching, listItems } from "./apis/jellyfin";
|
||||
|
||||
// 1s = 10_000_000 ticks
|
||||
const ticksToSeconds = (ticks: number) => ticks / 10_000_000;
|
Loading…
Add table
Add a link
Reference in a new issue