Skip to content

Instantly share code, notes, and snippets.

@javascripter
Created June 11, 2009 08:30
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 javascripter/127783 to your computer and use it in GitHub Desktop.
Save javascripter/127783 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "webrick/httpproxy"
require "uri"
s = WEBrick::HTTPProxyServer.new(
:Port => 0721,
:ProxyContentHandler => lambda do|req, res|
if req.unparsed_uri.start_with?("http://utauga.jp/karaoke/wmv.php?contents_id=kar")
kar_id = req.query["contents_id"]
now = Time.now.strftime "%H%M%S"
url = "http://utauga.jp/karaoke/asx.php?id=#{ URI.escape(kar_id) }&Time=#{ URI.escape(now) }"
res.body = <<"."
<object
id="Player"
width="320"
height="240"
classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6"
codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
standby="Loading Microsoft Windows Media Player components..."
URL="#{ url }"
stretchtofit="true">
<param name="autostart" value="false">
<param name="playcount" value="1">
<embed height="100%" width="100%" name="plugin" src="#{ url }" type="video/x-ms-asf" autostart="true">
</object>
.
end
end
)
Signal.trap('INT') do
s.shutdown
end
s.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment