InputUsername/rescrobbled

Extract artist's name from xesam:title

Closed this issue · 4 comments

I'm using MPV to stream radio from internet, and somehow the metadata from MPV shows only xesam:title with the artist's name in it.
Example:

> playerctl metadata
mpv   xesam:url                 http://hits.j1fm.tokyo/
mpv   mpris:trackid             '/0'
mpv   xesam:title               Yuuki Aoi - Cupid Revue
mpv   mpris:length              520019591

Is it possible to extract artist's name from xesam:title? Because somehow last.fm doesn't recognize the track because the artist name in it.

That sounds doable and it's probably a good idea to use that as a fallback if the artist is missing. Thanks for the suggestion!

I've decided not to build in this behavior. However, the most recent release (v0.3.0) supports the filter-script config option. You can point it at a script that will be run to filter metadata. The filter script takes the artist, title and album as input and should output the filtered metadata on separate lines.

An example script to extract the artist from the title if the artist is missing:

#!/usr/bin/env python

import sys

artist, title, album = (l.rstrip() for l in sys.stdin.readlines())

if len(artist) == 0:
    artist, title = title.split(' - ', maxsplit=1)

print(artist, title, album, sep='\n')

Let me know if this solution works for you!

Thanks, it works perfectly on my radio!
I'll close this issue now

Glad to hear, thank you!