added what im watching
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { getLatestPlaylistSong } from '#lib/server/jellyfin';
|
||||
import { JELLYFIN_PLAYLIST_ID } from '$app/env/private';
|
||||
import { getLatestPlaylistSong, getLatestWatchedSeries } from '#lib/server/jellyfin';
|
||||
import { JELLYFIN_PLAYLIST_ID, JELLYFIN_LIBRARY_ID } from '$app/env/private';
|
||||
|
||||
export const load: PageServerLoad = () => {
|
||||
const latestSong = getLatestPlaylistSong(globalThis.fetch, JELLYFIN_PLAYLIST_ID);
|
||||
console.log(JELLYFIN_LIBRARY_ID);
|
||||
const latestSeries = getLatestWatchedSeries(globalThis.fetch, JELLYFIN_LIBRARY_ID);
|
||||
|
||||
latestSong.catch(() => {});
|
||||
latestSeries.catch(() => {});
|
||||
|
||||
return {
|
||||
streamed: {
|
||||
latestSong
|
||||
latestSong,
|
||||
latestSeries
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -66,7 +66,48 @@
|
||||
<p>{error}</p>
|
||||
{/await}
|
||||
</div>
|
||||
<div class="sub-container" style="--container-color:var(--ctp-peach);">watching</div>
|
||||
<div
|
||||
class="sub-container flex items-center gap-3 overflow-hidden pr-3"
|
||||
style="--container-color:var(--ctp-peach);"
|
||||
>
|
||||
{#await data.streamed.latestSeries}
|
||||
<p>Loading Latest Watched Series...</p>
|
||||
{:then series}
|
||||
<img
|
||||
src={series.poster}
|
||||
class="aspect-1/1 h-full w-auto shrink-0 object-contain"
|
||||
alt=""
|
||||
/>
|
||||
<div class="flex min-w-0 flex-col justify-center">
|
||||
<p class="fira-mono-medium">Currently Watching…</p>
|
||||
<div
|
||||
id="music-title-block"
|
||||
onclick={() =>
|
||||
window.open(`https://thetvdb.com/search?query=${series.name}`, '_blank')}
|
||||
style="cursor: pointer;"
|
||||
role="link"
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
}
|
||||
}}
|
||||
tabindex="0"
|
||||
title="{series.name} S{series.episode.seasonNumber}E{series.episode
|
||||
.episodeNumber} - {series.episode.name}"
|
||||
class="pl-2"
|
||||
>
|
||||
<p class="fira-mono-bold w-full truncate text-2xl">
|
||||
{series.name}
|
||||
</p>
|
||||
<p class="fira-mono-medium w-full truncate text-xl">
|
||||
S{series.episode.seasonNumber}E{series.episode.episodeNumber} - {series.episode
|
||||
.name}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{:catch error}
|
||||
<p>{error}</p>
|
||||
{/await}
|
||||
</div>
|
||||
<div class="sub-container" style="--container-color:var(--ctp-red);">reading</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
32
src/routes/posters/[itemId]/+server.ts
Normal file
32
src/routes/posters/[itemId]/+server.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
import { JELLYFIN_URL, JELLYFIN_API_KEY } from '$app/env/private';
|
||||
|
||||
export const GET: RequestHandler = async ({ params, fetch }) => {
|
||||
const { itemId } = params;
|
||||
|
||||
if (!/^[a-zA-Z0-9-]+$/.test(itemId)) {
|
||||
error(400, 'Invalid item ID');
|
||||
}
|
||||
|
||||
const response = await fetch(
|
||||
`${JELLYFIN_URL}/Items/${encodeURIComponent(itemId)}/Images/Primary`,
|
||||
{
|
||||
headers: {
|
||||
'X-Emby-Token': JELLYFIN_API_KEY
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
error(response.status, 'Poster unavailable');
|
||||
}
|
||||
|
||||
return new Response(response.body, {
|
||||
headers: {
|
||||
'Content-Type': response.headers.get('Content-Type') ?? 'image/jpeg',
|
||||
'Cache-Control': 'private, max-age=3600'
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user