videoinfo 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +3 -0
- data/README.md +115 -0
- data/bin/videoinfo +9 -0
- data/lib/videoinfo.rb +82 -0
- data/lib/videoinfo/cli.rb +53 -0
- data/lib/videoinfo/errors.rb +4 -0
- data/lib/videoinfo/image_host.rb +9 -0
- data/lib/videoinfo/image_hosts/imgur.rb +37 -0
- data/lib/videoinfo/result.rb +21 -0
- data/lib/videoinfo/results/movie_result.rb +47 -0
- data/lib/videoinfo/version.rb +3 -0
- data/lib/videoinfo/video.rb +59 -0
- data/lib/videoinfo/videos/movie.rb +62 -0
- data/videoinfo.gemspec +23 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2d9f23008adc1a077641356b4fde1287788ab376
|
4
|
+
data.tar.gz: 511ba79416ab3b21e1a953c03d0f608574a156b5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d2c7f16d606e4518facbd133a9692e0b6bde23011e13014ec04ec987dba5c95d15f0f0309bc954b2d53aa20ec363fe41711c0283af1c4e5eac13d25ea1c212ce
|
7
|
+
data.tar.gz: bada7f288cacddc5db52c5cdb51bd97b9588944ae83f6fbcbb0baffcd41310da006db0f25fef50e9817cce437c4ccb7bd038fad55d89ca75fd837d86e4b065ee
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
## Videoinfo
|
2
|
+
|
3
|
+
Videoinfo is a simple tool for aggregating video metadata and capturing/uploading screenshots.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
First, you'll want to install the prerequisite binaries and make sure they are in your PATH.
|
8
|
+
|
9
|
+
* [mediainfo](http://mediaarea.net/en-us/MediaInfo/Download)
|
10
|
+
* [ffmpeg](https://www.ffmpeg.org/download.html)
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'videoinfo'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
bundle install
|
19
|
+
|
20
|
+
Or install it yourself with:
|
21
|
+
|
22
|
+
$ gem install videoinfo
|
23
|
+
|
24
|
+
## Configuration
|
25
|
+
|
26
|
+
There are only a few configuration options:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
Videoinfo.mediainfo_binary = '/path/to/mediainfo' # defaults to 'mediainfo'
|
30
|
+
Videoinfo.ffmpeg_binary = '/path/to/ffmpeg' # defaults to 'ffmpeg'
|
31
|
+
Videoinfo.image_host = ImageHosts::Imgur.new # can be any object that responds to upload(File)
|
32
|
+
Videoinfo.interactive = true # defaults to true when using the command line, false otherwise
|
33
|
+
```
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
#### Command Line
|
38
|
+
|
39
|
+
```
|
40
|
+
$ videoinfo -h
|
41
|
+
Usage: videoinfo [options] "MOVIENAME" file
|
42
|
+
-i, --image-host=IMAGEHOST The ImageHost to use for uploading screenshots. Default: Imgur
|
43
|
+
-s, --screenshots=SCREENSHOTS The number of screenshots to create, max 7. Default: 2
|
44
|
+
-n, --no-prompt Disable interactive mode
|
45
|
+
-h, --help Show this message
|
46
|
+
|
47
|
+
$ videoinfo -s 5 -i Imgur 'Hackers' Hackers.1995.mkv > hackers.txt
|
48
|
+
Is your movie "Hackers (1995)" (tt0113243)? [Y/n] y
|
49
|
+
```
|
50
|
+
|
51
|
+
#### In scripts
|
52
|
+
|
53
|
+
The simpliest way to analyze a movie is with `Videoinfo.analyze_movie()`:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
result = Videoinfo.analyze_movie('hackers', 'Hackers.1995.mkv', 0) # => #<Videoinfo::Results::MovieResult>
|
57
|
+
result.imdb_id # => "0113243"
|
58
|
+
result.title # => "Hackers"
|
59
|
+
result.plot_summary # => "A young boy is arrested..."
|
60
|
+
result.release_date # => "15 September 1995 (USA)"
|
61
|
+
result.rating # => 6.2
|
62
|
+
result.rating_over_ten # => "6.2 / 10"
|
63
|
+
result.genres # => ["Action", "Crime", "Drama", "Thriller"]
|
64
|
+
result.director # => "Iain Softley"
|
65
|
+
result.writers # => ["Rafael Moreu"]
|
66
|
+
result.runtime # => 107
|
67
|
+
result.imdb_url # => "http://www.imdb.com/title/tt0113243"
|
68
|
+
result.wiki_url # => "https://en.wikipedia.org/wiki/Hackers_(film)"
|
69
|
+
result.trailer_url # => "https://www.youtube.com/watch?v=vCobCU9FfzI"
|
70
|
+
result.screenshot_urls # => ["https://i.imgur.com/SoBhWfQ.png", ...]
|
71
|
+
result.mediainfo # => "General..."
|
72
|
+
```
|
73
|
+
|
74
|
+
Or, you can be more explicit:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
movie = Videoinfo::Videos::Movie.new('hackers', 'Hackers.1995.mkv', 5)
|
78
|
+
movie.populate_result! # => #<Videoinfo::Results::MovieResult>
|
79
|
+
movie.result # => #<Videoinfo::Results::MovieResult>
|
80
|
+
movie.search_imdb # => [#<Imdb::Movie>, ...]
|
81
|
+
movie.search_wiki # => "https://en.wikipedia.org/wiki/Hackers_(film)"
|
82
|
+
movie.search_youtube # => "https://www.youtube.com/watch?v=vCobCU9FfzI"
|
83
|
+
movie.read_mediainfo # => "General..."
|
84
|
+
movie.capture_screenshots # => [#<Tempfile:/var/folders/l1/qf5v1rlj6n99n20_rhwrp_5r0000gn/T/ss_20.20140803-67537-ur85vi.png>, ...]
|
85
|
+
Videoinfo.upload_screenshot(file) # => "https://i.imgur.com/SoBhWfQ.png"
|
86
|
+
```
|
87
|
+
|
88
|
+
## Contributing
|
89
|
+
|
90
|
+
You are welcome to submit patches with bug fixes or feature additions. Please
|
91
|
+
make sure to test your changes throughly and keep to the style you see throughout
|
92
|
+
the rest of the code base. Indent with 2 spaces and no trailing spaces at the end
|
93
|
+
of lines. Just follow the steps below.
|
94
|
+
|
95
|
+
1. Fork and clone the repository
|
96
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
97
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
98
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
99
|
+
5. Create a Pull Request
|
100
|
+
|
101
|
+
## Links
|
102
|
+
|
103
|
+
* Code: `git clone git@github.com:ryanjohns/videoinfo.git`
|
104
|
+
* Home: <https://github.com/ryanjohns/videoinfo>
|
105
|
+
* Bugs: <https://github.com/ryanjohns/videoinfo/issues>
|
106
|
+
* mediainfo: <http://mediaarea.net/en-us/MediaInfo/Download>
|
107
|
+
* ffmpeg: <https://www.ffmpeg.org/download.html>
|
108
|
+
|
109
|
+
## Author/Maintainter
|
110
|
+
|
111
|
+
* [Ryan Johns](https://github.com/ryanjohns)
|
112
|
+
|
113
|
+
## License
|
114
|
+
|
115
|
+
Videoinfo is released under the [MIT License](http://www.opensource.org/licenses/MIT).
|
data/bin/videoinfo
ADDED
data/lib/videoinfo.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'shellwords'
|
3
|
+
require 'cgi'
|
4
|
+
require 'uri'
|
5
|
+
require 'net/https'
|
6
|
+
require 'json'
|
7
|
+
require 'securerandom'
|
8
|
+
require 'imdb'
|
9
|
+
require 'videoinfo/errors'
|
10
|
+
require 'videoinfo/image_host'
|
11
|
+
require 'videoinfo/image_hosts/imgur'
|
12
|
+
require 'videoinfo/result'
|
13
|
+
require 'videoinfo/results/movie_result'
|
14
|
+
require 'videoinfo/version'
|
15
|
+
require 'videoinfo/video'
|
16
|
+
require 'videoinfo/videos/movie'
|
17
|
+
|
18
|
+
module Videoinfo
|
19
|
+
|
20
|
+
# Helper method to analyze a movie.
|
21
|
+
def self.analyze_movie(name, file, screenshots = 0)
|
22
|
+
Videos::Movie.new(name, file, screenshots).populate_result!
|
23
|
+
end
|
24
|
+
|
25
|
+
# Performs a google search and returns the top 10 results.
|
26
|
+
def self.google(term)
|
27
|
+
uri = URI("https://www.google.com/search?hl=en&q=#{CGI.escape(term)}")
|
28
|
+
begin
|
29
|
+
response = Net::HTTP.get_response(uri)
|
30
|
+
document = Nokogiri::HTML(response.body.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => ''))
|
31
|
+
document.css('cite').map { |node| node.inner_text }
|
32
|
+
rescue => e
|
33
|
+
raise Error, "could not search google for '#{term}'. #{e.message}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Uploads a screenshot to the currently configured image_host and returns a URL to the image.
|
38
|
+
def self.upload_screenshot(image)
|
39
|
+
image_host.upload(image)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Set the path of the mediainfo binary.
|
43
|
+
def self.mediainfo_binary=(mediainfo)
|
44
|
+
@mediainfo_binary = mediainfo.to_s.shellescape
|
45
|
+
end
|
46
|
+
|
47
|
+
# Get the path to the mediainfo binary, defaulting to 'mediainfo'.
|
48
|
+
def self.mediainfo_binary
|
49
|
+
@mediainfo_binary ||= 'mediainfo'
|
50
|
+
end
|
51
|
+
|
52
|
+
# Set the path of the ffmpeg binary.
|
53
|
+
def self.ffmpeg_binary=(ffmpeg)
|
54
|
+
@ffmpeg_binary = ffmpeg.to_s.shellescape
|
55
|
+
end
|
56
|
+
|
57
|
+
# Get the path to the ffmpeg binary, defaulting to 'ffmpeg'.
|
58
|
+
def self.ffmpeg_binary
|
59
|
+
@ffmpeg_binary ||= 'ffmpeg'
|
60
|
+
end
|
61
|
+
|
62
|
+
# Set the image host class. Must be an object that responds to upload(File) and returns a URL.
|
63
|
+
def self.image_host=(host)
|
64
|
+
@image_host = host
|
65
|
+
end
|
66
|
+
|
67
|
+
# Get the image host class, defaulting to ImageHosts::Imgur.new.
|
68
|
+
def self.image_host
|
69
|
+
@image_host ||= ImageHosts::Imgur.new
|
70
|
+
end
|
71
|
+
|
72
|
+
# Set interactive mode to true or false.
|
73
|
+
def self.interactive=(value)
|
74
|
+
@interactive = value
|
75
|
+
end
|
76
|
+
|
77
|
+
# True if interactive mode is enabled, defaulting to false.
|
78
|
+
def self.interactive?
|
79
|
+
@interactive ||= false
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Videoinfo
|
4
|
+
class CLI
|
5
|
+
|
6
|
+
# Analyze a video from command line arguments and print the result to STDOUT.
|
7
|
+
def self.run(args)
|
8
|
+
Videoinfo.interactive = true
|
9
|
+
screenshots = 2
|
10
|
+
option_parser = OptionParser.new do |opts|
|
11
|
+
opts.banner = 'Usage: videoinfo [options] "MOVIENAME" file'
|
12
|
+
opts.on('-i', '--image-host=IMAGEHOST', "The ImageHost to use for uploading screenshots. Default: #{Videoinfo.image_host.class.to_s.split('::').last}") do |host|
|
13
|
+
begin
|
14
|
+
Videoinfo.image_host = Videoinfo::ImageHosts.const_get(host).new
|
15
|
+
rescue
|
16
|
+
hosts = Videoinfo::ImageHosts.constants.map(&:to_s).join(', ')
|
17
|
+
STDERR.puts "ERROR: '#{host}' is an unknown image host. Available hosts: #{hosts}"
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
opts.on('-s', '--screenshots=SCREENSHOTS', "The number of screenshots to create, max 7. Default: #{screenshots}") do |ss|
|
22
|
+
screenshots = ss.to_i
|
23
|
+
if screenshots > 7
|
24
|
+
STDERR.puts opts
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
opts.on('-n', '--no-prompt', 'Disable interactive mode') do
|
29
|
+
Videoinfo.interactive = false
|
30
|
+
end
|
31
|
+
opts.on('-h', '--help', 'Show this message') do
|
32
|
+
puts opts
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
name, file = option_parser.parse!(args)
|
38
|
+
if name.to_s == '' || file.to_s == ''
|
39
|
+
STDERR.puts option_parser
|
40
|
+
exit 1
|
41
|
+
end
|
42
|
+
|
43
|
+
begin
|
44
|
+
result = Videoinfo.analyze_movie(name, file, screenshots)
|
45
|
+
puts result.to_s
|
46
|
+
rescue Error => e
|
47
|
+
STDERR.puts "ERROR: #{e.message}"
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Videoinfo
|
2
|
+
module ImageHosts
|
3
|
+
class Imgur < ImageHost
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@boundary = SecureRandom.hex(6)
|
7
|
+
@header = { 'Content-Type' => "multipart/form-data, boundary=#{@boundary}" }
|
8
|
+
@uri = URI.parse('https://imgur.com/upload')
|
9
|
+
@http = Net::HTTP.new(@uri.host, @uri.port)
|
10
|
+
@http.use_ssl = true
|
11
|
+
end
|
12
|
+
|
13
|
+
def upload(image)
|
14
|
+
begin
|
15
|
+
request = Net::HTTP::Post.new(@uri.request_uri, @header)
|
16
|
+
request.body = post_body(image)
|
17
|
+
response = @http.request(request)
|
18
|
+
img_name = JSON.parse(response.body)['data']['hash']
|
19
|
+
"https://i.imgur.com/#{img_name}.png"
|
20
|
+
rescue => e
|
21
|
+
raise Error, "could not upload image #{File.basename(image.path)}. #{e.message}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def post_body(image)
|
28
|
+
body = "--#{@boundary}\r\n"
|
29
|
+
body << "Content-Disposition: form-data; name=\"Filedata\"; filename=\"#{File.basename(image.path)}\"\r\n"
|
30
|
+
body << "Content-Type: image/png\r\n\r\n"
|
31
|
+
body << image.read
|
32
|
+
body << "\r\n\r\n--#{@boundary}--\r\n"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Videoinfo
|
2
|
+
class Result
|
3
|
+
|
4
|
+
attr_accessor :mediainfo, :screenshot_urls
|
5
|
+
|
6
|
+
def to_s
|
7
|
+
output = []
|
8
|
+
|
9
|
+
if screenshot_urls && screenshot_urls.size > 0
|
10
|
+
output += ['[b]Screenshots:[/b]', '[quote][align=center]']
|
11
|
+
output += screenshot_urls.map { |url| "[img=#{url}]" }
|
12
|
+
output += ['[/align][/quote]', '']
|
13
|
+
end
|
14
|
+
|
15
|
+
output += ['[mediainfo]', mediainfo, '[/mediainfo]']
|
16
|
+
|
17
|
+
output.join("\n")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Videoinfo
|
2
|
+
module Results
|
3
|
+
class MovieResult < Result
|
4
|
+
|
5
|
+
attr_accessor :imdb_id, :title, :plot_summary, :release_date, :rating, :genres, :director, :writers, :runtime, :wiki_url, :trailer_url
|
6
|
+
|
7
|
+
def rating_over_ten
|
8
|
+
rating ? "#{rating} / 10" : nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def imdb_url
|
12
|
+
imdb_id ? "http://www.imdb.com/title/tt#{imdb_id}" : nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
output = ['[b]Description:[/b]', '[quote]', plot_summary, '[/quote]', '']
|
17
|
+
output << '[b]Information:[/b]'
|
18
|
+
output << '[quote]'
|
19
|
+
output << "Title: #{title}"
|
20
|
+
output << "Rating: #{rating_over_ten}"
|
21
|
+
output << "Release Date: #{release_date}"
|
22
|
+
output << "Genres: #{(genres || []).join(' | ')}"
|
23
|
+
output << "Director: #{director}" if director
|
24
|
+
output << "Writers: #{writers.join(', ')}" if writers && writers.size > 0
|
25
|
+
output << "Runtime: #{runtime} minutes" if runtime
|
26
|
+
output << "Wikipedia url: #{wiki_url}" if wiki_url
|
27
|
+
output << "IDMB url: #{imdb_url}"
|
28
|
+
output << '[/quote]'
|
29
|
+
|
30
|
+
if trailer_url
|
31
|
+
output += ['', '[b]Trailer:[/b]', '[quote]', "[center][youtube]#{trailer_url}[/youtube][/center]", '[/quote]']
|
32
|
+
end
|
33
|
+
|
34
|
+
if screenshot_urls && screenshot_urls.size > 0
|
35
|
+
output += ['', '[b]Screenshots:[/b]', '[quote][align=center]']
|
36
|
+
output += screenshot_urls.map { |url| "[img=#{url}]" }
|
37
|
+
output += ['[/align][/quote]']
|
38
|
+
end
|
39
|
+
|
40
|
+
output += ['', '[mediainfo]', mediainfo, '[/mediainfo]']
|
41
|
+
|
42
|
+
output.join("\n")
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Videoinfo
|
2
|
+
class Video
|
3
|
+
|
4
|
+
attr_accessor :name, :file, :screenshots, :result
|
5
|
+
|
6
|
+
def initialize(name, file, screenshots = 0)
|
7
|
+
self.name = name
|
8
|
+
self.file = file
|
9
|
+
self.screenshots = screenshots
|
10
|
+
end
|
11
|
+
|
12
|
+
def file=(f)
|
13
|
+
@file = File.expand_path(f)
|
14
|
+
end
|
15
|
+
|
16
|
+
def result
|
17
|
+
@result ||= Result.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def populate_result!
|
21
|
+
result.mediainfo = read_mediainfo
|
22
|
+
result.screenshot_urls = capture_screenshots.map { |ss| Videoinfo.upload_screenshot(ss) }
|
23
|
+
|
24
|
+
result
|
25
|
+
end
|
26
|
+
|
27
|
+
def read_mediainfo
|
28
|
+
raise Error, "#{file}: file not found" unless File.file?(file)
|
29
|
+
|
30
|
+
info = Dir.chdir(File.dirname(file)) { %x(#{Videoinfo.mediainfo_binary} #{File.basename(file).shellescape}) }
|
31
|
+
raise Error, 'unable to read mediainfo' unless $?.success?
|
32
|
+
|
33
|
+
info
|
34
|
+
end
|
35
|
+
|
36
|
+
def capture_screenshots
|
37
|
+
return [] unless screenshots > 0
|
38
|
+
raise Error, "#{file}: file not found" unless File.file?(file)
|
39
|
+
|
40
|
+
duration = %x(#{Videoinfo.mediainfo_binary} --Inform="General;%Duration%" #{file.shellescape}).strip.to_f / 1000
|
41
|
+
raise Error, 'unable to determine video duration' unless $?.success? && duration > 0
|
42
|
+
|
43
|
+
images = []
|
44
|
+
stepsize = screenshots == 1 ? 100 : 60 / (screenshots - 1)
|
45
|
+
(20..80).step(stepsize) do |percent|
|
46
|
+
image = Tempfile.new(["ss_#{percent}.", '.png'])
|
47
|
+
%x(#{Videoinfo.ffmpeg_binary} -y -ss #{duration * percent / 100} -i #{file.shellescape} -vframes 1 -f image2 #{image.path} -v quiet)
|
48
|
+
if $?.success?
|
49
|
+
images << image
|
50
|
+
else
|
51
|
+
raise Error, "ERROR: unable to capture screenshot at #{percent}% into the video"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
images
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Videoinfo
|
2
|
+
module Videos
|
3
|
+
class Movie < Video
|
4
|
+
|
5
|
+
def result
|
6
|
+
@result ||= Results::MovieResult.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def populate_result!
|
10
|
+
result.mediainfo = read_mediainfo
|
11
|
+
|
12
|
+
movie = search_imdb.first
|
13
|
+
if movie
|
14
|
+
result.imdb_id = movie.id
|
15
|
+
result.title = movie.title.sub(/\(\d{4}\)/, '').strip
|
16
|
+
result.plot_summary = movie.plot_summary
|
17
|
+
result.release_date = movie.release_date
|
18
|
+
result.rating = movie.rating
|
19
|
+
result.genres = movie.genres
|
20
|
+
result.director = movie.director.first
|
21
|
+
result.writers = movie.writers.compact
|
22
|
+
result.runtime = movie.length
|
23
|
+
result.wiki_url = search_wiki
|
24
|
+
result.trailer_url = search_youtube
|
25
|
+
end
|
26
|
+
|
27
|
+
result.screenshot_urls = capture_screenshots.map { |ss| Videoinfo.upload_screenshot(ss) }
|
28
|
+
|
29
|
+
result
|
30
|
+
end
|
31
|
+
|
32
|
+
def search_imdb
|
33
|
+
movies = []
|
34
|
+
begin
|
35
|
+
movies = Imdb::Search.new(name).movies
|
36
|
+
rescue => e
|
37
|
+
raise Error, "could not search IMDB. #{e.message}"
|
38
|
+
end
|
39
|
+
|
40
|
+
return movies unless Videoinfo.interactive?
|
41
|
+
|
42
|
+
movies.each do |m|
|
43
|
+
STDERR.print "Is your movie \"#{m.title}\" (tt#{m.id})? [Y/n] "
|
44
|
+
return [m] if STDIN.gets.strip !~ /^(n|no)$/i
|
45
|
+
end
|
46
|
+
|
47
|
+
[]
|
48
|
+
end
|
49
|
+
|
50
|
+
def search_wiki
|
51
|
+
wiki_url = Videoinfo.google("site:wikipedia.org #{result.title || name} film").first
|
52
|
+
wiki_url ? "https://#{wiki_url}" : nil
|
53
|
+
end
|
54
|
+
|
55
|
+
def search_youtube
|
56
|
+
youtube_url = Videoinfo.google("site:youtube.com #{result.title || name} trailer").first
|
57
|
+
youtube_url ? "https://#{youtube_url}" : nil
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/videoinfo.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('../lib/videoinfo/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'videoinfo'
|
7
|
+
s.version = Videoinfo::VERSION
|
8
|
+
s.summary = 'Simple tool for aggregating video metadata and capturing screenshots'
|
9
|
+
s.description = 'Combines metadata from a variety of sources with codec details from mediainfo to produce a marked-up summary for a video file. Also captures screenshots using ffmpeg and uploads them to a configurable image host.'
|
10
|
+
s.authors = ['Ryan Johns']
|
11
|
+
s.email = 'ryanjohns@gmail.com'
|
12
|
+
s.homepage = 'https://github.com/ryanjohns/videoinfo'
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ['lib']
|
18
|
+
|
19
|
+
s.add_runtime_dependency 'imdb', '~> 0.8'
|
20
|
+
|
21
|
+
s.requirements << 'mediainfo'
|
22
|
+
s.requirements << 'ffmpeg'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: videoinfo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Johns
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: imdb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.8'
|
27
|
+
description: Combines metadata from a variety of sources with codec details from mediainfo
|
28
|
+
to produce a marked-up summary for a video file. Also captures screenshots using
|
29
|
+
ffmpeg and uploads them to a configurable image host.
|
30
|
+
email: ryanjohns@gmail.com
|
31
|
+
executables:
|
32
|
+
- videoinfo
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- ".gitignore"
|
37
|
+
- CHANGELOG.md
|
38
|
+
- Gemfile
|
39
|
+
- README.md
|
40
|
+
- bin/videoinfo
|
41
|
+
- lib/videoinfo.rb
|
42
|
+
- lib/videoinfo/cli.rb
|
43
|
+
- lib/videoinfo/errors.rb
|
44
|
+
- lib/videoinfo/image_host.rb
|
45
|
+
- lib/videoinfo/image_hosts/imgur.rb
|
46
|
+
- lib/videoinfo/result.rb
|
47
|
+
- lib/videoinfo/results/movie_result.rb
|
48
|
+
- lib/videoinfo/version.rb
|
49
|
+
- lib/videoinfo/video.rb
|
50
|
+
- lib/videoinfo/videos/movie.rb
|
51
|
+
- videoinfo.gemspec
|
52
|
+
homepage: https://github.com/ryanjohns/videoinfo
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements:
|
71
|
+
- mediainfo
|
72
|
+
- ffmpeg
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 2.2.2
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Simple tool for aggregating video metadata and capturing screenshots
|
78
|
+
test_files: []
|