mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-30 11:28:19 +03:00
Merge branch 'master' of https://github.com/ajayyy/SponsorBlockServer
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
FROM node:16-alpine as builder
|
FROM node:18-alpine as builder
|
||||||
RUN apk add --no-cache --virtual .build-deps python3 make g++
|
RUN apk add --no-cache --virtual .build-deps python3 make g++
|
||||||
COPY package.json package-lock.json tsconfig.json entrypoint.sh ./
|
COPY package.json package-lock.json tsconfig.json entrypoint.sh ./
|
||||||
COPY src src
|
COPY src src
|
||||||
RUN npm ci && npm run tsc
|
RUN npm ci && npm run tsc
|
||||||
|
|
||||||
FROM node:16-alpine as app
|
FROM node:18-alpine as app
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
RUN apk add --no-cache git postgresql-client
|
RUN apk add --no-cache git postgresql-client
|
||||||
COPY --from=builder ./node_modules ./node_modules
|
COPY --from=builder ./node_modules ./node_modules
|
||||||
|
|||||||
1083
package-lock.json
generated
1083
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
42
package.json
42
package.json
@@ -19,42 +19,42 @@
|
|||||||
"author": "Ajay Ramachandran",
|
"author": "Ajay Ramachandran",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.27.2",
|
"axios": "^1.1.3",
|
||||||
"better-sqlite3": "^7.6.0",
|
"better-sqlite3": "^7.6.2",
|
||||||
"cron": "^2.0.0",
|
"cron": "^2.1.0",
|
||||||
"express": "^4.18.1",
|
"express": "^4.18.2",
|
||||||
"express-promise-router": "^4.1.1",
|
"express-promise-router": "^4.1.1",
|
||||||
"express-rate-limit": "^6.4.0",
|
"express-rate-limit": "^6.7.0",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"pg": "^8.7.3",
|
"pg": "^8.8.0",
|
||||||
"rate-limit-redis": "^3.0.1",
|
"rate-limit-redis": "^3.0.1",
|
||||||
"redis": "^4.2.0",
|
"redis": "^4.5.0",
|
||||||
"sync-mysql": "^3.0.1"
|
"sync-mysql": "^3.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
||||||
"@types/better-sqlite3": "^7.5.0",
|
"@types/better-sqlite3": "^7.6.2",
|
||||||
"@types/cron": "^2.0.0",
|
"@types/cron": "^2.0.0",
|
||||||
"@types/express": "^4.17.13",
|
"@types/express": "^4.17.14",
|
||||||
"@types/lodash": "^4.14.182",
|
"@types/lodash": "^4.14.189",
|
||||||
"@types/mocha": "^9.1.1",
|
"@types/mocha": "^10.0.0",
|
||||||
"@types/node": "^18.0.3",
|
"@types/node": "^18.11.9",
|
||||||
"@types/pg": "^8.6.5",
|
"@types/pg": "^8.6.5",
|
||||||
"@types/sinon": "^10.0.13",
|
"@types/sinon": "^10.0.13",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
"@typescript-eslint/eslint-plugin": "^5.44.0",
|
||||||
"@typescript-eslint/parser": "^5.30.6",
|
"@typescript-eslint/parser": "^5.44.0",
|
||||||
"axios-mock-adapter": "^1.21.2",
|
"axios-mock-adapter": "^1.21.2",
|
||||||
"eslint": "^8.19.0",
|
"eslint": "^8.28.0",
|
||||||
"mocha": "^10.0.0",
|
"mocha": "^10.1.0",
|
||||||
"nodemon": "^2.0.19",
|
"nodemon": "^2.0.20",
|
||||||
"nyc": "^15.1.0",
|
"nyc": "^15.1.0",
|
||||||
"sinon": "^14.0.0",
|
"sinon": "^14.0.2",
|
||||||
"ts-mock-imports": "^1.3.8",
|
"ts-mock-imports": "^1.3.8",
|
||||||
"ts-node": "^10.8.2",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "^4.7.4"
|
"typescript": "^4.9.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export interface innerTubeVideoDetails {
|
export interface innerTubeVideoDetails {
|
||||||
"videoId": string,
|
"videoId": string,
|
||||||
"title": string,
|
"title": string,
|
||||||
"lengthSeconds": string, // yes, don't ask.
|
"lengthSeconds"?: string, // yes, don't ask.
|
||||||
"channelId": string,
|
"channelId": string,
|
||||||
"isOwnerViewing": boolean,
|
"isOwnerViewing": boolean,
|
||||||
"shortDescription": string,
|
"shortDescription": string,
|
||||||
|
|||||||
@@ -3,6 +3,30 @@ import { Logger } from "./logger";
|
|||||||
import { innerTubeVideoDetails } from "../types/innerTubeApi.model";
|
import { innerTubeVideoDetails } from "../types/innerTubeApi.model";
|
||||||
import DiskCache from "./diskCache";
|
import DiskCache from "./diskCache";
|
||||||
|
|
||||||
|
const privateResponse = (videoId: string): innerTubeVideoDetails => ({
|
||||||
|
videoId,
|
||||||
|
title: "",
|
||||||
|
channelId: "",
|
||||||
|
// exclude video duration
|
||||||
|
isOwnerViewing: false,
|
||||||
|
shortDescription: "",
|
||||||
|
isCrawlable: false,
|
||||||
|
thumbnail: {
|
||||||
|
thumbnails: [{
|
||||||
|
url: "https://s.ytimg.com/yts/img/meh7-vflGevej7.png",
|
||||||
|
width: 140,
|
||||||
|
height: 100
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
allowRatings: false,
|
||||||
|
viewCount: "0", // yes, don't ask
|
||||||
|
author: "",
|
||||||
|
isPrivate: true,
|
||||||
|
isUnpluggedCorpus: true,
|
||||||
|
isLiveContent: false,
|
||||||
|
publishDate: ""
|
||||||
|
});
|
||||||
|
|
||||||
async function getFromITube (videoID: string): Promise<innerTubeVideoDetails> {
|
async function getFromITube (videoID: string): Promise<innerTubeVideoDetails> {
|
||||||
// start subrequest
|
// start subrequest
|
||||||
const url = "https://www.youtube.com/youtubei/v1/player";
|
const url = "https://www.youtube.com/youtubei/v1/player";
|
||||||
@@ -20,9 +44,9 @@ async function getFromITube (videoID: string): Promise<innerTubeVideoDetails> {
|
|||||||
});
|
});
|
||||||
/* istanbul ignore else */
|
/* istanbul ignore else */
|
||||||
if (result.status === 200) {
|
if (result.status === 200) {
|
||||||
return result.data.videoDetails;
|
return result.data?.videoDetails ?? privateResponse(videoID);
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject(result.status);
|
return Promise.reject(`Innertube returned non-200 response: ${result.status}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,4 +46,9 @@ describe("innertube API test", function() {
|
|||||||
const videoDetail = await getVideoDetails(videoID);
|
const videoDetail = await getVideoDetails(videoID);
|
||||||
assert.ok(videoDetail);
|
assert.ok(videoDetail);
|
||||||
});
|
});
|
||||||
|
it("Should not fail when getting data for private video", async function () {
|
||||||
|
const privateVideoId = "ZuibAax0VD8";
|
||||||
|
const videoDetail = await getVideoDetails(privateVideoId);
|
||||||
|
assert.ok(videoDetail);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -1292,4 +1292,20 @@ describe("postSkipSegments", () => {
|
|||||||
})
|
})
|
||||||
.catch(err => done(err));
|
.catch(err => done(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Should successfully submit if video is private", (done) => {
|
||||||
|
const videoID = "private-video";
|
||||||
|
postSkipSegmentParam({
|
||||||
|
videoID,
|
||||||
|
startTime: 1,
|
||||||
|
endTime: 5,
|
||||||
|
category: "sponsor",
|
||||||
|
userID: submitUserTwo
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
assert.strictEqual(res.status, 200);
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(err => done(err));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ export class YouTubeApiMock {
|
|||||||
lengthSeconds: 100,
|
lengthSeconds: 100,
|
||||||
} as APIVideoData
|
} as APIVideoData
|
||||||
};
|
};
|
||||||
|
} else if (obj.id === "private-video") {
|
||||||
|
return {
|
||||||
|
err: false,
|
||||||
|
data: {} as APIVideoData
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
err: false,
|
err: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user