From 4af17475e6fe36c2f27b1c81f0f672fab6b0847e Mon Sep 17 00:00:00 2001 From: WardPearce Date: Tue, 22 Oct 2024 21:27:11 +1300 Subject: [PATCH] Added boards --- materialious/src/lib/Api/model.ts | 24 ++++++++++++----------- materialious/src/lib/patches/youtubejs.ts | 20 ++++++++++++++++++- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/materialious/src/lib/Api/model.ts b/materialious/src/lib/Api/model.ts index ee0529b0..ffae475d 100644 --- a/materialious/src/lib/Api/model.ts +++ b/materialious/src/lib/Api/model.ts @@ -91,20 +91,22 @@ export interface VideoPlay extends Video { recommendedVideos: VideoBase[]; authorThumbnails: Image[]; captions: Captions[]; - storyboards?: { - url: string; - templateUrl: string; - width: number; - height: number; - count: number; - interval: number; - storyboardWidth: number; - storyboardHeight: number; - storyboardCount: number; - }[]; + storyboards?: StoryBoard[]; fallbackPatch?: 'youtubejs' | 'piped'; } +export interface StoryBoard { + url: string; + templateUrl: string; + width: number; + height: number; + count: number; + interval: number; + storyboardWidth: number; + storyboardHeight: number; + storyboardCount: number; +} + export interface ReturnYTDislikes { id: string; dateCreated: string; diff --git a/materialious/src/lib/patches/youtubejs.ts b/materialious/src/lib/patches/youtubejs.ts index 0271bf30..a88efc89 100644 --- a/materialious/src/lib/patches/youtubejs.ts +++ b/materialious/src/lib/patches/youtubejs.ts @@ -1,4 +1,4 @@ -import type { AdaptiveFormats, Captions, Image, Thumbnail, VideoBase, VideoPlay } from '$lib/Api/model'; +import type { AdaptiveFormats, Captions, Image, StoryBoard, Thumbnail, VideoBase, VideoPlay } from '$lib/Api/model'; import { numberWithCommas } from '$lib/misc'; import { interfaceRegionStore, poTokenCacheStore } from '$lib/store'; import { Capacitor } from '@capacitor/core'; @@ -148,6 +148,23 @@ export async function patchYoutubeJs(videoId: string): Promise { }); }); + let storyboard: StoryBoard[] = []; + if (video.storyboards && 'boards' in video.storyboards) { + video.storyboards.boards.forEach(board => { + storyboard.push({ + templateUrl: board.template_url, + url: board.template_url, + count: board.storyboard_count, + height: board.thumbnail_height, + width: board.thumbnail_width, + interval: board.interval, + storyboardCount: board.storyboard_count, + storyboardHeight: board.thumbnail_height, + storyboardWidth: board.thumbnail_width + }); + }); + } + return { type: 'video', title: video.primary_info.title ? video.primary_info.title.toString() : '', @@ -178,6 +195,7 @@ export async function patchYoutubeJs(videoId: string): Promise { hlsUrl: video.streaming_data?.hls_manifest_url || undefined, liveNow: video.basic_info.is_live || false, premium: false, + storyboards: storyboard, isUpcoming: false, videoId: videoId, videoThumbnails: video.basic_info.thumbnail as Thumbnail[],