envoi-mam-agent 1.1.0

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.
@@ -0,0 +1,117 @@
1
+ module Envoi
2
+
3
+ module Mam
4
+
5
+ class Wiredrive
6
+
7
+ class Agent < Envoi::Mam::Agent
8
+
9
+ def after_initialize
10
+
11
+ end
12
+
13
+ def initialize_api_client(args = {})
14
+ @api_client = args[:api_client] || begin
15
+ client_args = {}
16
+ Ubiquity::Wiredrive::API::V3::Client.new(client_args)
17
+ end
18
+ end
19
+
20
+ def download(args = {})
21
+
22
+ presentation_invitation_token = args[:presentation_invitation_token]
23
+ if presentation_invitation_token
24
+ presentation_password = args[:presentation_password]
25
+ r = api_client.presentation_get_using_token(presentation_invitation_token, presentation_password)
26
+
27
+ end
28
+
29
+ end
30
+
31
+ # Downloads a file from a URI or file location and saves it to a local path
32
+ #
33
+ # @param [String] download_file_path The source path of the file being downloaded
34
+ # @param [String] destination_file_path The destination path for the file being downloaded
35
+ # @param [Boolean] overwrite Determines if the destination file will be overwritten if it is found to exist
36
+ #
37
+ # @return [Hash]
38
+ # * :download_file_path [String] The source path of the file being downloaded
39
+ # * :overwrite [Boolean] The value of the overwrite parameter when the method was called
40
+ # * :file_downloaded [Boolean] Indicates if the file was downloaded, will be false if overwrite was true and the file existed
41
+ # * :destination_file_existed [String|Boolean] The value will be 'unknown' if overwrite is true because the file exist check will not have been run inside of the method
42
+ # * :destination_file_path [String] The destination path for the file being downloaded
43
+ def download_file(download_file_path, destination_file_path, overwrite = false)
44
+ logger.debug { "Downloading '#{download_file_path}' -> '#{destination_file_path}' Overwrite: #{overwrite}" }
45
+ file_existed = 'unknown'
46
+ if overwrite or not (file_existed = File.exists?(destination_file_path))
47
+ File.open(destination_file_path, 'wb') { |tf|
48
+ open(download_file_path) { |sf| tf.write sf.read }
49
+ }
50
+ file_downloaded = true
51
+ else
52
+ file_downloaded = false
53
+ end
54
+ { :download_file_path => download_file_path, :overwrite => overwrite, :file_downloaded => file_downloaded, :destination_file_existed => file_existed, :destination_file_path => destination_file_path }
55
+ end
56
+
57
+
58
+ def presentation_assets_download(args = {}, options = {})
59
+ assets = args[:assets]
60
+ destination_path = args[:destination_path]
61
+ assets.each { |a| presentation_asset_download(a, destination_path, options) }
62
+ end
63
+
64
+ def presentation_asset_download(asset, destination_path, options = {})
65
+ destination_dir = destination_path
66
+ overwrite = options.fetch(:overwrite, false)
67
+
68
+ media_elements = asset['media']
69
+ # media_elements.concat asset['thumbnails']
70
+ media_elements.each do |media|
71
+ url = media['downloadUrl'] || media['url']
72
+ uri = URI(url)
73
+ file_name = CGI.unescape(File.basename(uri.path))
74
+ destination_file_path = File.join(destination_dir, file_name)
75
+ download_file(url, destination_file_path, overwrite)
76
+ end
77
+
78
+ thumbnails = asset['thumbnails']
79
+ thumbnails.each do |media|
80
+ url = media['downloadUrl'] || media['url']
81
+ uri = URI(url)
82
+ file_name = CGI.unescape(File.basename(uri.path)) + "_thumbnail_#{media['category']}.#{media['extension']}"
83
+ destination_file_path = File.join(destination_dir, file_name)
84
+ download_file(url, destination_file_path, overwrite)
85
+ end
86
+
87
+ end
88
+
89
+ # @param [Object] presentation_invitation_token
90
+ # @param [Object] presentation_password
91
+ # @param [Object] options
92
+ # @option options [Boolean] :preserve_auth_token Determines if the api clients auth token is reset to the
93
+ # value it was before retrieving the presentation
94
+ # @return [Object]
95
+ def presentation_get_using_token(presentation_invitation_token, presentation_password = nil, options = {})
96
+ preserve_auth_token = options.fetch(:preserve_auth_token, true)
97
+ auth_token = api_client.presentation_authorize_get(token: presentation_invitation_token, password: presentation_password)
98
+ presentation_id = api_client.response['presentation']['id']
99
+ original_auth_token = api_client.auth_token
100
+ api_client.auth_token = auth_token
101
+ presentation = api_client.presentation_get(:id => presentation_id)
102
+ api_client.auth_token = original_auth_token if preserve_auth_token
103
+ presentation
104
+ end
105
+
106
+
107
+ def upload(args = {})
108
+ raise 'Upload method is not implemented.'
109
+ end
110
+
111
+ end
112
+
113
+ end
114
+
115
+ end
116
+
117
+ end
metadata ADDED
@@ -0,0 +1,256 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: envoi-mam-agent
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - John Whitson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: adobe_media_encoder
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-sdk-s3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: daemons
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.15'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.15'
69
+ - !ruby/object:Gem::Dependency
70
+ name: ubiquity-envoi
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: ubiquity-iconik
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ubiquity-mediasilo-api-v3
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: ubiquity-vdms
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1'
125
+ - !ruby/object:Gem::Dependency
126
+ name: ubiquity-wiredrive
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1'
139
+ - !ruby/object:Gem::Dependency
140
+ name: vidispine
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: bundler
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.16'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.16'
167
+ - !ruby/object:Gem::Dependency
168
+ name: minitest
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '5.0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '5.0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rake
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '10.0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '10.0'
195
+ description: ''
196
+ email:
197
+ - john.whitson@gmail.com
198
+ executables:
199
+ - envoi-mam-agent
200
+ extensions: []
201
+ extra_rdoc_files: []
202
+ files:
203
+ - ".gitignore"
204
+ - ".rbenv-gemsets"
205
+ - ".ruby-version"
206
+ - ".travis.yml"
207
+ - CODE_OF_CONDUCT.md
208
+ - Gemfile
209
+ - LICENSE.txt
210
+ - README.md
211
+ - Rakefile
212
+ - bin/console
213
+ - bin/setup
214
+ - envoi-mam-agent.gemspec
215
+ - exe/envoi-mam-agent
216
+ - lib/envoi/mam/agent.rb
217
+ - lib/envoi/mam/agent/cli.rb
218
+ - lib/envoi/mam/agent/cli/commands.rb
219
+ - lib/envoi/mam/agent/cli/commands/iconik.rb
220
+ - lib/envoi/mam/agent/cli/commands/mediasilo.rb
221
+ - lib/envoi/mam/agent/cli/commands/vidispine.rb
222
+ - lib/envoi/mam/agent/cli/commands/wiredrive.rb
223
+ - lib/envoi/mam/agent/config_service_client.rb
224
+ - lib/envoi/mam/agent/transfer_client.rb
225
+ - lib/envoi/mam/agent/transfer_client/aspera.rb
226
+ - lib/envoi/mam/agent/transfer_client/s3.rb
227
+ - lib/envoi/mam/agent/version.rb
228
+ - lib/envoi/mam/iconik/agent.rb
229
+ - lib/envoi/mam/mediasilo/agent.rb
230
+ - lib/envoi/mam/vidispine/agent.rb
231
+ - lib/envoi/mam/wiredrive/agent.rb
232
+ homepage: http://www.github.com/XPlatform-Consulting/envoi-mam-agent
233
+ licenses:
234
+ - MIT
235
+ metadata: {}
236
+ post_install_message:
237
+ rdoc_options: []
238
+ require_paths:
239
+ - lib
240
+ required_ruby_version: !ruby/object:Gem::Requirement
241
+ requirements:
242
+ - - ">="
243
+ - !ruby/object:Gem::Version
244
+ version: '0'
245
+ required_rubygems_version: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ version: '0'
250
+ requirements: []
251
+ rubyforge_project:
252
+ rubygems_version: 2.5.2
253
+ signing_key:
254
+ specification_version: 4
255
+ summary: Library for interacting with MAMs.
256
+ test_files: []