ffprober 0.4.6 → 1.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
- SHA1:
3
- metadata.gz: f48bb0db1f7f7a981b59f158ab245b6570f173f6
4
- data.tar.gz: d6c4ab9014aaf6f000ae11db448620f15002fe7d
2
+ SHA256:
3
+ metadata.gz: 7d8c232d9ed83bd2d51a9ff879008d26deadc3ddf62970cca4e9e15ad118c01f
4
+ data.tar.gz: b13c5c21ac3942019be942f242d06c3d63d577c9332940dbd1e7e2bb3768f364
5
5
  SHA512:
6
- metadata.gz: 2996def445326304ff4ccafa381a855a43f5503a244b22bde01c5731c8b48aa50faae084b9e9985684710534cd2003ea1ca06c3837d1b029cf173045c1a42b4f
7
- data.tar.gz: e2dd182e05eeaaeff74d9c59bff424358a9ff831a07b7ccf530ed76612c76dd1af82c5be850d03ccf7110a0ea3f33ca131e0352cd136c11223efa5a8e61ca7a3
6
+ metadata.gz: 994061aa59b82948a63d753ca191c7a501e5d474117c67231ddd3131ef0574a51750693c697cafdd45269af7c29817619ef32a3405f5ac6988501ceef2d45b2e
7
+ data.tar.gz: 1209f4ff0162d55cc019d5434d87b0236e6bbb6b13b87a58c0a665e97ebc2701e6a5668e08580348497e36e48210a8efd4897c317f7b376e4cbc849a2c3f9007
@@ -1,13 +1,73 @@
1
- # Contributor Code of Conduct
1
+ # Contributor Covenant Code of Conduct
2
2
 
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
3
+ ## Our Pledge
4
4
 
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ education, socio-economic status, nationality, personal appearance, race,
10
+ religion, or sexual identity and orientation.
6
11
 
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
12
+ ## Our Standards
8
13
 
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
10
16
 
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
12
22
 
