Last active
August 29, 2015 14:07
-
-
Save Karunamon/9fe0d9e83b90c3d8930c to your computer and use it in GitHub Desktop.
Lame Icecast now playing badge creator
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/ruby | |
require 'xmlsimple' | |
require 'net/http' | |
require 'erb' | |
###CONFIG | |
#Stream mount point on the server | |
$mountpoint = 'live.ogg' | |
#URL to the icecast server root on the web, including trailing slash | |
$server = "http://isengard.tkware.us:8000/" | |
#### | |
url = $server + $mountpoint + ".xspf" | |
xmldata = Net::HTTP.get_response(URI.parse(url)).body | |
doc = XmlSimple.xml_in(xmldata) | |
#Words cannot express how much I hate XML right now. This kind of shit should not be necessary. | |
tracktitle = doc['trackList'].first['track'].first['title'].first | |
streamtitle = doc['trackList'].first['track'].first['annotation'].first.split("\n")[0].split('Stream Title: ')[1] | |
streamdesc = doc['trackList'].first['track'].first['annotation'].first.split("\n")[1].split('Stream Description: ')[1] | |
html = <<EOF | |
<html> | |
<body bgcolor="black"> | |
<font face='Helvetica' color="white"/> | |
<% if tracktitle.empty? %> | |
<p/> OFFLINE | |
<% else %> | |
<p/><%= streamtitle %> | |
<p/><%= tracktitle %> | |
<% end %> | |
<img src='8chanradiobar.png'/> | |
</html> | |
EOF | |
rendered_html = ERB.new(html).result | |
File.open('nowplaying.html', 'w') { |file| file.write(rendered_html) } | |
Kernel.exec('xvfb-run --server-args="-screen 0, 300x200x24" cutycapt --url=http://localhost/nowplaying.html --out=nowplaying.png --min-width=300 --min-height=100') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment