animoto 1.5.5 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/animoto.rb +1 -1
- data/lib/animoto/client.rb +1 -1
- data/lib/animoto/manifests/base.rb +17 -1
- data/lib/animoto/manifests/directing.rb +1 -0
- data/lib/animoto/manifests/directing_and_rendering.rb +2 -0
- data/lib/animoto/manifests/rendering.rb +1 -0
- data/lib/animoto/partner_metadata.rb +6 -0
- data/lib/example.rb +31 -9
- data/lib/example2.rb +63 -0
- data/spec/animoto/manifests/directing_and_rendering_spec.rb +11 -0
- metadata +7 -5
    
        data/lib/animoto.rb
    CHANGED
    
    
    
        data/lib/animoto/client.rb
    CHANGED
    
    
| @@ -28,14 +28,20 @@ module Animoto | |
| 28 28 | 
             
                  # @return [String]
         | 
| 29 29 | 
             
                  attr_accessor :http_callback_format
         | 
| 30 30 |  | 
| 31 | 
            +
                  attr_accessor :partner_metadata
         | 
| 32 | 
            +
             | 
| 31 33 | 
             
                  # Creates a new manifest
         | 
| 32 34 | 
             
                  #
         | 
| 33 35 | 
             
                  # @param [Hash{Symbol=>Object}] options
         | 
| 34 36 | 
             
                  # @option options [String] :http_callback_url a URL to receive a callback when this job is done
         | 
| 35 37 | 
             
                  # @option options [String] :http_callback_format the format of the callback
         | 
| 38 | 
            +
                  # @option options [String] :partner_metadata an array of hashes with a predefined format containing  
         | 
| 39 | 
            +
                  #   the hashes for ['partner_user_id', 'commercial_use', 'partner_intent', 'application_data']
         | 
| 40 | 
            +
                  #   where application_data is an array of hashes ['title', 'id', 'kind', 'type']
         | 
| 36 41 | 
             
                  def initialize options = {}
         | 
| 37 42 | 
             
                    @http_callback_url  = options[:http_callback_url]
         | 
| 38 43 | 
             
                    @http_callback_format = options[:http_callback_format]
         | 
| 44 | 
            +
                    @partner_metadata  = options[:partner_metadata]
         | 
| 39 45 | 
             
                  end
         | 
| 40 46 |  | 
| 41 47 | 
             
                  # Returns a representation of this manifest as a Hash, used to populate
         | 
| @@ -55,6 +61,16 @@ module Animoto | |
| 55 61 | 
             
                  end
         | 
| 56 62 |  | 
| 57 63 | 
             
                  private
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  # Helper method to put the partner_metadata into the manifest hash
         | 
| 66 | 
            +
                  #
         | 
| 67 | 
            +
                  # @param [Hash{String=>Object}] job_hash the hash version of the 'job' portion of this manifest
         | 
| 68 | 
            +
                  # @return [void]
         | 
| 69 | 
            +
                  def add_partner_metadata job_hash
         | 
| 70 | 
            +
                    if partner_metadata
         | 
| 71 | 
            +
                      job_hash['partner_metadata'] = partner_metadata
         | 
| 72 | 
            +
                    end
         | 
| 73 | 
            +
                  end
         | 
| 58 74 |  | 
| 59 75 | 
             
                  # Helper method to put the standard HTTP callback information into the manifest hash
         | 
| 60 76 | 
             
                  #
         | 
| @@ -70,4 +86,4 @@ module Animoto | |
| 70 86 | 
             
                  end
         | 
| 71 87 | 
             
                end
         | 
| 72 88 | 
             
              end
         | 
| 73 | 
            -
            end
         | 
| 89 | 
            +
            end
         | 
| @@ -145,6 +145,7 @@ module Animoto | |
| 145 145 | 
             
                    hash = { 'directing_job' => { 'directing_manifest' => {} } }
         | 
| 146 146 | 
             
                    job  = hash['directing_job']
         | 
| 147 147 | 
             
                    add_callback_information job
         | 
| 148 | 
            +
                    add_partner_metadata job
         | 
| 148 149 | 
             
                    manifest              = job['directing_manifest']
         | 
| 149 150 | 
             
                    manifest['style']     = style
         | 
| 150 151 | 
             
                    manifest['pacing']    = pacing if pacing
         | 
| @@ -55,7 +55,9 @@ module Animoto | |
| 55 55 | 
             
                    hash  = { 'directing_and_rendering_job' => {} }
         | 
| 56 56 | 
             
                    job   = hash['directing_and_rendering_job']
         | 
| 57 57 | 
             
                    add_callback_information job
         | 
| 58 | 
            +
                    add_partner_metadata job
         | 
| 58 59 | 
             
                    job['directing_manifest'] = self.directing_manifest.to_hash['directing_job']['directing_manifest']
         | 
