Sha256: 819cbfd8e5766d87e8b8ef12c434a6ee177fa12f6f44b4aa7a8b1ad9ef8dd581

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 KB

Contents

=begin
 OpenTok Ruby Library v0.90.0
 http://www.tokbox.com/

 Copyright 2010 - 2011, TokBox, Inc.
=end

module OpenTok
  class Archive
    attr_accessor :archive_id, :archive_title, :resources, :timeline

    def initialize(archive_id, archive_title, resources, timeline, api_url, token)
      @archive_id = archive_id
      @archive_title = archive_title
      @resources = resources
      @timeline = timeline
      @api_url = api_url
      @token = token
    end

    def do_request(path, token)
      Request.new(@api_url, token).fetch(path)
    end

    def download_archive_url(video_id, token="")
      if token.empty?
        # this token check supports previous implementation of download_archive_url
        "#{@api_url}/archive/url/#{@archive_id}/#{video_id}"
      else
        do_request "/archive/url/#{@archive_id}/#{video_id}", token
      end
    end

    alias_method :downloadArchiveURL, :download_archive_url

    def self.parse_manifest(manifest, api_url, token)
      archive_id = manifest.attributes['archiveid']
      archive_title = manifest.attributes['title']

      resources = []
      manifest.get_elements('resources')[0].get_elements('video').each do |video|
        resources << ArchiveVideoResource.parseXML(video)
      end

      timeline = []
      manifest.get_elements('timeline')[0].get_elements('event').each do |event|
        timeline << ArchiveTimelineEvent.parseXML(event)
      end

      Archive.new archive_id, archive_title, resources, timeline, api_url, token
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opentok-0.1.3 lib/open_tok/archive.rb
opentok-0.1.2 lib/open_tok/archive.rb
opentok-0.1.1 lib/open_tok/archive.rb
opentok-0.1.0 lib/open_tok/archive.rb