Skip to content

Instantly share code, notes, and snippets.

@xdite
Created February 20, 2014 13:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xdite/9114077 to your computer and use it in GitHub Desktop.
Save xdite/9114077 to your computer and use it in GitHub Desktop.
require 'digest'
filename = "House.Of.Cards.2013.S02E01.720p.WEB-DL.x264-Sohu.mp4"
f = File.new(filename, "rb")
puts f.stat.inspect
file_size = File.size?(filename)
offset = []
offset[0] = 4096
offset[1] = file_size / 3 * 2
offset[2] = file_size / 3
offset[3] = file_size - 8192
vhash = []
offset.each do |position|
#length , offset
vblock = IO.binread(filename, 4096, position)
md5 = Digest::MD5.hexdigest(vblock)
vhash << md5
end
hash = vhash.join(";")
require 'rubygems'
require 'httparty'
class SVPlayer
include HTTParty
base_uri 'www.shooter.cn'
def post(hash,filename)
options = { :body => {'filehash' => hash , 'pathinfo' => filename , 'format' => 'json', 'lang' => 'Chn'} }
self.class.post('/api/subapi.php', options)
end
end
puts SVPlayer.new.post(hash,filename)