import { about } from '#lib/content'; import type { HobbyStats } from '#lib/btop/types'; import { aniListStats, bookStats, listeningStats, screenStats } from '#lib/btop/hobbies'; import { getAniListProfile } from './anilist'; import { getListeningProfile } from './lastfm/profile'; import { getLibrary } from './library'; export async function getHobbyStats(): Promise { const anilistUsername = about.anilistUsername; const [library, listening, anime, manga] = await Promise.all([ getLibrary(), about.lastfmUsername ? getListeningProfile(about.lastfmUsername).catch(() => null) : null, anilistUsername ? getAniListProfile(anilistUsername, 'ANIME').catch(() => null) : null, anilistUsername ? getAniListProfile(anilistUsername, 'MANGA').catch(() => null) : null ]); const hasManga = !!manga?.statusCounts.some((status) => status.count > 0); return { listening: listening ? listeningStats(listening) : null, books: bookStats(library.books), shows: screenStats(library.shows), movies: screenStats(library.movies), anime: anime ? aniListStats(anime) : null, manga: manga && hasManga ? aniListStats(manga) : null }; }