stupeflix 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/examples/example.rb CHANGED
@@ -1,5 +1,7 @@
1
+ require 'stupeflix'
2
+
1
3
  # Set a unique identifier e.g. 'user/resource_id'
2
- id = "user/resource_id#{Time.now.to_i}"
4
+ id = "#{'abcdefghijk'.chars.to_a.shuffle.join}/slideshow#{Time.now.to_i}"
3
5
 
4
6
  # Configure credentials
5
7
  s = Stupeflix::Video.new id, YOUR_ACCESS_KEY, YOUR_SECRET_KEY
@@ -14,10 +16,43 @@ s.definition = Stupeflix::Definition.new do |xml|
14
16
  images.each_with_index do |i,x|
15
17
  xml.add_slide i, "Slide #{x}", duration: 4
16
18
  end
17
- end
19
+ end.doc.root.to_xml
18
20
 
19
21
  # POST profiles to request videos be generated accordingly
20
- s.profiles = '<profiles><profile name="720p"><stupeflixStore></stupeflixStore></profile></profiles>'
22
+ s.profiles = Nokogiri::XML::Builder.new do |x|
23
+ x.profiles {
24
+ x.profile(name: '720p') {
25
+ x.stupeflixStore
26
+ x.youtube(login: YOUR_YOUTUBE_USER, password: YOUR_YOUTUBE_PASSWORD) {
27
+ x.meta {
28
+ x.title 'Stupeflix API Test'
29
+ x.description 'A test of the Stupeflix Ruby API wrapper @ https://github.com/pgeraghty/stupeflix-api.'
30
+ #x.tags tags
31
+ x.channels 'Tech'
32
+ x.acl 'unlisted'
33
+ }
34
+ }
35
+ }
36
+ }
37
+ end.doc.root.to_xml(save_with: 0).gsub('<stupeflixStore/>', '<stupeflixStore></stupeflixStore>')
21
38
 
22
- # GET status of requested videos
23
- s.status
39
+ # GET status of requested videos, loop until done
40
+ result = nil
41
+ while result.nil?
42
+ status = s.status
43
+ status = status.first['status'] rescue status
44
+ result = if err = status['error'] rescue nil
45
+ err
46
+ elsif yt_id = status['available-1-url'].scan(/v=([^&]+)/i).flatten.first rescue nil
47
+ "Complete: http://www.youtube.com/watch?v=#{yt_id}&hd=1"
48
+ elsif (%w(queued generating generated uploading available).include? status['status'] rescue nil)
49
+ p 'Processing...'; nil
50
+ elsif (status.response.code.to_i != 200 rescue nil)
51
+ "Error: #{status}"
52
+ else
53
+ "Unknown Error: #{status}"
54
+ end
55
+ break if result
56
+ sleep 5
57
+ end
58
+ p result
@@ -1,3 +1,3 @@
1
1
  module Stupeflix
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/stupeflix.rb CHANGED
@@ -66,7 +66,7 @@ module Stupeflix
66
66
  yield x if block_given?
67
67
  }
68
68
  }
69
- end.root
69
+ end
70
70
  end
71
71
 
72
72
  def add_slide url, caption, options={}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stupeflix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: