For example, this command
mpv "${URL}" --term-status-msg="icy-title: ${metadata/icy-title}" | grep -oP "icy-title: \K.*"
returns these two lines:
icy-title:
Jackie Wilson - Reet Petite
But I want only the second line to be output, so just the title.
How does the mpv command need to be modified?
The AI (chatGPT) suggested:
Mpv supports the use of Lua scripts to customize behavior. One such script could extract and output the song title separately:
Create a file called songtitle.lua with the following content:
lua
local msg = mp.get_property_native("metadata/icy-title")
if msg then
local title = string.match(msg, "icy%-title%: (.*)")
if title then
print(title)
end
end
Start mpv with mpv --script=songtitle.lua "${URL}"
This script directly accesses the "icy-title" metadata and extracts the song title using string.match.
Can the mpv command be modified as desired without using a lua script?
That should be possible.
Does somebody has any idea?
mpv metadata (Song title)
- ncmprhnsbl
- DEV Team
- Posts: 4253
- Joined: 20 Mar 2012, 03:42
- Distribution: v5.0-64bit
- Location: australia
- Contact:
mpv metadata (Song title)
my audio files don't seem to give any of that type of metadata.. but anyway
how about just piping to tail like this:
the output without the grep part might shed some light on why the grep isn't doing what you want
how about just piping to tail like this:
Code: Select all
mpv "${URL}" --term-status-msg="icy-title: ${metadata/icy-title}" | grep -oP "icy-title: \K.*" | tail -n 1
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44