| 60 | 
            +
                    
         | 
| 59 61 | 
             
                    job['rendering_manifest'] = self.rendering_manifest.to_hash['rendering_job']['rendering_manifest']
         | 
| 60 62 | 
             
                    hash
         | 
| 61 63 | 
             
                  end
         | 
| @@ -63,6 +63,7 @@ module Animoto | |
| 63 63 | 
             
                    hash  = { 'rendering_job' => { 'rendering_manifest' => { 'rendering_parameters' => {} } } }
         | 
| 64 64 | 
             
                    job   = hash['rendering_job']
         | 
| 65 65 | 
             
                    add_callback_information job
         | 
| 66 | 
            +
                    add_partner_metadata job
         | 
| 66 67 | 
             
                    manifest = job['rendering_manifest']
         | 
| 67 68 | 
             
                    manifest['storyboard_url'] = storyboard.url if storyboard
         | 
| 68 69 | 
             
                    params = manifest['rendering_parameters']
         | 
    
        data/lib/example.rb
    CHANGED
    
    | @@ -1,14 +1,30 @@ | |
| 1 1 | 
             
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            require 'ruby-debug'
         | 
| 2 3 | 
             
            require 'animoto/client'
         | 
| 3 4 | 
             
            include Animoto
         | 
| 4 5 |  | 
| 5 6 | 
             
            # Create a new client using our application key and secret
         | 
| 6 7 | 
             
            client = Client.new("bb0d0e005ac4012dc17712313b013462", "c0fe4cfca8bf544b8d0e687247a600ef55ff82e3")
         | 
| 7 8 | 
             
            client.endpoint = "https://platform-staging.animoto.com" 
         | 
| 9 | 
            +
            #client = Client.new("698dbba063bc012ea77d1231380e2ed9", "fd3dc39b57878951b480db818c2f3c15")
         | 
| 10 | 
            +
            #client.endpoint = "https://platform-sandbox.animoto.com"
         | 
| 8 11 |  | 
| 9 | 
            -
            custom_footage = Postroll::CustomFootage.new("http://s3-s.animoto.com/Footage/wInVzO78f0SjP1GTFtfPrA/t.mp4") | 
| 10 | 
            -
             | 
| 11 | 
            -
            #custom_footage | 
| 12 | 
            +
            custom_footage = Postroll::CustomFootage.new("http://s3-s.animoto.com/Footage/wInVzO78f0SjP1GTFtfPrA/t.mp4?v=animotopro")
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            #custom_footage = Postroll::CustomFootage.new("http://s3-s.animoto.com/Footage/wInVzO78f0SjP1GTFtfPrA/t.mp4")
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            custom_footage = Postroll::CustomFootage.new("http://api.client.java.animoto.s3.amazonaws.com/test_assets/footage.mp4")
         | 
| 17 | 
            +
            custom_footage.start_time = 2.0
         | 
| 18 | 
            +
            custom_footage.duration = 3.0
         | 
| 19 | 
            +
             | 
| 20 | 
            +
             | 
| 21 | 
            +
            #application_data = {'application_data' => ['title', 'id', 'kind', 'type']}
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            #{'partner_metadata' => ['partner_user_id', 'commercial_use', 'partner_intent', application_data]}
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            app = {'title' => 'hello', 'id' => 'asdf', 'kind' => 'my', 'type' => 'video'}
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            metadata = {'partner_user_id' => '234', 'commercial_use' => 'our wish', 'partner_intent' => 'business', 'application_data' => app}
         | 
| 12 28 |  | 
| 13 29 | 
             
            # create a directing and rendering manifest with the video title and
         | 
| 14 30 | 
             
            # producer.  Also include rendering parameters like resolution, framerate,
         | 
| @@ -20,30 +36,36 @@ manifest = Manifests::DirectingAndRendering.new( | |
| 20 36 | 
             
              :pacing => "fast",
         | 
| 21 37 | 
             
              :framerate => 24,
         | 
| 22 38 | 
             
              :format => 'h264',
         | 
| 39 | 
            +
              :partner_metadata => metadata,
         | 
| 23 40 | 
             
              :postroll => custom_footage
         | 
| 24 41 | 
             
            )
         | 
| 25 42 |  | 
| 43 | 
            +
            id = { "partner_user_id" => "42-24010"}
         | 
| 44 | 
            +
             | 
| 26 45 | 
             
            # Add some images, text, and footage to our manifest.
         | 
| 27 46 |  | 
| 28 47 | 
             
            img1 = Assets::Image.new("http://cdn.toucharcade.com/wp-content/uploads/2012/12/hac1.jpg")
         | 
| 29 48 | 
             
            #img1.cover = "Doctorine of pace"
         | 
