Module: Videoinfo

Defined in:
lib/videoinfo.rb,
lib/videoinfo/cli.rb,
lib/videoinfo/video.rb,
lib/videoinfo/errors.rb,
lib/videoinfo/result.rb,
lib/videoinfo/version.rb,
lib/videoinfo/videos/tv.rb,
lib/videoinfo/image_host.rb,
lib/videoinfo/videos/movie.rb,
lib/videoinfo/image_hosts/imgur.rb,
lib/videoinfo/results/tv_result.rb,
lib/videoinfo/results/movie_result.rb

Defined Under Namespace

Modules: ImageHosts, Results, Videos Classes: CLI, Error, ImageHost, Result, Video

Constant Summary collapse

VERSION =
'0.5.3'

Class Method Summary collapse

Class Method Details

.analyze_movie(name, file, screenshots = 0) ⇒ Object

Helper method to analyze a movie.



24
25
26
# File 'lib/videoinfo.rb', line 24

def self.analyze_movie(name, file, screenshots = 0)
  Videos::Movie.new(name, file, screenshots).populate_result!
end

.analyze_tv(name, file, screenshots = 0) ⇒ Object

Helper method to analyze a tv episode or season.



29
30
31
# File 'lib/videoinfo.rb', line 29

def self.analyze_tv(name, file, screenshots = 0)
  Videos::Tv.new(name, file, screenshots).populate_result!
end

.ffmpeg_binaryObject

Get the path to the ffmpeg binary, defaulting to ‘ffmpeg’.



66
67
68
# File 'lib/videoinfo.rb', line 66

def self.ffmpeg_binary
  @ffmpeg_binary ||= 'ffmpeg'
end

.ffmpeg_binary=(ffmpeg) ⇒ Object

Set the path of the ffmpeg binary.



61
62
63
# File 'lib/videoinfo.rb', line 61

def self.ffmpeg_binary=(ffmpeg)
  @ffmpeg_binary = ffmpeg.to_s.shellescape
end

.google(term) ⇒ Object

Performs a google search and returns the top 10 results.



34
35
36
37
38
39
40
41
42
43
# File 'lib/videoinfo.rb', line 34

def self.google(term)
  uri = URI("https://www.google.com/search?hl=en&q=#{CGI.escape(term)}")
  begin
    response = Net::HTTP.get_response(uri)
    document = Nokogiri::HTML(response.body.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => ''))
    document.css('cite').map { |node| node.inner_text }
  rescue => e
    raise Error, "could not search google for '#{term}'. #{e.message}"
  end
end

.image_hostObject

Get the image host class, defaulting to ImageHosts::Imgur.new.



76
77
78
# File 'lib/videoinfo.rb', line 76

def self.image_host
  @image_host ||= ImageHosts::Imgur.new
end

.image_host=(host) ⇒ Object

Set the image host class. Must be an object that responds to upload(File) and returns a URL.



71
72
73
# File 'lib/videoinfo.rb', line 71

def self.image_host=(host)
  @image_host = host
end

.interactive=(value) ⇒ Object

Set interactive mode to true or false.



81
82
83
# File 'lib/videoinfo.rb', line 81

def self.interactive=(value)
  @interactive = value
end

.interactive?Boolean

True if interactive mode is enabled, defaulting to false.

Returns:

  • (Boolean)


86
87
88
# File 'lib/videoinfo.rb', line 86

def self.interactive?
  @interactive ||= false
end

.mediainfo_binaryObject

Get the path to the mediainfo binary, defaulting to ‘mediainfo’.



56
57
58
# File 'lib/videoinfo.rb', line 56

def self.mediainfo_binary
  @mediainfo_binary ||= 'mediainfo'
end

.mediainfo_binary=(mediainfo) ⇒ Object

Set the path of the mediainfo binary.



51
52
53
# File 'lib/videoinfo.rb', line 51

def self.mediainfo_binary=(mediainfo)
  @mediainfo_binary = mediainfo.to_s.shellescape
end

.upload_screenshot(image) ⇒ Object

Uploads a screenshot to the currently configured image_host and returns a URL to the image.



46
47
48
# File 'lib/videoinfo.rb', line 46

def self.upload_screenshot(image)
  image_host.upload(image)
end