mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-09-20 04:54:00 +02:00
Don't group different categories
This commit is contained in:
parent
7f7cc3a7ca
commit
6a98a215ac
3 changed files with 22 additions and 22 deletions
|
@ -307,8 +307,6 @@ function splitPercentOverlap(groups: OverlappingSegmentGroup[]): OverlappingSegm
|
|||
const overlapPercent = overlap / overallDuration;
|
||||
return (overlapPercent >= 0.1 && segment.actionType === compareSegment.actionType && segment.category === compareSegment.category && segment.actionType !== ActionType.Chapter)
|
||||
|| (overlapPercent >= 0.6 && segment.actionType !== compareSegment.actionType && segment.category === compareSegment.category)
|
||||
|| (overlapPercent >= 0.95 && segment.actionType === compareSegment.actionType && segment.category !== compareSegment.category
|
||||
&& segment.category !== "music_offtopic" && compareSegment.category !== "music_offtopic")
|
||||
|| (overlapPercent >= 0.8 && segment.actionType === ActionType.Chapter && compareSegment.actionType === ActionType.Chapter);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,16 +4,16 @@ import { HashedValue } from "../types/hash.model";
|
|||
import { Logger } from "./logger";
|
||||
|
||||
export const skipSegmentsKey = (videoID: VideoID, service: Service): string =>
|
||||
`segments.v3.${service}.videoID.${videoID}`;
|
||||
`segments.v4.${service}.videoID.${videoID}`;
|
||||
|
||||
export const skipSegmentGroupsKey = (videoID: VideoID, service: Service): string =>
|
||||
`segments.groups.v2.${service}.videoID.${videoID}`;
|
||||
`segments.groups.v3.${service}.videoID.${videoID}`;
|
||||
|
||||
export function skipSegmentsHashKey(hashedVideoIDPrefix: VideoIDHash, service: Service): string {
|
||||
hashedVideoIDPrefix = hashedVideoIDPrefix.substring(0, 4) as VideoIDHash;
|
||||
if (hashedVideoIDPrefix.length !== 4) Logger.warn(`Redis skip segment hash-prefix key is not length 4! ${hashedVideoIDPrefix}`);
|
||||
|
||||
return `segments.v3.${service}.${hashedVideoIDPrefix}`;
|
||||
return `segments.v4.${service}.${hashedVideoIDPrefix}`;
|
||||
}
|
||||
|
||||
export const reputationKey = (userID: UserID): string =>
|
||||
|
|
|
@ -447,23 +447,25 @@ describe("getSkipSegmentsByHash", () => {
|
|||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to get only one segment when two categories are at the same time", (done) => {
|
||||
client.get(`${endpoint}/7fac?categories=["sponsor","intro"]`)
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = res.data;
|
||||
assert.strictEqual(data.length, 1);
|
||||
const expected = [{
|
||||
segments: [{
|
||||
category: "intro"
|
||||
}]
|
||||
}];
|
||||
assert.ok(partialDeepEquals(data, expected));
|
||||
assert.strictEqual(data[0].segments.length, 1);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
// This behavior was causing unintended consequence, uncommend when a solution is found
|
||||
// https://discord.com/channels/603643120093233162/607338052221665320/928099684835274883
|
||||
// it("Should be able to get only one segment when two categories are at the same time", (done) => {
|
||||
// client.get(`${endpoint}/7fac?categories=["sponsor","intro"]`)
|
||||
// .then(res => {
|
||||
// assert.strictEqual(res.status, 200);
|
||||
// const data = res.data;
|
||||
// assert.strictEqual(data.length, 1);
|
||||
// const expected = [{
|
||||
// segments: [{
|
||||
// category: "intro"
|
||||
// }]
|
||||
// }];
|
||||
// assert.ok(partialDeepEquals(data, expected));
|
||||
// assert.strictEqual(data[0].segments.length, 1);
|
||||
// done();
|
||||
// })
|
||||
// .catch(err => done(err));
|
||||
// });
|
||||
|
||||
it("Should be able to get overlapping segments where one is non music and one is other", (done) => {
|
||||
client.get(`${endpoint}/3061?categories=["sponsor","music_offtopic"]`)
|
||||
|
|
Loading…
Reference in a new issue