active_encode 1.2.1 → 1.2.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20e6ade3d61ad1841bcc39b5fbb7b2574a193c420cd2de46ccd8870673e2a97b
4
- data.tar.gz: daa888be0970d54530da2d1dcbc3fcb0eb4e254ba52e219e6e83c8a054c6e445
3
+ metadata.gz: aa6172de1470349b8dd8c2422c51049402168ca45eba77aa62ab6b7d9637f4ae
4
+ data.tar.gz: 999ec2e97a500f3bb258db4d4fbfa6e5fa4132dfefb4a82da1667eefa6875cff
5
5
  SHA512:
6
- metadata.gz: ea736ead421bf6640916c675ba1b6f2529206ababccf9dd25776ba049a9eedd390171d0e2dd87c61c3fc68acdd80731cd86b8f35798435153fe6289f7c8fa8d0
7
- data.tar.gz: 753701c6f655a8ae671d1dd4c2538a5ae2ef47abe797297e9ffdd3c810f7c995ce2949a047b721405f34b4c83c132c29981bdb7e2416ac49813e18257e20bd40
6
+ metadata.gz: a78df8af781cf5f4f198a9b4d9e994108294fd0248725d9b6553a96fb829de41afc7a7ccc69cadacafe8d6cb4ac809cb4331c2331c968b7429b7306e19cf3f51
7
+ data.tar.gz: 358557321351790685a68c4604d6ca43592c928523085e96f5353603ffe8ad0bfc70b6bcde119b2275cb3d3bbec7b6be78c74b84c3f65900dcd2f0e8f3c38421
data/.circleci/config.yml CHANGED
@@ -25,6 +25,7 @@ jobs:
25
25
  steps:
26
26
  - run:
27
27
  command: |
28
+ sudo rm /etc/apt/sources.list.d/google-chrome.list # We don't need chrome and it is causing problems so just remove it
28
29
  sudo apt-get update
29
30
  sudo apt-get install libmms0
30
31
  sudo wget -P /tmp/ https://mediaarea.net/download/binary/libzen0/0.4.39/libzen0v5_0.4.39-1_amd64.Debian_11.deb
@@ -28,6 +28,8 @@ module ActiveEncode
28
28
 
29
29
  s3_object = FileLocator::S3File.new(input_url).object
30
30
  input_url = URI.parse(s3_object.presigned_url(:get))
31
+ when /^https?\:\/\//
32
+ input_url = URI.parse(input_url)
31
33
  end
32
34
 
33
35
  new_encode = ActiveEncode::Base.new(input_url, options)
@@ -232,7 +234,7 @@ module ActiveEncode
232
234
  Dir["#{File.absolute_path(working_path('outputs', id))}/*"].each do |file_path|
233
235
  output = ActiveEncode::Output.new
234
236
  output.url = "file://#{file_path}"
235
- sanitized_filename = ActiveEncode.sanitize_base encode.input.url
237
+ sanitized_filename = encode.input.url.match?(/^https?\:\/\//) ? ActiveEncode.sanitize_base(URI.parse(encode.input.url)) : ActiveEncode.sanitize_base(encode.input.url)
236
238
  output.label = file_path[/#{Regexp.quote(sanitized_filename)}.*\-(.*?)#{Regexp.quote(File.extname(file_path))}$/, 1]
237
239
  output.id = "#{encode.input.id}-#{output.label}"
238
240
  output.created_at = encode.created_at
@@ -17,10 +17,8 @@ module ActiveEncode
17
17
  MEDIAINFO_PATH = ENV["MEDIAINFO_PATH"] || "mediainfo"
18
18
  FFMPEG_PATH = ENV["FFMPEG_PATH"] || "ffmpeg"
19
19
 
20
- def create(input_url, options = {})
21
- # Decode file uris for ffmpeg (mediainfo works either way)
22
- input_url = Addressable::URI.unencode(input_url) if input_url.starts_with? "file:///"
23
- input_url = ActiveEncode.sanitize_input(input_url)
20
+ def create(original_input_url, options = {})
21
+ input_url = sanitize_input_url(original_input_url)
24
22
 
25
23
  new_encode = ActiveEncode::Base.new(input_url, options)
26
24
  new_encode.id = SecureRandom.uuid
@@ -76,9 +74,7 @@ module ActiveEncode
76
74
 
77
75
  # Copy derivatives to work directory
78
76
  options[:outputs].each do |opt|
79
- url = opt[:url]
80
- output_path = working_path("outputs/#{ActiveEncode.sanitize_base opt[:url]}#{File.extname opt[:url]}", new_encode.id)
81
- FileUtils.cp FileLocator.new(url).location, output_path
77
+ output_path = copy_derivative_to_working_path(opt[:url], new_encode.id)
82
78
  filename_label_hash[output_path] = opt[:label]
83
79
  end
84
80
 
@@ -271,6 +267,31 @@ module ActiveEncode
271
267
  write_errors new_encode
272
268
  new_encode
273
269
  end
270
+
271
+ def sanitize_input_url(url)
272
+ input_url = if url.starts_with?("file://")
273
+ # Decode file uris for ffmpeg (mediainfo works either way)
274
+ Addressable::URI.unencode(url)
275
+ elsif url.starts_with?("s3://")
276
+ # Change s3 uris into presigned http urls
277
+ FileLocator.new(url).location
278
+ else
279
+ url
280
+ end
281
+ ActiveEncode.sanitize_input(input_url)
282
+ end
283
+
284
+ def copy_derivative_to_working_path(url, id)
285
+ output_path = working_path("outputs/#{ActiveEncode.sanitize_base url}#{File.extname url}", id)
286
+ if url.start_with? "s3://"
287
+ # Use aws-sdk-s3 download_file method
288
+ # Single request mode needed for compatibility with minio
289
+ FileLocator::S3File.new(url).object.download_file(output_path, mode: 'single_request')
290
+ else
291
+ FileUtils.cp FileLocator.new(url).location, output_path
292
+ end
293
+ output_path
294
+ end
274
295
  end
275
296
  end
276
297
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveEncode
3
- VERSION = '1.2.1'
3
+ VERSION = '1.2.3'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_encode
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Klein, Chris Colvard, Phuong Dinh
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-21 00:00:00.000000000 Z
11
+ date: 2024-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -303,7 +303,7 @@ licenses:
303
303
  - Apache-2.0
304
304
  metadata:
305
305
  rubygems_mfa_required: 'true'
306
- post_install_message:
306
+ post_install_message:
307
307
  rdoc_options: []
308
308
  require_paths:
309
309
  - lib
@@ -318,8 +318,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
318
318
  - !ruby/object:Gem::Version
319
319
  version: '0'
320
320
  requirements: []
321
- rubygems_version: 3.1.6
322
- signing_key:
321
+ rubygems_version: 3.5.16
322
+ signing_key:
323
323
  specification_version: 4
324
324
  summary: Declare encode job classes that can be run by a variety of encoding services
325
325
  test_files: []