Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new option: secondary_sub_auto_load #110

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/RELEASE/subs2srs.conf
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,12 @@ miscinfo_format=%n EP%d (%t)
## But if you manually set secondary sid from the command line, mpvacious won't change it.
##

# Language of secondary subs.
# If you leave this parameter empty, no secondary subs will be automatically loaded.
secondary_sub_lang=eng,en,rus,ru,bel,be
# Load secondary subtitle track automatically when a file is opened.
secondary_sub_auto_load=yes

# Language of secondary subs. This is your native language or a language you know well.
# If you leave this parameter empty, secondary subs will NOT be automatically loaded.
secondary_sub_lang=eng,en,rus,ru
#secondary_sub_lang=

# Hover area.
Expand Down
3 changes: 2 additions & 1 deletion subs2srs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ local config = {
autoclip_command = "", -- command to run when autoclip is triggered. if empty, just copies sub_text to the clipboard.

-- Secondary subtitle
secondary_sub_lang = 'eng,en,rus,ru,bel,be', -- Language of secondary subs that should be automatically loaded.
secondary_sub_auto_load = true, -- Automatically load secondary subtitle track when a video file is opened.
secondary_sub_lang = 'eng,en,rus,ru,jp,jpn,ja', -- Language of secondary subs that should be automatically loaded.
secondary_sub_area = 0.15, -- Hover area. Fraction of the window from the top.
secondary_sub_visibility = 'auto', -- One of: 'auto', 'never', 'always'. Controls secondary_sid visibility. Ctrl+V to cycle.

Expand Down
4 changes: 2 additions & 2 deletions subtitles/secondary_sid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ end

local function on_mouse_move(_, state)
-- state = {x=int,y=int, hover=true|false, }
if self.visibility == 'auto' and state ~= nil then
if mp.get_property_native('secondary-sid') and self.visibility == 'auto' and state ~= nil then
mp.set_property_bool(
'secondary-sub-visibility',
state.hover and (state.y / window_height()) < self.config.secondary_sub_area
Expand All @@ -83,7 +83,7 @@ end
local function on_file_loaded()
-- If secondary sid is not already set, try to find and set it.
local secondary_sid = mp.get_property_native('secondary-sid')
if secondary_sid == false then
if secondary_sid == false and self.config.secondary_sub_auto_load == true then
secondary_sid = find_best_secondary_sid()
if secondary_sid ~= nil then
mp.set_property_native('secondary-sid', secondary_sid)
Expand Down