SponsorBlockServer/test/youtubeMock.ts

52 lines
1.7 KiB
TypeScript
Raw Normal View History

2021-06-03 04:34:38 +02:00
import { APIVideoData, APIVideoInfo } from "../src/types/youtubeApi.model";
export class YouTubeApiMock {
2021-06-03 04:34:38 +02:00
static async listVideos(videoID: string, ignoreCache = false): Promise<APIVideoInfo> {
const obj = {
id: videoID
};
if (obj.id === "knownWrongID") {
2021-04-09 02:37:19 +02:00
return {
2021-06-03 04:34:38 +02:00
err: "No video found"
2021-04-09 02:37:19 +02:00
};
}
2021-04-09 02:37:19 +02:00
if (obj.id === "noDuration") {
2021-04-09 02:37:19 +02:00
return {
err: null,
data: {
2021-06-03 04:34:38 +02:00
title: "Example Title",
lengthSeconds: 0,
videoThumbnails: [
2021-04-09 02:37:19 +02:00
{
2021-06-03 04:34:38 +02:00
quality: "maxres",
url: "https://sponsor.ajay.app/LogoSponsorBlockSimple256px.png",
second__originalUrl:"https://sponsor.ajay.app/LogoSponsorBlockSimple256px.png",
width: 1280,
height: 720
2020-10-17 20:56:54 +02:00
},
2021-06-03 04:34:38 +02:00
]
} as APIVideoData
2021-04-09 02:37:19 +02:00
};
} else {
2021-04-09 02:37:19 +02:00
return {
err: null,
data: {
2021-06-03 04:34:38 +02:00
title: "Example Title",
lengthSeconds: 4980,
videoThumbnails: [
2021-04-09 02:37:19 +02:00
{
2021-06-03 04:34:38 +02:00
quality: "maxres",
url: "https://sponsor.ajay.app/LogoSponsorBlockSimple256px.png",
second__originalUrl:"https://sponsor.ajay.app/LogoSponsorBlockSimple256px.png",
width: 1280,
height: 720
2020-10-17 20:56:54 +02:00
},
2021-06-03 04:34:38 +02:00
]
} as APIVideoData
2021-04-09 02:37:19 +02:00
};
}
}
}