three_sixty 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1 +1,3 @@
1
- 3/22/2010 - Bundled existing code into formal gem hosted on Sorenson's gemcutter
1
+ 3/22/2010 1.0.1 - Fixed bug in Ruby 1.8.6
2
+
3
+ 3/22/2010 1.0.0 - Bundled existing code into formal gem hosted on Sorenson's gemcutter
data/HOW_TO_BUILD.txt ADDED
@@ -0,0 +1,26 @@
1
+ 1. GET INTO THIS DIRECTORY
2
+ cd three_sixty_gem
3
+
4
+ 1.5. MAKE SURE YOU INCREMENT THE VERSION NUMBER in the Rakefile!!:);)!!!!!
5
+
6
+ 2. BUILD THE MANIFEST FILE
7
+ rake manifest
8
+
9
+ 3. BUILD THE GEMSPEC (BE SURE TO INCREMENT THE VERSION # IN RAKEFILE)
10
+ rake build_gemspec
11
+
12
+ 4. INSTALL THE GEM LOCALLY TO TEST
13
+ rake install three_sixty.gemspec
14
+
15
+ 5. CREATE THE GEM INTO PKG DIRECTORY
16
+ rake gem
17
+
18
+ 6. GET INTO PKG DIRECTOY
19
+ cd pkg
20
+
21
+ 7. PUSH GEM TO GEMCUTTER (MAKE SURE GEMCUTTER GEM IS INSTALLED)
22
+ gem install gemcutter (IF NEEDED)
23
+ gem push three_sixty-0.0.XXXXXXXXXX.gem (MAKE SURE YOU INCREMENTED THE VERSION NUMBER in the Rakefile!!!)
24
+
25
+ 8. INSTALL THE FINISHED GEM LOCALLY
26
+ gem install three_sixty
data/Manifest CHANGED
@@ -1,4 +1,6 @@
1
1
  CHANGELOG
2
+ HOW_TO_BUILD.txt
3
+ Manifest
2
4
  README
3
5
  Rakefile
4
6
  lib/sorenson/threesixty.rb
@@ -22,4 +24,4 @@ spec/spec.opts
22
24
  spec/spec_helper.rb
23
25
  spec/uploader_spec.rb
24
26
  tasks/rspec.rake
25
- Manifest
27
+ three_sixty.gemspec
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'cucumber'
7
7
  require 'cucumber/rake/task'
8
8
  require 'echoe'
9
9
 
10
- Echoe.new('three_sixty', '1.0.0') do |p|
10
+ Echoe.new('three_sixty', '1.0.1') do |p|
11
11
  p.description = "Ruby bindings for Sorenson 360 Backend"
12
12
  p.url = "https://github.com/sorenson/ThreeSixtyServices-Internal"
13
13
  p.author = "Sorenson Media"
@@ -1,152 +1,178 @@
1
+ # Sorenson Namespace
1
2
  module Sorenson
2
- module ThreeSixty
3
+ # Sorenson Services Namespace
4
+ module Services
5
+ # Allows you to access the resources associated with a sorenson services asset. An asset currently refers to video content.
3
6
  class Asset < Base
4
7
 
5
- # Attributes
6
- attr_accessor :account, :encodeDate, :frameRate, :height, :dateLastModified, :videoBitrateMode, :mediaType, :id, :accountId, :numberOfViews, :presetXml, :application, :audioCodec, :permalinkLocation, :status, :description, :videoDuration, :abstractFileId, :versionId, :dateRetrieved, :audioDataRate, :audioBitrateMode, :videoCodec, :displayName, :name, :videoDataRate, :authorId, :width, :fileSize, :defaultEmbed, :thumbnailImageUrl, :filters, :embedList, :httpLocation, :directAssetUrl, :subaccountId, :videoGuid
7
-
8
- # Class Methods
9
- def self.find_all(account, offset = nil, quantity = nil)
10
- data = post_to("/api/getMediaList?offset=#{offset}&quantity=#{quantity}&accountId=#{account.id}&sessionId=#{account.sessionId}&status=Live&sort=uploadDate")
11
-
12
- assets = []
13
-
14
- data['mediaList'].each do |entry|
15
- assets << Asset.new(account, entry) if account.subaccountId.blank? || account.subaccountId == entry['subaccountId']
16
- end
17
-
18
- assets
19
- end
20
-
21
- def self.find(account, id)
22
- data = post_to("/api/getAsset?mguid=#{id}&sessionId=#{account.sessionId}")
23
- Asset.new(account, data['media'].merge({'thumbLocation' => data['thumbLocation'], 'permalink' => data['permalinkLocation']}))
24
- end
25
-
26
- def self.get_embed_codes(video_guid, sessionId, account)
27
- data = post_to("/api/getAllEmbedcodes?vguid=#{video_guid}&sessionId=#{account.sessionId}")
28
- data['embedList']
29
- end
30
-
31
- def self.get_streaming_server_url
32
- "rtmp://cdnstreamingvideos.sorensonmedia.com/cfx/st"
33
- end
34
-
35
- # Instance Methods
36
- def initialize(account, data)
37
- self.account = account
38
- self.presetXml = data['presetXml']
39
- self.subaccountId = data['subaccountId']
40
- self.encodeDate = data['encodeDate']
41
- self.frameRate = data['frameRate']
42
- self.height = data['height']
43
- self.dateLastModified = data['dateLastModified']
44
- self.videoBitrateMode = data['videoBitrateMode']
45
- self.mediaType = data['mediaType']
46
- self.id = data['id']
47
- self.accountId = data['accountId']
48
- self.numberOfViews = data['numberOfViews']
49
- self.application = data['application']
50
- self.audioCodec = data['audioCodec']
51
- self.permalinkLocation = data['permalink']
52
- self.status = data['status']
53
- self.description = data['description']
54
- self.videoDuration = data['videoDuration']
55
- self.abstractFileId = data['abstractFileId']
56
- self.versionId = data['versionId']
57
- self.dateRetrieved = data['dateRetrieved']
58
- self.audioDataRate = data['audioDataRate']
59
- self.audioBitrateMode = data['audioBitrateMode']
60
- self.videoCodec = data['videoCodec']
61
- self.displayName = data['displayName']
62
- self.name = data['name']
63
- self.videoDataRate = data['videoDataRate']
64
- self.authorId = data['authorId']
65
- self.width = data['width']
66
- self.fileSize = data['fileSize']
67
- self.thumbnailImageUrl = data['thumbnail']['httpLocation'] if data['thumbnail']
68
- self.thumbnailImageUrl = data['thumbLocation'] if data['thumbLocation']
69
- self.httpLocation = data['httpLocation']
70
- self.directAssetUrl = "http://360.sorensonmedia.com/redirector/fetchFile?vguid=#{self.id}"
71
- self.videoGuid
72
-
73
- self.filters = []
74
- if data['filters']
75
- data['filters'].each do |filter|
76
- self.filters << filter['filterDescription']
77
- end
78
- end
79
-
80
- self.embedList = {}
81
- get_embed_codes
82
-
83
- self.videoGuid = self.embedList.empty? ? nil : self.embedList.first[1].match(/videoGUID=(.*?)&/)[1]
8
+
9
+ attr_accessor :encode_date, :frame_rate, :height, :date_last_modified, :video_bitrate_mode,
10
+ :media_type, :id, :account_id, :number_of_views, :application, :audio_codec,
11
+ :permalink_location, :status, :description, :video_duration, :abstract_file_id, :version_id,
12
+ :date_retrieved, :audio_data_rate, :audio_bitrate_mode, :video_codec, :display_name, :name,
13
+ :video_data_rate, :author_id, :width, :file_size, :thumbnail_image_url, :direct_asset_url,
14
+ :password, :metadata, :embed_list, :group_id, :video_guid, :streaming_server_and_video_path
15
+
16
+ # Get all of the assets as a list of guids. Use offset and quantity to return subsets.
17
+ # Sorenson::Services::Account.login('username', 'password')
18
+ # assets = Sorenson::Services::Asset.all
19
+ # names = assets.collect {|asset| asset.name}
20
+ # => names = ["name1", "name2"]
21
+ def self.all(offset = nil, quantity = nil)
22
+ list = get_from("/assets", :offset => offset, :quantity => quantity)["asset_list"]
23
+ list.collect {|a| new(a) }
24
+ end
25
+
26
+ # Get a list of asset guids by passing a tag name
27
+ def self.find_all_by_tag(tag_name)
28
+ get_from("/tags/#{tag_name}/assets", :account_id => account_id)
84
29
  end
85
30
 
86
- def get_streaming_video_path
87
- data = post_to("/api/getPlayerData?vguid=#{self.videoGuid}&cms=true")
88
- data['media']['accessLocation']['s3KeyName']
31
+ def self.find_all_by_flag(flag_name)
32
+ get_from("/flags/#{flag_name}/assets", :account_id => account_id)
33
+ end
34
+
35
+ def tags
36
+ Base.get_from("/assets/#{id}/tags")
37
+ end
38
+
39
+ def self.count
40
+ Base.get_from("/assets/count")["count"]
41
+ end
42
+
43
+ def self.find(id)
44
+ data = get_from("/assets/#{id}")
45
+ return nil if data[:status].eql?('invalid asset id')
46
+ new(data)
89
47
  end
90
48
 
91
- def delete
92
- data = post_to("/api/deleteAsset?fileVersionId=#{id}&sessionId=#{account.sessionId}")
49
+ def preset_xml
50
+ Base.get_from("/assets/#{id}/preset_xml")["preset_xml"]
93
51
  end
94
-
52
+
95
53
  def deactivate
96
- data = post_to("/api/deactivateAsset?fileVersionId=#{id}&sessionId=#{account.sessionId}")
54
+ Base.post_to("/assets/#{id}/deactivate")["status"]
97
55
  end
98
-
56
+
99
57
  def activate
100
- data = post_to("/api/activateAsset?fileVersionId=#{id}&sessionId=#{account.sessionId}")
58
+ Base.post_to("/assets/#{id}/activate")["status"]
59
+ end
60
+
61
+ def destroy
62
+ Base.delete_from("/assets/#{id}")["status"]
63
+ end
64
+
65
+ def save(attributes={})
66
+ Base.put_to("/assets/#{id}", :asset => {:name => name, :password => password, :description => description}.merge(attributes))
67
+ end
68
+
69
+ def add_category(name)
70
+ Category.new(Base.post_to("/assets/#{id}/categories", :category => {:name => name}))
71
+ end
72
+
73
+ def remove_category
74
+ category = self.category
75
+ return true if category.nil?
76
+ Base.delete_from("/assets/#{id}/categories/#{category.id}")
101
77
  end
102
78
 
103
- def setName(name)
104
- data = post_to("/api/setAssetName?fileVersionId=#{id}&newName=#{name}&sessionId=#{account.sessionId}")
79
+ def category
80
+ data = Base.get_from("/assets/#{id}/categories")
81
+ return nil if data["result"] == 'failure'
82
+ Category.new(data)
105
83
  end
106
84
 
107
- def setDescription(description)
108
- data = post_to("/api/setAssetDescription?fileVersionId=#{id}&newDescription=#{description}&sessionId=#{account.sessionId}")
85
+ def embed_codes
86
+ Base.get_from("/assets/#{id}/embed_codes")['embed_codes']
109
87
  end
110
-
111
- def setPassword(password)
112
- data = nil
113
- if password == '' || password.nil?
114
- data = post_to("/api/removeAssetSecurity?fileVersionId=#{id}&security=#{password}&sessionId=#{account.sessionId}")
88
+
89
+ def add_tags(tags)
90
+ Base.post_to("/assets/#{id}/tags", { :tag_list => tags })
91
+ end
92
+
93
+ def flags
94
+ Base.get_from("/assets/#{id}/flags")
95
+ end
96
+
97
+ def add_flags(flags)
98
+ Base.post_to("/assets/#{id}/flags", {:flag_list => flags})
99
+ end
100
+
101
+ def delete_metadata(key)
102
+ Base.delete_from("/assets/#{id}/metadata/#{key}")[:status]
103
+ end
104
+
105
+ def get_metadata_value(key)
106
+ data = Base.get_from("/assets/#{id}/metadata/#{key}")
107
+ return nil if data["status"] == 404
108
+ data["result"]
109
+ end
110
+
111
+ def set_metadata(key, value)
112
+ data = Base.post_to("/assets/#{id}/metadata", {:key => key, :value => value})
113
+ end
114
+
115
+ def metadata
116
+ Base.get_from("/assets/#{id}/metadata")
117
+ end
118
+
119
+ def group
120
+ return nil if @group_id.nil?
121
+ Group.new(Base.get_from("/groups/#{group_id}")['group'])
122
+ end
123
+
124
+ def add_group(group)
125
+ data = Base.put_to("/groups/#{group.id}/assets/#{id}")
126
+ if data['status'].eql?('Success')
127
+ @group_id = group.id
115
128
  else
116
- data = post_to("/api/setAssetSecurity?fileVersionId=#{id}&security=#{password}&sessionId=#{account.sessionId}")
129
+ data['status']
117
130
  end
118
- data
119
- end
120
-
121
- def getAllSubaccounts
122
- data = post_to("/api/getAllSubaccount?accountId=#{id}&sessionId=#{sessionId}")
123
- data
124
- end
125
-
126
- private
127
- def get_embed_codes
128
- data = post_to("/api/getAllEmbedcodes?vguid=#{id}&sessionId=#{account.sessionId}")
129
-
130
- if data['embedList']
131
- data['embedList'].each do |embed|
132
- embed =~ /width="(\d+)"/
133
- width = $1
134
-
135
- embed =~ /height="(\d+)"/
136
- height = $1
137
-
138
- ratio = (width.to_f / height.to_f)
139
-
140
- aspect = (ratio <= 1.33 ? 'Full Screen' : 'Widescreen')
141
-
142
- self.embedList["#{width}x#{height} - #{aspect}"] = embed
143
-
144
- end
131
+ end
132
+
133
+ def streaming_server_and_video_path
134
+ data = Base.get_from("/videos/#{id}/streaming_url")
135
+ if data['status'].eql?("not found")
136
+ nil
137
+ else
138
+ data
145
139
  end
146
-
147
- self.defaultEmbed = data['defaultEmbed']
148
140
  end
149
141
 
142
+ def initialize(data)
143
+ @encode_date = data['encode_date']
144
+ @frame_rate = data['frame_rate']
145
+ @height = data['height']
146
+ @date_last_modified = data['date_last_modified']
147
+ @video_bitrate_mode = data['video_bitrate_mode']
148
+ @media_type = data['media_type']
149
+ @id = data['id']
150
+ @account_id = data['account_id']
151
+ @number_of_views = data['number_of_views']
152
+ @application = data['application']
153
+ @audio_codec = data['audio_codec']
154
+ @permalink_location = data['permalink_location']
155
+ @status = data['status']
156
+ @description = data['description']
157
+ @video_duration = data['video_duration']
158
+ @abstract_file_id = data['abstract_file_id']
159
+ @version_id = data['version_id']
160
+ @date_retrieved = data['date_retrieved']
161
+ @audio_data_rate = data['audio_data_rate']
162
+ @audio_bitrate_mode = data['audio_bitrate_mode']
163
+ @video_codec = data['video_codec']
164
+ @display_name = data['display_name']
165
+ @name = data['name']
166
+ @video_data_rate = data['video_data_rate']
167
+ @author_id = data['author_id']
168
+ @width = data['width']
169
+ @file_size = data['file_size']
170
+ @thumbnail_image_url = data['thumbnail_image_url']
171
+ @direct_asset_url = data['direct_asset_url']
172
+ @group_id = data['group_id']
173
+ @embed_list = data['embed_list']
174
+ @video_guid = @embed_list.empty? ? nil : @embed_list.to_a.first[1].match(/videoGUID=(.*?)&/)[1]
175
+ end
150
176
  end
151
177
  end
152
178
  end
data/three_sixty.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{three_sixty}
5
- s.version = "1.0.0"
5
+ s.version = "1.0.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Sorenson Media"]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.description = %q{Ruby bindings for Sorenson 360 Backend}
11
11
  s.email = %q{video@sorensonmedia.com}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "README", "lib/sorenson/threesixty.rb", "lib/sorenson/threesixty/account.rb", "lib/sorenson/threesixty/account_summary.rb", "lib/sorenson/threesixty/asset.rb", "lib/sorenson/threesixty/asset_metrics.rb", "lib/sorenson/threesixty/base.rb", "lib/sorenson/threesixty/format_constraint.rb", "lib/sorenson/threesixty/rate_plan.rb", "lib/sorenson/threesixty/subaccount.rb", "lib/sorenson/threesixty/uploader.rb", "tasks/rspec.rake"]
