ehbrs_ruby_utils 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a5f85d8072d8f656d982d29d5b4267615628ef993347630ed4a796ea3f8937d
4
- data.tar.gz: d3c379fc4d4054cd628ed56a7a1ae8647cccf249de77333762d5f2010405561c
3
+ metadata.gz: 5190ccf9f17c01b8b59b4dc45cb9e711a8f059a755eb8cdb8e3367a6778fcf53
4
+ data.tar.gz: d9289e10d539ce6c9a5b714d23df7b70ac9b496327559f6eac767f9e864dead7
5
5
  SHA512:
6
- metadata.gz: 88c6613b66181f404d6530f2d43161e6a6e10bf70da7a96d43867c487066b7e26c2dd44e710775468b06bc612a5c2357463a0e3529a23bc976cf95f636796262
7
- data.tar.gz: f99bfc207698e18dcc708b0522ca249eee46288950fe16fd0e5fd554d3537b2c2a431954cc4f0456d08081f5512469fbe4a460dc18313480ded6fc874cb0350c
6
+ metadata.gz: c87878872a7ae1a224ac658b01c97085ca2b05f38c77dc28d60ab57b150d427af90f5b71defcba1726ab025dc019e8b0d27802a45120386bc7372888773ccc5b
7
+ data.tar.gz: 7e2e43b0755743b29c00bd9e5dbb39f7168a91122abfc926fcc4107a68acb329dad5ee9e8711ced986a62c190a3efcb694bdd32ff7f5c9a332b3d47d709bd693
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EhbrsRubyUtils
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -1,11 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
+ require 'ehbrs_ruby_utils/executables'
5
+ require 'ehbrs_ruby_utils/videos/stream'
6
+ require 'json'
4
7
 
5
8
  module EhbrsRubyUtils
6
9
  module Videos
7
- module Container
8
- require_sub __FILE__
10
+ class Container
11
+ enable_simple_cache
12
+ common_constructor :path do
13
+ self.path = path.to_pathname
14
+ end
15
+
16
+ ::EhbrsRubyUtils::Videos::Stream.lists.codec_type.each_value do |stream_type|
17
+ define_method stream_type.to_s.pluralize do
18
+ streams.select { |stream| stream.codec_type == stream_type }
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def probe_data_uncached
25
+ ::JSON.parse(
26
+ ::EhbrsRubyUtils::Executables.ffprobe.command(
27
+ '-hide_banner', '-print_format', 'json', '-show_format', '-show_streams', path
28
+ ).execute!
29
+ ).deep_symbolize_keys.freeze
30
+ end
31
+
32
+ def streams_uncached
33
+ probe_data.fetch(:streams).map do |stream_ffprobe_data|
34
+ ::EhbrsRubyUtils::Videos::Stream.new(stream_ffprobe_data)
35
+ end
36
+ end
9
37
  end
10
38
  end
11
39
  end
@@ -8,13 +8,19 @@ module EhbrsRubyUtils
8
8
  enable_simple_cache
9
9
  enable_listable
10
10
 
11
- lists.add_symbol :codec_type, :audio, :video, :subtitle, :other
11
+ lists.add_symbol :codec_type, :audio, :video, :subtitle, :data
12
12
 
13
13
  common_constructor :ffprobe_data do
14
14
  self.ffprobe_data = ffprobe_data.symbolize_keys.freeze
15
15
  self.class.lists.codec_type.value_validate!(codec_type)
16
16
  end
17
17
 
18
+ lists.codec_type.each_value do |v|
19
+ define_method "#{v}?" do
20
+ codec_type == v
21
+ end
22
+ end
23
+
18
24
  def to_s
19
25
  "#{index}|#{codec_type}|#{codec_name}|#{language}"
20
26
  end
@@ -34,7 +40,7 @@ module EhbrsRubyUtils
34
40
  end
35
41
 
36
42
  def tags
37
- ffprobe_data.fetch(:tags).symbolize_keys
43
+ ffprobe_data[:tags].if_present({}, &:symbolize_keys)
38
44
  end
39
45
 
40
46
  def language
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ehbrs_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-28 00:00:00.000000000 Z
11
+ date: 2020-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_ruby_utils
@@ -55,8 +55,6 @@ files:
55
55
  - lib/ehbrs_ruby_utils/version.rb
56
56
  - lib/ehbrs_ruby_utils/videos.rb
57
57
  - lib/ehbrs_ruby_utils/videos/container.rb
58
- - lib/ehbrs_ruby_utils/videos/container/file.rb
59
- - lib/ehbrs_ruby_utils/videos/container/info.rb
60
58
  - lib/ehbrs_ruby_utils/videos/convert_job.rb
61
59
  - lib/ehbrs_ruby_utils/videos/quality.rb
62
60
  - lib/ehbrs_ruby_utils/videos/resolution.rb
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require 'eac_ruby_utils/core_ext'
5
- require 'ehbrs_ruby_utils/executables'
6
- require 'ehbrs_ruby_utils/videos/container/info'
7
- require 'ehbrs_ruby_utils/videos/stream'
8
-
9
- module EhbrsRubyUtils
10
- module Videos
11
- module Container
12
- class File
13
- enable_simple_cache
14
- common_constructor :path do
15
- self.path = path.to_pathname
16
- end
17
-
18
- ::EhbrsRubyUtils::Videos::Stream.lists.codec_type.each_value do |stream_type|
19
- define_method stream_type.to_s.pluralize do
20
- streams.select { |stream| stream.codec_type == stream_type }
21
- end
22
- end
23
-
24
- private
25
-
26
- def info_uncached
27
- ::EhbrsRubyUtils::Videos::Container::Info.new(
28
- ::JSON.parse(
29
- ::EhbrsRubyUtils::Executables.ffprobe.command(
30
- '-hide_banner', '-print_format', 'json', '-show_format', '-show_streams', path
31
- ).execute!
32
- )
33
- )
34
- end
35
-
36
- def streams_uncached
37
- info.ffprobe_data.fetch(:streams).map do |stream_ffprobe_data|
38
- ::EhbrsRubyUtils::Videos::Stream.new(stream_ffprobe_data)
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'ehbrs_ruby_utils/videos/container/info'
5
-
6
- module EhbrsRubyUtils
7
- module Videos
8
- module Container
9
- class Info
10
- enable_simple_cache
11
- common_constructor :ffprobe_data do
12
- self.ffprobe_data = ffprobe_data.with_indifferent_access.freeze
13
- end
14
-
15
- def to_h
16
- ffprobe_data
17
- end
18
- end
19
- end
20
- end
21
- end