[mpv] steal mugen script from amoethyst
This commit is contained in:
@@ -2,6 +2,7 @@ profile=gpu-hq
|
||||
#gpu-api=vulkan
|
||||
gpu-context=wayland
|
||||
hwdec=none
|
||||
fullscreen=yes
|
||||
|
||||
#ao=jack
|
||||
#audio-channels=stereo
|
||||
|
||||
34
.config/mpv/scripts/mugen.lua
Normal file
34
.config/mpv/scripts/mugen.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
local utils = require("mp.utils")
|
||||
|
||||
local function get_kdata(kid)
|
||||
local resp = mp.command_native({
|
||||
name = "subprocess",
|
||||
args = { "curl", "-s", "https://kara.moe/api/karas/" .. kid },
|
||||
capture_stdout = true,
|
||||
})
|
||||
|
||||
return utils.parse_json(resp.stdout)
|
||||
end
|
||||
|
||||
local function get_title(kdata)
|
||||
return kdata.titles[kdata.titles_default_language]
|
||||
end
|
||||
|
||||
local function on_load()
|
||||
local path = mp.get_property("path")
|
||||
local kid = path:match("^https://kara.moe/kara/.-([0-9a-z-]+)$")
|
||||
if kid == nil then
|
||||
kid = path:match("^https://live.karaokes.moe/%?video=([0-9a-z-]+)$")
|
||||
end
|
||||
if kid ~= nil then
|
||||
local kdata = get_kdata(kid)
|
||||
local mediafile = "https://kara.moe/downloads/medias/" .. kdata.mediafile
|
||||
local subfile = "https://kara.moe/downloads/lyrics/" .. kdata.subfile
|
||||
mp.set_property("stream-open-filename", mediafile)
|
||||
mp.set_property("replaygain-fallback", kdata.gain)
|
||||
mp.set_property("title", get_title(kdata))
|
||||
mp.commandv("sub-add", subfile)
|
||||
end
|
||||
end
|
||||
|
||||
mp.register_event("start-file", on_load)
|
||||
@@ -1,3 +1,7 @@
|
||||
configuration {
|
||||
modi: "run,mugen:~/.config/rofi/modi/mugen";
|
||||
}
|
||||
|
||||
* {
|
||||
active-background: #20ABE0;
|
||||
active-foreground: @foreground;
|
||||
|
||||
27
.config/rofi/modi/mugen
Executable file
27
.config/rofi/modi/mugen
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
mugen_host=${MUGEN_HOST:-https://kara.moe}
|
||||
kara_api="${MUGEN_KARA_API:-$mugen_host/api/karas}"
|
||||
karamedia="${MUGEN_KARAOKEMEDIA:-$mugen_host/downloads}"
|
||||
|
||||
# karaoke medias and lyrics directories
|
||||
medias="$karamedia/medias"
|
||||
lyrics="$karamedia/lyrics"
|
||||
|
||||
kid=$ROFI_INFO
|
||||
|
||||
if [ -z "$@" ]; then
|
||||
/usr/bin/printf "\0prompt\x1fkaraoke search\n"
|
||||
exit 0
|
||||
else
|
||||
if [ -z "$kid" ]; then
|
||||
/usr/bin/printf "\0prompt\x1fmugen\n"
|
||||
query="$(echo "$@" | tr " " "+")"
|
||||
curl "https://kara.moe/api/karas/search?collections=dbcf2c22-524d-4708-99bb-601703633927,c7db86a0-ff64-4044-9be4-66dd1ef1d1c1,2fa2fe3f-bb56-45ee-aa38-eae60e76f224,efe171c0-e8a1-4d03-98c0-60ecf741ad52&filter=$query&size=100" | jq -r '.content | .[] | "\(.mediafile)\u0000info\u001f\(.kid)"'
|
||||
fi
|
||||
fi
|
||||
|
||||
# choose karaoke
|
||||
[ -z "$kid" ] && exit
|
||||
|
||||
mpv "https://kara.moe/kara/$kid" > /dev/null 2>&1 &
|
||||
exec 1>&-
|
||||
Reference in New Issue
Block a user