vdocipher 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vdocipher.rb +28 -24
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56b07398619529a0cb3133b99b95f71764d4a36a
4
- data.tar.gz: bf87bc5995964ee956d8f840fed6ed589f7b54fd
3
+ metadata.gz: efbe0acc8a10fdb58e5ea7973ee8af5ae71c2b13
4
+ data.tar.gz: 43fd5d2ffadf64c07fe353d3c303c29314268b34
5
5
  SHA512:
6
- metadata.gz: ce8988a70b9ccc2d459b1e8eaa25f121c7217b9aad40e34f9318ca892d044cea57298cbae8b37b2da2a4409fd2cf4dd79b4d200b04c23405f20ad12110383c23
7
- data.tar.gz: 98b2591a78eeca0161b9bba49578ac002021c0c3fcf06b04e9cc0eea139fa06c519a4067df3033e6ef1902b56051a594560db2eb60364f864e544554b90f2257
6
+ metadata.gz: d24b529d8e152b4a67843de0e5b687b4ea5230c8fde94a3a32ed97c9416c7cb1064fee36fd8530f0898cb41fc20f289813e2d6918f7b66cb4686f8549dbe2580
7
+ data.tar.gz: 3aa37be3d2de3571f342e7526b800023e8b4c97b49a00d908f08781cd67c2e1d55cea5a989f8d5201f5d66bfaea27ed8556a30592c9f7ff3a7dda511ebcad0e5
@@ -1,34 +1,38 @@
1
1
  require "net/http"
2
2
  require "json"
3
3
  class VdoCipher
4
- def initialize(conf)
5
- @key = conf[:clientSecretKey]
6
- end
7
- def play_code(id, attr="", theme="9ae8bbe8dd964ddc9bdb932cca1cb59a")
8
- if (@key == nil)
9
- return "key not set"
10
- end
11
- url = URI.parse('https://api.vdocipher.com/v2/otp?video='+ id)
12
- req = Net::HTTP::Post.new(url.to_s)
13
- req.body = 'clientSecretKey=' + @key
14
- res = Net::HTTP.start(url.host, url.port, use_ssl:true) {|http|
15
- http.request(req)
16
- }
17
- if(res.code != "200")
18
- return res.code
19
- end
20
- otp = JSON.parse(res.body)
21
- if( otp['error'] == "No video found" )
22
- return "video not found"
23
- end
4
+ @@version = '1.1.0'
5
+ attr_reader :version
6
+
7
+ def initialize(conf, version = '1.1.3')
8
+ @key = conf[:clientSecretKey]
9
+ @version = version
10
+ end
11
+ def play_code(id, attr="", theme="9ae8bbe8dd964ddc9bdb932cca1cb59a")
12
+ if (@key == nil)
13
+ return "key not set"
14
+ end
15
+ url = URI.parse('https://api.vdocipher.com/v2/otp?video='+ id)
16
+ req = Net::HTTP::Post.new(url.to_s)
17
+ req.body = 'clientSecretKey=' + @key
18
+ res = Net::HTTP.start(url.host, url.port, use_ssl:true) {|http|
19
+ http.request(req)
20
+ }
21
+ if(res.code != "200")
22
+ return 'Status code error: ' + res.code
23
+ end
24
+ otp = JSON.parse(res.body)
25
+ if( otp['error'] == "No video found" )
26
+ return "video not found"
27
+ end
24
28
  # make the theme configurable
25
- embedcode = <<EOS
29
+ embedcode = <<EOS
26
30
  <div id="vdo%s" %s></div>
27
31
  <script>
28
32
  (function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){ (v[o].d=v[o].d||[]).push(a);};
29
33
  if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0];
30
34
  a.async=1; a.src=e; m.parentNode.insertBefore(a,m);}
31
- })(window,document,"script","https://d1z78r8i505acl.cloudfront.net/playerAssets/vdo.js","vdo");
35
+ })(window,document,"script","https://d1z78r8i505acl.cloudfront.net/playerAssets/%s/vdo.js","vdo");
32
36
  vdo.add({
33
37
  otp: "%s",
34
38
  playbackInfo: btoa(JSON.stringify({
@@ -40,7 +44,7 @@ vdo.add({
40
44
  </script>
41
45
 
42
46
  EOS
43
- embedcode = embedcode % [otp["otp"], attr, otp["otp"], id, theme, otp["otp"]]
44
- end
47
+ embedcode = embedcode % [otp["otp"], attr, version, otp["otp"], id, theme, otp["otp"]]
48
+ end
45
49
  end
46
50
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vdocipher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vibhav Sinha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-12 00:00:00.000000000 Z
11
+ date: 2017-08-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Stream and manage videos hosted through vdocipher streaming service.
14
14
  email: info@vdocipher.com