mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 09:07:47 +01: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;
|
const overlapPercent = overlap / overallDuration;
|
||||||
return (overlapPercent >= 0.1 && segment.actionType === compareSegment.actionType && segment.category === compareSegment.category && segment.actionType !== ActionType.Chapter)
|
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.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);
|
|| (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";
|
import { Logger } from "./logger";
|
||||||
|
|
||||||
export const skipSegmentsKey = (videoID: VideoID, service: Service): string =>
|
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 =>
|
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 {
|
export function skipSegmentsHashKey(hashedVideoIDPrefix: VideoIDHash, service: Service): string {
|
||||||
hashedVideoIDPrefix = hashedVideoIDPrefix.substring(0, 4) as VideoIDHash;
|
hashedVideoIDPrefix = hashedVideoIDPrefix.substring(0, 4) as VideoIDHash;
|
||||||
if (hashedVideoIDPrefix.length !== 4) Logger.warn(`Redis skip segment hash-prefix key is not length 4! ${hashedVideoIDPrefix}`);
|
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 =>
|
export const reputationKey = (userID: UserID): string =>
|
||||||
|
|
|
@ -447,23 +447,25 @@ describe("getSkipSegmentsByHash", () => {
|
||||||
.catch(err => done(err));
|
.catch(err => done(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should be able to get only one segment when two categories are at the same time", (done) => {
|
// This behavior was causing unintended consequence, uncommend when a solution is found
|
||||||
client.get(`${endpoint}/7fac?categories=["sponsor","intro"]`)
|
// https://discord.com/channels/603643120093233162/607338052221665320/928099684835274883
|
||||||
.then(res => {
|
// it("Should be able to get only one segment when two categories are at the same time", (done) => {
|
||||||
assert.strictEqual(res.status, 200);
|
// client.get(`${endpoint}/7fac?categories=["sponsor","intro"]`)
|
||||||
const data = res.data;
|
// .then(res => {
|
||||||
assert.strictEqual(data.length, 1);
|
// assert.strictEqual(res.status, 200);
|
||||||
const expected = [{
|
// const data = res.data;
|
||||||
segments: [{
|
// assert.strictEqual(data.length, 1);
|
||||||
category: "intro"
|
// const expected = [{
|
||||||
}]
|
// segments: [{
|
||||||
}];
|
// category: "intro"
|
||||||
assert.ok(partialDeepEquals(data, expected));
|
// }]
|
||||||
assert.strictEqual(data[0].segments.length, 1);
|
// }];
|
||||||
done();
|
// assert.ok(partialDeepEquals(data, expected));
|
||||||
})
|
// assert.strictEqual(data[0].segments.length, 1);
|
||||||
.catch(err => done(err));
|
// done();
|
||||||
});
|
// })
|
||||||
|
// .catch(err => done(err));
|
||||||
|
// });
|
||||||
|
|
||||||
it("Should be able to get overlapping segments where one is non music and one is other", (done) => {
|
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"]`)
|
client.get(`${endpoint}/3061?categories=["sponsor","music_offtopic"]`)
|
||||||
|
|
Loading…
Reference in a new issue