diff options
Diffstat (limited to 'lass/2configs/mpv.nix')
-rw-r--r-- | lass/2configs/mpv.nix | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/lass/2configs/mpv.nix b/lass/2configs/mpv.nix index f88d0d91d..b11e54c2c 100644 --- a/lass/2configs/mpv.nix +++ b/lass/2configs/mpv.nix @@ -1,28 +1,10 @@ { pkgs, lib, ... }: let - - download_subs = pkgs.writers.writePython3 "download_sub" { - libraries = [ pkgs.python3Packages.subliminal ]; - } '' - from subliminal import download_best_subtitles, scan_video - from babelfish import Language - import sys - - video_filename = sys.argv[1] - - vid = scan_video(video_filename) - try: - sub = download_best_subtitles([vid], {Language('eng')})[vid][0] - - filename = '/tmp/' + vid.title + '.srt' - - with open(filename, 'wb+') as file: - file.write(sub.content) - - print(filename) - except: # noqa - print("/dev/null") + dl_subs = pkgs.writers.writeDashBin "dl_subs" '' + filename=$1 + ${pkgs.subdl}/bin/subdl --output='/tmp/{m}.{M}.sub' "$filename" 1>&2 + echo "/tmp/$(basename "$filename").sub" ''; autosub = pkgs.writeText "autosub.lua" '' @@ -39,10 +21,9 @@ let function download() log('Searching subtitles ...', 10) - table = { args = {"${download_subs}", mp.get_property('path')} } - result = utils.subprocess(table) + path = mp.get_property('path') + result = utils.subprocess({ args = {"${dl_subs}/bin/dl_subs", path} }) if result.error == nil then - -- remove trailing newline from subtitle filename filename = string.gsub(result.stdout, "\n", "") log(filename) mp.commandv('sub_add', filename) @@ -78,6 +59,8 @@ let mpvInput = pkgs.writeText "mpv.input" '' : script-binding console/enable + x add audio-delay -0.050 + X add audio-delay 0.050 ''; mpvConfig = pkgs.writeText "mpv.conf" '' @@ -89,14 +72,7 @@ let paths = [ (pkgs.writeDashBin "mpv" '' set -efu - if [ -n "''${DISPLAY+x}" ]; then - Y_RES=$(${pkgs.xorg.xrandr}/bin/xrandr | - ${pkgs.jc}/bin/jc --xrandr | - ${pkgs.jq}/bin/jq '.screens[0].current_width' - ) - else - Y_RES=1000 - fi + Y_RES=1081 # we need to disable sponsorblock local database because of # https://github.com/po5/mpv_sponsorblock/issues/31 exec ${pkgs.mpv.override { @@ -105,7 +81,6 @@ let youtube-quality ]; }}/bin/mpv \ - -vo=gpu \ --no-config \ --input-conf=${mpvInput} \ --include=${mpvConfig} \ @@ -113,6 +88,7 @@ let --ytdl-format="best[height<$Y_RES]" \ --script-opts=ytdl_hook-ytdl_path=${pkgs.yt-dlp}/bin/yt-dlp \ --script-opts-append=sponsorblock-local_database=no \ + --audio-channels=2 \ "$@" '') pkgs.mpv @@ -122,5 +98,6 @@ let in { environment.systemPackages = [ mpv + dl_subs ]; } |