mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-02 07:21:33 -07:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
176edd67f1
|
|||
| 4d65dec340 | |||
|
6607c333bc
|
|||
|
b2bbf1ae12
|
@@ -1,5 +1,14 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v0.19.1 (2026-08-01)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Word Card Type: Adds a setting (Settings > Mining/Anki > Kiku/Lapis Features > "Word Card Type") to choose which card-type flag SubMiner marks on Kiku/Lapis word cards — `word-and-sentence` (default), `click`, `sentence`, `audio`, or `none`. Click cards (`IsClickCard`) can now be flagged, and setting any card-type flag clears the others so a note can't claim two types at once.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Yomitan Popup: Fixes the macOS Yomitan popup going inert after mining a card — clicks outside the popup no longer pass through to mpv, and scrolling over the popup scrolls its definitions instead of seeking playback.
|
||||||
|
- YouTube Playlist Links: Fixes opening a video from a playlist URL (e.g. a Watch Later link with `list=`/`index=`) timing out while probing subtitles, metadata, or the playback URL.
|
||||||
|
|
||||||
## v0.19.0 (2026-07-29)
|
## v0.19.0 (2026-07-29)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
type: fixed
|
|
||||||
area: overlay
|
|
||||||
|
|
||||||
- Fixed the macOS Yomitan popup going inert after mining a card: clicking outside the popup no longer passes through to mpv (with the overlay flickering hidden and shown), and scrolling over the popup scrolls its definitions again instead of seeking mpv.
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
type: added
|
|
||||||
area: anki
|
|
||||||
|
|
||||||
- Added `ankiConnect.lapisKiku.wordCardKind` (Settings > Mining/Anki > Kiku/Lapis Features > "Word Card Type") to choose which card-type flag SubMiner marks on Kiku/Lapis word cards: `word-and-sentence` (default, unchanged behavior), `click`, `sentence`, `audio`, or `none` to leave the flags alone. Requested by Kiku users who only want `IsClickCard` set.
|
|
||||||
- Word cards can now be flagged as Kiku click cards (`IsClickCard`), which SubMiner previously never set.
|
|
||||||
- Setting a card-type flag now clears `IsClickCard` alongside the other card-type flags, so a note can no longer claim two card types at once.
|
|
||||||
@@ -607,7 +607,7 @@
|
|||||||
"deleteDuplicateInAuto": true // When Kiku field grouping is "auto", delete the duplicate source card after grouping completes. Values: true | false
|
"deleteDuplicateInAuto": true // When Kiku field grouping is "auto", delete the duplicate source card after grouping completes. Values: true | false
|
||||||
}, // Is kiku setting.
|
}, // Is kiku setting.
|
||||||
"lapisKiku": {
|
"lapisKiku": {
|
||||||
"wordCardKind": "word-and-sentence" // Card-type flag SubMiner marks on Kiku/Lapis word cards: word-and-sentence (IsWordAndSentenceCard), click (IsClickCard), sentence (IsSentenceCard), audio (IsAudioCard), or none to leave the flags untouched. Only applies when isKiku.enabled or isLapis.enabled; the other card-type flags are cleared so a note never claims two kinds. Cards mined with the dedicated sentence/audio actions keep their own flag. Values: word-and-sentence | click | sentence | audio | none
|
"wordCardKind": "word-and-sentence" // Card-type flag SubMiner marks on Kiku/Lapis word cards. Only one flag is set at a time; the others are cleared. Requires isKiku.enabled or isLapis.enabled. Values: word-and-sentence | click | sentence | audio | none
|
||||||
} // Lapis kiku setting.
|
} // Lapis kiku setting.
|
||||||
}, // Automatic Anki updates and media generation options.
|
}, // Automatic Anki updates and media generation options.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v0.19.1 (2026-08-01)
|
||||||
|
|
||||||
|
**Added**
|
||||||
|
- Word Card Type: Adds a setting (Settings > Mining/Anki > Kiku/Lapis Features > "Word Card Type") to choose which card-type flag SubMiner marks on Kiku/Lapis word cards — `word-and-sentence` (default), `click`, `sentence`, `audio`, or `none`. Click cards (`IsClickCard`) can now be flagged, and setting any card-type flag clears the others so a note can't claim two types at once.
|
||||||
|
|
||||||
|
**Fixed**
|
||||||
|
- Yomitan Popup: Fixes the macOS Yomitan popup going inert after mining a card — clicks outside the popup no longer pass through to mpv, and scrolling over the popup scrolls its definitions instead of seeking playback.
|
||||||
|
- YouTube Playlist Links: Fixes opening a video from a playlist URL (e.g. a Watch Later link with `list=`/`index=`) timing out while probing subtitles, metadata, or the playback URL.
|
||||||
|
|
||||||
## v0.19.0 (2026-07-29)
|
## v0.19.0 (2026-07-29)
|
||||||
|
|
||||||
**Added**
|
**Added**
|
||||||
|
|||||||
@@ -607,7 +607,7 @@
|
|||||||
"deleteDuplicateInAuto": true // When Kiku field grouping is "auto", delete the duplicate source card after grouping completes. Values: true | false
|
"deleteDuplicateInAuto": true // When Kiku field grouping is "auto", delete the duplicate source card after grouping completes. Values: true | false
|
||||||
}, // Is kiku setting.
|
}, // Is kiku setting.
|
||||||
"lapisKiku": {
|
"lapisKiku": {
|
||||||
"wordCardKind": "word-and-sentence" // Card-type flag SubMiner marks on Kiku/Lapis word cards: word-and-sentence (IsWordAndSentenceCard), click (IsClickCard), sentence (IsSentenceCard), audio (IsAudioCard), or none to leave the flags untouched. Only applies when isKiku.enabled or isLapis.enabled; the other card-type flags are cleared so a note never claims two kinds. Cards mined with the dedicated sentence/audio actions keep their own flag. Values: word-and-sentence | click | sentence | audio | none
|
"wordCardKind": "word-and-sentence" // Card-type flag SubMiner marks on Kiku/Lapis word cards. Only one flag is set at a time; the others are cleared. Requires isKiku.enabled or isLapis.enabled. Values: word-and-sentence | click | sentence | audio | none
|
||||||
} // Lapis kiku setting.
|
} // Lapis kiku setting.
|
||||||
}, // Automatic Anki updates and media generation options.
|
}, // Automatic Anki updates and media generation options.
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ SubMiner auto-loads Japanese subtitles when you play a YouTube URL, giving you t
|
|||||||
|
|
||||||
When SubMiner detects a YouTube URL (or `ytsearch:` target), it pauses mpv at startup and runs a subtitle pipeline before resuming playback:
|
When SubMiner detects a YouTube URL (or `ytsearch:` target), it pauses mpv at startup and runs a subtitle pipeline before resuming playback:
|
||||||
|
|
||||||
1. **Probe** --- `yt-dlp --dump-single-json` extracts all available subtitle tracks (manual uploads and auto-generated captions) along with video metadata.
|
1. **Probe** --- `yt-dlp --dump-single-json` extracts all available subtitle tracks (manual uploads and auto-generated captions) along with video metadata. Every yt-dlp call passes `--no-playlist`, so playlist links (for example a Watch Later URL with `list=`/`index=`) resolve to the single video instead of the whole playlist.
|
||||||
2. **Discover** --- Each track is normalized into a `YoutubeTrackOption` with language code, kind (`manual` or `auto`), display label, and direct download URL.
|
2. **Discover** --- Each track is normalized into a `YoutubeTrackOption` with language code, kind (`manual` or `auto`), display label, and direct download URL.
|
||||||
3. **Select** --- SubMiner picks the best primary track (Japanese, preferring manual over auto) and secondary track (English, preferring manual over auto).
|
3. **Select** --- SubMiner picks the best primary track (Japanese, preferring manual over auto) and secondary track (English, preferring manual over auto).
|
||||||
4. **Download** --- Selected tracks are fetched via direct URL when available, falling back to `yt-dlp --write-subs` / `--write-auto-subs`. YouTube TimedText XML formats (`srv1`/`srv2`/`srv3`) are converted to VTT on the fly. Auto-generated VTT captions are normalized to remove rolling-caption duplication.
|
4. **Download** --- Selected tracks are fetched via direct URL when available, falling back to `yt-dlp --write-subs` / `--write-auto-subs`. YouTube TimedText XML formats (`srv1`/`srv2`/`srv3`) are converted to VTT on the fly. Auto-generated VTT captions are normalized to remove rolling-caption duplication.
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"name": "subminer",
|
"name": "subminer",
|
||||||
"productName": "SubMiner",
|
"productName": "SubMiner",
|
||||||
"desktopName": "SubMiner.desktop",
|
"desktopName": "SubMiner.desktop",
|
||||||
"version": "0.19.0",
|
"version": "0.19.1",
|
||||||
"description": "All-in-one sentence mining overlay with AnkiConnect and dictionary integration",
|
"description": "All-in-one sentence mining overlay with AnkiConnect and dictionary integration",
|
||||||
"packageManager": "bun@1.3.5",
|
"packageManager": "bun@1.3.5",
|
||||||
"main": "dist/main-entry.js",
|
"main": "dist/main-entry.js",
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
## Highlights
|
||||||
|
### Added
|
||||||
|
- Kiku/Lapis Word Card Type Setting
|
||||||
|
- A new setting (Mining/Anki > Kiku/Lapis Features > "Word Card Type") lets you choose which card-type flag gets marked on Kiku/Lapis word cards, including a click-card option that SubMiner couldn't set before.
|
||||||
|
- Handy if you only want click cards flagged instead of the default word-and-sentence marking.
|
||||||
|
- Choosing a card type now clears any other flags automatically, so a note can't end up marked as two types at once.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Yomitan Popup on macOS
|
||||||
|
- Fixed the popup going unresponsive after mining a card — clicks outside it no longer leak through to mpv, and the overlay no longer flickers hidden and shown.
|
||||||
|
- Scrolling over the popup now scrolls its definitions instead of seeking the video.
|
||||||
|
- YouTube Playlist Links
|
||||||
|
- Opening a video from a playlist URL (like a Watch Later link with `list=`/`index=`) no longer times out while loading subtitles, metadata, or playback info.
|
||||||
|
|
||||||
|
## What's Changed
|
||||||
|
|
||||||
|
- feat(anki): add configurable word card type for Kiku/Lapis by @ksyasuda in #175
|
||||||
|
- fix(overlay): keep Yomitan popup interactive on macOS/Windows by @ksyasuda in #177
|
||||||
|
- fix(youtube): prevent playlist URLs from stalling yt-dlp probes by @ksyasuda in #180
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
See the README and docs/installation guide for full setup steps.
|
||||||
|
|
||||||
|
## Assets
|
||||||
|
|
||||||
|
- Linux: `SubMiner.AppImage`
|
||||||
|
- macOS: `SubMiner-*.dmg` and `SubMiner-*.zip`
|
||||||
|
- Windows: `SubMiner-*.exe` and `SubMiner-*-win.zip`
|
||||||
|
- Optional extras: `subminer-assets.tar.gz` and the `subminer` launcher
|
||||||
|
|
||||||
|
Note: the `subminer` wrapper script uses Bun (`#!/usr/bin/env bun`), so `bun` must be installed and on `PATH`.
|
||||||
@@ -6,7 +6,7 @@ import * as os from 'node:os';
|
|||||||
import * as path from 'node:path';
|
import * as path from 'node:path';
|
||||||
|
|
||||||
import type { YoutubeMediaCacheMode } from '../../../types/integrations';
|
import type { YoutubeMediaCacheMode } from '../../../types/integrations';
|
||||||
import { getYoutubeYtDlpCommand } from './ytdlp-command';
|
import { getYoutubeYtDlpCommand, YTDLP_SINGLE_VIDEO_ARG } from './ytdlp-command';
|
||||||
|
|
||||||
type MediaCacheSessionState = 'running' | 'ready' | 'failed';
|
type MediaCacheSessionState = 'running' | 'ready' | 'failed';
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ function normalizeMaxHeight(maxHeight: number | undefined): number {
|
|||||||
|
|
||||||
function createYtDlpArgs(url: string, outputTemplate: string, maxHeight?: number): string[] {
|
function createYtDlpArgs(url: string, outputTemplate: string, maxHeight?: number): string[] {
|
||||||
return [
|
return [
|
||||||
'--no-playlist',
|
YTDLP_SINGLE_VIDEO_ARG,
|
||||||
'--no-warnings',
|
'--no-warnings',
|
||||||
'--force-ipv4',
|
'--force-ipv4',
|
||||||
'--retries',
|
'--retries',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { spawn } from 'node:child_process';
|
import { spawn } from 'node:child_process';
|
||||||
import type { YoutubeVideoMetadata } from '../immersion-tracker/types';
|
import type { YoutubeVideoMetadata } from '../immersion-tracker/types';
|
||||||
import { getYoutubeYtDlpCommand } from './ytdlp-command';
|
import { getYoutubeYtDlpCommand, YTDLP_SINGLE_VIDEO_ARG } from './ytdlp-command';
|
||||||
|
|
||||||
const YOUTUBE_METADATA_PROBE_TIMEOUT_MS = 15_000;
|
const YOUTUBE_METADATA_PROBE_TIMEOUT_MS = 15_000;
|
||||||
|
|
||||||
@@ -85,15 +85,23 @@ function pickChannelThumbnail(thumbnails: YtDlpThumbnail[] | undefined): string
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function probeYoutubeVideoMetadata(
|
export function buildYoutubeMetadataProbeArgs(targetUrl: string): string[] {
|
||||||
targetUrl: string,
|
return [
|
||||||
): Promise<YoutubeVideoMetadata | null> {
|
YTDLP_SINGLE_VIDEO_ARG,
|
||||||
const { stdout } = await runCapture(getYoutubeYtDlpCommand(), [
|
|
||||||
'--dump-single-json',
|
'--dump-single-json',
|
||||||
'--no-warnings',
|
'--no-warnings',
|
||||||
'--skip-download',
|
'--skip-download',
|
||||||
targetUrl,
|
targetUrl,
|
||||||
]);
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function probeYoutubeVideoMetadata(
|
||||||
|
targetUrl: string,
|
||||||
|
): Promise<YoutubeVideoMetadata | null> {
|
||||||
|
const { stdout } = await runCapture(
|
||||||
|
getYoutubeYtDlpCommand(),
|
||||||
|
buildYoutubeMetadataProbeArgs(targetUrl),
|
||||||
|
);
|
||||||
let info: YtDlpYoutubeMetadata;
|
let info: YtDlpYoutubeMetadata;
|
||||||
try {
|
try {
|
||||||
info = JSON.parse(stdout) as YtDlpYoutubeMetadata;
|
info = JSON.parse(stdout) as YtDlpYoutubeMetadata;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { spawn } from 'node:child_process';
|
import { spawn } from 'node:child_process';
|
||||||
import { getYoutubeYtDlpCommand } from './ytdlp-command';
|
import { getYoutubeYtDlpCommand, YTDLP_SINGLE_VIDEO_ARG } from './ytdlp-command';
|
||||||
|
|
||||||
const YOUTUBE_PLAYBACK_RESOLVE_TIMEOUT_MS = 15_000;
|
const YOUTUBE_PLAYBACK_RESOLVE_TIMEOUT_MS = 15_000;
|
||||||
const DEFAULT_PLAYBACK_FORMAT = 'b';
|
const DEFAULT_PLAYBACK_FORMAT = 'b';
|
||||||
@@ -85,17 +85,18 @@ function runCapture(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function buildYoutubePlaybackResolveArgs(targetUrl: string, format: string): string[] {
|
||||||
|
return [YTDLP_SINGLE_VIDEO_ARG, '--get-url', '--no-warnings', '-f', format, targetUrl];
|
||||||
|
}
|
||||||
|
|
||||||
export async function resolveYoutubePlaybackUrl(
|
export async function resolveYoutubePlaybackUrl(
|
||||||
targetUrl: string,
|
targetUrl: string,
|
||||||
format = DEFAULT_PLAYBACK_FORMAT,
|
format = DEFAULT_PLAYBACK_FORMAT,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const { stdout } = await runCapture(getYoutubeYtDlpCommand(), [
|
const { stdout } = await runCapture(
|
||||||
'--get-url',
|
getYoutubeYtDlpCommand(),
|
||||||
'--no-warnings',
|
buildYoutubePlaybackResolveArgs(targetUrl, format),
|
||||||
'-f',
|
);
|
||||||
format,
|
|
||||||
targetUrl,
|
|
||||||
]);
|
|
||||||
const playbackUrl =
|
const playbackUrl =
|
||||||
stdout
|
stdout
|
||||||
.split(/\r?\n/)
|
.split(/\r?\n/)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { spawn } from 'node:child_process';
|
import { spawn } from 'node:child_process';
|
||||||
import type { YoutubeTrackOption } from './track-probe';
|
import type { YoutubeTrackOption } from './track-probe';
|
||||||
import { getYoutubeYtDlpCommand } from './ytdlp-command';
|
import { getYoutubeYtDlpCommand, YTDLP_SINGLE_VIDEO_ARG } from './ytdlp-command';
|
||||||
import {
|
import {
|
||||||
convertYoutubeTimedTextToVtt,
|
convertYoutubeTimedTextToVtt,
|
||||||
isYoutubeTimedTextExtension,
|
isYoutubeTimedTextExtension,
|
||||||
@@ -126,14 +126,14 @@ function pickLatestSubtitleFileForLanguage(
|
|||||||
return candidates[0] ?? null;
|
return candidates[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildDownloadArgs(input: {
|
export function buildDownloadArgs(input: {
|
||||||
targetUrl: string;
|
targetUrl: string;
|
||||||
outputTemplate: string;
|
outputTemplate: string;
|
||||||
sourceLanguages: string[];
|
sourceLanguages: string[];
|
||||||
includeAutoSubs: boolean;
|
includeAutoSubs: boolean;
|
||||||
includeManualSubs: boolean;
|
includeManualSubs: boolean;
|
||||||
}): string[] {
|
}): string[] {
|
||||||
const args = ['--skip-download', '--no-warnings'];
|
const args = [YTDLP_SINGLE_VIDEO_ARG, '--skip-download', '--no-warnings'];
|
||||||
if (input.includeAutoSubs) {
|
if (input.includeAutoSubs) {
|
||||||
args.push('--write-auto-subs');
|
args.push('--write-auto-subs');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { spawn } from 'node:child_process';
|
import { spawn } from 'node:child_process';
|
||||||
import type { YoutubeTrackOption } from '../../../types';
|
import type { YoutubeTrackOption } from '../../../types';
|
||||||
import { formatYoutubeTrackLabel, normalizeYoutubeLangCode, type YoutubeTrackKind } from './labels';
|
import { formatYoutubeTrackLabel, normalizeYoutubeLangCode, type YoutubeTrackKind } from './labels';
|
||||||
import { getYoutubeYtDlpCommand } from './ytdlp-command';
|
import { getYoutubeYtDlpCommand, YTDLP_SINGLE_VIDEO_ARG } from './ytdlp-command';
|
||||||
|
|
||||||
const YOUTUBE_TRACK_PROBE_TIMEOUT_MS = 15_000;
|
const YOUTUBE_TRACK_PROBE_TIMEOUT_MS = 15_000;
|
||||||
|
|
||||||
@@ -111,12 +111,15 @@ function toTracks(entries: Record<string, YtDlpSubtitleEntry> | undefined, kind:
|
|||||||
|
|
||||||
export type { YoutubeTrackOption };
|
export type { YoutubeTrackOption };
|
||||||
|
|
||||||
|
export function buildYoutubeTrackProbeArgs(targetUrl: string): string[] {
|
||||||
|
return [YTDLP_SINGLE_VIDEO_ARG, '--dump-single-json', '--no-warnings', targetUrl];
|
||||||
|
}
|
||||||
|
|
||||||
export async function probeYoutubeTracks(targetUrl: string): Promise<YoutubeTrackProbeResult> {
|
export async function probeYoutubeTracks(targetUrl: string): Promise<YoutubeTrackProbeResult> {
|
||||||
const { stdout } = await runCapture(getYoutubeYtDlpCommand(), [
|
const { stdout } = await runCapture(
|
||||||
'--dump-single-json',
|
getYoutubeYtDlpCommand(),
|
||||||
'--no-warnings',
|
buildYoutubeTrackProbeArgs(targetUrl),
|
||||||
targetUrl,
|
);
|
||||||
]);
|
|
||||||
const trimmedStdout = stdout.trim();
|
const trimmedStdout = stdout.trim();
|
||||||
if (!trimmedStdout) {
|
if (!trimmedStdout) {
|
||||||
throw new Error('yt-dlp returned empty output while probing subtitle tracks');
|
throw new Error('yt-dlp returned empty output while probing subtitle tracks');
|
||||||
|
|||||||
@@ -4,6 +4,13 @@ import path from 'node:path';
|
|||||||
const DEFAULT_YTDLP_COMMAND = 'yt-dlp';
|
const DEFAULT_YTDLP_COMMAND = 'yt-dlp';
|
||||||
const WINDOWS_YTDLP_COMMANDS = ['yt-dlp.cmd', 'yt-dlp.exe', 'yt-dlp'];
|
const WINDOWS_YTDLP_COMMANDS = ['yt-dlp.cmd', 'yt-dlp.exe', 'yt-dlp'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* yt-dlp expands `list=`/`index=` URL params into the whole playlist unless told not to, which
|
||||||
|
* makes single-video extraction hang (e.g. a full Watch Later list) until our timeouts fire.
|
||||||
|
* Every yt-dlp invocation targeting one video must include this.
|
||||||
|
*/
|
||||||
|
export const YTDLP_SINGLE_VIDEO_ARG = '--no-playlist';
|
||||||
|
|
||||||
function resolveFromPath(commandName: string): string | null {
|
function resolveFromPath(commandName: string): string | null {
|
||||||
if (!process.env.PATH) {
|
if (!process.env.PATH) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import test from 'node:test';
|
||||||
|
import { buildYoutubeMetadataProbeArgs } from './metadata-probe';
|
||||||
|
import { buildYoutubePlaybackResolveArgs } from './playback-resolve';
|
||||||
|
import { buildDownloadArgs } from './track-download';
|
||||||
|
import { buildYoutubeTrackProbeArgs } from './track-probe';
|
||||||
|
import { YTDLP_SINGLE_VIDEO_ARG } from './ytdlp-command';
|
||||||
|
|
||||||
|
// Regression guard for issue #179: a `list=`/`index=` URL made yt-dlp enumerate the whole
|
||||||
|
// playlist (e.g. Watch Later) and blow past our 15s timeouts on every single-video call.
|
||||||
|
const PLAYLIST_URL = 'https://www.youtube.com/watch?v=LKfWC6CgFng&list=WL&index=3';
|
||||||
|
|
||||||
|
const cases: Array<{ name: string; args: string[] }> = [
|
||||||
|
{ name: 'track probe', args: buildYoutubeTrackProbeArgs(PLAYLIST_URL) },
|
||||||
|
{ name: 'metadata probe', args: buildYoutubeMetadataProbeArgs(PLAYLIST_URL) },
|
||||||
|
{ name: 'playback resolve', args: buildYoutubePlaybackResolveArgs(PLAYLIST_URL, 'b') },
|
||||||
|
{
|
||||||
|
name: 'subtitle download',
|
||||||
|
args: buildDownloadArgs({
|
||||||
|
targetUrl: PLAYLIST_URL,
|
||||||
|
outputTemplate: '/tmp/out.%(ext)s',
|
||||||
|
sourceLanguages: ['ja'],
|
||||||
|
includeAutoSubs: true,
|
||||||
|
includeManualSubs: false,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
test('YTDLP_SINGLE_VIDEO_ARG is the yt-dlp flag that disables playlist expansion', () => {
|
||||||
|
assert.equal(YTDLP_SINGLE_VIDEO_ARG, '--no-playlist');
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const { name, args } of cases) {
|
||||||
|
test(`${name} passes --no-playlist for playlist-scoped URLs`, () => {
|
||||||
|
assert.ok(args.includes('--no-playlist'), `${name} args: ${args.join(' ')}`);
|
||||||
|
assert.equal(args.at(-1), PLAYLIST_URL);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import assert from 'node:assert/strict';
|
|||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
import {
|
import {
|
||||||
getPlaybackFeedbackNotificationOptions,
|
getPlaybackFeedbackNotificationOptions,
|
||||||
|
getSubsyncStatusNotificationOptions,
|
||||||
getYoutubeFlowStatusNotificationOptions,
|
getYoutubeFlowStatusNotificationOptions,
|
||||||
notifyConfiguredStatus,
|
notifyConfiguredStatus,
|
||||||
} from './configured-status-notification';
|
} from './configured-status-notification';
|
||||||
@@ -158,6 +159,64 @@ test('notifyConfiguredStatus can suppress desktop delivery for progress ticks',
|
|||||||
assert.deepEqual(calls, ['overlay:subsync-status:Subsync:Subsync: syncing |:progress:pin']);
|
assert.deepEqual(calls, ['overlay:subsync-status:Subsync:Subsync: syncing |:progress:pin']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('subsync progress keeps the osd spinner frame but strips it from the overlay card', () => {
|
||||||
|
const calls: string[] = [];
|
||||||
|
|
||||||
|
for (const frame of ['|', '/', '-', '\\']) {
|
||||||
|
const message = `Subsync: syncing ${frame}`;
|
||||||
|
notifyConfiguredStatus(
|
||||||
|
message,
|
||||||
|
{
|
||||||
|
getNotificationType: () => 'both',
|
||||||
|
showOsd: (osdMessage) => {
|
||||||
|
calls.push(`osd:${osdMessage}`);
|
||||||
|
},
|
||||||
|
showOverlayNotification: (payload) =>
|
||||||
|
calls.push(
|
||||||
|
`overlay:${payload.body}:${payload.variant}:${payload.persistent ? 'pin' : 'auto'}`,
|
||||||
|
),
|
||||||
|
showDesktopNotification: (title, options) =>
|
||||||
|
calls.push(`desktop:${title}:${options.body ?? ''}`),
|
||||||
|
},
|
||||||
|
getSubsyncStatusNotificationOptions(message),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.deepEqual(calls, [
|
||||||
|
'overlay:Subsync: syncing:progress:pin',
|
||||||
|
'overlay:Subsync: syncing:progress:pin',
|
||||||
|
'overlay:Subsync: syncing:progress:pin',
|
||||||
|
'overlay:Subsync: syncing:progress:pin',
|
||||||
|
]);
|
||||||
|
|
||||||
|
calls.length = 0;
|
||||||
|
notifyConfiguredStatus(
|
||||||
|
'Subsync: syncing /',
|
||||||
|
{
|
||||||
|
getNotificationType: () => 'osd',
|
||||||
|
showOsd: (osdMessage) => {
|
||||||
|
calls.push(`osd:${osdMessage}`);
|
||||||
|
},
|
||||||
|
showOverlayNotification: (payload) => calls.push(`overlay:${payload.body}`),
|
||||||
|
showDesktopNotification: (title, options) =>
|
||||||
|
calls.push(`desktop:${title}:${options.body ?? ''}`),
|
||||||
|
},
|
||||||
|
getSubsyncStatusNotificationOptions('Subsync: syncing /'),
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(calls, ['osd:Subsync: syncing /']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('subsync result notifications keep their message intact', () => {
|
||||||
|
assert.equal(
|
||||||
|
getSubsyncStatusNotificationOptions('Subtitle synchronized with ffsubsync').overlayBody,
|
||||||
|
'Subtitle synchronized with ffsubsync',
|
||||||
|
);
|
||||||
|
const failure = getSubsyncStatusNotificationOptions('ffsubsync synchronization failed: boom');
|
||||||
|
assert.equal(failure.variant, 'error');
|
||||||
|
assert.equal(failure.overlayBody, 'ffsubsync synchronization failed: boom');
|
||||||
|
});
|
||||||
|
|
||||||
test('notifyConfiguredStatus routes feedback through overlay without desktop delivery', () => {
|
test('notifyConfiguredStatus routes feedback through overlay without desktop delivery', () => {
|
||||||
const calls: string[] = [];
|
const calls: string[] = [];
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ export interface ConfiguredStatusNotificationDeps {
|
|||||||
|
|
||||||
export interface ConfiguredStatusNotificationOptions {
|
export interface ConfiguredStatusNotificationOptions {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
/** Overrides the overlay card body (the OSD/desktop paths keep the raw message). */
|
||||||
|
overlayBody?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
variant?: OverlayNotificationPayload['variant'];
|
variant?: OverlayNotificationPayload['variant'];
|
||||||
persistent?: boolean;
|
persistent?: boolean;
|
||||||
@@ -31,6 +33,23 @@ export function getPlaybackFeedbackNotificationOptions(
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getSubsyncStatusNotificationOptions(
|
||||||
|
message: string,
|
||||||
|
): ConfiguredStatusNotificationOptions {
|
||||||
|
const syncing = message.startsWith('Subsync: syncing');
|
||||||
|
const failed = message.toLowerCase().includes('failed');
|
||||||
|
return {
|
||||||
|
id: 'subsync-status',
|
||||||
|
title: 'Subsync',
|
||||||
|
// The overlay card renders its own animated spinner, so drop the ASCII
|
||||||
|
// spinner frame that the OSD path still needs.
|
||||||
|
overlayBody: syncing ? message.replace(/\s+[|/\-\\]$/, '') : message,
|
||||||
|
variant: failed ? 'error' : syncing ? 'progress' : 'info',
|
||||||
|
persistent: syncing,
|
||||||
|
desktop: !syncing,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function getYoutubeFlowStatusNotificationOptions(
|
export function getYoutubeFlowStatusNotificationOptions(
|
||||||
message: string,
|
message: string,
|
||||||
): ConfiguredStatusNotificationOptions {
|
): ConfiguredStatusNotificationOptions {
|
||||||
@@ -74,7 +93,7 @@ export function notifyConfiguredStatus(
|
|||||||
deps.showOverlayNotification({
|
deps.showOverlayNotification({
|
||||||
id: options.id,
|
id: options.id,
|
||||||
title: options.title ?? 'SubMiner',
|
title: options.title ?? 'SubMiner',
|
||||||
body: message,
|
body: options.overlayBody ?? message,
|
||||||
variant: options.variant ?? 'info',
|
variant: options.variant ?? 'info',
|
||||||
persistent: options.persistent ?? false,
|
persistent: options.persistent ?? false,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { withConfiguredOverlayNotificationPosition } from './overlay-notificatio
|
|||||||
import { createOverlayNotificationDelivery } from './overlay-notification-delivery';
|
import { createOverlayNotificationDelivery } from './overlay-notification-delivery';
|
||||||
import {
|
import {
|
||||||
getPlaybackFeedbackNotificationOptions,
|
getPlaybackFeedbackNotificationOptions,
|
||||||
|
getSubsyncStatusNotificationOptions,
|
||||||
getYoutubeFlowStatusNotificationOptions,
|
getYoutubeFlowStatusNotificationOptions,
|
||||||
notifyConfiguredStatus,
|
notifyConfiguredStatus,
|
||||||
type ConfiguredStatusNotificationOptions,
|
type ConfiguredStatusNotificationOptions,
|
||||||
@@ -195,15 +196,7 @@ export function createOverlayNotificationsRuntime(deps: OverlayNotificationsRunt
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showSubsyncStatusNotification(message: string): void {
|
function showSubsyncStatusNotification(message: string): void {
|
||||||
const syncing = message.startsWith('Subsync: syncing');
|
showConfiguredStatusNotification(message, getSubsyncStatusNotificationOptions(message));
|
||||||
const failed = message.toLowerCase().includes('failed');
|
|
||||||
showConfiguredStatusNotification(message, {
|
|
||||||
id: 'subsync-status',
|
|
||||||
title: 'Subsync',
|
|
||||||
variant: failed ? 'error' : syncing ? 'progress' : 'info',
|
|
||||||
persistent: syncing,
|
|
||||||
desktop: !syncing,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showYoutubeFlowStatusNotification(message: string): void {
|
function showYoutubeFlowStatusNotification(message: string): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user