summaryrefslogtreecommitdiffstats
path: root/lass
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2020-04-11 17:31:13 +0200
committerlassulus <lassulus@lassul.us>2020-04-11 17:31:13 +0200
commit430cfa251f7e6d7f768b579cb01af9173e2e8bbc (patch)
tree06b225b8056b971e821dfc6add07a25bed10fa01 /lass
parent47b379a4680b21f982bfc0822601baa1c8425540 (diff)
l mpv: bind subtitle search to key
Diffstat (limited to 'lass')
-rw-r--r--lass/2configs/mpv.nix15
1 files changed, 8 insertions, 7 deletions
diff --git a/lass/2configs/mpv.nix b/lass/2configs/mpv.nix
index 7dc43a9ee..5d7bfed60 100644
--- a/lass/2configs/mpv.nix
+++ b/lass/2configs/mpv.nix
@@ -12,14 +12,17 @@ let
video_filename = sys.argv[1]
vid = scan_video(video_filename)
- sub = download_best_subtitles([vid], {Language('eng')})[vid][0]
+ try:
+ sub = download_best_subtitles([vid], {Language('eng')})[vid][0]
- filename = '/tmp/' + vid.title + '.srt'
+ filename = '/tmp/' + vid.title + '.srt'
- with open(filename, 'wb+') as file:
- file.write(sub.content)
+ with open(filename, 'wb+') as file:
+ file.write(sub.content)
- print(filename)
+ print(filename)
+ except: # noqa
+ print("/dev/null")
'';
autosub = pkgs.writeText "autosub.lua" ''
@@ -70,7 +73,6 @@ let
download()
end
- mp.register_event('file-loaded', control_download)
mp.add_key_binding('S', "download_subs", download)
'';
@@ -79,7 +81,6 @@ let
paths = [
(pkgs.writeDashBin "mpv" ''
exec ${pkgs.mpv}/bin/mpv --no-config --script=${autosub} "$@"
- # exec ${pkgs.mpv}/bin/mpv --no-config "$@"
'')
pkgs.mpv
];