commit 1debdaf1dbefd4b7ff56bdb8912c7021f98f6d37
parent d9cf58d866bbacabac4dd027fa4bd650a4bfa4a8
Author: Pablo Cárdenas <pablo.cardenas@imca.edu.pe>
Date: Sat, 30 May 2026 04:05:46 -0300
mpv: fixed mpv and related software
Diffstat:
10 files changed, 304 insertions(+), 75 deletions(-)
diff --git a/.config/mpv/input.conf b/.config/mpv/input.conf
@@ -1 +1,4 @@
c run "/bin/bash" "-c" "echo \"${sub-text}\" | tr \"\\n\" \" \" | xclip -selection clipboard"
+X script-binding vtt/convert-vtt
+F5 script-binding deepl/sub_ab_loop
+C script-binding deepl/show-translation-deepl
diff --git a/.config/mpv/mpv.conf b/.config/mpv/mpv.conf
@@ -0,0 +1,3 @@
+save-watch-history=yes
+write-filename-in-watch-later-config=yes
+gpu-api=opengl
diff --git a/.config/mpv/scripts/deepl.lua b/.config/mpv/scripts/deepl.lua
@@ -1,10 +1,12 @@
http_request = require("http.request")
json = require("dkjson")
+
DEEPL_API_KEY = os.getenv("DEEPL_API_KEY")
overlay = mp.create_osd_overlay("ass-events")
overlay.z = 10
+
function show_translation_deepl()
local sub_text = mp.get_property('sub-text')
if sub_text and sub_text ~= "" then
@@ -25,7 +27,6 @@ function show_translation_deepl()
else
print("No text to show")
end
-
end
@@ -52,6 +53,7 @@ function translate_deepl(source_text)
return translated_text
end
+
function sub_ab_loop()
local a = mp.get_property("sub-start")
local b = mp.get_property("sub-end")
@@ -61,9 +63,10 @@ function sub_ab_loop()
mp.set_property("ab-loop-b", b+delay)
end
-mp.add_key_binding('F5', 'sub_ab_loop', sub_ab_loop)
-mp.add_key_binding('C', 'show-translation-deepl', show_translation_deepl)
+
+mp.add_key_binding(nil, 'sub_ab_loop', sub_ab_loop)
+mp.add_key_binding(nil, 'show-translation-deepl', show_translation_deepl)
+
mp.observe_property('sub-end', 'number', function (_, sub_end)
overlay:remove()
end)
-
diff --git a/.config/mpv/scripts/vtt.lua b/.config/mpv/scripts/vtt.lua
@@ -1,78 +1,158 @@
local mp = require 'mp'
-mp.register_event("file-loaded", function()
+local function convert_vtt_subtitles()
+ local sid = mp.get_property_native("sid")
local tracks = mp.get_property_native("track-list")
+ local current_subtitle_track
- for _, t in ipairs(tracks) do
- if t["type"] == "sub" and t.external and t["external-filename"]:match("%.vtt$") then
- local f = io.open((t["external-filename"]), "r")
- local path_new = os.tmpname() .. ".srt"
- local file_new = io.open(path_new, 'w')
- local path_sentences = os.tmpname() .. ".srt"
- local file_sentences = io.open(path_sentences, 'w')
-
- local str_start
- local str_end
- local index = 1
- local index_sentence = 1
- local i_line = 0
- local sentence = {}
- local previous_timestamp_sentence = "00:00:00.000"
- for line in f:lines() do
- if i_line % 8 == 4 then
- str_start, str_end = line:match("(%d%d:%d%d:%d%d%.%d+)%s+-->%s+(%d%d:%d%d:%d%d%.%d+)")
- end
- if i_line % 8 == 6 then
- -- remove <c> tags
- line = line:gsub("</?c>", "")
-
- -- prepend start time
- line = " " .. line .. "<" .. str_end .. ">"
-
- local previous_timestamp = str_start
- for content, timestamp in line:gmatch("([^<]*)<(%d%d:%d%d:%d%d%.%d+)>") do
- local word = content:gsub(">", ">"):gsub(" ", " ")
-
- file_new:write(index, '\n')
- file_new:write(previous_timestamp .. " --> " .. timestamp, '\n')
- file_new:write(word, '\n')
- file_new:write('\n')
-
- if word:sub(1, 3) == " >>" then
- file_sentences:write(index_sentence, '\n')
- file_sentences:write(previous_timestamp_sentence .. " --> " .. previous_timestamp, '\n')
- file_sentences:write(table.concat(sentence), '\n')
- file_sentences:write('\n')
- index_sentence = index_sentence + 1
- previous_timestamp_sentence = previous_timestamp
- sentence = {}
- end
-
- table.insert(sentence, word)
-
- if word:sub(-1) == "." or word:sub(-1) == "?" or word:sub(-1) == ":" or word:sub(-2) == ".\"" or word:sub(-2) == "?\"" then
- file_sentences:write(index_sentence, '\n')
- file_sentences:write(previous_timestamp_sentence .. " --> " .. timestamp, '\n')
- file_sentences:write(table.concat(sentence), '\n')
- file_sentences:write('\n')
- index_sentence = index_sentence + 1
- previous_timestamp_sentence = timestamp
- sentence = {}
- end
-
- previous_timestamp = timestamp
- index = index + 1
- end
+ if sid and sid ~= "no" then
+ for _, track in ipairs(tracks) do
+ if track["type"] == "sub" and track.id == sid then
+ current_subtitle_track = track
+ break
+ end
+ end
+ end
+ if not current_subtitle_track then
+ mp.osd_message("No selected subtitle track")
+ return
+ end
+
+ local path = current_subtitle_track["external-filename"]
+ if not current_subtitle_track.external or not path or not (path:match("%.vtt$") or path:match("^edl://")) then
+ mp.osd_message("Selected subtitle is not an external VTT")
+ return
+ end
+
+ if path:match("^edl://") then
+ local body = path:sub(7)
+ local url
+
+ -- ytdl_hook adds subtitles as EDL with the real URL in a
+ -- length-prefixed segment after the delay_open headers.
+ for entry in body:gmatch("[^;]+") do
+ if not entry:match("^!") then
+ local len, value = entry:match("^%%(%d+)%%(.*)")
+
+ if len then
+ url = value:sub(1, tonumber(len))
+ else
+ url = entry:match("^[^,]+")
end
- i_line = i_line + 1
+
+ break
end
- file_new:close()
+ end
+
+ if url then
+ if url:match("[?&]fmt=") then
+ url = url:gsub("([?&])fmt=[^&]*", "%1fmt=vtt")
+ elseif url:match("%?") then
+ url = url .. "&fmt=vtt"
+ else
+ url = url .. "?fmt=vtt"
+ end
+
+ local res = mp.command_native({
+ name = "subprocess",
+ args = {"curl", "-L", "-s", url},
+ capture_stdout = true,
+ capture_stderr = true,
+ })
+
+ if not res or res.status ~= 0 or res.stdout == "" then
+ mp.msg.warn("Could not download VTT subtitle")
+ return
+ end
+
+ path = os.tmpname() .. ".vtt"
+ local file_vtt = io.open(path, "w")
+ file_vtt:write(res.stdout)
+ file_vtt:close()
+ else
+ path = nil
+ end
+ end
+
+ local f = path and io.open(path, "r")
+ if not f then
+ mp.msg.warn("Could not open VTT subtitle")
+ return
+ end
- mp.commandv("sub-add", path_new, "select")
- mp.commandv("sub-add", path_sentences, "select")
- mp.msg.info("Loaded converted VTT → SRT")
+ local path_new = os.tmpname() .. ".srt"
+ local file_new = io.open(path_new, 'w')
+ local path_sentences = os.tmpname() .. ".srt"
+ local file_sentences = io.open(path_sentences, 'w')
+
+ local str_start
+ local str_end
+ local index = 1
+ local index_sentence = 1
+ local i_line = 0
+ local sentence = {}
+ local previous_timestamp_sentence = "00:00:00.000"
+ for line in f:lines() do
+ if i_line % 8 == 4 then
+ str_start, str_end = line:match("(%d%d:%d%d:%d%d%.%d+)%s+-->%s+(%d%d:%d%d:%d%d%.%d+)")
end
+ if i_line % 8 == 6 then
+ local line = line
+
+ -- remove <c> tags
+ line = line:gsub("</?c>", "")
+
+ -- prepend start time
+ line = " " .. line .. "<" .. str_end .. ">"
+
+ local previous_timestamp = str_start
+ for content, timestamp in line:gmatch("([^<]*)<(%d%d:%d%d:%d%d%.%d+)>") do
+ local word = content:gsub(">", ">"):gsub(" ", " ")
+
+ file_new:write(index, '\n')
+ file_new:write(previous_timestamp .. " --> " .. timestamp, '\n')
+ file_new:write(word, '\n')
+ file_new:write('\n')
+
+ if word:sub(1, 3) == " >>" then
+ file_sentences:write(index_sentence, '\n')
+ file_sentences:write(previous_timestamp_sentence .. " --> " .. previous_timestamp, '\n')
+ file_sentences:write(table.concat(sentence), '\n')
+ file_sentences:write('\n')
+ index_sentence = index_sentence + 1
+ previous_timestamp_sentence = previous_timestamp
+ sentence = {}
+ end
+
+ table.insert(sentence, word)
+
+ if word:sub(-1) == "." or word:sub(-1) == "?" or word:sub(-1) == ":" or word:sub(-2) == ".\"" or word:sub(-2) == "?\"" then
+ file_sentences:write(index_sentence, '\n')
+ file_sentences:write(previous_timestamp_sentence .. " --> " .. timestamp, '\n')
+ file_sentences:write(table.concat(sentence), '\n')
+ file_sentences:write('\n')
+ index_sentence = index_sentence + 1
+ previous_timestamp_sentence = timestamp
+ sentence = {}
+ end
+
+ previous_timestamp = timestamp
+ index = index + 1
+ end
+ end
+ i_line = i_line + 1
end
-end)
+ file_new:close()
+ file_sentences:close()
+ f:close()
+
+ mp.commandv("sub-add", path_new, "select")
+ mp.commandv("sub-add", path_sentences, "select")
+
+ mp.osd_message("Loaded converted VTT subtitles")
+ mp.msg.info("Loaded converted VTT subtitles")
+end
+
+mp.add_key_binding(nil, "convert-vtt", convert_vtt_subtitles)
-- vim: sts=4 sw=4 et
diff --git a/.config/newsboat/config b/.config/newsboat/config
@@ -4,7 +4,7 @@ auto-reload yes
reload-threads 100
-macro v set browser "setsid -f mpv --audio-device=alsa/pulse --ytdl-raw-options=sub-langs=\"[en.*,es.*,fr.*,pt.*]\",write-sub=,write-auto-sub= </dev/null >/dev/null 2>&1"; open-in-browser; set browser "$BROWSER"
+macro v set browser "setsid -f mpv </dev/null >/dev/null 2>&1"; open-in-browser; set browser "$BROWSER"
#html-renderer "sed 's/</</g;s/>/>/g;s/&/\\&/g' | perl -pe 's:<q>.*?(MIRA|LEE TAMBI).*?</q>::g' | perl -pe 's|^<ul>.*?</ul>||' | perl -pe 's|(<img.*?alt=\")(.*?)(\".*?/>)|<p>\\1 [IMG] \\2\\3</p>|g' | lynx -nonumbers -hiddenlinks=ignore -nolist -image_links -stdin --assume_charset=utf-8 --display-charset=utf-8 -dump -width=1024"
diff --git a/.config/qutebrowser/config.py b/.config/qutebrowser/config.py
@@ -26,8 +26,8 @@ config.bind(',lp', 'spawn --userscript qute-pass -p')
config.bind(',lo', 'spawn --userscript qute-pass -o')
config.bind(',lu', 'spawn --userscript qute-pass -u')
config.bind(',ll', 'spawn --userscript qute-pass -a')
-config.bind(',m', 'spawn mpv --audio-device=pulse --ytdl-raw-options=sub-langs="[en.*,es.*,fr.*,pt.*]",write-sub=,write-auto-sub= {url}')
-config.bind(',M', 'hint links spawn mpv --audio-device=alsa/pulse --ytdl-raw-options=sub-langs="[en.*,es.*,fr.*,pt.*]",write-sub=,write-auto-sub= {hint-url}')
+config.bind(',m', 'spawn --output --detach mpv {url}')
+config.bind(',M', 'hint links spawn --output --detach mpv {hint-url}')
config.set("content.notifications.enabled", True, "https://app.slack.com")
config.set("content.notifications.enabled", True, "https://calendar.google.com")
@@ -35,5 +35,9 @@ config.set("content.notifications.enabled", True, "https://mail.google.com")
config.set("content.notifications.enabled", True, "https://web.whatsapp.com")
config.set("content.media.audio_video_capture", True, "https://meet.google.com")
config.set("content.desktop_capture", True, "https://meet.google.com")
+config.set("content.images", True, "mail.google.com")
+config.set("content.images", True, "accounts.google.com")
+config.set("content.images", True, "lichess.org")
+config.set("content.register_protocol_handler", False, "https://mail.google.com?extsrc=mailto&url=%25s")
config.load_autoconfig()
diff --git a/.config/yt-dlp/config b/.config/yt-dlp/config
@@ -1 +1,5 @@
--f "best[height<=720]"
+--format best[height<=720]
+--sub-langs en,es,fr,it,pt
+--write-subs
+--write-auto-subs
+--cookies-from-browser chromium:~/.local/share/qutebrowser/webengine
diff --git a/.config/ytfzf/conf.sh b/.config/ytfzf/conf.sh
@@ -0,0 +1,10 @@
+#Variables {{{
+ytdl_pref="best[height<=720]"
+#show_thumbnails=1
+thumbnail_viewer=mpv
+#}}}
+
+##Functions {{{
+#}}}
+
+# vim: fdm=marker
diff --git a/.local/.gitignore b/.local/.gitignore
@@ -61,3 +61,8 @@
!/share/qutebrowser
/share/qutebrowser/*
!/share/qutebrowser/userscripts
+!/share/qutebrowser/sessions
+/share/qutebrowser/sessions/default.yml
+
+# texlive
+!/share/texmf
diff --git a/.local/share/qutebrowser/sessions/impa.yml b/.local/share/qutebrowser/sessions/impa.yml
@@ -0,0 +1,117 @@
+windows:
+- active: true
+ geometry: null
+ tabs:
+ - history:
+ - active: true
+ title: ''
+ url: qute://treegroup/Communication
+ treetab_node_data:
+ children:
+ - 4
+ - 5
+ - 8
+ collapsed: false
+ parent: 2
+ uid: 3
+ - history:
+ - active: true
+ title: ''
+ url: https://web.whatsapp.com/
+ treetab_node_data:
+ children: []
+ collapsed: false
+ parent: 3
+ uid: 4
+ - history:
+ - active: true
+ title: ''
+ url: qute://treegroup/Google
+ treetab_node_data:
+ children:
+ - 6
+ - 7
+ collapsed: false
+ parent: 3
+ uid: 5
+ - history:
+ - active: true
+ title: ''
+ url: https://mail.google.com/mail/u/0/#inbox
+ treetab_node_data:
+ children: []
+ collapsed: false
+ parent: 5
+ uid: 6
+ - history:
+ - active: true
+ title: ''
+ url: https://mail.google.com/mail/u/1/#inbox
+ treetab_node_data:
+ children: []
+ collapsed: false
+ parent: 5
+ uid: 7
+ - history:
+ - active: true
+ title: ''
+ url: qute://treegroup/slack
+ treetab_node_data:
+ children:
+ - 9
+ - 10
+ collapsed: false
+ parent: 3
+ uid: 8
+ - history:
+ - active: true
+ title: ''
+ url: https://app.slack.com/client/T0B1RM2MF29/C0AEY8RCMC2
+ treetab_node_data:
+ children: []
+ collapsed: false
+ parent: 8
+ uid: 9
+ - history:
+ - active: true
+ title: ''
+ url: https://app.slack.com/client/T0AQ846HNS1/C0AR5QCUMNU
+ treetab_node_data:
+ children:
+ - 16
+ collapsed: false
+ parent: 8
+ uid: 10
+ - history:
+ - active: true
+ title: ''
+ url: https://homolog2.susep.gov.br/bibliotecaweb/glossario.aspx#null
+ treetab_node_data:
+ children: []
+ collapsed: false
+ parent: 10
+ uid: 16
+ - history:
+ - active: true
+ title: ''
+ url: qute://treegroup/centro-pi
+ treetab_node_data:
+ children:
+ - 12
+ collapsed: false
+ parent: 2
+ uid: 11
+ - history:
+ - active: true
+ title: ''
+ url: https://git.impa.br/centropi/susepreclamacoes
+ treetab_node_data:
+ children: []
+ collapsed: false
+ parent: 11
+ uid: 12
+ treetab_root:
+ children:
+ - 3
+ - 11
+ uid: 2