Wilder Lopes
Wilder Lopes

Reputation: 13

How to get artist and title information using python-vlc?

I'm trying to record and get song information (title and artist) from web radios using python-vlc lib. The recording functionality is working well but the media parse to get the song information doesn't work! This is my code:

inst = vlc.Instance() # Create a VLC instance

p = inst.media_player_new() # Create a player instance
cmd1 = "sout=file/ts:%s" % outfile
media = inst.media_new("http://playerservices.streamtheworld.com/api/livestream-redirect/JBFMAAC1.aac", cmd1)
media.get_mrl()

p.set_media(media)
p.play()

media.parse()

for i in range(13):
    print("{} - {}".format(i, media.get_meta(i)))

It's always returning "MediaParsedStatus.skipped" status. And all song information returns "None". I tested the same radio in VLC App and there it works fine. Anyone can help me? thanks in advance

Upvotes: 0

Views: 2086

Answers (1)

mfkl
mfkl

Reputation: 2159

Since this is a stream, libvlc will not parse it by default (only local files).

You need to use a flag to tell libvlc to parse the media even if it is a network stream.

Use libvlc_media_parse_with_options with MediaParseFlag set to network (1).

Upvotes: 1

Related Questions