This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

mpv: take best rated subtitle, cleanup

+2 -25
+2 -25
2configs/mpv.nix
··· 6 6 filename=$1 7 7 cd "$(dirname "$filename")" 8 8 filename=$(basename "$filename") 9 - ${pkgs.subdl}/bin/subdl --output='/tmp/{m}.{M}.sub' "$filename" 1>&2 9 + ${pkgs.subdl}/bin/subdl --download=best-rating --output='/tmp/{m}.{M}.sub' "$filename" 1>&2 10 10 echo "/tmp/$filename.sub" 11 11 ''; 12 12 13 13 autosub = pkgs.writeText "autosub.lua" '' 14 - -- Requires Subliminal version 1.0 or newer 15 - -- Make sure to specify your system's Subliminal location below: 16 - local utils = require 'mp.utils' 14 + utils = require 'mp.utils' 17 15 18 16 -- Log function: log to both terminal and mpv OSD (On-Screen Display) 19 17 function log(string, secs) ··· 34 32 else 35 33 log('Subtitles failed downloading') 36 34 end 37 - end 38 - 39 - -- Control function: only download if necessary 40 - function control_download() 41 - duration = tonumber(mp.get_property('duration')) 42 - if duration < 900 then 43 - mp.msg.warn('Video is less than 15 minutes\n', '=> NOT downloading any subtitles') 44 - return 45 - end 46 - -- There does not seem to be any documentation for the 'sub' property, 47 - -- but it works on both internally encoded as well as external subtitle files! 48 - -- -> sub = '1' when subtitles are present 49 - -- -> sub = 'no' when subtitles are not present 50 - -- -> sub = 'auto' when called before the 'file-loaded' event is triggered 51 - sub = mp.get_property('sub') 52 - if sub == '1' then 53 - mp.msg.warn('Sub track is already present\n', '=> NOT downloading other subtitles') 54 - return 55 - end 56 - mp.msg.warn('No sub track was detected\n', '=> Proceeding to download subtitles:') 57 - download() 58 35 end 59 36 60 37 mp.add_key_binding('S', "download_subs", download)