SponsorBlockServer/test/youtubeMock.js

67 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-04-07 02:05:26 +02:00
/*
YouTubeAPI.videos.list({
part: "snippet",
id: videoID
}, function (err, data) {});
*/
// https://developers.google.com/youtube/v3/docs/videos
const YouTubeAPI = {
videos: {
list: (obj, callback) => {
2020-04-24 19:20:40 +02:00
if (obj.id === "knownWrongID") {
2020-04-07 02:05:26 +02:00
callback(undefined, {
pageInfo: {
totalResults: 0
},
items: []
});
2020-04-24 19:20:40 +02:00
} if (obj.id === "noDuration") {
callback(undefined, {
pageInfo: {
totalResults: 1
},
items: [
{
contentDetails: {
duration: "PT0S"
},
snippet: {
title: "Example Title",
thumbnails: {
maxres: {
url: "https://sponsor.ajay.app/LogoSponsorBlockSimple256px.png"
}
}
}
}
]
});
} else {
2020-04-07 02:05:26 +02:00
callback(undefined, {
pageInfo: {
totalResults: 1
},
items: [
{
contentDetails: {
duration: "PT1H23M30S"
2020-04-07 02:12:12 +02:00
},
snippet: {
title: "Example Title",
thumbnails: {
maxres: {
url: "https://sponsor.ajay.app/LogoSponsorBlockSimple256px.png"
}
}
2020-04-07 02:05:26 +02:00
}
}
]
});
}
}
}
};
module.exports = YouTubeAPI;