Class: Sorenson::Services::Asset
- Defined in:
- lib/sorenson/services/asset.rb
Overview
Allows you to access the resources associated with a sorenson services asset. An asset currently refers to video content.
Instance Attribute Summary collapse
-
#abstract_file_id ⇒ Object
Returns the value of attribute abstract_file_id.
-
#account_id ⇒ Object
Returns the value of attribute account_id.
-
#application ⇒ Object
Returns the value of attribute application.
-
#audio_bitrate_mode ⇒ Object
Returns the value of attribute audio_bitrate_mode.
-
#audio_codec ⇒ Object
Returns the value of attribute audio_codec.
-
#audio_data_rate ⇒ Object
Returns the value of attribute audio_data_rate.
-
#author_id ⇒ Object
Returns the value of attribute author_id.
-
#date_last_modified ⇒ Object
Returns the value of attribute date_last_modified.
-
#date_retrieved ⇒ Object
Returns the value of attribute date_retrieved.
-
#description ⇒ Object
Returns the value of attribute description.
-
#direct_asset_url ⇒ Object
Returns the value of attribute direct_asset_url.
-
#display_name ⇒ Object
Returns the value of attribute display_name.
-
#embed_list ⇒ Object
Returns the value of attribute embed_list.
-
#encode_date ⇒ Object
Returns the value of attribute encode_date.
-
#file_size ⇒ Object
Returns the value of attribute file_size.
-
#frame_rate ⇒ Object
Returns the value of attribute frame_rate.
-
#group_id ⇒ Object
Returns the value of attribute group_id.
-
#height ⇒ Object
Returns the value of attribute height.
-
#id ⇒ Object
Returns the value of attribute id.
-
#media_type ⇒ Object
Returns the value of attribute media_type.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#number_of_views ⇒ Object
Returns the value of attribute number_of_views.
-
#password ⇒ Object
Returns the value of attribute password.
-
#permalink_location ⇒ Object
Returns the value of attribute permalink_location.
-
#status ⇒ Object
Returns the value of attribute status.
-
#streaming_server_and_video_path ⇒ Object
Returns the value of attribute streaming_server_and_video_path.
-
#thumbnail_image_url ⇒ Object
Returns the value of attribute thumbnail_image_url.
-
#version_id ⇒ Object
Returns the value of attribute version_id.
-
#video_bitrate_mode ⇒ Object
Returns the value of attribute video_bitrate_mode.
-
#video_codec ⇒ Object
Returns the value of attribute video_codec.
-
#video_data_rate ⇒ Object
Returns the value of attribute video_data_rate.
-
#video_duration ⇒ Object
Returns the value of attribute video_duration.
-
#video_guid ⇒ Object
Returns the value of attribute video_guid.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
-
.all(offset = nil, quantity = nil) ⇒ Object
Get all of the assets as a list of guids.
- .count ⇒ Object
- .find(id) ⇒ Object
- .find_all_by_flag(flag_name) ⇒ Object
-
.find_all_by_tag(tag_name) ⇒ Object
Get a list of asset guids by passing a tag name.
Instance Method Summary collapse
- #activate ⇒ Object
- #add_category(name) ⇒ Object
- #add_flags(flags) ⇒ Object
- #add_group(group) ⇒ Object
- #add_tags(tags) ⇒ Object
- #category ⇒ Object
- #deactivate ⇒ Object
- #delete_metadata(key) ⇒ Object
- #destroy ⇒ Object
- #embed_codes ⇒ Object
- #flags ⇒ Object
- #get_metadata_value(key) ⇒ Object
- #group ⇒ Object
-
#initialize(data) ⇒ Asset
constructor
A new instance of Asset.
- #preset_xml ⇒ Object
- #remove_category ⇒ Object
- #save(attributes = {}) ⇒ Object
- #set_metadata(key, value) ⇒ Object
- #tags ⇒ Object
Methods inherited from Base
delete_from, get_from, host, login_no_resource, parse_response, post_to, put_to, verify_account_settings
Constructor Details
#initialize(data) ⇒ Asset
Returns a new instance of Asset.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/sorenson/services/asset.rb', line 142 def initialize(data) @encode_date = data['encode_date'] @frame_rate = data['frame_rate'] @height = data['height'] @date_last_modified = data['date_last_modified'] @video_bitrate_mode = data['video_bitrate_mode'] @media_type = data['media_type'] @id = data['id'] @account_id = data['account_id'] @number_of_views = data['number_of_views'] @application = data['application'] @audio_codec = data['audio_codec'] @permalink_location = data['permalink_location'] @status = data['status'] @description = data['description'] @video_duration = data['video_duration'] @abstract_file_id = data['abstract_file_id'] @version_id = data['version_id'] @date_retrieved = data['date_retrieved'] @audio_data_rate = data['audio_data_rate'] @audio_bitrate_mode = data['audio_bitrate_mode'] @video_codec = data['video_codec'] @display_name = data['display_name'] @name = data['name'] @video_data_rate = data['video_data_rate'] @author_id = data['author_id'] @width = data['width'] @file_size = data['file_size'] @thumbnail_image_url = data['thumbnail_image_url'] @direct_asset_url = data['direct_asset_url'] @group_id = data['group_id'] @embed_list = data['embed_list'] @video_guid = @embed_list.empty? ? nil : @embed_list.to_a.first[1].match(/videoGUID=(.*?)&/)[1] end |
Instance Attribute Details
#abstract_file_id ⇒ Object
Returns the value of attribute abstract_file_id.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def abstract_file_id @abstract_file_id end |
#account_id ⇒ Object
Returns the value of attribute account_id.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def account_id @account_id end |
#application ⇒ Object
Returns the value of attribute application.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def application @application end |
#audio_bitrate_mode ⇒ Object
Returns the value of attribute audio_bitrate_mode.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def audio_bitrate_mode @audio_bitrate_mode end |
#audio_codec ⇒ Object
Returns the value of attribute audio_codec.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def audio_codec @audio_codec end |
#audio_data_rate ⇒ Object
Returns the value of attribute audio_data_rate.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def audio_data_rate @audio_data_rate end |
#author_id ⇒ Object
Returns the value of attribute author_id.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def @author_id end |
#date_last_modified ⇒ Object
Returns the value of attribute date_last_modified.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def date_last_modified @date_last_modified end |
#date_retrieved ⇒ Object
Returns the value of attribute date_retrieved.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def date_retrieved @date_retrieved end |
#description ⇒ Object
Returns the value of attribute description.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def description @description end |
#direct_asset_url ⇒ Object
Returns the value of attribute direct_asset_url.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def direct_asset_url @direct_asset_url end |
#display_name ⇒ Object
Returns the value of attribute display_name.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def display_name @display_name end |
#embed_list ⇒ Object
Returns the value of attribute embed_list.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def @embed_list end |
#encode_date ⇒ Object
Returns the value of attribute encode_date.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def encode_date @encode_date end |
#file_size ⇒ Object
Returns the value of attribute file_size.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def file_size @file_size end |
#frame_rate ⇒ Object
Returns the value of attribute frame_rate.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def frame_rate @frame_rate end |
#group_id ⇒ Object
Returns the value of attribute group_id.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def group_id @group_id end |
#height ⇒ Object
Returns the value of attribute height.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def height @height end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def id @id end |
#media_type ⇒ Object
Returns the value of attribute media_type.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def media_type @media_type end |
#metadata ⇒ Object
Returns the value of attribute metadata.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def name @name end |
#number_of_views ⇒ Object
Returns the value of attribute number_of_views.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def number_of_views @number_of_views end |
#password ⇒ Object
Returns the value of attribute password.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def password @password end |
#permalink_location ⇒ Object
Returns the value of attribute permalink_location.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def permalink_location @permalink_location end |
#status ⇒ Object
Returns the value of attribute status.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def status @status end |
#streaming_server_and_video_path ⇒ Object
Returns the value of attribute streaming_server_and_video_path.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def streaming_server_and_video_path @streaming_server_and_video_path end |
#thumbnail_image_url ⇒ Object
Returns the value of attribute thumbnail_image_url.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def thumbnail_image_url @thumbnail_image_url end |
#version_id ⇒ Object
Returns the value of attribute version_id.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def version_id @version_id end |
#video_bitrate_mode ⇒ Object
Returns the value of attribute video_bitrate_mode.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def video_bitrate_mode @video_bitrate_mode end |
#video_codec ⇒ Object
Returns the value of attribute video_codec.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def video_codec @video_codec end |
#video_data_rate ⇒ Object
Returns the value of attribute video_data_rate.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def video_data_rate @video_data_rate end |
#video_duration ⇒ Object
Returns the value of attribute video_duration.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def video_duration @video_duration end |
#video_guid ⇒ Object
Returns the value of attribute video_guid.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def video_guid @video_guid end |
#width ⇒ Object
Returns the value of attribute width.
9 10 11 |
# File 'lib/sorenson/services/asset.rb', line 9 def width @width end |
Class Method Details
.all(offset = nil, quantity = nil) ⇒ Object
Get all of the assets as a list of guids. Use offset and quantity to return subsets.
Sorenson::Services::Account.login('username', 'password')
assets = Sorenson::Services::Asset.all
names = assets.collect {|asset| asset.name}
=> names = ["name1", "name2"]
21 22 23 24 |
# File 'lib/sorenson/services/asset.rb', line 21 def self.all(offset = nil, quantity = nil) list = get_from("/assets", :offset => offset, :quantity => quantity)["asset_list"] list.collect {|a| new(a) } end |
.count ⇒ Object
39 40 41 |
# File 'lib/sorenson/services/asset.rb', line 39 def self.count Base.get_from("/assets/count")["count"] end |
.find(id) ⇒ Object
43 44 45 46 47 |
# File 'lib/sorenson/services/asset.rb', line 43 def self.find(id) data = get_from("/assets/#{id}") return nil if data[:status].eql?('invalid asset id') new(data) end |
.find_all_by_flag(flag_name) ⇒ Object
31 32 33 |
# File 'lib/sorenson/services/asset.rb', line 31 def self.find_all_by_flag(flag_name) get_from("/flags/#{flag_name}/assets", :account_id => account_id) end |
.find_all_by_tag(tag_name) ⇒ Object
Get a list of asset guids by passing a tag name
27 28 29 |
# File 'lib/sorenson/services/asset.rb', line 27 def self.find_all_by_tag(tag_name) get_from("/tags/#{tag_name}/assets", :account_id => account_id) end |
Instance Method Details
#activate ⇒ Object
57 58 59 |
# File 'lib/sorenson/services/asset.rb', line 57 def activate Base.post_to("/assets/#{id}/activate")["status"] end |
#add_category(name) ⇒ Object
69 70 71 |
# File 'lib/sorenson/services/asset.rb', line 69 def add_category(name) Category.new(Base.post_to("/assets/#{id}/categories", :category => {:name => name})) end |
#add_flags(flags) ⇒ Object
97 98 99 |
# File 'lib/sorenson/services/asset.rb', line 97 def add_flags(flags) Base.post_to("/assets/#{id}/flags", {:flag_list => flags}) end |
#add_group(group) ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/sorenson/services/asset.rb', line 124 def add_group(group) data = Base.put_to("/groups/#{group.id}/assets/#{id}") if data['status'].eql?('Success') @group_id = group.id else data['status'] end end |
#add_tags(tags) ⇒ Object
89 90 91 |
# File 'lib/sorenson/services/asset.rb', line 89 def () Base.post_to("/assets/#{id}/tags", { :tag_list => }) end |
#category ⇒ Object
79 80 81 82 83 |
# File 'lib/sorenson/services/asset.rb', line 79 def category data = Base.get_from("/assets/#{id}/categories") return nil if data["result"] == 'failure' Category.new(data) end |
#deactivate ⇒ Object
53 54 55 |
# File 'lib/sorenson/services/asset.rb', line 53 def deactivate Base.post_to("/assets/#{id}/deactivate")["status"] end |
#delete_metadata(key) ⇒ Object
101 102 103 |
# File 'lib/sorenson/services/asset.rb', line 101 def (key) Base.delete_from("/assets/#{id}/metadata/#{key}")[:status] end |
#destroy ⇒ Object
61 62 63 |
# File 'lib/sorenson/services/asset.rb', line 61 def destroy Base.delete_from("/assets/#{id}")["status"] end |
#embed_codes ⇒ Object
85 86 87 |
# File 'lib/sorenson/services/asset.rb', line 85 def Base.get_from("/assets/#{id}/embed_codes")['embed_codes'] end |
#flags ⇒ Object
93 94 95 |
# File 'lib/sorenson/services/asset.rb', line 93 def flags Base.get_from("/assets/#{id}/flags") end |
#get_metadata_value(key) ⇒ Object
105 106 107 108 109 |
# File 'lib/sorenson/services/asset.rb', line 105 def (key) data = Base.get_from("/assets/#{id}/metadata/#{key}") return nil if data["status"] == 404 data["result"] end |
#group ⇒ Object
119 120 121 122 |
# File 'lib/sorenson/services/asset.rb', line 119 def group return nil if @group_id.nil? Group.new(Base.get_from("/groups/#{group_id}")['group']) end |
#preset_xml ⇒ Object
49 50 51 |
# File 'lib/sorenson/services/asset.rb', line 49 def preset_xml Base.get_from("/assets/#{id}/preset_xml")["preset_xml"] end |
#remove_category ⇒ Object
73 74 75 76 77 |
# File 'lib/sorenson/services/asset.rb', line 73 def remove_category category = self.category return true if category.nil? Base.delete_from("/assets/#{id}/categories/#{category.id}") end |
#save(attributes = {}) ⇒ Object
65 66 67 |
# File 'lib/sorenson/services/asset.rb', line 65 def save(attributes={}) Base.put_to("/assets/#{id}", :asset => {:name => name, :password => password, :description => description}.merge(attributes)) end |