about summary refs log tree commit diff
path: root/mpv/.local
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>1970-01-01 03:00:00 +0300
committerAzat Bahawi <azat@bahawi.net>2022-09-20 11:51:54 +0300
commit38bab29776950ac2364ed64195b89887717c33de (patch)
treeedaaf366a55dbe96d268019124536bc504c64e87 /mpv/.local
chore: init HEAD master
Diffstat (limited to '')
-rw-r--r--mpv/.local/etc/mpv/input.conf16
-rw-r--r--mpv/.local/etc/mpv/mpv.conf100
-rw-r--r--mpv/.local/etc/mpv/scripts/autoload.lua129
-rw-r--r--mpv/.local/etc/mpv/scripts/autosub.lua27
4 files changed, 272 insertions, 0 deletions
diff --git a/mpv/.local/etc/mpv/input.conf b/mpv/.local/etc/mpv/input.conf
new file mode 100644
index 0000000..ed0a2de
--- /dev/null
+++ b/mpv/.local/etc/mpv/input.conf
@@ -0,0 +1,16 @@
+RIGHT seek  10
+LEFT  seek -10
+UP    seek  60
+DOWN  seek -60
+
+Shift+RIGHT no-osd seek  1 exact
+Shift+LEFT  no-osd seek -1 exact
+Shift+UP    no-osd seek  5 exact
+Shift+DOWN  no-osd seek -5 exact
+
+ALT+k add sub-scale +0.1
+ALT+j add sub-scale -0.1
+
+B cycle-values background "#000000" "#ffffff"
+
+# vim:filetype=config
diff --git a/mpv/.local/etc/mpv/mpv.conf b/mpv/.local/etc/mpv/mpv.conf
new file mode 100644
index 0000000..f365d0b
--- /dev/null
+++ b/mpv/.local/etc/mpv/mpv.conf
@@ -0,0 +1,100 @@
+### General ###
+
+audio-display=no
+autofit-larger=100%x95%
+cursor-autohide=1000
+force-seekable=no
+fullscreen=yes
+load-unsafe-playlists=yes
+msg-color=yes
+msg-module=yes
+prefetch-playlist=yes
+save-position-on-quit=no
+screenshot-format=jpg
+screenshot-template="%F [%p]"
+stop-screensaver=yes
+term-osd-bar=yes
+use-filedir-conf=yes
+
+### OSD ###
+
+osd-bar-align-y=0
+osd-bar-h=2
+osd-bar-w=60
+osd-border-color="#FF262626"
+osd-border-size=2.5
+osd-color="#FFFFFFFF"
+osd-duration=2500
+osd-font-size=40
+osd-fractions=yes
+osd-level=1
+osd-shadow-color="#33000000"
+osd-status-msg='${time-pos} / ${duration}${?percent-pos: (${percent-pos}%)}${?frame-drop-count:${!frame-drop-count==0: Dropped: ${frame-drop-count}}}\n${?chapter:Chapter: ${chapter}}'
+
+### OSC ###
+
+no-osc
+
+### Subtitles ###
+
+sub-auto=fuzzy
+sub-file-paths-append=ass
+sub-file-paths-append=srt
+
+sub-ass-force-margins=yes
+sub-ass-force-style=Kerning=yes
+sub-fix-timing=yes
+sub-use-margins=yes
+
+sub-font-size=40
+sub-color="#FFFFFFFF"
+sub-border-color="#FF262626"
+sub-border-size=2.5
+sub-shadow-offset=1
+sub-shadow-color="#33000000"
+sub-spacing=0.5
+
+### Languages ###
+
+alang=japanese,jp,jpn,jaJP,ja-JP,english,en,eng,enUS,en-US,russian,ru,rus,ruRU,ru-RU
+slang=japanese,jp,jpn,jaJP,ja-JP,english,en,eng,enUS,en-US,russian,ru,rus,ruRU,ru-RU
+
+### youtube-dl ###
+
+ytdl=yes
+ytdl-raw-options=sub-lang="jp,jpn,jaJP,ja-JP,en,eng,enUS,en-US,ru,rus,ruRU,ru-RU",write-sub=
+ytdl-format=(bestvideo[height<=?1080][fps<=?30][protocol!=http_dash_segments])+(bestaudio[acodec=opus]/bestaudio)/best
+
+### Audio ###
+
+audio-file-auto=fuzzy
+
+volume=100
+volume-max=200
+
+### Video ###
+
+blend-subtitles=yes
+
+### Extensions ###
+
+[extension.webm]
+cache=no
+loop-file=inf
+
+[extension.gif]
+profile=extension.webm
+
+### Protocols ###
+
+[protocol.http]
+force-window=immediate
+
+[protocol.https]
+force-window=immediate
+
+### Default ###
+
+[default]
+
+# vim:filetype=cfg
diff --git a/mpv/.local/etc/mpv/scripts/autoload.lua b/mpv/.local/etc/mpv/scripts/autoload.lua
new file mode 100644
index 0000000..2d0a12e
--- /dev/null
+++ b/mpv/.local/etc/mpv/scripts/autoload.lua
@@ -0,0 +1,129 @@
+MAXENTRIES = 30
+
+function Set (t)
+    local set = {}
+    for _, v in pairs(t) do set[v] = true end
+    return set
+end
+
+EXTENSIONS = Set {
+    '3gp',
+    'avi',
+    'flac',
+    'flv',
+    'm4a',
+    'm4v',
+    'mkv',
+    'mp3',
+    'mp4',
+    'mpeg',
+    'mpg',
+    'ogv',
+    'ogv',
+    'rmvb',
+    'wav',
+    'webm',
+    'wma',
+    'wmv',
+}
+
+mputils = require 'mp.utils'
+
+function add_files_at(index, files)
+    index = index - 1
+    local oldcount = mp.get_property_number("playlist-count", 1)
+    for i = 1, #files do
+        mp.commandv("loadfile", files[i], "append")
+        mp.commandv("playlist_move", oldcount + i - 1, index + i - 1)
+    end
+end
+
+function get_extension(path)
+    match = string.match(path, "%.([^%.]+)$" )
+    if match == nil then
+        return "nomatch"
+    else
+        return match
+    end
+end
+
+table.filter = function(t, iter)
+    for i = #t, 1, -1 do
+        if not iter(t[i]) then
+            table.remove(t, i)
+        end
+    end
+end
+
+function find_and_add_entries()
+    local path = mp.get_property("path", "")
+    local dir, filename = mputils.split_path(path)
+    if #dir == 0 then
+        return
+    end
+
+    local files = mputils.readdir(dir, "files")
+    if files == nil then
+        return
+    end
+    table.filter(files, function (v, k)
+        local ext = get_extension(v)
+        if ext == nil then
+            return false
+        end
+        return EXTENSIONS[string.lower(ext)]
+    end)
+    table.sort(files, function (a, b)
+        return string.lower(a) < string.lower(b)
+    end)
+
+    if dir == "." then
+        dir = ""
+    end
+
+    local pl = mp.get_property_native("playlist", {})
+    local pl_current = mp.get_property_number("playlist-pos", 0) + 1
+    local current
+    for i = 1, #files do
+        if files[i] == filename then
+            current = i
+            break
+        end
+    end
+    if current == nil then
+        return
+    end
+
+    local append = {[-1] = {}, [1] = {}}
+    for direction = -1, 1, 2 do
+        for i = 1, MAXENTRIES do
+            local file = files[current + i * direction]
+            local pl_e = pl[pl_current + i * direction]
+            if file == nil or file[1] == "." then
+                break
+            end
+
+            local filepath = dir .. file
+            if pl_e then
+                if pl_e.filename == filepath then
+                    break
+                end
+            end
+
+            if direction == -1 then
+                if pl_current == 1 then
+                    mp.msg.info("Prepending " .. file)
+                    table.insert(append[-1], 1, filepath)
+                end
+            else
+                mp.msg.info("Adding " .. file)
+                table.insert(append[1], filepath)
+            end
+        end
+    end
+
+    add_files_at(pl_current + 1, append[1])
+    add_files_at(pl_current, append[-1])
+end
+
+mp.register_event("start-file", find_and_add_entries)
diff --git a/mpv/.local/etc/mpv/scripts/autosub.lua b/mpv/.local/etc/mpv/scripts/autosub.lua
new file mode 100644
index 0000000..a44564e
--- /dev/null
+++ b/mpv/.local/etc/mpv/scripts/autosub.lua
@@ -0,0 +1,27 @@
+local utils = require 'mp.utils'
+
+function display_error()
+    mp.msg.warn("Subtitle download failed: ")
+    mp.osd_message("Subtitle download failed")
+end
+
+function load_sub_fn()
+    path = mp.get_property("path")
+    srt_path = string.gsub(path, "%.%w+$", ".srt")
+    t = { args = { "subliminal", "download", "-s", "-f", "-l", "en", path } }
+
+    mp.osd_message("Searching subtitle")
+    res = utils.subprocess(t)
+    if res.error == nil then
+        if mp.commandv("sub_add", srt_path) then
+            mp.msg.warn("Subtitle download succeeded")
+            mp.osd_message("Subtitle '" .. srt_path .. "' download succeeded")
+        else
+            display_error()
+        end
+    else
+        display_error()
+    end
+end
+
+mp.add_key_binding("b", "auto_load_subs", load_sub_fn)

Consider giving Nix/NixOS a try! <3