mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-03 19:21:32 -07:00
c5140b0f7b
- Add `subminer anime` / `--anime` and a tray entry to open a browser that searches installed Aniyomi extension sources, shows cover art and episodes, and plays into mpv with overlay/mining attached - Add an Extensions tab to add repos and install/update/remove sources, and per-source settings for sources needing config - Support searching all sources at once with streaming, per-source results and status - Prefer Japanese audio/subtitle tracks from the source and keep the primary subtitle slot reserved for Japanese - Fix window/tray/Dock handling so the browser and mpv can be switched between without quitting the app or losing the Dock icon - Add anime.repos, anime.extensionsDir, anime.preferredQuality config keys (no bundled repos or discovery)
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
import type {
|
|
AnimeBrowserSearchResult,
|
|
AnimeBrowserSource,
|
|
InstalledExtensionView,
|
|
} from '../types/anime-browser';
|
|
|
|
/** Display strings for the anime browser, kept separate from the DOM. */
|
|
|
|
/** `Nyaa (ja)`, or just the name for a source that serves every language. */
|
|
export function sourceOptionLabel(source: AnimeBrowserSource): string {
|
|
return source.lang === 'all' ? source.name : `${source.name} (${source.lang})`;
|
|
}
|
|
|
|
/**
|
|
* The status line after a search.
|
|
*
|
|
* An all-sources search can half-succeed, so the sources that failed are named
|
|
* rather than folded into a count the user cannot act on.
|
|
*/
|
|
export function summarizeSearch(result: AnimeBrowserSearchResult): string {
|
|
const count = `${result.entries.length} result${result.entries.length === 1 ? '' : 's'}`;
|
|
if (result.failures.length === 0) return count;
|
|
const names = result.failures.map((failure) => failure.sourceName).join(', ');
|
|
return `${count} · ${result.failures.length} unavailable: ${names}`;
|
|
}
|
|
|
|
/** `pkg · 3 sources · en, ja`, trimmed to what the extension actually reported. */
|
|
export function describeInstalled(view: InstalledExtensionView): string {
|
|
const parts = [view.pkg];
|
|
if (view.sourceCount > 0) {
|
|
parts.push(`${view.sourceCount} source${view.sourceCount === 1 ? '' : 's'}`);
|
|
}
|
|
if (view.langs.length > 0) parts.push(view.langs.join(', '));
|
|
return parts.join(' · ');
|
|
}
|