61 lines
1.7 KiB
Lua
61 lines
1.7 KiB
Lua
local preferred_alangs = {"jpn", "ja", "japanese"}
|
|
local preferred_slangs = {"jpn", "ja", "japanese"}
|
|
|
|
local phrases = {
|
|
"日本語オンリーで行こう!英語なんて大嫌い!",
|
|
"これで完全に日本語モードです!",
|
|
"やったね!日本語が優先されました!",
|
|
"日本語が一番!英語は嫌いだ!",
|
|
"今、完全に日本語です!英語はなし!"
|
|
}
|
|
|
|
function select_tracks()
|
|
local tracks = mp.get_property_native("track-list")
|
|
|
|
-- Disable all subtitles at the beginning
|
|
for _, track in ipairs(tracks) do
|
|
if track.type == "sub" then
|
|
mp.set_property("sid", "no", track.id)
|
|
end
|
|
end
|
|
|
|
local japanese_subtitle_tracks = {}
|
|
|
|
-- Enable Japanese subtitles if available
|
|
for _, track in ipairs(tracks) do
|
|
if track.type == "sub" and table.contains(preferred_slangs, track.lang) then
|
|
table.insert(japanese_subtitle_tracks, track.id)
|
|
end
|
|
end
|
|
|
|
if #japanese_subtitle_tracks > 0 then
|
|
mp.set_property("sid", japanese_subtitle_tracks[1])
|
|
end
|
|
|
|
-- Add a delay to ensure the tracks are loaded before displaying the phrase
|
|
mp.add_timeout(5, function()
|
|
show_phrase()
|
|
end)
|
|
end
|
|
|
|
function table.contains(table, value)
|
|
for _, v in ipairs(table) do
|
|
if v == value then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
function show_phrase()
|
|
local phrase = phrases[math.random(#phrases)]
|
|
mp.osd_message(phrase, 2000)
|
|
end
|
|
|
|
mp.register_event("file-loaded", select_tracks)
|
|
|
|
-- Ensure the phrase shows up when MPV is not in idle mode
|
|
if not mp.get_property_native("idle") then
|
|
select_tracks()
|
|
end
|