Class: Videoinfo::Videos::Movie
Instance Attribute Summary
#file, #name, #screenshots
Instance Method Summary
collapse
#capture_screenshots, #initialize, #read_mediainfo
Instance Method Details
#populate_result! ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/videoinfo/videos/movie.rb', line 9
def populate_result!
result.mediainfo = read_mediainfo
movie = search_imdb.first
if movie
result.imdb_id = movie.id
result.title = movie.title.sub(/\(\d{4}\)/, '').strip
result.plot_summary = movie.plot_summary
result.release_date = movie.release_date
result.rating = movie.rating
result.genres = movie.genres
result.director = movie.director.first
result.writers = movie.writers.compact
result.runtime = movie.length
result.wiki_url = search_wiki
result.trailer_url = search_youtube
end
result.screenshot_urls = capture_screenshots.map { |ss| Videoinfo.upload_screenshot(ss) }
result
end
|
#result ⇒ Object
5
6
7
|
# File 'lib/videoinfo/videos/movie.rb', line 5
def result
@result ||= Results::MovieResult.new
end
|
#search_imdb ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/videoinfo/videos/movie.rb', line 32
def search_imdb
movies = []
begin
movies = Imdb::Search.new(name).movies
rescue => e
raise Error, "could not search IMDB. #{e.message}"
end
return movies unless Videoinfo.interactive?
movies.each do |m|
STDERR.print "Is your movie \"#{m.title}\" (tt#{m.id})? [Y/n] "
return [m] if STDIN.gets.strip !~ /^(n|no)$/i
end
[]
end
|
#search_wiki ⇒ Object
50
51
52
53
|
# File 'lib/videoinfo/videos/movie.rb', line 50
def search_wiki
wiki_url = Videoinfo.google("site:wikipedia.org #{result.title || name} film").first
wiki_url ? "https://#{wiki_url}" : nil
end
|
#search_youtube ⇒ Object
55
56
57
58
|
# File 'lib/videoinfo/videos/movie.rb', line 55
def search_youtube
youtube_url = Videoinfo.google("site:youtube.com #{result.title || name} trailer").first
youtube_url ? "https://#{youtube_url}" : nil
end
|