diff --git a/lib/vdocipher.rb b/lib/vdocipher.rb old mode 100644 new mode 100755 index f334bba..8bf86af --- a/lib/vdocipher.rb +++ b/lib/vdocipher.rb @@ -1,50 +1,57 @@ require "net/http" require "json" + class VdoCipher - @@version = '1.1.0' + @@version = '1.1.1' attr_reader :version def initialize(conf, version = '1.1.3') @key = conf[:clientSecretKey] @version = version end + def play_code(id, attr="", theme="9ae8bbe8dd964ddc9bdb932cca1cb59a") - if (@key == nil) - return "key not set" - end - url = URI.parse('https://api.vdocipher.com/v2/otp?video='+ id) - req = Net::HTTP::Post.new(url.to_s) - req.body = 'clientSecretKey=' + @key + return "key not set" if (@key == nil) + + url = URI.parse("https://dev.vdocipher.com/api/videos/#{id}/otp") + + header = { 'Content-Type': 'text/json', 'Authorization': "Apisecret #{@key}" } + + req = Net::HTTP::Post.new(url.request_uri, header) res = Net::HTTP.start(url.host, url.port, use_ssl:true) {|http| http.request(req) } + if(res.code != "200") return 'Status code error: ' + res.code end + otp = JSON.parse(res.body) if( otp['error'] == "No video found" ) return "video not found" end + # make the theme configurable + div_id = Time.now.to_i + embedcode = < +
- EOS - embedcode = embedcode % [otp["otp"], attr, version, otp["otp"], id, theme, otp["otp"]] + embedcode end -end - +end \ No newline at end of file diff --git a/vdocipher.gemspec b/vdocipher.gemspec old mode 100644 new mode 100755 index c623ea1..c414506 --- a/vdocipher.gemspec +++ b/vdocipher.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'vdocipher' - s.version = '1.1.0' + s.version = '1.1.1' s.date = '2017-08-24' s.summary = "VdoCipher API interface" s.description = "Stream and manage videos hosted through vdocipher streaming service."