mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 12:55:16 -07:00
fix: delegate multi-line digit selection to visible overlay (#78)
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { isYoutubeMediaPath, isYoutubePlaybackActive } from './youtube-playback';
|
||||
import {
|
||||
isSameYoutubeMediaPath,
|
||||
isYoutubeMediaPath,
|
||||
isYoutubePlaybackActive,
|
||||
shouldUseCachedYoutubeParsedCues,
|
||||
} from './youtube-playback';
|
||||
|
||||
test('isYoutubeMediaPath detects youtube watch and short urls', () => {
|
||||
assert.equal(isYoutubeMediaPath('https://www.youtube.com/watch?v=abc123'), true);
|
||||
@@ -22,3 +27,49 @@ test('isYoutubePlaybackActive checks both current media and mpv video paths', ()
|
||||
assert.equal(isYoutubePlaybackActive('https://www.youtube.com/watch?v=abc123', null), true);
|
||||
assert.equal(isYoutubePlaybackActive('/tmp/video.mkv', '/tmp/video.mkv'), false);
|
||||
});
|
||||
|
||||
test('isSameYoutubeMediaPath matches equivalent youtube urls by video id', () => {
|
||||
assert.equal(
|
||||
isSameYoutubeMediaPath('https://www.youtube.com/watch?v=abc123&t=30', 'https://youtu.be/abc123'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
isSameYoutubeMediaPath(
|
||||
'https://www.youtube.com/embed/abc123',
|
||||
'https://www.youtube-nocookie.com/embed/abc123',
|
||||
),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
isSameYoutubeMediaPath('https://www.youtube.com/watch?v=abc123', 'https://youtu.be/xyz789'),
|
||||
false,
|
||||
);
|
||||
assert.equal(isSameYoutubeMediaPath('/tmp/video.mkv', 'https://youtu.be/abc123'), false);
|
||||
});
|
||||
|
||||
test('shouldUseCachedYoutubeParsedCues requires cached cues for the same youtube video', () => {
|
||||
assert.equal(
|
||||
shouldUseCachedYoutubeParsedCues({
|
||||
videoPath: 'https://www.youtube.com/watch?v=abc123&t=30',
|
||||
cachedMediaPath: 'https://youtu.be/abc123',
|
||||
cachedCueCount: 12,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
shouldUseCachedYoutubeParsedCues({
|
||||
videoPath: 'https://www.youtube.com/watch?v=abc123',
|
||||
cachedMediaPath: 'https://youtu.be/abc123',
|
||||
cachedCueCount: 0,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
shouldUseCachedYoutubeParsedCues({
|
||||
videoPath: 'https://www.youtube.com/watch?v=abc123',
|
||||
cachedMediaPath: 'https://youtu.be/other',
|
||||
cachedCueCount: 12,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user