-
-
Notifications
You must be signed in to change notification settings - Fork 67
Add custom sub filter #151
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
base: master
Are you sure you want to change the base?
Conversation
Additional scripts should be placed outside of the source directory. The principle is that end users shouldn't mess with the source code. Also, if you install mpvacious from the AUR, you won't have permissions to modify the files (unless using sudo). I suggest using |
local function prepare_for_exporting(sub_text) | ||
if not h.is_empty(sub_text) then | ||
sub_text = h.trim(sub_text) | ||
sub_text = subs_observer.clipboard_prepare(sub_text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this unintentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dId his because I think the text exported to the card should be the same as what is prepared for clipboard.
Could this cause any issues?
I prefer to use |
mpv will try to run it as if it was a user script for mpv. But you can avoid it if there's no If the scripts are saved to the user's home directory, the AUR installation will work, but mpvacious will probably fail to discover the script. |
According to this part of the manual, I can use an entry like |
subs2srs.lua
Outdated
mp.add_key_binding("Ctrl+C", "mpvacious-copy-secondary-sub-to-clipboard", subs_observer.copy_current_secondary_to_clipboard) | ||
mp.add_key_binding("Ctrl+t", "mpvacious-autocopy-toggle", subs_observer.toggle_autocopy) | ||
mp.add_key_binding("Ctrl+g", "mpvacious-animated-snapshot-toggle", encoder.snapshot.toggle_animation) | ||
mp.add_key_binding("Alt+m", "mpvacious-toggle-custom-sub-filter", subs_observer.toggle_custom_sub_filter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need a key binding to change this. The user can just edit the config file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.
This PR adds the ability for users to create their own script to process subtitles.
Mpvacious now can load an optional module.
The custom script returns a table that optionally includes two functions,
preprocess(text)
andtrim(text)
, either of them could be nil (i.e not implemented).The
preprocess(text)
is executed before trimming, andtrim(text)
is used to replace the defaulthelpers.trim(text)
function.In my use case, I need to extract the Japanese subtitle from a bilingual subtitle line.
I have pasted my script and attached a sample of the bilingual subtitle file for reference.
[KitaujiSub] Make Heroine ga Oosugiru! [01][WebRip][HEVC_AAC][CHS_JP&CHT_JP].zip