mpv metadata (Song title)
Posted: 07 Apr 2024, 11:40
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 "${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?