diff --git a/materialious/src/lib/Api/index.ts b/materialious/src/lib/Api/index.ts index 112b1020..6fad8be5 100644 --- a/materialious/src/lib/Api/index.ts +++ b/materialious/src/lib/Api/index.ts @@ -1,6 +1,6 @@ import { get } from 'svelte/store'; import { auth, returnYTDislikesInstance } from '../../store'; -import type { Channel, ChannelPage, Comments, Playlist, ReturnYTDislikes, SearchSuggestion, Subscription, Video, VideoPlay } from './model'; +import type { Channel, ChannelPage, Comments, Playlist, PlaylistPage, ReturnYTDislikes, SearchSuggestion, Subscription, Video, VideoPlay } from './model'; export function buildPath(path: string): string { return `${import.meta.env.VITE_DEFAULT_INVIDIOUS_INSTANCE}/api/v1/${path}`; @@ -141,4 +141,9 @@ export async function postHistory(videoId: string) { method: 'POST', ...buildAuthHeaders() }); +} + +export async function getPlaylist(playlistId: string, page: number = 1): Promise { + const resp = await fetch(buildPath(`playlists/${playlistId}?page=${page}`)); + return await resp.json(); } \ No newline at end of file diff --git a/materialious/src/lib/Api/model.ts b/materialious/src/lib/Api/model.ts index 7a6eb969..4699060a 100644 --- a/materialious/src/lib/Api/model.ts +++ b/materialious/src/lib/Api/model.ts @@ -178,6 +178,22 @@ export interface Playlist { videos: PlaylistVideo[]; } +export interface PlaylistPageVideo extends PlaylistVideo { + author: string; + index: number; + authorId: string; + viewCount: number; +} + +export interface PlaylistPage extends Playlist { + description: string; + descriptionHtml: string; + viewCount: number; + updated: number; + isListed: boolean; + videos: PlaylistPageVideo[]; +} + export interface ChannelPage extends Channel { allowedRegions: string[]; tabs: string[]; diff --git a/materialious/src/lib/Thumbnail.svelte b/materialious/src/lib/Thumbnail.svelte index d1a9ef20..6fc6afa1 100644 --- a/materialious/src/lib/Thumbnail.svelte +++ b/materialious/src/lib/Thumbnail.svelte @@ -2,10 +2,10 @@ import { onMount } from 'svelte'; import { get } from 'svelte/store'; import { playerSavePlaybackPosition } from '../store'; - import type { Notification, Video, VideoBase } from './Api/model'; + import type { Notification, PlaylistPageVideo, Video, VideoBase } from './Api/model'; import { cleanNumber, truncate, videoLength } from './misc'; - export let video: VideoBase | Video | Notification; + export let video: VideoBase | Video | Notification | PlaylistPageVideo; let loading = true; let loaded = false; @@ -75,7 +75,8 @@
{truncate(video.title)}
- {video.author}{#if !('publishedText' in video)} + {video.author}{#if !('publishedText' in video) && 'viewCountText' in video}  • {video.viewCountText}{/if}
{#if 'publishedText' in video} diff --git a/materialious/src/lib/VideoList.svelte b/materialious/src/lib/VideoList.svelte index 2be80a41..4371559d 100644 --- a/materialious/src/lib/VideoList.svelte +++ b/materialious/src/lib/VideoList.svelte @@ -1,9 +1,9 @@ diff --git a/materialious/src/routes/playlist/[slug]/+page.svelte b/materialious/src/routes/playlist/[slug]/+page.svelte new file mode 100644 index 00000000..f3e7253b --- /dev/null +++ b/materialious/src/routes/playlist/[slug]/+page.svelte @@ -0,0 +1,39 @@ + + +
+ +
+

{data.playlist.title}

+

{cleanNumber(data.playlist.viewCount)} views • {data.playlist.videoCount} videos

+
+

{data.playlist.description}

+
+ + diff --git a/materialious/src/routes/playlist/[slug]/+page.ts b/materialious/src/routes/playlist/[slug]/+page.ts new file mode 100644 index 00000000..64fec2ff --- /dev/null +++ b/materialious/src/routes/playlist/[slug]/+page.ts @@ -0,0 +1,7 @@ +import { getPlaylist } from '$lib/Api/index.js'; + +export async function load({ params }) { + return { + playlist: await getPlaylist(params.slug) + }; +} \ No newline at end of file