ffprober 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.0
1
+ 2.5.0
data/.travis.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
2
 
3
3
  before_install:
4
- - gem install bundler
4
+ - gem update --system
5
+ - gem install bundler
5
6
 
6
7
  before_script:
7
8
  - echo $PATH
@@ -21,14 +22,8 @@ addons:
21
22
  repo_token: e319ec7d18fb8e1f05b460c3ef8fac58af3844d7bfa3d44de6b82eb874bb3e31
22
23
 
23
24
  rvm:
24
- - 2.0.0-p648
25
- - 2.1.8
26
- - 2.2.4
27
- - 2.3.0
28
- - rbx-2
25
+ - 2.3.6
26
+ - 2.4.3
27
+ - 2.5.0
29
28
  - ruby-head
30
29
  - jruby-head
31
-
32
- matrix:
33
- allow_failures:
34
- - rvm: rbx-2
data/CODE_OF_CONDUCT.md CHANGED
@@ -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,10 @@
1
+ 0.5.2 / 2017-01-18
2
+ ==========
3
+
4
+ * exposes a from_url method that allows probing URLs
5
+ * validates URL input and raises error if invalid URL
6
+ * raises an error if ffprobe responses with an error message in the JSON
7
+
1
8
  0.5.1 / 2016-02-07
2
9
  ===================
3
10
 
data/Gemfile CHANGED
@@ -1,9 +1,11 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- # gem "pry"
4
- # gem "rubocop"
5
- # gem "codeclimate-test-reporter", require: false
6
- # gem 'simplecov', require: false
3
+ source 'https://rubygems.org'
4
+
5
+ group :test do
6
+ gem 'codeclimate-test-reporter', '~> 1.0.0'
7
+ gem 'simplecov'
8
+ end
7
9
 
8
10
  # Specify your gem's dependencies in ffprober.gemspec
9
11
  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 3.3
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,7 +43,7 @@ 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.3, 2.4, 2.5, JRuby (head) and Rubinius and ruby-head.
47
47
 
