videoinfo 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a86593efef4a57d606da91d247d826ee4fb153ba
4
- data.tar.gz: 97f1924ce62876d15b980c9083f93466a0d9fc11
3
+ metadata.gz: 33e98615cb1b94110418f42ea3028e4770c1c078
4
+ data.tar.gz: 4e69fa05d0c0f9639057da5e4e5af7cf738d6732
5
5
  SHA512:
6
- metadata.gz: 7710e0b861920c50b3689ae184a7dc5484627367bcf4f87ea1b31cbcc11bf982cee21f0359826318ec3ba2dfd2ea74b50fc65a70cc85286b145230f2aa9382e2
7
- data.tar.gz: 1cc9288f163af5cf4f0b2beb0403a75ef824f6233bb535986e6a3aa75c44a2ed59fc0ed1d6d51e2b3a5ea806669db97594ba747ebe319157751420a8097e9e54
6
+ metadata.gz: 1d70fe7bb03a34f7302904d7d948183604a67f353c09da91a60a7d9ad1e65bf74ac006ff1ac5d965f18994afb310f61ee19d36e68e218dff9e2b72bb6def4b9d
7
+ data.tar.gz: d778dab1561ec8bc158cdf9159c1794662d5e25a8a2e9fd8d462a58abfd982dbdf334e82e542bfdfe18be1b4d2aae660e9f3860c223b099a7be13becfac92e68
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## CHANGELOG
2
2
 
3
+ #### Version 0.5.0 (September 29, 2015)
4
+ * Add support for TV episodes
5
+
3
6
  #### Version 0.4.0 (August 8, 2014)
4
7
  * Fixed using custom image hosts from the command line
5
8
 
data/README.md CHANGED
@@ -38,9 +38,10 @@ Videoinfo.interactive = true # defaults to true when using
38
38
 
39
39
  ```
40
40
  $ videoinfo -h
41
- Usage: videoinfo [options] "MOVIENAME" file
42
- -i, --image-host=IMAGEHOST The ImageHost to use for uploading screenshots. Default: Imgur
41
+ Usage: videoinfo [options] "MOVIENAME/SHOWNAME" file
42
+ -i, --image-host=IMAGEHOST The image host to use for uploading screenshots. Default: Imgur
43
43
  -s, --screenshots=SCREENSHOTS The number of screenshots to create, max 7. Default: 2
44
+ -e, --episode=EPISODE The TV show episode or season number. Formats: S01E01 or S01
44
45
  -n, --no-prompt Disable interactive mode
45
46
  -h, --help Show this message
46
47
 
@@ -85,6 +86,13 @@ movie.capture_screenshots # => [#<Tempfile:/var/folders/l1/qf5v1rlj6n99n
85
86
  Videoinfo.upload_screenshot(file) # => "https://i.imgur.com/SoBhWfQ.png"
86
87
  ```
87
88
 
