parsing blog successfully and requesting youtube

This commit is contained in:
2026-11-04 13:46:19 +00:00
parent 0e65b8004e
commit 1ce397b734
132 changed files with 18999 additions and 52 deletions

View File

@@ -8,5 +8,8 @@ export const variables = defineEnvVars({
JELLYFIN_LIBRARY_ID: {},
KOMGA_URL: {},
KOMGA_API_KEY: {},
KOMGA_LIBRARY_ID: {}
KOMGA_LIBRARY_ID: {},
BLOG_URL: {},
GOOGLE_API_KEY: {},
CHANNEL_ID: {}
});

35
src/lib/server/content.ts Normal file
View File

@@ -0,0 +1,35 @@
import { XMLParser } from 'fast-xml-parser';
import { GOOGLE_API_KEY } from '$app/env/private';
const parser = new XMLParser({
ignoreAttributes: false,
attributeNamePrefix: '@_',
parseAttributeValue: true,
trimValues: true
});
async function fetchXml(url: string) {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Failed to fetch XML: ${response.status}`);
}
const xmlText = await response.text();
return parser.parse(xmlText);
}
export async function fetchBlogArticles(url: string) {
const blogArticles = await fetchXml(url);
}
export async function getChannelInfo(channelId: string) {
const response = await fetch(
`https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=${channelId}&key=${GOOGLE_API_KEY}`
);
if (!response.ok) {
throw new Error(`Failed to get Channel Information: ${response.status}`);
}
}

View File

@@ -1,13 +1,22 @@
import type { PageServerLoad } from './$types';
import { getLatestPlaylistSong, getLatestWatchedSeries } from '#lib/server/jellyfin';
import { getLatestBook } from '#lib/server/komga';
import { JELLYFIN_PLAYLIST_ID, JELLYFIN_LIBRARY_ID, KOMGA_LIBRARY_ID } from '$app/env/private';
import { fetchBlogArticles, getChannelInfo } from '#lib/server/content';
import {
JELLYFIN_PLAYLIST_ID,
JELLYFIN_LIBRARY_ID,
KOMGA_LIBRARY_ID,
BLOG_URL,
CHANNEL_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);
const latestBook = getLatestBook(globalThis.fetch, KOMGA_LIBRARY_ID);
const blogArticles = fetchBlogArticles(BLOG_URL);
const info = getChannelInfo(CHANNEL_ID);
latestSong.catch(() => {});
latestSeries.catch(() => {});