From b7ea5689c75fdb6aca0867c74e8687d08a8f62b1 Mon Sep 17 00:00:00 2001 From: Max Baumann Date: Tue, 15 Dec 2020 13:33:38 +0100 Subject: [PATCH] refactor(types): add VideoInfo interface --- src/content.ts | 4 +-- src/types.ts | 79 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 3 deletions(-) diff --git a/src/content.ts b/src/content.ts index 18b7a646..f176980a 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1,6 +1,6 @@ import Config from "./config"; -import { SponsorTime, CategorySkipOption, VideoID, SponsorHideType, FetchResponse } from "./types"; +import { SponsorTime, CategorySkipOption, VideoID, SponsorHideType, FetchResponse, VideoInfo } from "./types"; import { ContentContainer } from "./types"; import Utils from "./utils"; @@ -25,7 +25,7 @@ let sponsorTimes: SponsorTime[] = null; let sponsorVideoID: VideoID = null; // JSON video info -let videoInfo: any = null; +let videoInfo: VideoInfo = null; //the channel this video is about let channelID; diff --git a/src/types.ts b/src/types.ts index d7818e01..423adf1e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -78,6 +78,82 @@ interface BackgroundScriptContainer { unregisterFirefoxContentScript: (id: string) => void } +interface VideoInfo { + responseContext: { + serviceTrackingParams: Array<{service: string, params: Array<{key: string, value: string}>}>, + webResponseContextExtensionData: { + hasDecorated: boolean + } + }, + playabilityStatus: { + status: string, + playableInEmbed: boolean, + miniplayer: { + miniplayerRenderer: { + playbackMode: string + } + } + }; + streamingData: unknown; + playbackTracking: unknown; + videoDetails: { + videoId: string, + title: string, + lengthSeconds: string, + keywords: string[], + channelId: string, + isOwnerViewing: boolean, + shortDescription: string, + isCrawlable: boolean, + thumbnail: { + thumbnails: Array<{url: string, width: number, height: number}> + }, + averageRating: number, + allowRatings: boolean, + viewCount: string, + author: string, + isPrivate: boolean, + isUnpluggedCorpus: boolean, + isLiveContent: boolean, + }; + playerConfig: unknown; + storyboards: unknown; + microformat: { + playerMicroformatRenderer: { + thumbnail: { + thumbnails: Array<{url: string, width: number, height: number}> + }, + embed: { + iframeUrl: string, + flashUrl: string, + width: number, + height: number, + flashSecureUrl: string, + }, + title: { + simpleText: string, + }, + description: { + simpleText: string, + }, + lengthSeconds: string, + ownerProfileUrl: string, + externalChannelId: string, + availableCountries: string[], + isUnlisted: boolean, + hasYpcMetadata: boolean, + viewCount: string, + category: string, + publishDate: string, + ownerChannelName: string, + uploadDate: string, + } + }; + trackingParams: string; + attestation: unknown; + messages: unknown; +} + type VideoID = string; export { @@ -91,5 +167,6 @@ export { SponsorHideType, PreviewBarOption, Registration, - BackgroundScriptContainer + BackgroundScriptContainer, + VideoInfo, };