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
Net::HTTPResponse.instance_eval do | |
attr_reader :socket | |
def read_status_line(sock) | |
str = sock.readline | |
m = /\A(?:HTTP|ICY)(?:\/(\d+\.\d+))?\s+(\d\d\d)(?:\s+(.*))?\z/in.match(str) || raise(Net::HTTPBadResponse, "wrong status line: #{str.dump}") | |
m.captures | |
end | |
end |
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
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 |
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
def song_page | |
url_string = "#{@url.scheme}://#{@url.host}:#{@url.port}" | |
if %(SHOUTcast).include? @server | |
if Gem::Version.new(@version) > Gem::Version.new('2.0') | |
return "#{url_string}/stats?sid=1" | |
else | |
return "#{url_string}/7.html" | |
end | |
elsif %(Icecast).include? @server | |
return false if @url.to_s.include? 'dirble' |
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
Net::HTTPResponse.instance_eval do | |
attr_reader :socket | |
def read_status_line(sock) | |
str = sock.readline | |
m = /\A(?:HTTP|ICY)(?:\/(\d+\.\d+))?\s+(\d\d\d)(?:\s+(.*))?\z/in.match(str) || raise(Net::HTTPBadResponse, "wrong status line: #{str.dump}") | |
m.captures | |
end | |
end |
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
{ | |
Script to submit song info to the Dirble AIR API (https://dirble.com/broadcasters/providers). | |
The stationId & airKey values need to be set for this to work. | |
} | |
const STATION_ID = ''; | |
const AIRKEY = ''; | |
var player : TPlayer; | |
var song : TSongInfo; |
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
$esquery = '{ | |
"fields" : ["name", "bitrate", "genres","urlid","country", "country_name"], | |
"query": | |
{ | |
"query_string": { | |
"query":"'.$query.'" | |
} | |
} | |
}'; | |
echo json_encode(($this->elasticsearch->advancedquery("station",$esquery))); |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/"> | |
<ShortName>Opensearch</ShortName> | |
<InputEncoding>UTF-8</InputEncoding> | |
<Description>Opensearch to search in your browser.</Description> | |
<Contact>opensearch@test.org</Contact> | |
<Url type="text/html" method="get" template="http://localhost:3000/search?q={searchTerms}"/> | |
<moz:SearchForm>http://localhost:3000/</moz:SearchForm> | |
</OpenSearchDescription> |
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
var dispatcher = new WebSocketRails('localhost/websocket'); | |
dispatcher.on_open = function(data) { | |
console.log('connected!'); | |
var stationid = $('#songhistorylist').data("id"); | |
var stationname = 'station' + String(stationid); | |
var channel = dispatcher.subscribe(stationname); | |
channel.bind('new_song', function (song) { |
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
gem 'websocket-rails', github: 'moaa/websocket-rails', branch: 'threadsocket-rails' | |
gem 'websocket-rails-js', github: 'websocket-rails/websocket-rails-js', branch: 'sub_protocols' |