diff --git a/materialious/src/lib/Api/index.ts b/materialious/src/lib/Api/index.ts index 49b07cc5..112b1020 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, ReturnYTDislikes, SearchSuggestion, Subscription, Video, VideoPlay } from './model'; +import type { Channel, ChannelPage, Comments, Playlist, ReturnYTDislikes, SearchSuggestion, Subscription, Video, VideoPlay } from './model'; export function buildPath(path: string): string { return `${import.meta.env.VITE_DEFAULT_INVIDIOUS_INSTANCE}/api/v1/${path}`; @@ -65,7 +65,7 @@ export async function getSearch(search: string, options: { sort_by?: "relevance" | "rating" | "upload_date" | "view_count", type?: "video" | "playlist" | "channel" | "all"; page?: string; -}): Promise<(Channel | Video)[]> { +}): Promise<(Channel | Video | Playlist)[]> { if (typeof options.sort_by === "undefined") { options.sort_by = "relevance"; } diff --git a/materialious/src/lib/Api/model.ts b/materialious/src/lib/Api/model.ts index f1dea827..7a6eb969 100644 --- a/materialious/src/lib/Api/model.ts +++ b/materialious/src/lib/Api/model.ts @@ -159,6 +159,25 @@ export interface Channel { authorThumbnails: Image[]; } +export interface PlaylistVideo { + title: string; + videoId: string; + lengthSeconds: number; + videoThumbnails: Thumbnail[]; +} + +export interface Playlist { + type: "playlist"; + title: string; + playlistId: string; + playlistThumbnail: string; + author: string; + authorId: string; + authorVerified: boolean; + videoCount: number; + videos: PlaylistVideo[]; +} + export interface ChannelPage extends Channel { allowedRegions: string[]; tabs: string[]; diff --git a/materialious/src/lib/Channel.svelte b/materialious/src/lib/Channel.svelte deleted file mode 100644 index 84dc6160..00000000 --- a/materialious/src/lib/Channel.svelte +++ /dev/null @@ -1,24 +0,0 @@ - - - -
-
- {channel.author} -
-
{truncate(channel.author, 14)}
-
- {cleanNumber(channel.subCount)} subscribers -
-

{channel.description}

-
-
diff --git a/materialious/src/lib/ChannelThumbnail.svelte b/materialious/src/lib/ChannelThumbnail.svelte new file mode 100644 index 00000000..79f9a1b0 --- /dev/null +++ b/materialious/src/lib/ChannelThumbnail.svelte @@ -0,0 +1,44 @@ + + + +
+
+ {#if loading} + + {:else} + {channel.author} + {/if} +
+
{truncate(channel.author, 14)}
+
+ {cleanNumber(channel.subCount)} subscribers +
+

{channel.description}

+
+
diff --git a/materialious/src/lib/PlaylistThumbnail.svelte b/materialious/src/lib/PlaylistThumbnail.svelte new file mode 100644 index 00000000..2727022a --- /dev/null +++ b/materialious/src/lib/PlaylistThumbnail.svelte @@ -0,0 +1,60 @@ + + + + {#if loading} + + {:else} + Thumbnail for playlist + {/if} +
+ {playlist.videoCount} videos +
+
+ +
+ +
diff --git a/materialious/src/lib/Thumbnail.svelte b/materialious/src/lib/Thumbnail.svelte index b37e98f5..d1a9ef20 100644 --- a/materialious/src/lib/Thumbnail.svelte +++ b/materialious/src/lib/Thumbnail.svelte @@ -11,6 +11,8 @@ let loaded = false; let failed = false; + let img: HTMLImageElement; + let progress: string | null; if (get(playerSavePlaybackPosition)) { progress = localStorage.getItem(`v_${video.videoId}`); @@ -19,8 +21,8 @@ } onMount(() => { - const img = new Image(); - img.src = video.videoThumbnails[3].url; + img = new Image(); + img.src = video.videoThumbnails[4].url; img.onload = () => { loaded = true; @@ -44,7 +46,7 @@ Thumbnail for video {:else} @@ -59,14 +61,11 @@ > {/if} {#if !('liveVideo' in video) || !video.liveVideo} -
+
 {videoLength(video.lengthSeconds)} 
{:else} -
+
LIVE
{/if} diff --git a/materialious/src/routes/search/[slug]/+page.svelte b/materialious/src/routes/search/[slug]/+page.svelte index dd793595..d105e42f 100644 --- a/materialious/src/routes/search/[slug]/+page.svelte +++ b/materialious/src/routes/search/[slug]/+page.svelte @@ -1,6 +1,7 @@