48
48
  [![Build Status](https://secure.travis-ci.org/beanieboi/ffprober.png?branch=master)](http://travis-ci.org/beanieboi/ffprober)
49
49
 
data/Rakefile CHANGED
@@ -1,9 +1,11 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
3
5
 
4
6
  Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
7
9
  t.test_files = FileList['test/**/*_test.rb']
8
10
  end
9
11
 
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "ffprober"
4
+ require 'bundler/setup'
5
+ require 'ffprober'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "ffprober"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start
data/circle.yml ADDED
@@ -0,0 +1,5 @@
1
+ dependencies:
2
+ pre:
3
+ - echo $PATH
4
+ - cp test/ffprobe ~/bin
5
+ - gem update --system
@@ -1,4 +1,6 @@
1
- require_relative "../lib/ffprober"
1
+ # frozen_string_literal: true
2
2
 
3
- parser = Ffprober::Parser.from_file("../spec/assets/s'ample video.m4v")
3
+ require_relative '../lib/ffprober'
4
+
5
+ parser = Ffprober::Parser.from_file("../test/assets/s'ample video.m4v")
4
6
  puts parser.video_streams.inspect
data/ffprober.gemspec CHANGED
@@ -1,26 +1,28 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "ffprober/version"
5
+ require 'ffprober/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "ffprober"
8
+ spec.name = 'ffprober'
8
9
  spec.version = Ffprober::VERSION
9
- spec.authors = ["beanieboi"]
10
- spec.email = ["beanie@benle.de"]
10
+ spec.authors = ['beanieboi']
11
+ spec.email = ['beanie@benle.de']
11
12
 
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"
13
+ spec.description = 'a Ruby wrapper for ffprobe'
14
+ spec.summary = 'a Ruby wrapper for ffprobe (part of ffmpeg)'
15
+ spec.homepage = 'https://github.com/beanieboi/ffprober'
16
+ spec.license = 'MIT'
16
17
 
17
18
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
19
+ spec.bindir = 'exe'
19
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
21
+ spec.require_paths = ['lib']
21
22
 
22
23
  spec.required_ruby_version = '~> 2.0'
23
24
 
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "minitest"
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'minitest'
27
+ spec.add_development_dependency 'rubocop'
26
28
  end
data/lib/ffprober.rb CHANGED
@@ -1,34 +1,42 @@
1
- require_relative "ffprober/version"
1
+ # frozen_string_literal: true
2
2
 
3
- autoload :JSON, "json"
3
+ require_relative 'ffprober/version'
4
+
5
+ autoload :JSON, 'json'
4
6
 
5
7
  module Ffprober
6
8
  class EmptyInput < StandardError; end
7
9
  class InvalidInputFileError < StandardError; end
8
10
  class NoFfprobeFound < StandardError; end
9
11
  class UnsupportedVersion < StandardError; end
12
+ class FfprobeError < StandardError
13
+ def initialize(ff_err)
14
+ super("Ffprobe responded with: #{ff_err[:string]} (#{ff_err[:code]})")
15
+ end
16
+ end
10
17
 
11
- autoload :AudioStream, "ffprober/audio_stream"
12
- autoload :Chapter, "ffprober/chapter"
13
- autoload :DataStream, "ffprober/data_stream"
14
- autoload :DynamicInitializer, "ffprober/dynamic_initializer"
15
- autoload :FfprobeVersion, "ffprober/ffprobe_version"
16
- autoload :Format, "ffprober/format"
17
- autoload :Parser, "ffprober/parser"
18
- autoload :Stream, "ffprober/stream"
19
- autoload :SubtitleStream, "ffprober/subtitle_stream"
20
- autoload :VideoStream, "ffprober/video_stream"
21
- autoload :Wrapper, "ffprober/wrapper"
18
+ autoload :AudioStream, 'ffprober/audio_stream'
19
+ autoload :Chapter, 'ffprober/chapter'
20
+ autoload :DataStream, 'ffprober/data_stream'
21
+ autoload :DynamicInitializer, 'ffprober/dynamic_initializer'
22
+ autoload :FfprobeVersion, 'ffprober/ffprobe_version'
23
+ autoload :Format, 'ffprober/format'
24
+ autoload :Parser, 'ffprober/parser'
25
+ autoload :Stream, 'ffprober/stream'
26
+ autoload :SubtitleStream, 'ffprober/subtitle_stream'
27
+ autoload :VideoStream, 'ffprober/video_stream'
28
+ autoload :Wrapper, 'ffprober/wrapper'
22
29
 
23
30
  module Ffmpeg
24
- autoload :Exec, "ffprober/ffmpeg/exec"
25
- autoload :Finder, "ffprober/ffmpeg/finder"
26
- autoload :Version, "ffprober/ffmpeg/version"
27
- autoload :VersionValidator, "ffprober/ffmpeg/version_validator"
31
+ autoload :Exec, 'ffprober/ffmpeg/exec'
32
+ autoload :Finder, 'ffprober/ffmpeg/finder'
33
+ autoload :Version, 'ffprober/ffmpeg/version'
34
+ autoload :VersionValidator, 'ffprober/ffmpeg/version_validator'
28
35
  end
29
36
 
30
37
  module Parsers
31
- autoload :File, "ffprober/parsers/file"
32
- autoload :Json, "ffprober/parsers/json"
38
+ autoload :FileParser, 'ffprober/parsers/file'
39
+ autoload :UrlParser, 'ffprober/parsers/url'
40
+ autoload :JsonParser, 'ffprober/parsers/json'
33
41
  end
34
42
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Ffprober
2
4
  class AudioStream < Stream
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Ffprober
2
4
  class Chapter
3
5
  include Ffprober::DynamicInitializer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Ffprober
2
4
  class DataStream < Stream
3
5
  end
@@ -1,13 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Ffprober
2
4
  module DynamicInitializer
3
5
  def initialize(object_attribute_hash)
4
6
  object_attribute_hash.each do |key, value|
5
7
  instance_variable_set("@#{key}", value)
6
8
 
7
- unless self.class.method_defined?(key)
8
- self.class.send(:define_method, key) do
9
- instance_variable_get("@#{key}")
10
- end
9
+ next if self.class.method_defined?(key)
10
+ self.class.send(:define_method, key) do
11
+ instance_variable_get("@#{key}")
11
12
  end
12
13
  end
13
14
  end
@@ -1,29 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'shellwords'
4
+
1
5
  module Ffprober
2
6
  module Ffmpeg
3
7
  class Exec
4
- CHAPTER_SUPPORT = Gem::Version.new("2.0.0")
8
+ CHAPTER_SUPPORT = Gem::Version.new('2.0.0')
5
9
 
6
- def initialize(ffprobe_finder=Ffprober::Ffmpeg::Finder)
7
- @ffprobe_finder = ffprobe_finder
10
+ def initialize(finder = Ffprober::Ffmpeg::Finder)
11
+ @finder = finder
8
12
  end
9
13
 
10
- def json_output(file_to_parse)
11
- `#{@ffprobe_finder.path} #{ffprobe_options} #{Shellwords.escape(file_to_parse)}`
14
+ def json_output(filename)
15
+ `#{@finder.path} #{ffprobe_options} #{Shellwords.escape(filename)}`
12
16
  end
13
17
 
14
18
  def ffprobe_version_output
15
19
  @ffprobe_version_output ||= begin
16
- if @ffprobe_finder.path.nil?
17
- ""
20
+ if @finder.path.nil?
21
+ ''
18
22
  else
19
- `#{@ffprobe_finder.path} -version`
23
+ `#{@finder.path} -version`
20
24
  end
21
25
  end
22
26
  end
23
27
 
24
28
  def ffprobe_options
25
- options = "-v quiet -print_format json -show_format -show_streams"
26
- options << " -show_chapters" if ffprobe_version.version >= CHAPTER_SUPPORT
29
+ base_options = '-v quiet -print_format json -show_format'\
30
+ ' -show_streams -show_error'
31
+
32
+ if ffprobe_version.version >= CHAPTER_SUPPORT
33
+ options = base_options + ' -show_chapters'
34
+ end
35
+
27
36
  options
28
37
  end
29
38
 
@@ -1,23 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Ffprober
2
4
  module Ffmpeg
3
5
  class Finder
4
- SEARCH_PATHS = ENV["PATH"]
6
+ SEARCH_PATHS = ENV['PATH']
5
7
 
6
8
  def self.path
7
- fail Ffprober::NoFfprobeFound if executable_path.nil?
9
+ raise Ffprober::NoFfprobeFound if executable_path.nil?
8
10
  @path ||= File.expand_path(executable_name, executable_path)
9
11
  end
10
12
 
11
13
  def self.executable_name
12
- @executable_name ||= self.windows? ? "ffprobe.exe" : "ffprobe"
14
+ @executable_name ||= windows? ? 'ffprobe.exe' : 'ffprobe'
13
15
  end
14
16
 
15
17
  def self.windows?
16
- !!(RUBY_PLATFORM =~ /(mingw|mswin)/)
18
+ !(RUBY_PLATFORM =~ /(mingw|mswin)/).nil?
17
19
  end
18
20
 
19
21
  def self.executable_path
20
- @@executable_path ||= begin
22
+ @executable_path ||= begin
21
23
  SEARCH_PATHS.split(File::PATH_SEPARATOR).detect do |path_to_check|
22
24
  File.executable?(File.join(path_to_check, executable_name))
23
25
  end
@@ -1,20 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Ffprober
2
4
  module Ffmpeg
3
5
  class Version
4
- def initialize(ffprobe_exec=Ffprober::Ffmpeg::Exec.new)
6
+ def initialize(ffprobe_exec = Ffprober::Ffmpeg::Exec.new)
5
7
  @ffprobe_exec = ffprobe_exec
6
8
  end
7
9
 
8
10
  VERSION_REGEX = /^(ffprobe|avprobe|ffmpeg) version (\d+)\.?(\d+)\.?(\d+)*/
9
11
  NIGHTLY_REGEX = /^(ffprobe|avprobe|ffmpeg) version (N|git)-/
10
- VERSION_FALLBACK = [0, 0, 0]
12
+ VERSION_FALLBACK = [0, 0, 0].freeze
11
13
 
12
14
  def version
13
- @version ||= Gem::Version.new(parse_version.join("."))
15
+ @version ||= Gem::Version.new(parse_version.join('.'))
14
16
  end
15
17
 
16
18
  def nightly?
17
- !!(ffprobe_version_output =~ NIGHTLY_REGEX)
19
+ !(ffprobe_version_output =~ NIGHTLY_REGEX).nil?
18
20
  end
19
21
 
20
22
  private
@@ -32,7 +34,7 @@ module Ffprober
32
34
  end
33
35
 
34
36
  def to_s
35
- parse_version.join(".")
37
+ parse_version.join('.')
36
38
  end
37
39
  end
38
40
  end