Created
August 9, 2017 08:58
-
-
Save PofMagicfingers/7b272365837b2e6d309066dc384e88c3 to your computer and use it in GitHub Desktop.
Show remaining time in vlc, and current listener count in a icecast webradio
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/bin/env ruby | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
VLC_URL = "http://vlc:8080/requests/status.xml" | |
ICECAST_STATUS = "http://webradio:8000/status2.xsl" | |
l_count = 0 | |
ccount = 0 | |
while 1 > 0 | |
vlcrc = Nokogiri::HTML(open(PAGE_URL)) | |
length = (vlcrc.css("length").text.to_i - vlcrc.css("time").text.to_i) | |
if ccount % 20 == 0 | |
puts "LIST" | |
listeners = Nokogiri::HTML(open(ICECAST_STATUS)) | |
l_arr = listeners.text.split(",") | |
l_count = l_arr[9].to_i | |
end | |
system("clear") | |
minute = (length/60) | |
seconds = length-(minute*60) | |
# puts ("%02d" % ("#{length/60}".to_i)) + ":" + ("%02d" % ("#{(length-(length/60))}".to_i)) | |
puts "%02d" % minute + ":" + "%02d" % seconds | |
puts l_count | |
sleep 0.8 | |
ccount = ccount + 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment