mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-23 00:11:28 -07:00
fix: align youtube playback with shared overlay startup
This commit is contained in:
40
src/core/services/youtube/labels.ts
Normal file
40
src/core/services/youtube/labels.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
export type YoutubeTrackKind = 'manual' | 'auto';
|
||||
|
||||
export function normalizeYoutubeLangCode(value: string): string {
|
||||
return value.trim().toLowerCase().replace(/_/g, '-').replace(/[^a-z0-9-]+/g, '');
|
||||
}
|
||||
|
||||
export function isJapaneseYoutubeLang(value: string): boolean {
|
||||
const normalized = normalizeYoutubeLangCode(value);
|
||||
return (
|
||||
normalized === 'ja' ||
|
||||
normalized === 'jp' ||
|
||||
normalized === 'jpn' ||
|
||||
normalized === 'japanese' ||
|
||||
normalized.startsWith('ja-') ||
|
||||
normalized.startsWith('jp-')
|
||||
);
|
||||
}
|
||||
|
||||
export function isEnglishYoutubeLang(value: string): boolean {
|
||||
const normalized = normalizeYoutubeLangCode(value);
|
||||
return (
|
||||
normalized === 'en' ||
|
||||
normalized === 'eng' ||
|
||||
normalized === 'english' ||
|
||||
normalized === 'enus' ||
|
||||
normalized === 'en-us' ||
|
||||
normalized.startsWith('en-')
|
||||
);
|
||||
}
|
||||
|
||||
export function formatYoutubeTrackLabel(input: {
|
||||
language: string;
|
||||
kind: YoutubeTrackKind;
|
||||
title?: string;
|
||||
}): string {
|
||||
const language = input.language.trim() || 'unknown';
|
||||
const base = input.title?.trim() || language;
|
||||
return `${base} (${input.kind})`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user