Skip to content

Instantly share code, notes, and snippets.

@confact
Created September 23, 2017 12:49
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 confact/d46050c0abacd0d4b6782098260a5677 to your computer and use it in GitHub Desktop.
Save confact/d46050c0abacd0d4b6782098260a5677 to your computer and use it in GitHub Desktop.
Getting current playing songs from html pages
def get_song
@get_song ||= if @server == 'SHOUTcast'
if Gem::Version.new(@version) > Gem::Version.new('2.0')
data = hash_get_song_page
data['SHOUTCASTSERVER']['SONGTITLE'] || ''
else
get_song_page.split(',').last.gsub('</body></html>', '')
end
elsif @server == 'Icecast'
data = hash_get_song_page
data['playlist']['trackList']['track']['title'] || ''
else
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment