Skip to content

Instantly share code, notes, and snippets.

@FreeApp2014
Created June 19, 2020 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FreeApp2014/c2360595a1e1a752bab72d7a40c282c6 to your computer and use it in GitHub Desktop.
Save FreeApp2014/c2360595a1e1a752bab72d7a40c282c6 to your computer and use it in GitHub Desktop.
Get currently playing song information using vlc telnet rc interface
#!/usr/local/bin/node
let input = require("child_process").execSync('echo info | nc 127.0.0.1 4212').toString("utf-8");
let regex = /^\| album: (.*)/mg;
let album = regex.exec(input);
album = (album == null ? "Unknown Album" : album[1]);
regex = /^\| title: (.*)/mg;
let title = regex.exec(input);
title = ( title == null ? "Unknown Title" : title[1]);
if (title == "Unknown Title" || title == ""){
regex = /^\| filename: (.*)/mg;
title = regex.exec(input);
title = ( title == null ? "Unknown Title" : title[1]);
}
regex = /^\| artist: (.*)/mg;
let artist = regex.exec(input);
artist = (artist == null ? "Unknown Artist" : artist[1]);
console.log(artist == "" ? "Unknown Artist" : artist);
console.log(album == "" ? "Unknown Album" : album);
console.log(title == "" ? "Unknown Title" : title);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment