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 +40 -5
- data/lib/stupeflix/version.rb +1 -1
- data/lib/stupeflix.rb +1 -1
- metadata +1 -1
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 = "
|
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 =
|
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
|
-
|
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
|
data/lib/stupeflix/version.rb
CHANGED
data/lib/stupeflix.rb
CHANGED