13
- This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ich@abwesend.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
data/Changes.md CHANGED
@@ -1,3 +1,43 @@
1
+ 1.0 / 2020-11-28
2
+ ==========
3
+
4
+ * added Sorbet types
5
+ * added a bunch of Rubocops
6
+
7
+ 0.5.5 / 2020-03-28
8
+ ==========
9
+
10
+ * no code changes, i had to release to to make sure that GitHub Actions are working
11
+
12
+ 0.5.4 / 2020-03-28
13
+ ==========
14
+
15
+ * due to security issues in rake, the minimum version is now 12.3.3
16
+
17
+ 0.5.3 / 2019-02-16
18
+ ==========
19
+
20
+ * fixed running on older ffmpeg versions. (PR: https://github.com/beanieboi/ffprober/pull/83) thanks @sevilla
21
+
22
+ 0.5.2 / 2017-01-18
23
+ ==========
24
+
25
+ * exposes a from_url method that allows probing URLs
26
+ * validates URL input and raises error if invalid URL
27
+ * raises an error if ffprobe responses with an error message in the JSON
28
+
29
+ 0.5.1 / 2016-02-07
30
+ ===================
31
+
32
+ * expose parsed json via ffprober.json
33
+
34
+ 0.5.0 / unreleased
35
+ ===================
36
+
37
+ * autoload, reduce initial object count by 3k
38
+ * refactorings, clean up warnings etc.
39
+ * remove check for maximum ffprober version, makes upgrading ffmpeg way easier
40
+
1
41
  0.4.6 / 2015-11-12
2
42
  ===================
3
43
 
data/Gemfile CHANGED
@@ -1,8 +1,12 @@
1
- source "https://rubygems.org"
1
+ # typed: strong
2
+ # frozen_string_literal: true
2
3
 
3
- gem "pry"
4
- gem "rubocop"
5
- gem "codeclimate-test-reporter", require: nil
4
+ source 'https://rubygems.org'
5
+
6
+ group :test do
7
+ gem 'simplecov'
8
+ gem 'sorbet'
9
+ end
6
10
 
7
11
  # Specify your gem's dependencies in ffprober.gemspec
8
12
  gemspec
data/README.md CHANGED
@@ -27,7 +27,7 @@ Or install it yourself as:
27
27
 
28
28
  ## FFMPEG version
29
29
 
30
- tested with ffprobe version 0.9 upto 2.2
30
+ tested with ffprobe version 0.9 upto 4.3.1
31
31
 
32
32
  according to [ffmpeg changelog](http://git.videolan.org/?p=ffmpeg.git;a=blob_plain;f=Changelog) json output was added in version 0.9
33
33
 
@@ -43,13 +43,13 @@ help me collecting various version outputs of fprobe/ffmpeg
43
43
 
44
44
  ## Supported Rubies
45
45
 
46
- Ffprober is tested under 2.0, 2.1, JRuby (head) and Rubinius and ruby-head.
46
+ Ffprober is tested under 2.4, 2.5, 2.6 and 2.7.
47
47
 
48
- [![Build Status](https://secure.travis-ci.org/beanieboi/ffprober.png?branch=master)](http://travis-ci.org/beanieboi/ffprober)
48
+ [![Build Status](https://github.com/beanieboi/ffprober/workflows/Ruby/badge.svg)](https://github.com/beanieboi/ffprober/actions?query=workflow%3ARuby)
49
49
 
50
- [![Code Climate](https://codeclimate.com/github/beanieboi/ffprober.png)](https://codeclimate.com/github/beanieboi/ffprober)
50
+ [![Maintainability](https://api.codeclimate.com/v1/badges/34d393657d54b233ebbc/maintainability)](https://codeclimate.com/github/beanieboi/ffprober/maintainability)
51
51
 
52
- [![Test Coverage](https://codeclimate.com/github/beanieboi/ffprober/badges/coverage.svg)](https://codeclimate.com/github/beanieboi/ffprober)
52
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/34d393657d54b233ebbc/test_coverage)](https://codeclimate.com/github/beanieboi/ffprober/test_coverage)
53
53
 
54
54
  ## Contributors
55
55
 
@@ -1,26 +1,44 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # typed: strong
2
+ # frozen_string_literal: true
3
+
4
+ lib = File.expand_path('lib', __dir__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "ffprober/version"
6
+ require 'ffprober/version'
5
7
 
6
8
  Gem::Specification.new do |spec|
7
- spec.name = "ffprober"
9
+ spec.name = 'ffprober'
8
10
  spec.version = Ffprober::VERSION
9
- spec.authors = ["beanieboi"]
10
- spec.email = ["beanie@benle.de"]
11
+ spec.authors = ['beanieboi']
12
+ spec.email = ['beanie@benle.de']
11
13
 
12
- spec.description = %q{a Ruby wrapper for ffprobe}
13
- spec.summary = %q{a Ruby wrapper for ffprobe (part of ffmpeg)}
14
- spec.homepage = "https://github.com/beanieboi/ffprober"
15
- spec.license = "MIT"
14
+ spec.description = 'a Ruby wrapper for ffprobe'
15
+ spec.summary = 'a Ruby wrapper for ffprobe (part of ffmpeg)'
16
+ spec.homepage = 'https://github.com/beanieboi/ffprober'
17
+ spec.license = 'MIT'
16
18
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
19
+ spec.files = Dir[
20
+ 'CODE_OF_CONDUCT.md',
21
+ 'CONTRIBUTING.md',
22
+ 'Changes.md',
23
+ 'Gemfile',
24
+ 'ffprober.gemspec',
25
+ 'lib/**/*',
26
+ 'LICENSE',
27
+ 'README.md'
28
+ ]
29
+ spec.bindir = 'exe'
19
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
31
+ spec.require_paths = ['lib']
32
+
33
+ spec.required_ruby_version = '>= 2.0'
21
34
 
22
- spec.required_ruby_version = '~> 2.0'
35
+ spec.add_runtime_dependency 'sorbet-runtime'
23
36
 
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "rspec", "~> 3.0"
37
+ spec.add_development_dependency 'minitest', '~> 5'
38
+ spec.add_development_dependency 'rake', '~> 12.3'
39
+ spec.add_development_dependency 'rubocop', '~> 1'
40
+ spec.add_development_dependency 'rubocop-minitest'
41
+ spec.add_development_dependency 'rubocop-packaging'
42
+ spec.add_development_dependency 'rubocop-sorbet'
43
+ spec.add_development_dependency 'simplecov', '~> 0.19'
26
44
  end
@@ -1,23 +1,51 @@
1
- require_relative "ffprober/version"
2
- require_relative "ffprober/dynamic_initializer"
3
- require_relative "ffprober/parser"
4
- require_relative "ffprober/format"
5
- require_relative "ffprober/stream"
6
- require_relative "ffprober/audio_stream"
7
- require_relative "ffprober/data_stream"
8
- require_relative "ffprober/video_stream"
9
- require_relative "ffprober/subtitle_stream"
10
- require_relative "ffprober/chapter"
11
- require_relative "ffprober/ffprobe_version"
12
- require_relative "ffprober/wrapper"
13
- require_relative "ffprober/errors"
14
-
15
- require_relative "ffprober/ffmpeg/finder"
16
- require_relative "ffprober/ffmpeg/version"
17
- require_relative "ffprober/ffmpeg/version_validator"
18
- require_relative "ffprober/parsers/file"
19
- require_relative "ffprober/parsers/json"
20
- require "json"
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler'
5
+ Bundler.setup
6
+
7
+ require 'sorbet-runtime'
8
+ require_relative 'ffprober/version'
9
+
10
+ autoload :JSON, 'json'
21
11
 
22
12
  module Ffprober
13
+ class EmptyInput < StandardError; end
14
+
15
+ class InvalidInputFileError < StandardError; end
16
+
17
+ class NoFfprobeFound < StandardError; end
18
+
19
+ class UnsupportedVersion < StandardError; end
20
+
21
+ class FfprobeError < StandardError
22
+ def initialize(ff_err)
23
+ super("Ffprobe responded with: #{ff_err[:string]} (#{ff_err[:code]})")
24
+ end
25
+ end
26
+
27
+ autoload :AudioStream, 'ffprober/audio_stream'
28
+ autoload :Chapter, 'ffprober/chapter'
29
+ autoload :DataStream, 'ffprober/data_stream'
30
+ autoload :DynamicInitializer, 'ffprober/dynamic_initializer'
31
+ autoload :FfprobeVersion, 'ffprober/ffprobe_version'
32
+ autoload :Format, 'ffprober/format'
33
+ autoload :Parser, 'ffprober/parser'
34
+ autoload :Stream, 'ffprober/stream'
35
+ autoload :SubtitleStream, 'ffprober/subtitle_stream'
36
+ autoload :VideoStream, 'ffprober/video_stream'
37
+ autoload :Wrapper, 'ffprober/wrapper'
38
+
39
+ module Ffmpeg
40
+ autoload :Exec, 'ffprober/ffmpeg/exec'
41
+ autoload :Finder, 'ffprober/ffmpeg/finder'
42
+ autoload :Version, 'ffprober/ffmpeg/version'
43
+ autoload :VersionValidator, 'ffprober/ffmpeg/version_validator'
44
+ end
45
+
46
+ module Parsers
47
+ autoload :FileParser, 'ffprober/parsers/file'
48
+ autoload :UrlParser, 'ffprober/parsers/url'
49
+ autoload :JsonParser, 'ffprober/parsers/json'
50
+ end
23
51
  end
@@ -1,3 +1,6 @@
1
+ # typed: strong
2
+ # frozen_string_literal: true
3
+
1
4
  module Ffprober
2
5
  class AudioStream < Stream
3
6
  end
@@ -1,3 +1,6 @@
1
+ # typed: strong
2
+ # frozen_string_literal: true
3
+
1
4
  module Ffprober
2
5
  class Chapter
3
6
  include Ffprober::DynamicInitializer
@@ -1,3 +1,6 @@
1
+ # typed: strong
2
+ # frozen_string_literal: true
3
+
1
4
  module Ffprober
2
5
  class DataStream < Stream
3
6
  end
@@ -1,13 +1,18 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
1
4
  module Ffprober
2
5
  module DynamicInitializer
6
+ include Kernel
7
+
3
8
  def initialize(object_attribute_hash)
4
9
  object_attribute_hash.each do |key, value|
5
10
  instance_variable_set("@#{key}", value)
6
11
 
7
- unless self.class.method_defined?(key)
8
- self.class.send(:define_method, key) do
9
- instance_variable_get("@#{key}")
10
- end
12
+ next if self.class.method_defined?(key)
13
+
14
+ self.class.send(:define_method, key) do
15
+ instance_variable_get("@#{key}")
11
16
  end
12
17
  end
13
18
  end
@@ -0,0 +1,51 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require 'shellwords'
5
+
6
+ module Ffprober
7
+ module Ffmpeg
8
+ class Exec
9
+ extend T::Sig
10
+
11
+ CHAPTER_SUPPORT = T.let(Gem::Version.new('2.0.0'), Gem::Version)
12
+
13
+ sig { params(finder: T.any(Ffprober::Ffmpeg::Finder, T.untyped)).void }
14
+ def initialize(finder = Ffprober::Ffmpeg::Finder.new)
15
+ @finder = finder
16
+ @ffprobe_version_output = T.let(nil, T.nilable(String))
17
+ end
18
+
19
+ sig { params(filename: String).returns(String) }
20
+ def json_output(filename)
21
+ `#{@finder.path} #{ffprobe_options} #{Shellwords.escape(filename)}`
22
+ end
23
+
24
+ sig { returns(String) }
25
+ def ffprobe_version_output
26
+ @ffprobe_version_output ||= begin
27
+ if @finder.path.nil?
28
+ ''
29
+ else
30
+ `#{@finder.path} -version`
31
+ end
32
+ end
33
+ end
34
+
35
+ sig { returns(String) }
36
+ def ffprobe_options
37
+ base_options = '-v quiet -print_format json -show_format'\
38
+ ' -show_streams -show_error'
39
+
40
+ options = "#{base_options} -show_chapters" if ffprobe_version.version >= CHAPTER_SUPPORT
41
+
42
+ options || base_options
43
+ end
44
+
45
+ sig { returns(Ffprober::Ffmpeg::Version) }
46
+ def ffprobe_version
47
+ Ffprober::Ffmpeg::Version.new(self)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,22 +1,50 @@
1
+ # typed: strong
2
+ # frozen_string_literal: true
3
+
1
4
  module Ffprober
2
5
  module Ffmpeg
3
6
  class Finder
4
- def self.path
5
- @path ||= begin
6
- path = ENV["PATH"].split(File::PATH_SEPARATOR).detect do |path_to_check|
7
- File.executable?(File.join(path_to_check, executable_name))
8
- end
7
+ extend T::Sig
8
+ SEARCH_PATHS = T.let(ENV['PATH'], T.nilable(String))
9
9
 
10
- path && File.expand_path(executable_name, path)
11
- end
10
+ sig { returns(String) }
11
+ attr_reader :executable_name
12
+
13
+ sig { void }
14
+ def initialize
15
+ @executable_path = T.let(nil, T.nilable(String))
16
+ @executable_name = T.let(executable_name_picker, String)
17
+ @path = T.let(nil, T.nilable(String))
18
+ end
19
+
20
+ sig { returns(String) }
21
+ def path
22
+ raise Ffprober::NoFfprobeFound, 'ffprobe executable not found' if executable_path.nil?
23
+
24
+ @path ||= File.expand_path(executable_name, executable_path)
25
+ end
26
+
27
+ sig { returns(T::Boolean) }
28
+ def windows?
29
+ !(RUBY_PLATFORM =~ /(mingw|mswin)/).nil?
12
30
  end
13
31
 
14
- def self.executable_name
15
- @executable_name ||= self.windows? ? "ffprobe.exe" : "ffprobe"
32
+ sig { returns(String) }
33
+ def executable_name_picker
34
+ if windows?
35
+ T.let('ffprobe.exe', String)
36
+ else
37
+ T.let('ffprobe', String)
38
+ end
16
39
  end
17
40
 
18
- def self.windows?
19
- !!(RUBY_PLATFORM =~ /(mingw|mswin)/)
41
+ sig { returns(T.nilable(String)) }
42
+ def executable_path
43
+ @executable_path ||= begin
44
+ T.must(SEARCH_PATHS).split(File::PATH_SEPARATOR).detect do |path_to_check|
45
+ File.executable?(File.join(path_to_check, executable_name))
46
+ end
47
+ end
20
48
  end
21
49
  end
22
50
  end