89
+ It works with TV shows too:
90
+
91
+ ```ruby
92
+ result = Videoinfo.analyze_tv('survivor s01e01', 'survivor.s01e01.mkv', 0) # => #<Videoinfo::Results::TvResult>
93
+ tv = Videoinfo::Videos::Tv.new('survivor s01e01', 'survivor.s01e01.mkv', 3)
94
+ ````
95
+
88
96
  ## Contributing
89
97
 
90
98
  You are welcome to submit patches with bug fixes or feature additions. Please
data/lib/videoinfo.rb CHANGED
@@ -11,9 +11,11 @@ require 'videoinfo/image_host'
11
11
  require 'videoinfo/image_hosts/imgur'
12
12
  require 'videoinfo/result'
13
13
  require 'videoinfo/results/movie_result'
14
+ require 'videoinfo/results/tv_result'
14
15
  require 'videoinfo/version'
15
16
  require 'videoinfo/video'
16
17
  require 'videoinfo/videos/movie'
18
+ require 'videoinfo/videos/tv'
17
19
 
18
20
  module Videoinfo
19
21
 
@@ -22,6 +24,11 @@ module Videoinfo
22
24
  Videos::Movie.new(name, file, screenshots).populate_result!
23
25
  end
24
26
 
27
+ # Helper method to analyze a tv episode or season.
28
+ def self.analyze_tv(name, file, screenshots = 0)
29
+ Videos::Tv.new(name, file, screenshots).populate_result!
30
+ end
31
+
25
32
  # Performs a google search and returns the top 10 results.
26
33
  def self.google(term)
27
34
  uri = URI("https://www.google.com/search?hl=en&q=#{CGI.escape(term)}")
data/lib/videoinfo/cli.rb CHANGED
@@ -10,9 +10,10 @@ module Videoinfo
10
10
  Videoinfo.interactive = true
11
11
  image_host = ENV[ENV_IMAGE_HOST] || Videoinfo.image_host.class.to_s.split('::').last
12
12
  screenshots = 2
13
+ episode = nil
13
14
  option_parser = OptionParser.new do |opts|
14
- opts.banner = 'Usage: videoinfo [options] "MOVIENAME" file'
15
- opts.on('-i', '--image-host=IMAGEHOST', "The ImageHost to use for uploading screenshots. Default: #{image_host}") do |host|
15
+ opts.banner = 'Usage: videoinfo [options] "MOVIENAME/SHOWNAME" file'
16
+ opts.on('-i', '--image-host=IMAGEHOST', "The image host to use for uploading screenshots. Default: #{image_host}") do |host|
16
17
  image_host = host
17
18
  end
18
19
  opts.on('-s', '--screenshots=SCREENSHOTS', "The number of screenshots to create, max 7. Default: #{screenshots}") do |ss|
@@ -22,6 +23,14 @@ module Videoinfo
22
23
  exit 1
23
24
  end
24
25
  end
26
+ opts.on('-e', '--episode=EPISODE', 'The TV show episode or season number. Formats: S01E01 or S01') do |ep|
27
+ if ep =~ /\AS\d{2,3}\z/i || ep =~ /\AS\d{2,3}E\d{2,3}\z/i
28
+ episode = ep
29
+ else
30
+ STDERR.puts opts
31
+ exit 1
32
+ end
33
+ end
25
34
  opts.on('-n', '--no-prompt', 'Disable interactive mode') do
26
35
  Videoinfo.interactive = false
27
36
  end
@@ -41,13 +50,17 @@ module Videoinfo
41
50
  exit 1
42
51
  end
43
52
 
44
- if name.to_s == '' || file.to_s == ''
53
+ if name.to_s.strip == '' || file.to_s.strip == ''
45
54
  STDERR.puts option_parser
46
55
  exit 1
47
56
  end
48
57
 
49
58
  begin
50
- result = Videoinfo.analyze_movie(name, file, screenshots)
59
+ if episode
60
+ result = Videoinfo.analyze_tv("#{name} #{episode}".strip, file.strip, screenshots)
61
+ else
62
+ result = Videoinfo.analyze_movie(name.strip, file.strip, screenshots)
63
+ end
51
64
  puts result.to_s
52
65
  rescue Error => e
53
66
  STDERR.puts "ERROR: #{e.message}"
@@ -0,0 +1,50 @@
1
+ module Videoinfo
2
+ module Results
3
+ class TvResult < Result
4
+
5
+ attr_accessor :imdb_id, :title, :plot, :rating, :genres, :country, :premiered, :season_number, :episode_number, :episode_imdb_id, :episode_title, :episode_url, :episode_rating, :air_date
6
+
7
+ def rating_over_ten
8
+ rating ? "#{rating} / 10" : nil
9
+ end
10
+
11
+ def episode_rating_over_ten
12
+ episode_rating ? "#{episode_rating} / 10" : nil
13
+ end
14
+
15
+ def imdb_url
16
+ imdb_id ? "http://www.imdb.com/title/tt#{imdb_id}" : nil
17
+ end
18
+
19
+ def to_s
20
+ output = ['[b]Description:[/b]', '[quote]', plot, '[/quote]', '']
21
+ output << '[b]Information:[/b]'
22
+ output << '[quote]'
23
+ output << "Show Name: #{title}"
24
+ output << "Show url: #{imdb_url}"
25
+ output << "Rating: #{rating_over_ten}"
26
+ output << "Genres: #{(genres || []).join(' | ')}"
27
+ output << "Country: #{country}"
28
+ output << "Premiered: #{premiered}" if premiered
29
+ output << "Season Number: #{season_number}" if season_number
30
+ output << "Episode Number: #{episode_number}" if episode_number
31
+ output << "Episode Name: #{episode_title}" if episode_title
32
+ output << "Episode url: #{episode_url}" if episode_url
33
+ output << "Episode Rating: #{episode_rating_over_ten}" if episode_rating_over_ten
34
+ output << "Air Date: #{air_date}" if air_date
35
+ output << '[/quote]'
36
+
37
+ if screenshot_urls && screenshot_urls.size > 0
38
+ output += ['', '[b]Screenshots:[/b]', '[quote][align=center]']
39
+ output += screenshot_urls.map { |url| "[img=#{url}]" }
40
+ output += ['[/align][/quote]']
41
+ end
42
+
43
+ output += ['', '[mediainfo]', mediainfo, '[/mediainfo]']
44
+
45
+ output.join("\n")
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -1,3 +1,3 @@
1
1
  module Videoinfo
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -0,0 +1,80 @@
1
+ module Videoinfo
2
+ module Videos
3
+ class Tv < Video
4
+
5
+ attr_reader :episode_string, :season_number, :episode_number
6
+
7
+ def result
8
+ @result ||= Results::TvResult.new
9
+ end
10
+
11
+ def populate_result!
12
+ result.mediainfo = read_mediainfo
13
+
14
+ serie = search_imdb.first
15
+ if serie
16
+ result.imdb_id = serie.id
17
+ result.title = serie.title
18
+ result.plot = serie.plot
19
+ result.rating = serie.rating
20
+ result.genres = serie.genres
21
+ result.country = serie.countries.first
22
+ result.premiered = serie.year
23
+
24
+ if season_number
25
+ season = serie.season(season_number.to_i)
26
+ if season
27
+ result.season_number = season.season_number
28
+ if episode_number
29
+ episode = season.episode(episode_number.to_i)
30
+ if episode
31
+ result.episode_number = episode.episode
32
+ result.episode_imdb_id = episode.id
33
+ result.episode_title = episode.title
34
+ result.episode_url = episode.url
35
+ result.episode_rating = episode.rating
36
+ result.air_date = episode.air_date
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ result.screenshot_urls = capture_screenshots.map { |ss| Videoinfo.upload_screenshot(ss) }
44
+
45
+ result
46
+ end
47
+
48
+ def search_imdb
49
+ series = []
50
+ begin
51
+ series = Imdb::Search.new(name).movies
52
+ rescue => e
53
+ raise Error, "could not search IMDB. #{e.message}"
54
+ end
55
+
56
+ return series.map { |s| Imdb::Serie.new(s.id) } unless Videoinfo.interactive?
57
+
58
+ series.each do |s|
59
+ STDERR.print "Is your series \"#{s.title}\" (tt#{s.id})? [Y/n] "
60
+ return [Imdb::Serie.new(s.id)] if STDIN.gets.strip !~ /^(n|no)$/i
61
+ end
62
+
63
+ []
64
+ end
65
+
66
+ def name=(n)
67
+ @episode_string = n.slice!(/(\AS\d{2,3}E\d{2,3}\ |\ S\d{2,3}E\d{2,3}\z|\AS\d{2,3}\ |\ S\d{2,3}\z)/i)
68
+ @name = n
69
+
70
+ if @episode_string
71
+ @episode_string.strip!
72
+ @season_number, @episode_number = @episode_string.gsub(/[SE]/i, ' ').split
73
+ end
74
+
75
+ @name
76
+ end
77
+
78
+ end
79
+ end
80
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: videoinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Johns
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-08 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: imdb
@@ -45,9 +45,11 @@ files:
45
45
  - lib/videoinfo/image_hosts/imgur.rb
46
46
  - lib/videoinfo/result.rb
47
47
  - lib/videoinfo/results/movie_result.rb
48
+ - lib/videoinfo/results/tv_result.rb
48
49
  - lib/videoinfo/version.rb
49
50
  - lib/videoinfo/video.rb
50
51
  - lib/videoinfo/videos/movie.rb
52
+ - lib/videoinfo/videos/tv.rb
51
53
  - videoinfo.gemspec
52
54
  homepage: https://github.com/ryanjohns/videoinfo
53
55
  licenses:
@@ -71,7 +73,7 @@ requirements:
71
73
  - mediainfo
72
74
  - ffmpeg
73
75
  rubyforge_project:
74
- rubygems_version: 2.2.2
76
+ rubygems_version: 2.4.6
75
77
  signing_key:
76
78
  specification_version: 4
77
79
  summary: Simple tool for aggregating video metadata and capturing screenshots