Created
June 19, 2020 11:08
-
-
Save FreeApp2014/c2360595a1e1a752bab72d7a40c282c6 to your computer and use it in GitHub Desktop.
Get currently playing song information using vlc telnet rc interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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