mediainfo 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/mediainfo.rb +20 -16
- data/lib/mediainfo/string.rb +19 -1
- data/lib/mediainfo/version.rb +1 -1
- data/mediainfo.gemspec +2 -0
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4008669b840fdfc16238d0e8650a6960437d77a65daa2b69ebaf74007e849a70
|
4
|
+
data.tar.gz: f1c8031c41b8466b7e0c916f361316a294629e60565e12cc160e452b38e219d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c12fa15b217f661a9d242fb2f54a7dbc52eeac835e41cc3ecb5cd6905b5b9b35c09097f9b8b2b0aab5652cc1a8f59768ebab3dbbac185f13c3f6fafc6d5091a
|
7
|
+
data.tar.gz: 5e75f9f1da3a1d807421cd201615497d577706dc337c59dd6f95eb814b46bd886eb5553f09d6c805727d9a60caedda46415aece461676969b3d18db5b48c7edb
|
data/README.md
CHANGED
@@ -8,6 +8,8 @@ MediaInfo is a class wrapping [the mediainfo CLI](http://mediainfo.sourceforge.n
|
|
8
8
|
|
9
9
|
## Usage
|
10
10
|
|
11
|
+
- Versions > 1.3.0 support S3 URLs. See rspec test for example of how to obtain the supported URL.
|
12
|
+
|
11
13
|
#### Parsing raw XML
|
12
14
|
media_info = MediaInfo.from(File.open('iphone6+_video.mov.xml').read)
|
13
15
|
#### Handling a local file
|
data/lib/mediainfo.rb
CHANGED
@@ -55,16 +55,6 @@ module MediaInfo
|
|
55
55
|
return xml_parser
|
56
56
|
end
|
57
57
|
|
58
|
-
def self.run(input = nil)
|
59
|
-
raise ArgumentError, 'Your input cannot be blank.' if input.nil?
|
60
|
-
command = "#{location} #{input} --Output=XML 2>&1"
|
61
|
-
raw_response = `#{command}`
|
62
|
-
unless $? == 0
|
63
|
-
raise ExecutionError, "Execution of '#{command}' failed. #{raw_response.inspect}"
|
64
|
-
end
|
65
|
-
return raw_response
|
66
|
-
end
|
67
|
-
|
68
58
|
def self.from(input)
|
69
59
|
return from_uri(input) if input.is_a?(URI)
|
70
60
|
return from_string(input) if input.is_a?(String)
|
@@ -96,13 +86,27 @@ module MediaInfo
|
|
96
86
|
from_uri(URI(input))
|
97
87
|
end
|
98
88
|
|
89
|
+
def self.run(input = nil)
|
90
|
+
raise ArgumentError, 'Your input cannot be blank.' if input.nil?
|
91
|
+
command = "#{location} '#{input}' --Output=XML"
|
92
|
+
raw_response, errors, status = Open3.capture3(command)
|
93
|
+
unless errors.empty? && status.exitstatus == 0
|
94
|
+
raise ExecutionError, "Execution of '#{command}' failed: \n #{errors.red}"
|
95
|
+
end
|
96
|
+
return raw_response
|
97
|
+
end
|
98
|
+
|
99
99
|
def self.from_uri(input)
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
100
|
+
if input.host.include?('amazonaws.com')
|
101
|
+
MediaInfo::Tracks.new(MediaInfo.run(input.to_s)) # Removed URI.escape due to Error parsing the X-Amz-Credential parameter; the Credential is mal-formed; expecting "<YOUR-AKID>/YYYYMMDD/REGION/SERVICE/aws4_request"
|
102
|
+
else
|
103
|
+
http = Net::HTTP.new(input.host, input.port) # Check if input is valid
|
104
|
+
request = Net::HTTP::Head.new(input.request_uri) # Only grab the Headers to be sure we don't try and download the whole file; Doesn't work with presigned_urls in aws/s3
|
105
|
+
http.use_ssl = true if input.is_a? URI::HTTPS # For https support
|
106
|
+
http_request = http.request(request)
|
107
|
+
raise RemoteUrlError, "HTTP call to #{input} is not working : #{http_request.value}" unless http_request.is_a?(Net::HTTPOK)
|
108
|
+
MediaInfo::Tracks.new(MediaInfo.run(URI.escape(input.to_s)))
|
109
|
+
end
|
106
110
|
end
|
107
111
|
|
108
112
|
def self.set_singleton_method(object,name,parameters)
|
data/lib/mediainfo/string.rb
CHANGED
@@ -10,6 +10,24 @@ class String
|
|
10
10
|
#
|
11
11
|
# see: http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_02_03
|
12
12
|
def shell_escape_double_quotes
|
13
|
-
'
|
13
|
+
''+gsub(/\\|"|\$|`/, '\\\\\0')+''
|
14
14
|
end unless method_defined?(:shell_escape_double_quotes)
|
15
|
+
|
16
|
+
# colorization
|
17
|
+
def colorize(color_code)
|
18
|
+
"\e[#{color_code}m#{self}\e[0m"
|
19
|
+
end
|
20
|
+
|
21
|
+
def red
|
22
|
+
colorize(31)
|
23
|
+
end
|
24
|
+
|
25
|
+
def green
|
26
|
+
colorize(32)
|
27
|
+
end
|
28
|
+
|
29
|
+
def yellow
|
30
|
+
colorize(33)
|
31
|
+
end
|
32
|
+
|
15
33
|
end
|
data/lib/mediainfo/version.rb
CHANGED
data/mediainfo.gemspec
CHANGED
@@ -25,6 +25,8 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_development_dependency 'rake', '~> 12.3'
|
26
26
|
s.add_development_dependency 'rspec', '~> 3.0'
|
27
27
|
s.add_development_dependency 'nokogiri', '>= 1.8', '< 2.0' # Ability to parse XML response # Optional and should be included by user in their own gemfile
|
28
|
+
s.add_development_dependency 'aws-sdk-s3'
|
29
|
+
s.add_development_dependency 'pry'
|
28
30
|
|
29
31
|
if s.respond_to? :specification_version then
|
30
32
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mediainfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Thomas Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,6 +72,34 @@ dependencies:
|
|
72
72
|
- - "<"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '2.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: aws-sdk-s3
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: pry
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
75
103
|
description: MediaInfo is a class wrapping the mediainfo CLI (http://mediainfo.sourceforge.net)
|
76
104
|
that standardizes attributes/methods and also converts most values into something
|
77
105
|
Ruby can understand.
|