patches-mpvacious/force-japanese.patch

100 lines
5.5 KiB
Diff
Raw Normal View History

2024-07-22 19:44:14 +00:00
Binary files mpvacious/.git/index and mpvacious-patched/.git/index differ
diff -ruN mpvacious/.git/logs/HEAD mpvacious-patched/.git/logs/HEAD
--- mpvacious/.git/logs/HEAD 2024-07-22 15:31:00.086132886 -0400
+++ mpvacious-patched/.git/logs/HEAD 2024-07-22 15:30:14.821186211 -0400
@@ -1 +1 @@
-0000000000000000000000000000000000000000 aa86597d5e65c9c40b12841a945be7a3cd0fb7b3 hashirama <noroi_harau@tutanota.com> 1721676660 -0400 clone: from https://github.com/Ajatt-Tools/mpvacious.git
+0000000000000000000000000000000000000000 aa86597d5e65c9c40b12841a945be7a3cd0fb7b3 hashirama <noroi_harau@tutanota.com> 1721676614 -0400 clone: from https://github.com/Ajatt-Tools/mpvacious.git
diff -ruN mpvacious/.git/logs/refs/heads/master mpvacious-patched/.git/logs/refs/heads/master
--- mpvacious/.git/logs/refs/heads/master 2024-07-22 15:31:00.086132886 -0400
+++ mpvacious-patched/.git/logs/refs/heads/master 2024-07-22 15:30:14.821186211 -0400
@@ -1 +1 @@
-0000000000000000000000000000000000000000 aa86597d5e65c9c40b12841a945be7a3cd0fb7b3 hashirama <noroi_harau@tutanota.com> 1721676660 -0400 clone: from https://github.com/Ajatt-Tools/mpvacious.git
+0000000000000000000000000000000000000000 aa86597d5e65c9c40b12841a945be7a3cd0fb7b3 hashirama <noroi_harau@tutanota.com> 1721676614 -0400 clone: from https://github.com/Ajatt-Tools/mpvacious.git
diff -ruN mpvacious/.git/logs/refs/remotes/origin/HEAD mpvacious-patched/.git/logs/refs/remotes/origin/HEAD
--- mpvacious/.git/logs/refs/remotes/origin/HEAD 2024-07-22 15:31:00.086132886 -0400
+++ mpvacious-patched/.git/logs/refs/remotes/origin/HEAD 2024-07-22 15:30:14.821186211 -0400
@@ -1 +1 @@
-0000000000000000000000000000000000000000 aa86597d5e65c9c40b12841a945be7a3cd0fb7b3 hashirama <noroi_harau@tutanota.com> 1721676660 -0400 clone: from https://github.com/Ajatt-Tools/mpvacious.git
+0000000000000000000000000000000000000000 aa86597d5e65c9c40b12841a945be7a3cd0fb7b3 hashirama <noroi_harau@tutanota.com> 1721676614 -0400 clone: from https://github.com/Ajatt-Tools/mpvacious.git
Binary files mpvacious/.git/objects/pack/pack-020c392851862423cb8bce6808896d817fd39b29.idx and mpvacious-patched/.git/objects/pack/pack-020c392851862423cb8bce6808896d817fd39b29.idx differ
Binary files mpvacious/.git/objects/pack/pack-020c392851862423cb8bce6808896d817fd39b29.pack and mpvacious-patched/.git/objects/pack/pack-020c392851862423cb8bce6808896d817fd39b29.pack differ
Binary files mpvacious/.git/objects/pack/pack-020c392851862423cb8bce6808896d817fd39b29.rev and mpvacious-patched/.git/objects/pack/pack-020c392851862423cb8bce6808896d817fd39b29.rev differ
Binary files mpvacious/.git/objects/pack/pack-7da0665222863ab22efcaeebb25779cd86662677.idx and mpvacious-patched/.git/objects/pack/pack-7da0665222863ab22efcaeebb25779cd86662677.idx differ
Binary files mpvacious/.git/objects/pack/pack-7da0665222863ab22efcaeebb25779cd86662677.pack and mpvacious-patched/.git/objects/pack/pack-7da0665222863ab22efcaeebb25779cd86662677.pack differ
Binary files mpvacious/.git/objects/pack/pack-7da0665222863ab22efcaeebb25779cd86662677.rev and mpvacious-patched/.git/objects/pack/pack-7da0665222863ab22efcaeebb25779cd86662677.rev differ
2024-07-22 19:51:49 +00:00
diff -ruN mpvacious/main.lua mpvacious-patched/main.lua
--- mpvacious/main.lua 2024-07-22 15:31:00.090132616 -0400
+++ mpvacious-patched/main.lua 2024-07-22 15:51:08.536987877 -0400
@@ -1 +1,2 @@
+require("utils.force-japanese")
require('subs2srs')
2024-07-22 19:44:14 +00:00
diff -ruN mpvacious/utils/force-japanese.lua mpvacious-patched/utils/force-japanese.lua
--- mpvacious/utils/force-japanese.lua 1969-12-31 20:00:00.000000000 -0400
+++ mpvacious-patched/utils/force-japanese.lua 2024-07-22 15:31:41.919310736 -0400
@@ -0,0 +1,64 @@
+local assdraw = require 'mp.assdraw'
+
+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")
+ local selected_aid = nil
+ local selected_sid = nil
+
+ for _, lang in ipairs(preferred_alangs) do
+ for _, track in ipairs(tracks) do
+ if track.type == "audio" and track.lang == lang then
+ selected_aid = track.id
+ break
+ end
+ end
+ if selected_aid then break end
+ end
+
+ for _, lang in ipairs(preferred_slangs) do
+ for _, track in ipairs(tracks) do
+ if track.type == "sub" and track.lang == lang then
+ selected_sid = track.id
+ break
+ end
+ end
+ if selected_sid then break end
+ end
+
+ if selected_aid then
+ mp.set_property("aid", selected_aid)
+ mp.add_timeout(3, show_phrase)
+ end
+
+ if selected_sid then
+ mp.set_property("sid", selected_sid)
+ mp.add_timeout(3, show_phrase)
+ end
+end
+
+function show_phrase()
+ local phrase = phrases[math.random(#phrases)]
+ local ass = assdraw.ass_new()
+ ass:append("{\\an9\\fs20\\bord1\\shad0\\c&HFFFFFF&\\3c&H000000&}")
+ ass:append(phrase)
+ mp.set_osd_ass(0, 0, ass.text)
+ mp.add_timeout(2, function() mp.set_osd_ass(0, 0, "") end)
+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