mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2026-01-30 06:10:52 +03:00
add innerTube as primary videoInfo endpoint
- drop videoInfo.genreUrl since it's always empty - bump ts target to ES2021 for Promise.any - fix mocks to return err: false - get maxResThumbnail from static endpoint
This commit is contained in:
@@ -4,10 +4,10 @@ import assert from "assert";
|
||||
import { YouTubeAPI } from "../../src/utils/youtubeApi";
|
||||
import * as innerTube from "../../src/utils/innerTubeAPI";
|
||||
import { partialDeepEquals } from "../utils/partialDeepEquals";
|
||||
|
||||
import { getVideoDetails } from "../../src/utils/getVideoDetails";
|
||||
|
||||
const videoID = "dQw4w9WgXcQ";
|
||||
const expected = { // partial type of innerTubeVideoDetails
|
||||
const expectedInnerTube = { // partial type of innerTubeVideoDetails
|
||||
videoId: videoID,
|
||||
title: "Rick Astley - Never Gonna Give You Up (Official Music Video)",
|
||||
lengthSeconds: "212",
|
||||
@@ -25,17 +25,12 @@ const currentViews = 1284257550;
|
||||
describe("innertube API test", function() {
|
||||
it("should be able to get innerTube details", async () => {
|
||||
const result = await innerTube.getPlayerData(videoID);
|
||||
assert.ok(partialDeepEquals(result, expected));
|
||||
assert.ok(partialDeepEquals(result, expectedInnerTube));
|
||||
});
|
||||
it("Should have more views than current", async () => {
|
||||
const result = await innerTube.getPlayerData(videoID);
|
||||
assert.ok(Number(result.viewCount) >= currentViews);
|
||||
});
|
||||
it("Should have the same video duration from both endpoints", async () => {
|
||||
const playerData = await innerTube.getPlayerData(videoID);
|
||||
const length = await innerTube.getLength(videoID);
|
||||
assert.equal(Number(playerData.lengthSeconds), length);
|
||||
});
|
||||
it("Should have equivalent response from NewLeaf", async function () {
|
||||
if (!config.newLeafURLs || config.newLeafURLs.length <= 0 || config.newLeafURLs[0] == "placeholder") this.skip();
|
||||
const itResponse = await innerTube.getPlayerData(videoID);
|
||||
@@ -48,4 +43,8 @@ describe("innertube API test", function() {
|
||||
// validate authorId
|
||||
assert.strictEqual(itResponse.channelId, newLeafResponse.data?.authorId);
|
||||
});
|
||||
it("Should return data from generic endpoint", async function () {
|
||||
const videoDetail = await getVideoDetails(videoID);
|
||||
assert.ok(videoDetail);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user