Class: Sorenson::ThreeSixty::Asset

Inherits:
Base
  • Object
show all
Defined in:
lib/sorenson/threesixty/asset.rb

Constant Summary

Constants inherited from Base

Base::TOKEN_SALT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

debug=, debug?, host, #post_to, post_to, protocol, token_for, use_ssl=, use_ssl?

Constructor Details

#initialize(account, data) ⇒ Asset

Instance Methods



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/sorenson/threesixty/asset.rb', line 36

def initialize(, data)
  self.                = 
  self.presetXml              = data['presetXml']
  self.subaccountId           = data['subaccountId']
  self.encodeDate             = data['encodeDate']
  self.frameRate              = data['frameRate']
  self.height                 = data['height']
  self.dateLastModified       = data['dateLastModified']
  self.videoBitrateMode       = data['videoBitrateMode']
  self.mediaType              = data['mediaType']
  self.id                     = data['id']
  self.accountId              = data['accountId']
  self.numberOfViews          = data['numberOfViews']
  self.application            = data['application']
  self.audioCodec             = data['audioCodec']
  self.permalinkLocation      = data['permalink']
  self.status                 = data['status']
  self.description            = data['description']
  self.videoDuration          = data['videoDuration']
  self.abstractFileId         = data['abstractFileId']
  self.versionId              = data['versionId']
  self.dateRetrieved          = data['dateRetrieved']
  self.audioDataRate          = data['audioDataRate']
  self.audioBitrateMode       = data['audioBitrateMode']
  self.videoCodec             = data['videoCodec']
  self.displayName            = data['displayName']
  self.name                   = data['name']
  self.videoDataRate          = data['videoDataRate']
  self.authorId               = data['authorId']
  self.width                  = data['width']
  self.fileSize               = data['fileSize']
  self.thumbnailImageUrl      = data['thumbnail']['httpLocation'] if data['thumbnail']
  self.thumbnailImageUrl      = data['thumbLocation'] if data['thumbLocation']
  self.httpLocation           = data['httpLocation']
  self.directAssetUrl         = "http://360.sorensonmedia.com/redirector/fetchFile?vguid=#{self.id}"
  self.videoGuid              

  self.filters = []
  if data['filters']
    data['filters'].each do |filter|
      self.filters << filter['filterDescription']
    end
  end
  
  self.embedList = {}
  get_embed_codes
  
  self.videoGuid = self.embedList.empty? ? nil : self.embedList.to_a.first[1].match(/videoGUID=(.*?)&/)[1]
end

Instance Attribute Details

#abstractFileIdObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def abstractFileId
  @abstractFileId
end

#accountObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def 
  @account
end

#accountIdObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def accountId
  @accountId
end

#applicationObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def application
  @application
end

#audioBitrateModeObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def audioBitrateMode
  @audioBitrateMode
end

#audioCodecObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def audioCodec
  @audioCodec
end

#audioDataRateObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def audioDataRate
  @audioDataRate
end

#authorIdObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def authorId
  @authorId
end

#dateLastModifiedObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def dateLastModified
  @dateLastModified
end

#dateRetrievedObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def dateRetrieved
  @dateRetrieved
end

#defaultEmbedObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def defaultEmbed
  @defaultEmbed
end

#descriptionObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def description
  @description
end

#directAssetUrlObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def directAssetUrl
  @directAssetUrl
end

#displayNameObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def displayName
  @displayName
end

#embedListObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def embedList
  @embedList
end

#encodeDateObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def encodeDate
  @encodeDate
end

#fileSizeObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def fileSize
  @fileSize
end

#filtersObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def filters
  @filters
end

#frameRateObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def frameRate
  @frameRate
end

#heightObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def height
  @height
end

#httpLocationObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def httpLocation
  @httpLocation
end

#idObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def id
  @id
end

#mediaTypeObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def mediaType
  @mediaType
end

#nameObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def name
  @name
end

#numberOfViewsObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def numberOfViews
  @numberOfViews
end

#permalinkLocationObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def permalinkLocation
  @permalinkLocation
end

#presetXmlObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def presetXml
  @presetXml
end

#statusObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def status
  @status
end

#subaccountIdObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def subaccountId
  @subaccountId
end

#thumbnailImageUrlObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def thumbnailImageUrl
  @thumbnailImageUrl
end

#versionIdObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def versionId
  @versionId
end

#videoBitrateModeObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def videoBitrateMode
  @videoBitrateMode
end

#videoCodecObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def videoCodec
  @videoCodec
end

#videoDataRateObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def videoDataRate
  @videoDataRate
end

#videoDurationObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def videoDuration
  @videoDuration
end

#videoGuidObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def videoGuid
  @videoGuid
end

#widthObject

Attributes



6
7
8
# File 'lib/sorenson/threesixty/asset.rb', line 6

def width
  @width
end

Class Method Details

.find(account, id) ⇒ Object



21
22
23
24
# File 'lib/sorenson/threesixty/asset.rb', line 21

def self.find(, id)
  data = post_to("/api/getAsset?mguid=#{id}&sessionId=#{.sessionId}")
  Asset.new(, data['media'].merge({'thumbLocation' => data['thumbLocation'], 'permalink' => data['permalinkLocation']}))
end

.find_all(account, offset = nil, quantity = nil) ⇒ Object

Class Methods



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sorenson/threesixty/asset.rb', line 9

def self.find_all(, offset = nil, quantity = nil)
  data = post_to("/api/getMediaList?offset=#{offset}&quantity=#{quantity}&accountId=#{.id}&sessionId=#{.sessionId}&status=Live&sort=uploadDate")
  
  assets = []
  
  data['mediaList'].each do |entry|
    assets << Asset.new(, entry) if .subaccountId.blank? || .subaccountId == entry['subaccountId']
  end
  
  assets
end

.get_embed_codes(video_guid, sessionId, account) ⇒ Object



26
27
28
29
# File 'lib/sorenson/threesixty/asset.rb', line 26

def self.get_embed_codes(video_guid, sessionId, )
  data = post_to("/api/getAllEmbedcodes?vguid=#{video_guid}&sessionId=#{.sessionId}")
  data['embedList']
end

.get_streaming_server_urlObject



31
32
33
# File 'lib/sorenson/threesixty/asset.rb', line 31

def self.get_streaming_server_url
  "rtmp://cdnstreamingvideos.sorensonmedia.com/cfx/st" 
end

Instance Method Details

#activateObject



99
100
101
# File 'lib/sorenson/threesixty/asset.rb', line 99

def activate
  data = post_to("/api/activateAsset?fileVersionId=#{id}&sessionId=#{.sessionId}")
end

#deactivateObject



95
96
97
# File 'lib/sorenson/threesixty/asset.rb', line 95

def deactivate
  data = post_to("/api/deactivateAsset?fileVersionId=#{id}&sessionId=#{.sessionId}")
end

#deleteObject



91
92
93
# File 'lib/sorenson/threesixty/asset.rb', line 91

def delete
  data = post_to("/api/deleteAsset?fileVersionId=#{id}&sessionId=#{.sessionId}")
end

#get_streaming_video_pathObject



86
87
88
89
# File 'lib/sorenson/threesixty/asset.rb', line 86

def get_streaming_video_path
  data = post_to("/api/getPlayerData?vguid=#{self.videoGuid}&cms=true") 
  data['media']['accessLocation']['s3KeyName']
end

#getAllSubaccountsObject



121
122
123
124
# File 'lib/sorenson/threesixty/asset.rb', line 121

def getAllSubaccounts
  data = post_to("/api/getAllSubaccount?accountId=#{id}&sessionId=#{sessionId}")
  data
end

#setDescription(description) ⇒ Object



107
108
109
# File 'lib/sorenson/threesixty/asset.rb', line 107

def setDescription(description)
  data = post_to("/api/setAssetDescription?fileVersionId=#{id}&newDescription=#{description}&sessionId=#{.sessionId}")
end

#setName(name) ⇒ Object



103
104
105
# File 'lib/sorenson/threesixty/asset.rb', line 103

def setName(name)
  data = post_to("/api/setAssetName?fileVersionId=#{id}&newName=#{name}&sessionId=#{.sessionId}")
end

#setPassword(password) ⇒ Object



111
112
113
114
115
116
117
118
119
# File 'lib/sorenson/threesixty/asset.rb', line 111

def setPassword(password)
  data = nil
  if password == '' || password.nil?
    data = post_to("/api/removeAssetSecurity?fileVersionId=#{id}&security=#{password}&sessionId=#{.sessionId}")
  else
    data = post_to("/api/setAssetSecurity?fileVersionId=#{id}&security=#{password}&sessionId=#{.sessionId}")
  end
  data
end