| 30 49 | 
             
            #img1.rotation = 2
         | 
| 31 50 | 
             
            #img1.spotlit = true
         | 
| 32 | 
            -
             | 
| 51 | 
            +
            img1.caption = "Birds can't walk"
         | 
| 33 52 |  | 
| 34 53 | 
             
            img2 = Assets::Image.new("http://api.client.java.animoto.s3.amazonaws.com/test_assets/image.jpg")
         | 
| 35 54 | 
             
            img3 = Assets::Image.new("http://blogs.independent.co.uk/wp-content/uploads/2012/12/some-girls-300x225.jpg")
         | 
| 36 55 |  | 
| 37 56 | 
             
            card1 = Assets::TitleCard.new("f1", "01234567890123456789")
         | 
| 38 | 
            -
             | 
| 57 | 
            +
            card2 = Assets::TitleCard.new("f1", "012sssh 256789")
         | 
| 58 | 
            +
            card3 = Assets::TitleCard.new("f1", "01234333333")
         | 
| 59 | 
            +
            footage1 = Assets::Footage.new("http://s3-s.animoto.com/Footage/wInVzO78f0SjP1GTFtfPrA/t.mp4")
         | 
| 39 60 |  | 
| 40 61 |  | 
| 41 62 | 
             
            manifest << img1
         | 
| 42 63 | 
             
            manifest << card1
         | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 64 | 
            +
            manifest << img2
         | 
| 65 | 
            +
            manifest << img3
         | 
| 66 | 
            +
            manifest << card2
         | 
| 67 | 
            +
            manifest << card3
         | 
| 68 | 
            +
            manifest << footage1
         | 
| 47 69 |  | 
| 48 70 | 
             
            # Setup the soundtrack.
         | 
| 49 71 | 
             
            manifest << Assets::Song.new("http://api.client.java.animoto.s3.amazonaws.com/test_assets/song.mp3", :artist => "Fishy Joe")
         | 
    
        data/lib/example2.rb
    ADDED
    
    | @@ -0,0 +1,63 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            require 'ruby-debug'
         | 
| 3 | 
            +
            require 'animoto/client'
         | 
| 4 | 
            +
            include Animoto
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            client = Client.new("bb0d0e005ac4012dc17712313b013462", "c0fe4cfca8bf544b8d0e687247a600ef55ff82e3")
         | 
| 7 | 
            +
            client.endpoint = "https://platform-staging.animoto.com" 
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            custom_footage = Postroll::CustomFootage.new("http://s3-s.animoto.com/Footage/wInVzO78f0SjP1GTFtfPrA/t.mp4?v=animotopro")
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            custom_footage = Postroll::CustomFootage.new("http://api.client.java.animoto.s3.amazonaws.com/test_assets/footage.mp4")
         | 
| 12 | 
            +
            custom_footage.start_time = 2.0
         | 
| 13 | 
            +
            custom_footage.duration = 3.0
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            metadata = {'partner_user_id' => '234', 'commercial_use' => 'our wish'}
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            manifest = Manifests::DirectingAndRendering.new(
         | 
| 18 | 
            +
              :title => "Amazing Venus3!",
         | 
| 19 | 
            +
              :resolution => "360p",
         | 
| 20 | 
            +
              :style => "original",
         | 
| 21 | 
            +
              :pacing => "fast",
         | 
| 22 | 
            +
              :framerate => 24,
         | 
| 23 | 
            +
              :format => 'h264',
         | 
| 24 | 
            +
              :partner_metadata => metadata,
         | 
| 25 | 
            +
              :postroll => custom_footage
         | 
| 26 | 
            +
            )
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            id = { "partner_user_id" => "42-24010"}
         | 
| 29 | 
            +
            manifest.partner_metadata = 'asdf'
         | 
| 30 | 
            +
            debugger
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            img1 = Assets::Image.new("http://cdn.toucharcade.com/wp-content/uploads/2012/12/hac1.jpg")
         | 
| 33 | 
            +
            img1.caption = "Birds can't walk"
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            img2 = Assets::Image.new("http://api.client.java.animoto.s3.amazonaws.com/test_assets/image.jpg")
         | 
| 36 | 
            +
            img3 = Assets::Image.new("http://blogs.independent.co.uk/wp-content/uploads/2012/12/some-girls-300x225.jpg")
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            card1 = Assets::TitleCard.new("f1", "01234567890123456789")
         | 
| 39 | 
            +
            card2 = Assets::TitleCard.new("f1", "012sssh 256789")
         | 
| 40 | 
            +
            card3 = Assets::TitleCard.new("f1", "01234333333")
         | 
| 41 | 
            +
            footage1 = Assets::Footage.new("http://s3-s.animoto.com/Footage/wInVzO78f0SjP1GTFtfPrA/t.mp4")
         | 
