2021-06-03 04:34:38 +02:00
|
|
|
import { APIVideoData, APIVideoInfo } from "../src/types/youtubeApi.model";
|
2020-10-20 21:56:07 +02:00
|
|
|
|
|
|
|
export class YouTubeApiMock {
|
2021-06-03 04:34:38 +02:00
|
|
|
static async listVideos(videoID: string, ignoreCache = false): Promise<APIVideoInfo> {
|
2020-10-20 21:56:07 +02:00
|
|
|
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
|
|
|
};
|
2020-10-20 21:56:07 +02:00
|
|
|
}
|
2021-04-09 02:37:19 +02:00
|
|
|
|
2020-10-20 21:56:07 +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
|
|
|
};
|
2020-10-20 21:56:07 +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
|
|
|
};
|
2020-10-20 21:56:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|