mpv: update plugins list

Also add ytmdl back (from my old dotfiles)
This commit is contained in:
Hoang Nguyen 2022-07-21 23:15:22 +07:00
parent 43335f7a41
commit 755f525d93
No known key found for this signature in database
GPG key ID: 813CF484F4993419
16 changed files with 112 additions and 401 deletions

View file

@ -37,7 +37,7 @@ ansible-playbook -v -i hosts dotfiles.yml --tags 'never,all'
- [ ] Separated Waybar config files for Sway and River
- [ ] [catppuccin](https://github.com/catppuccin/catppuccin) theme
- [ ] [eww](https://github.com/elkowar/eww)
- [ ] [swhkd](https://github.com/waycrate/swhkd) (maybe?)
- [ ] ~~[swhkd](https://github.com/waycrate/swhkd)~~
- [ ] [senpai](https://git.sr.ht/~taiite/senpai)
- [ ] Remove `pipewire-pulse` completely (is there alternative to pavucontrol for pipewire??)
- [ ] [ugrep](https://github.com/Genivia/ugrep) instead of [ripgrep](https://github.com/BurntSushi/ripgrep)

View file

@ -13,12 +13,12 @@
- role: packages
tags: packages
- role: soundtheme
tags: [ sound, theme ]
tags: [sound, theme]
- role: system
tags: system
become: yes
- role: wallpapers
tags: [ wallpaper, theme ]
tags: [wallpaper, theme]
- role: chromium
tags: chromium
become: yes

View file

@ -3,33 +3,35 @@
# Avoid fzf.vim from distro repo
- name: packages | Install fzf
tags: fzf
command:
cmd: go install -ldflags '-s -w' github.com/junegunn/fzf@latest
command: go install -ldflags '-s -w' github.com/junegunn/fzf@latest
- name: packages | Install koneko
tags: koneko
command:
cmd: go install -ldflags '-s -w' github.com/irevenko/koneko@latest
command: go install -ldflags '-s -w' github.com/irevenko/koneko@latest
- name: packages | Install what-anime-cli
tags: what-anime-cli
command:
cmd: go install -ldflags '-s -w' github.com/irevenko/what-anime-cli@latest
command: go install -ldflags '-s -w' github.com/irevenko/what-anime-cli@latest
- name: packages | Install wiki
tags: wiki
command:
cmd: go install -ldflags '-s -w' github.com/betapictoris/wiki@latest
command: go install -ldflags '-s -w' github.com/betapictoris/wiki@latest
- name: packages | Install lux
tags: lux
command:
cmd: go install -ldflags '-s -w' github.com/iawia002/lux@latest
command: go install -ldflags '-s -w' github.com/iawia002/lux@latest
- name: packages | Install vim-startuptime
tags: vim
command:
cmd: go install -ldflags '-s -w' github.com/rhysd/vim-startuptime@latest
command: go install -ldflags '-s -w' github.com/rhysd/vim-startuptime@latest
- name: package | Install footloose
tags: footloose
command: go install -ldflags '-s -w' github.com/weaveworks/footloose@latest
# - name: package | Install kubeval
# tags: kubeval
# command: go install -ldflags '-s -w' github.com/instrumenta/kubeval@latest
# NOTE: Clair server is required
# - Install with 'go install github.com/quay/clair/v4/cmd/clair@latest' or use docker image
@ -37,12 +39,10 @@
# Default open on localhost:6060
- name: packages | Install clairctl
tags: clair
command:
cmd: go install -ldflags '-s -w' github.com/quay/clair/v4/cmd/clairctl@latest
command: go install -ldflags '-s -w' github.com/quay/clair/v4/cmd/clairctl@latest
- name: packages | Clean go cache
command:
cmd: go clean -modcache -cache
command: go clean -modcache -cache
tags: go
environment:
GOPATH: '{{ ansible_env.HOME }}/.local/share/go'
@ -87,6 +87,18 @@
community.general.cargo:
name: tickrs
state: latest
- name: package | Install git-stack
tags: git-stack
community.general.cargo:
name: git-stack
state: latest
- name: package | Install git-branch-stash
tags: git-branch-stash
community.general.cargo:
name: git-branch-stash-cli
state: latest
tags: rust
environment:
CARGO_HOME: '{{ ansible_env.HOME }}/.local/share/cargo'

View file

@ -48,5 +48,6 @@
anime4kcpp, primecount, primesieve, jinja2-cli, cointop, libwhich, muon,
termshark, wavemon, pastel, minisign, glab, github-cli, didder, kubefwd,
flexget, systeroid, treedude, streamlink, ps_mem, kubectl-krew, sexpect,
expect, csview, asfa, hwatch, terragrunt, kubergrunt, httm
expect, csview, asfa, hwatch, terragrunt, kubergrunt, httm, bettercap,
apptainer, desync, rootlesskit
state: present

View file

@ -1,3 +1,3 @@
---
anime4k_shaders_version: 4.0.1
thumbnail_script_version: 0.4.6
material_iconic_font_version: 2.2.0

View file

@ -1,259 +0,0 @@
--=============================================================================
-->> SUBLIMINAL PATH:
--=============================================================================
-- This script uses Subliminal to download subtitles,
-- so make sure to specify your system's Subliminal location below:
local subliminal = 'subliminal'
--=============================================================================
-->> SUBTITLE LANGUAGE:
--=============================================================================
-- Specify languages in this order:
-- { 'language name', 'ISO-639-1', 'ISO-639-2' } !
-- (See: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
local languages = {
-- If subtitles are found for the first language,
-- other languages will NOT be downloaded,
-- so put your preferred language first:
{ 'English', 'en', 'eng' },
-- { 'Dutch', 'nl', 'dut' },
-- { 'Spanish', 'es', 'spa' },
-- { 'French', 'fr', 'fre' },
-- { 'German', 'de', 'ger' },
-- { 'Italian', 'it', 'ita' },
-- { 'Portuguese', 'pt', 'por' },
-- { 'Polish', 'pl', 'pol' },
{ 'Russian', 'ru', 'rus' },
-- { 'Chinese', 'zh', 'chi' },
-- { 'Arabic', 'ar', 'ara' },
}
--=============================================================================
-->> PROVIDER LOGINS:
--=============================================================================
-- These are completely optional and not required
-- for the functioning of the script!
-- If you use any of these services, simply uncomment it
-- and replace 'USERNAME' and 'PASSWORD' with your own:
local logins = {
-- { '--addic7ed', 'USERNAME', 'PASSWORD' },
-- { '--legendastv', 'USERNAME', 'PASSWORD' },
-- { '--opensubtitles', 'USERNAME', 'PASSWORD' },
-- { '--subscenter', 'USERNAME', 'PASSWORD' },
}
--=============================================================================
-->> ADDITIONAL OPTIONS:
--=============================================================================
local bools = {
auto = false, -- Automatically download subtitles, no hotkeys required
debug = false, -- Use `--debug` in subliminal command for debug output
force = true, -- Force download; will overwrite existing subtitle files
utf8 = true, -- Save all subtitle files as UTF-8
}
local excludes = {
-- Movies with a path containing any of these strings/paths
-- will be excluded from auto-downloading subtitles.
-- Full paths are also allowed, e.g.:
-- '/home/david/Videos',
'no-subs-dl',
}
local includes = {
-- If anything is defined here, only the movies with a path
-- containing any of these strings/paths will auto-download subtitles.
-- Full paths are also allowed, e.g.:
-- '/home/david/Videos',
}
--=============================================================================
local utils = require 'mp.utils'
-- Download function: download the best subtitles in most preferred language
function download_subs(language)
language = language or languages[1]
if #language == 0 then
log('No Language found\n')
return false
end
log('Searching ' .. language[1] .. ' subtitles ...', 30)
-- Build the `subliminal` command, starting with the executable:
local table = { args = { subliminal } }
local a = table.args
for _, login in ipairs(logins) do
a[#a + 1] = login[1]
a[#a + 1] = login[2]
a[#a + 1] = login[3]
end
if bools.debug then
-- To see `--debug` output start MPV from the terminal!
a[#a + 1] = '--debug'
end
a[#a + 1] = 'download'
if bools.force then
a[#a + 1] = '-f'
end
if bools.utf8 then
a[#a + 1] = '-e'
a[#a + 1] = 'utf-8'
end
a[#a + 1] = '-l'
a[#a + 1] = language[2]
a[#a + 1] = '-d'
a[#a + 1] = directory
a[#a + 1] = filename --> Subliminal command ends with the movie filename.
local result = utils.subprocess(table)
if string.find(result.stdout, 'Downloaded 1 subtitle') then
-- When multiple external files are present,
-- always activate the most recently downloaded:
mp.set_property('slang', language[2])
-- Subtitles are downloaded successfully, so rescan to activate them:
mp.commandv('rescan_external_files')
log(language[1] .. ' subtitles ready!')
return true
else
log('No ' .. language[1] .. ' subtitles found\n')
return false
end
end
-- Manually download second language subs by pressing 'n':
function download_subs2()
download_subs(languages[2])
end
-- Control function: only download if necessary
function control_downloads()
-- Make MPV accept external subtitle files with language specifier:
mp.set_property('sub-auto', 'fuzzy')
-- Set subtitle language preference:
mp.set_property('slang', languages[1][2])
mp.msg.warn('Reactivate external subtitle files:')
mp.commandv('rescan_external_files')
directory, filename = utils.split_path(mp.get_property('path'))
if not autosub_allowed() then
return
end
sub_tracks = {}
for _, track in ipairs(mp.get_property_native('track-list')) do
if track['type'] == 'sub' then
sub_tracks[#sub_tracks + 1] = track
end
end
if bools.debug then -- Log subtitle properties to terminal:
for _, track in ipairs(sub_tracks) do
mp.msg.warn('Subtitle track', track['id'], ':\n{')
for k, v in pairs(track) do
if type(v) == 'string' then v = '"' .. v .. '"' end
mp.msg.warn(' "' .. k .. '":', v)
end
mp.msg.warn('}\n')
end
end
for _, language in ipairs(languages) do
if should_download_subs_in(language) then
if download_subs(language) then return end -- Download successful!
else return end -- No need to download!
end
log('No subtitles were found')
end
-- Check if subtitles should be auto-downloaded:
function autosub_allowed()
local duration = tonumber(mp.get_property('duration'))
local active_format = mp.get_property('file-format')
if not bools.auto then
mp.msg.warn('Automatic downloading disabled!')
return false
elseif duration < 900 then
mp.msg.warn('Video is less than 15 minutes\n' ..
'=> NOT auto-downloading subtitles')
return false
elseif directory:find('^http') then
mp.msg.warn('Automatic subtitle downloading is disabled for web streaming')
return false
elseif active_format:find('^cue') then
mp.msg.warn('Automatic subtitle downloading is disabled for cue files')
return false
else
local not_allowed = {'aiff', 'ape', 'flac', 'mp3', 'ogg', 'wav', 'wv', 'tta'}
for _, file_format in pairs(not_allowed) do
if file_format == active_format then
mp.msg.warn('Automatic subtitle downloading is disabled for audio files')
return false
end
end
for _, exclude in pairs(excludes) do
local escaped_exclude = exclude:gsub('%W','%%%0')
local excluded = directory:find(escaped_exclude)
if excluded then
mp.msg.warn('This path is excluded from auto-downloading subs')
return false
end
end
for i, include in ipairs(includes) do
local escaped_include = include:gsub('%W','%%%0')
local included = directory:find(escaped_include)
if included then break
elseif i == #includes then
mp.msg.warn('This path is not included for auto-downloading subs')
return false
end
end
end
return true
end
-- Check if subtitles should be downloaded in this language:
function should_download_subs_in(language)
for i, track in ipairs(sub_tracks) do
local subtitles = track['external'] and
'subtitle file' or 'embedded subtitles'
if not track['lang'] and (track['external'] or not track['title'])
and i == #sub_tracks then
local status = track['selected'] and ' active' or ' present'
log('Unknown ' .. subtitles .. status)
mp.msg.warn('=> NOT downloading new subtitles')
return false -- Don't download if 'lang' key is absent
elseif track['lang'] == language[3] or track['lang'] == language[2] or
(track['title'] and track['title']:lower():find(language[3])) then
if not track['selected'] then
mp.set_property('sid', track['id'])
log('Enabled ' .. language[1] .. ' ' .. subtitles .. '!')
else
log(language[1] .. ' ' .. subtitles .. ' active')
end
mp.msg.warn('=> NOT downloading new subtitles')
return false -- The right subtitles are already present
end
end
mp.msg.warn('No ' .. language[1] .. ' subtitles were detected\n' ..
'=> Proceeding to download:')
return true
end
-- Log function: log to both terminal and MPV OSD (On-Screen Display)
function log(string, secs)
secs = secs or 2.5 -- secs defaults to 2.5 when secs parameter is absent
mp.msg.warn(string) -- This logs to the terminal
mp.osd_message(string, secs) -- This logs to MPV screen
end
mp.add_key_binding('Ctrl+b', 'download_subs', download_subs)
mp.add_key_binding('Ctrl+n', 'download_subs2', download_subs2)
mp.register_event('file-loaded', control_downloads)

View file

@ -16,6 +16,3 @@ Ctrl+` no-osd change-list glsl-shaders clr ""; show-text "GLSL shaders cleared"
# Ctrl+5 no-osd change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Restore_CNN_Soft_VL.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_VL.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Restore_CNN_Soft_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode B+B (HQ)"
# Ctrl+6 no-osd change-list glsl-shaders set "~~/shaders/Anime4K_Clamp_Highlights.glsl:~~/shaders/Anime4K_Upscale_Denoise_CNN_x2_VL.glsl:~~/shaders/Anime4K_AutoDownscalePre_x2.glsl:~~/shaders/Anime4K_AutoDownscalePre_x4.glsl:~~/shaders/Anime4K_Restore_CNN_M.glsl:~~/shaders/Anime4K_Upscale_CNN_x2_M.glsl"; show-text "Anime4K: Mode C+A (HQ)"
# Ctrl+` no-osd change-list glsl-shaders clr ""; show-text "GLSL shaders cleared"
# mpv_thumbnail_script ─────────────────────────────────────────────────────────
Alt+s script-binding generate-thumbnails

View file

@ -1,70 +0,0 @@
# The thumbnail cache directory.
# On Windows this defaults to %TEMP%\mpv_thumbs_cache,
# and on other platforms to /tmp/mpv_thumbs_cache.
# The directory will be created automatically, but must be writeable!
# Use absolute paths, and take note that environment variables like %TEMP% are unsupported (despite the default)!
cache_directory=/tmp/mpv_thumbnails
# THIS IS NOT A WINDOWS PATH. COMMENT IT OUT OR ADJUST IT YOURSELF.
# Whether to generate thumbnails automatically on video load, without a keypress
# Defaults to yes
autogenerate=no
# Only automatically thumbnail videos shorter than this (in seconds)
# You will have to press T (or your own keybind) to enable the thumbnail previews
# Set to 0 to disable the check, ie. thumbnail videos no matter how long they are
# Defaults to 3600 (one hour)
autogenerate_max_duration=3600
# Use mpv to generate thumbnail even if ffmpeg is found in PATH
# ffmpeg is slightly faster than mpv but lacks support for ordered chapters in MKVs,
# which can break the resulting thumbnails. You have been warned.
# Defaults to yes (don't use ffmpeg)
prefer_mpv=yes
# Explicitly disable subtitles on the mpv sub-calls
# mpv can and will by default render subtitles into the thumbnails.
# If this is not what you wish, set mpv_no_sub to yes
# Defaults to no
mpv_no_sub=yes
# Enable to disable the built-in keybind ("T") to add your own, see after the block
disable_keybinds=yes
# The maximum dimensions of the thumbnails, in pixels
# Defaults to 200 and 200
thumbnail_width=200
thumbnail_height=200
# The thumbnail count target
# (This will result in a thumbnail every ~10 seconds for a 25 minute video)
thumbnail_count=150
# The above target count will be adjusted by the minimum and
# maximum time difference between thumbnails.
# The thumbnail_count will be used to calculate a target separation,
# and min/max_delta will be used to constrict it.
# In other words, thumbnails will be:
# - at least min_delta seconds apart (limiting the amount)
# - at most max_delta seconds apart (raising the amount if needed)
# Defaults to 5 and 90, values are seconds
min_delta=5
max_delta=90
# 120 seconds aka 2 minutes will add more thumbnails only when the video is over 5 hours long!
# Below are overrides for remote urls (you generally want less thumbnails, because it's slow!)
# Thumbnailing network paths will be done with mpv (leveraging youtube-dl)
# Allow thumbnailing network paths (naive check for "://")
# Defaults to no
thumbnail_network=no
# Override thumbnail count, min/max delta, as above
remote_thumbnail_count=60
remote_min_delta=15
remote_max_delta=120
# Try to grab the raw stream and disable ytdl for the mpv subcalls
# Much faster than passing the url to ytdl again, but may cause problems with some sites
# Defaults to yes
remote_direct_stream=yes

View file

@ -4,7 +4,7 @@
path: '~/.config/mpv/{{ item }}'
state: directory
mode: 0755
loop: [ shaders, scripts, script-opts ]
loop: [fonts, shaders, scripts, script-opts]
- name: Copy config
template:
@ -26,32 +26,36 @@
command: unzip /tmp/Anime4K.zip -d ~/.config/mpv/shaders
args:
creates: ~/.config/mpv/shaders/Anime4K_Clamp_Highlights.glsl
tags: [ mpv-extend, anime4k_shaders ]
tags: [mpv-extend, mpv-anime4k]
- block:
- name: Download mpv_thumbnail_script
- name: Download mordenx OSC script
get_url:
url: 'https://github.com/marzzzello/mpv_thumbnail_script/releases/download/{{ thumbnail_script_version }}/{{ item }}'
dest: ~/.config/mpv/scripts/
mode: 0644
loop:
- mpv_thumbnail_script_client_osc.lua
- mpv_thumbnail_script_server.lua
- name: Copy mpv_thumbnail_script configuration
copy:
src: mpv_thumbnail_script.conf
dest: ~/.config/mpv/script-opts/mpv_thumbnail_script.conf
force: yes
url: https://github.com/cyl0/MordenX/raw/main/mordenx.lua
dest: ~/.config/mpv/scripts/mordenx.lua
mode: 0644
- name: Ensure OSC is disabled in mpv config file
- name: Download Material Design Iconic font zip file
get_url:
url: 'https://github.com/zavoloklom/material-design-iconic-font/releases/download/{{ material_iconic_font_version }}/material-design-iconic-font.zip'
dest: /tmp/material-design-iconic-font.zip
mode: 0644
- name: Unzip Material Design Iconic font
command: unzip -j /tmp/material-design-iconic-font.zip fonts/Material-Design-Iconic-Font.ttf -d ~/.config/mpv/fonts
args:
creates: ~/.config/mpv/fonts/Material-Design-Iconic-Font.ttf
- name: Disable default OSC and border in mpv config
lineinfile:
path: ~/.config/mpv/mpv.conf
state: present
regexp: '^osc='
line: osc=no
tags: [ mpv-extend, thumbnail ]
regexp: '^{{ item | regex_replace("no$", "") }}'
line: '{{ item }}'
loop:
- osc=no
- border=no
tags: [mpv-extend, mpv-mordenx]
- block:
# Need python3-dev
@ -67,7 +71,7 @@
dest: ~/.local/bin/ffsubsync
state: link
- name: Clone autosubsync-mpv repositories
- name: Clone autosubsync-mpv repository
git:
depth: 1
repo: https://github.com/joaquintorres/autosubsync-mpv.git
@ -79,37 +83,21 @@
dest: ~/.config/mpv/script-opts/autosubsync.conf
force: yes
mode: 0644
tags: [ mpv-extend, subsync ]
tags: [mpv-extend, mpv-subsync]
# Doesn't work well, so disable for now
- block:
- name: Install subliminal with pip
pip:
name: subliminal
virtualenv: ~/.config/mpv/venv
state: latest
- name: Symlink subliminal executable
file:
src: ~/.config/mpv/venv/bin/subliminal
dest: ~/.local/bin/subliminal
state: link
# https://github.com/davidde/mpv-autosub
- name: Copy modified autosub.lua
copy:
src: autosub.lua
dest: ~/.config/mpv/scripts/autosub.lua
force: yes
mode: 0644
tags: [ never, mpv-extend, autosub ]
- name: Install mpv-gif script
get_url:
url: https://github.com/tyalie/mpv-gif-generator/raw/main/mpv-gif.lua
dest: ~/.config/mpv/scripts/mpv-gif.lua
mode: 0644
tags: [mpv-extend, mpv-gif]
- name: Install mpv-webm script
get_url:
url: https://github.com/ekisu/mpv-webm/releases/download/latest/webm.lua
dest: ~/.config/mpv/scripts/webm.lua
mode: 0644
tags: [ mpv-extend, webm ]
tags: [mpv-extend, mpv-webm]
- name: Copy input config
copy:

View file

@ -8,3 +8,10 @@ screenshot-directory=~/Pictures/Screenshots
screenshot-high-bit-depth=no
screenshot-format=png
hwdec=auto
osd-font="{{ sans_font }}"
osd-font-size={{ (font_size + 6.5) | float }}
sub-font="{{ sans_font }}"
sub-font-size={{ (font_size * 2) | float }}
sub-border-size=2
sub-border-color="{{ background }}"
sub-color="{{ white2 }}"

View file

@ -43,6 +43,7 @@ set -gx TS_NODE_HISTORY $XDG_DATA_HOME/ts-node/history
set -gx WINEPREFIX $XDG_DATA_HOME/wine
set -gx PYENV_ROOT $XDG_DATA_HOME/pyenv
set -gx KREW_ROOT $XDG_DATA_HOME/krew
set -gx APPTAINER_CACHEDIR $XDG_CACHE_HOME/apptainer
set -gx MANPATH :$XDG_DATA_HOME/man
# common envs

View file

@ -0,0 +1,2 @@
---
ytdl_download_dir: ~/Downloads/ytdl

View file

@ -1,2 +0,0 @@
--geo-bypass
--output ~/Downloads/ytdl/%(title)s.%(ext)s

View file

@ -6,8 +6,35 @@
mode: 0755
- name: Copy config
copy:
src: config
template:
src: ytdl.j2
dest: ~/.config/yt-dlp/config
force: yes
mode: 0644
- block:
- name: Create ytmdl config directory
file:
path: ~/.config/ytmdl
state: directory
mode: 0755
- name: Install ytmdl with pip
pip:
name: ytmdl
virtualenv: ~/.config/ytmdl/venv
state: latest
- name: Symlink ytmdl executable
file:
src: ~/.config/ytmdl/venv/bin/ytmdl
dest: ~/.local/bin/ytmdl
state: link
- name: Copy ytmdl config
template:
src: ytmdl.j2
dest: ~/.config/ytmdl/config
force: yes
mode: 0644
tags: ytmdl

View file

@ -0,0 +1,2 @@
--geo-bypass
--output {{ ytdl_download_dir }}/%(title)s.%(ext)s

View file

@ -0,0 +1,5 @@
SONG_DIR = "{{ ytdl_download_dir }}"
QUALITY = "320"
METADATA_PROVIDERS = "itunes, gaana, deezer, lastfm, saavn, musicbrainz"
DEFAULT_FORMAT = "mp3"
ON_META_ERROR = "manual"