| 42 | 
            +
             | 
| 43 | 
            +
             | 
| 44 | 
            +
            manifest << img1
         | 
| 45 | 
            +
            manifest << card1
         | 
| 46 | 
            +
            manifest << img2
         | 
| 47 | 
            +
            manifest << img3
         | 
| 48 | 
            +
            manifest << card2
         | 
| 49 | 
            +
            manifest << card3
         | 
| 50 | 
            +
            manifest << footage1
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            manifest << Assets::Song.new("http://api.client.java.animoto.s3.amazonaws.com/test_assets/song.mp3", :artist => "Fishy Joe")
         | 
| 53 | 
            +
             | 
| 54 | 
            +
             | 
| 55 | 
            +
             | 
| 56 | 
            +
             | 
| 57 | 
            +
            dr_job = client.render!(manifest)
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            while dr_job.pending?
         | 
| 60 | 
            +
              sleep(1)
         | 
| 61 | 
            +
              puts "making it ready..."
         | 
| 62 | 
            +
              client.reload!(dr_job)
         | 
| 63 | 
            +
            end
         | 
| @@ -20,6 +20,17 @@ describe Animoto::Manifests::DirectingAndRendering do | |
| 20 20 | 
             
                  manifest.to_hash.should have_key('directing_and_rendering_job')
         | 
| 21 21 | 
             
                  manifest.to_hash['directing_and_rendering_job'].should be_a(Hash)
         | 
| 22 22 | 
             
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                describe "when the partner metadata is set" do
         | 
| 25 | 
            +
                  before do
         | 
| 26 | 
            +
                    manifest.partner_metadata = {'partner_user_id' => '234', 'commercial_use' => 'No'}
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  it "should have the HTTP callback URL in the job" do
         | 
| 30 | 
            +
                    manifest.to_hash['directing_and_rendering_job'].should have_key('partner_metadata')
         | 
| 31 | 
            +
                    manifest.to_hash['directing_and_rendering_job']['partner_metadata'].should == manifest.partner_metadata
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                end
         | 
| 23 34 |  | 
| 24 35 | 
             
                describe "when the callback url is set" do
         | 
| 25 36 | 
             
                  before do
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: animoto
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 15
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 1
         | 
| 8 8 | 
             
              - 5
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 1.5. | 
| 9 | 
            +
              - 6
         | 
| 10 | 
            +
              version: 1.5.6
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Animoto
         | 
| @@ -15,7 +15,7 @@ autorequire: | |
| 15 15 | 
             
            bindir: bin
         | 
| 16 16 | 
             
            cert_chain: []
         | 
| 17 17 |  | 
| 18 | 
            -
            date: 2013- | 
| 18 | 
            +
            date: 2013-07-24 00:00:00 Z
         | 
| 19 19 | 
             
            dependencies: 
         | 
| 20 20 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 21 21 | 
             
              name: json
         | 
| @@ -61,6 +61,7 @@ files: | |
| 61 61 | 
             
            - ./lib/animoto/manifests/rendering.rb
         | 
| 62 62 | 
             
            - ./lib/animoto/manifests/storyboard_bundling.rb
         | 
| 63 63 | 
             
            - ./lib/animoto/manifests/storyboard_unbundling.rb
         | 
| 64 | 
            +
            - ./lib/animoto/partner_metadata.rb
         | 
| 64 65 | 
             
            - ./lib/animoto/postroll.rb
         | 
| 65 66 | 
             
            - ./lib/animoto/postrolls/custom_footage.rb
         | 
| 66 67 | 
             
            - ./lib/animoto/resources/base.rb
         | 
| @@ -84,6 +85,7 @@ files: | |
| 84 85 | 
             
            - ./lib/animoto/support/string.rb
         | 
| 85 86 | 
             
            - ./lib/animoto.rb
         | 
| 86 87 | 
             
            - ./lib/example.rb
         | 
| 88 | 
            +
            - ./lib/example2.rb
         | 
| 87 89 | 
             
            - ./spec/animoto/assets/base_spec.rb
         | 
| 88 90 | 
             
            - ./spec/animoto/assets/footage_spec.rb
         | 
| 89 91 | 
             
            - ./spec/animoto/assets/image_spec.rb
         | 
| @@ -141,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 141 143 | 
             
            requirements: []
         | 
| 142 144 |  | 
| 143 145 | 
             
            rubyforge_project: 
         | 
| 144 | 
            -
            rubygems_version: 1.8. | 
| 146 | 
            +
            rubygems_version: 1.8.25
         | 
| 145 147 | 
             
            signing_key: 
         | 
| 146 148 | 
             
            specification_version: 3
         | 
| 147 149 | 
             
            summary: Client for working with the Animoto RESTful HTTP API
         |