13
- s.files = ["CHANGELOG", "README", "Rakefile", "lib/sorenson/threesixty.rb", "lib/sorenson/threesixty/account.rb", "lib/sorenson/threesixty/account_summary.rb", "lib/sorenson/threesixty/asset.rb", "lib/sorenson/threesixty/asset_metrics.rb", "lib/sorenson/threesixty/base.rb", "lib/sorenson/threesixty/format_constraint.rb", "lib/sorenson/threesixty/rate_plan.rb", "lib/sorenson/threesixty/subaccount.rb", "lib/sorenson/threesixty/uploader.rb", "spec/account_spec.rb", "spec/account_summary_spec.rb", "spec/asset_metrics_spec.rb", "spec/asset_spec.rb", "spec/base_spec.rb", "spec/format_constraint_spec.rb", "spec/rate_plan_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/uploader_spec.rb", "tasks/rspec.rake", "Manifest", "three_sixty.gemspec"]
13
+ s.files = ["CHANGELOG", "HOW_TO_BUILD.txt", "Manifest", "README", "Rakefile", "lib/sorenson/threesixty.rb", "lib/sorenson/threesixty/account.rb", "lib/sorenson/threesixty/account_summary.rb", "lib/sorenson/threesixty/asset.rb", "lib/sorenson/threesixty/asset_metrics.rb", "lib/sorenson/threesixty/base.rb", "lib/sorenson/threesixty/format_constraint.rb", "lib/sorenson/threesixty/rate_plan.rb", "lib/sorenson/threesixty/subaccount.rb", "lib/sorenson/threesixty/uploader.rb", "spec/account_spec.rb", "spec/account_summary_spec.rb", "spec/asset_metrics_spec.rb", "spec/asset_spec.rb", "spec/base_spec.rb", "spec/format_constraint_spec.rb", "spec/rate_plan_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/uploader_spec.rb", "tasks/rspec.rake", "three_sixty.gemspec"]
14
14
  s.homepage = %q{https://github.com/sorenson/ThreeSixtyServices-Internal}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Three_sixty", "--main", "README"]
16
16
  s.require_paths = ["lib"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: three_sixty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sorenson Media
@@ -54,6 +54,8 @@ extra_rdoc_files:
54
54
  - tasks/rspec.rake
55
55
  files:
56
56
  - CHANGELOG
57
+ - HOW_TO_BUILD.txt
58
+ - Manifest
57
59
  - README
58
60
  - Rakefile
59
61
  - lib/sorenson/threesixty.rb
@@ -77,7 +79,6 @@ files:
77
79
  - spec/spec_helper.rb
78
80
  - spec/uploader_spec.rb
79
81
  - tasks/rspec.rake
80
- - Manifest
81
82
  - three_sixty.gemspec
82
83
  has_rdoc: true
83
84
  homepage: https://github.com/sorenson/ThreeSixtyServices-Internal