diff options
| author | marcellus <msimon_fr@hotmail.com> | 2023-05-04 00:13:20 +0200 |
|---|---|---|
| committer | marcellus <msimon_fr@hotmail.com> | 2023-05-04 00:13:20 +0200 |
| commit | 13535011bb12163a4f9035cf2f231e856565e950 (patch) | |
| tree | da15860273c94d6f9dba02e7d9e5b7e9749438db /mpv/music | |
| parent | 7e1032434d90db737e319d3eb21721b7fed388be (diff) | |
fix: overall patches
Diffstat (limited to 'mpv/music')
| -rw-r--r-- | mpv/music/local.lua | 30 | ||||
| -rw-r--r-- | mpv/music/online.lua | 9 |
2 files changed, 39 insertions, 0 deletions
diff --git a/mpv/music/local.lua b/mpv/music/local.lua new file mode 100644 index 0000000..dfb9e2d --- /dev/null +++ b/mpv/music/local.lua @@ -0,0 +1,30 @@ +local utils = require "mp.utils" + +function notify_current_media() + local path = mp.get_property_native("path") + local origin, title = utils.split_path(path) + + local metadata = mp.get_property_native("metadata") + if metadata then + function tag(name) + return metadata[string.upper(name)] or metadata[name] + end + + title = tag("title") or title + origin = tag("artist_credit") or tag("artist") or "" + + local album = tag("album") + if album then + origin = string.format("%s — %s", origin, album) + end + + local year = tag("original_year") or tag("year") + if year then + origin = string.format("%s (%s)", origin, year) + end + end + mp.command_native({"run", "pkill", "-RTMIN+1", "dwmblocks"}) + return mp.command_native({"run", "env", "HERBE_ID=/music", "herbe", title, origin}) +end + +mp.register_event("file-loaded", notify_current_media)
\ No newline at end of file diff --git a/mpv/music/online.lua b/mpv/music/online.lua new file mode 100644 index 0000000..bcd5d18 --- /dev/null +++ b/mpv/music/online.lua @@ -0,0 +1,9 @@ +local utils = require "mp.utils" + +function notify_current_media(key) + local title = mp.get_property(key) + mp.command_native({"run", "pkill", "-RTMIN+1", "dwmblocks"}) + return mp.command_native({"run", "env", "HERBE_ID=/music", "herbe", title}) +end + +mp.observe_property("media-title", string, notify_current_media)
\ No newline at end of file |
