SponsorBlockServer/test/youtubeMock.ts

53 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-09-23 05:34:46 +02:00
// eslint-disable-next-line require-await
2021-07-04 07:34:31 +02:00
static async listVideos(videoID: string): 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-07-12 08:43:46 +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-07-12 08:43:46 +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
};
}
}
}