Add support for multiple caption languages

This commit is contained in:
Brahim Hadriche committed 2023-01-29 20:27:24 -05:00
1 parent d91411b740
commit 5aac07d36c
3 files changed
+198 -16

No files matched your search

+1
View File
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- A script to sync between Youtube profile and and Invidious profile
- Moved most of Playlet logic to Playlet Lib
- Support for multiple caption languages
## [0.6.0] - 2023-01-10
### Added
@@ -1,24 +1,19 @@
function SetCaptions(metadata as object, videoPlayer as object, contentNode as object) as void
' TODO: check if we have caption settings ON
' TODO: read favorate language from system settings
' TODO: populate list of caption tracks
if metadata.captions.Count() = 0
return
end if
videoPlayer.globalCaptionMode = "ON"
contentNode.ClosedCaptions = True
selectedCaption = metadata.captions[0]
isoLanguageList = ParseJson(ReadAsciiFile("libpkg:/config/ISO-639-1-to-ISO-639-2T.json"))
instance = InvidiousSettings.GetSelectedInstance()
subtitleTracks = []
' Use favorite caption langauage, or the first one
for each caption in metadata.captions
if caption.language_code = "en"
selectedCaption = caption
exit for
end if
subtitleTracks.Push({
Description: caption.label,
Language: isoLanguageList[caption.language_code] ?? caption.language_code,
TrackName: instance + caption.url
})
end for
contentNode.SubtitleConfig = {
ShowSubtitle: 1,
TrackName: InvidiousSettings.GetSelectedInstance() + selectedCaption.url
}
contentNode.ClosedCaptions = True
contentNode.SubtitleTracks = subtitleTracks
end function
@@ -0,0 +1,186 @@
{
"aa": "aar",
"ab": "abk",
"af": "afr",
"ak": "aka",
"sq": "alb",
"am": "amh",
"ar": "ara",
"an": "arg",
"hy": "hye",
"as": "asm",
"av": "ava",
"ae": "ave",
"ay": "aym",
"az": "aze",
"ba": "bak",
"bm": "bam",
"eu": "eus",
"be": "bel",
"bn": "ben",
"bh": "bih",
"bi": "bis",
"bo": "tib",
"bs": "bos",
"br": "bre",
"bg": "bul",
"my": "mya",
"ca": "cat",
"cs": "cze",
"ch": "cha",
"ce": "che",
"zh": "zho",
"cu": "chu",
"cv": "chv",
"kw": "cor",
"co": "cos",
"cr": "cre",
"cy": "wel",
"da": "dan",
"de": "ger",
"dv": "div",
"nl": "dut",
"dz": "dzo",
"el": "gre",
"en": "eng",
"eo": "epo",
"et": "est",
"ee": "ewe",
"fo": "fao",
"fa": "per",
"fj": "fij",
"fi": "fin",
"fr": "fra",
"fy": "fry",
"ff": "ful",
"ka": "geo",
"gd": "gla",
"ga": "gle",
"gl": "glg",
"gv": "glv",
"gn": "grn",
"gu": "guj",
"ht": "hat",
"ha": "hau",
"he": "heb",
"hz": "her",
"hi": "hin",
"ho": "hmo",
"hr": "hrv",
"hu": "hun",
"ig": "ibo",
"is": "ice",
"io": "ido",
"ii": "iii",
"iu": "iku",
"ie": "ile",
"ia": "ina",
"id": "ind",
"ik": "ipk",
"it": "ita",
"jv": "jav",
"ja": "jpn",
"kl": "kal",
"kn": "kan",
"ks": "kas",
"kr": "kau",
"kk": "kaz",
"km": "khm",
"ki": "kik",
"rw": "kin",
"ky": "kir",
"kv": "kom",
"kg": "kon",
"ko": "kor",
"kj": "kua",
"ku": "kur",
"lo": "lao",
"la": "lat",
"lv": "lav",
"li": "lim",
"ln": "lin",
"lt": "lit",
"lb": "ltz",
"lu": "lub",
"lg": "lug",
"mk": "mkd",
"mh": "mah",
"ml": "mal",
"mi": "mri",
"mr": "mar",
"ms": "may",
"mg": "mlg",
"mt": "mlt",
"mn": "mon",
"na": "nau",
"nv": "nav",
"nr": "nbl",
"nd": "nde",
"ng": "ndo",
"ne": "nep",
"nn": "nno",
"nb": "nob",
"no": "nor",
"ny": "nya",
"oc": "oci",
"oj": "oji",
"or": "ori",
"om": "orm",
"os": "oss",
"pa": "pan",
"pi": "pli",
"pl": "pol",
"pt": "por",
"ps": "pus",
"qu": "que",
"rm": "roh",
"ro": "ron",
"rn": "run",
"ru": "rus",
"sg": "sag",
"sa": "san",
"si": "sin",
"sk": "slk",
"sl": "slv",
"se": "sme",
"sm": "smo",
"sn": "sna",
"sd": "snd",
"so": "som",
"st": "sot",
"es": "spa",
"sc": "srd",
"sr": "srp",
"ss": "ssw",
"su": "sun",
"sw": "swa",
"sv": "swe",
"ty": "tah",
"ta": "tam",
"tt": "tat",
"te": "tel",
"tg": "tgk",
"tl": "tgl",
"th": "tha",
"ti": "tir",
"to": "ton",
"tn": "tsn",
"ts": "tso",
"tk": "tuk",
"tr": "tur",
"tw": "twi",
"ug": "uig",
"uk": "ukr",
"ur": "urd",
"uz": "uzb",
"ve": "ven",
"vi": "vie",
"vo": "vol",
"wa": "wln",
"wo": "wol",
"xh": "xho",
"yi": "yid",
"yo": "yor",
"za": "zha",
"zu": "zul"
}