subtitle_it 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ba994bab78c7d2abcca319da9a1aeea70054119
4
- data.tar.gz: 61b309ea11dd3a8280020f9730936a7eb4ec9e50
3
+ metadata.gz: e7e689a69c1ee1db901aa8c97651f1eaae2d40a0
4
+ data.tar.gz: b74b880955817937099c773f69bde83b5f61ff8e
5
5
  SHA512:
6
- metadata.gz: cf011b00c3682d28a8756b07ae1e91871cb120d43c1a6cd567e0b63e96a31ebf8af46cddd5ae71964ce35888d5e2cb19dae39ded26e60c7ab3f538dc67c897dc
7
- data.tar.gz: 3dd03b48ac2bf130f72159ff9fa1d6f7358eb4ad424a1e819ba0490f2fc43ea51cf4372cc9f9da99273c928473986110fa9b48f86d9b94fa7f2fbf65c35e1784
6
+ metadata.gz: 16c219776a8c22a05f9d4e14c0e6ccb4391b33d8323a6ff159058174f0171673f66ad227a45385a08b374985f15d35dcf5ecf5b57a690b722e5193934b67665b
7
+ data.tar.gz: 952cead4beaee7653cb729c26f7b53dbb51bda920f1b44348fe7cf4540f7f6dfcf3f69d157040b805c777b2b1c424b272d9e0c832e63eab807556ccacc1684a7
@@ -1,7 +1,11 @@
1
1
  module SubtitleIt
2
+ #
3
+ # Le Movie
4
+ #
2
5
  class Movie
3
6
  attr_reader :filename
4
7
  attr_accessor :info
8
+
5
9
  CHUNK_SIZE = 64 * 1024 # in bytes
6
10
 
7
11
  def initialize(filename)
@@ -44,12 +44,12 @@ module SubtitleIt
44
44
  args = {
45
45
  'sublanguageid' => lang_name || '',
46
46
  'moviehash' => movie.haxx,
47
- 'moviebytesize' => movie.size
47
+ # 'moviebytesize' => movie.size
48
48
  }
49
49
 
50
50
  result = request('SearchSubtitles', [args])
51
51
  return [] unless result['data'] # if no results result['data'] == false
52
- result['data'].inject([]) do |subs, sub_info|
52
+ result['data'].reduce([]) do |subs, sub_info|
53
53
  subs << Subtitle.new(info: sub_info)
54
54
  subs
55
55
  end
@@ -95,7 +95,7 @@ module SubtitleIt
95
95
 
96
96
  def request(method, *args)
97
97
  unless NO_TOKEN.include? method
98
- fail 'Need to be logged in for this.' unless logged_in?
98
+ raise 'Need to be logged in for this.' unless logged_in?
99
99
  args = [@token, *args]
100
100
  end
101
101
 
@@ -103,8 +103,8 @@ module SubtitleIt
103
103
 
104
104
  unless self.class.result_status_ok?(result)
105
105
  # 'status' of the form 'XXX Message'
106
- fail XMLRPC::FaultException.new(result['status'].to_i,
107
- result['status'][4..-1])
106
+ raise XMLRPC::FaultException.new(result['status'].to_i,
107
+ result['status'][4..-1])
108
108
  end
109
109
 
110
110
  result
@@ -9,20 +9,32 @@ require 'subtitle_it/formats/mpl'
9
9
  # http://www.opensubtitles.org/addons/export_languages.php
10
10
 
11
11
  module SubtitleIt
12
- MOVIE_EXTS = %w(3g2 3gp 3gp2 3gpp 60d ajp asf asx avchd avi bik bix box cam dat divx dmf dv dvr-ms evo flc fli flic flv flx gvi gvp h264 m1v m2p m2ts m2v m4e m4v mjp mjpeg mjpg mkv moov mov movhd movie movx mp4 mpe mpeg mpg mpv mpv2 mxf nsv nut ogg ogm omf ps qt ram rm rmvb swf ts vfw vid video viv vivo vob vro wm wmv wmx wrap wvx wx x264 xvid)
13
- SUB_EXTS = %w(srt sub smi txt ssa ass mpl xml yml rsb)
12
+ MOVIE_EXTS = %w(3g2 3gp 3gp2 3gpp 60d ajp asf asx avchd avi bik bix box cam
13
+ dat divx dmf dv dvr-ms evo flc fli flic flv flx gvi gvp h264
14
+ m1v m2p m2ts m2v m4e m4v mjp mjpeg mjpg mkv moov mov movhd
15
+ movie movx mp4 mpe mpeg mpg mpv mpv2 mxf nsv nut ogg ogm omf
16
+ ps qt ram rm rmvb swf ts vfw vid video viv vivo vob vro wm
17
+ wmv wmx wrap wvx wx x264 xvid).freeze
14
18
 
19
+ SUB_EXTS = %w(srt sub smi txt ssa ass mpl xml yml rsb).freeze
20
+
21
+ #
22
+ # Le Subtitle pour le Movie
23
+ #
15
24
  class Subtitle
16
25
  include Comparable
17
26
  include Formats
18
- attr_reader :id, :raw, :format, :lines, :style, :info, :filename, :rating, :language, :user, :release_name,
19
- :osdb_id, :download_count, :download_url, :original_filename
27
+
28
+ attr_reader :id, :raw, :format, :lines, :style, :info, :filename, :rating,
29
+ :language, :user, :release_name, :osdb_id, :original_filename,
30
+ :download_count, :download_url
31
+
20
32
  attr_writer :style, :lines, :fps
21
33
 
22
34
  def initialize(args = {})
23
35
  # Looks like opensubtitle is the only provider around..
24
36
  # If a second one comes need big refactor...
25
- if @info = args[:info]
37
+ if (@info = args[:info])
26
38
  # @osdb_info = info
27
39
  @osdb_id = @info['IDSubtitleFile'].to_s
28
40
  @original_filename = @info['SubFileName'].to_s
@@ -32,11 +44,11 @@ module SubtitleIt
32
44
  @release_name = @info['MovieReleaseName'].to_s
33
45
  @download_count = @info['SubDownloadsCnt'].to_i
34
46
  @rating = @info['SubRating'].to_f
35
- @uploaded_at = @info['SubAddDate'].to_s # TODO: convert to time object?
47
+ @uploaded_at = @info['SubAddDate'].to_s # TODO: convert to Date?
36
48
  @download_url = @info['SubDownloadLink'].to_s
37
49
  end
38
50
  @fps = args[:fps] || 23.976
39
- return unless dump = args[:dump]
51
+ return unless args[:dump]
40
52
  parse_dump(args[:dump], args[:format])
41
53
  end
42
54
 
@@ -52,7 +64,7 @@ module SubtitleIt
52
64
 
53
65
  # Force subtitles to be UTF-8
54
66
  def encode_dump(dump)
55
- dump = dump.read unless dump.kind_of?(String)
67
+ dump = dump.read unless dump.is_a?(String)
56
68
 
57
69
  enc = CharlockHolmes::EncodingDetector.detect(dump)
58
70
  if enc[:encoding] != 'UTF-8'
@@ -63,7 +75,7 @@ module SubtitleIt
63
75
  end
64
76
 
65
77
  def parse_dump(dump, format)
66
- fail unless SUB_EXTS.include?(format)
78
+ raise unless SUB_EXTS.include?(format)
67
79
  @raw = encode_dump(dump)
68
80
  @format = format
69
81
  parse_lines!
@@ -1,3 +1,3 @@
1
1
  module SubtitleIt
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'.freeze
3
3
  end
@@ -6,10 +6,10 @@ Gem::Specification.new do |s|
6
6
  s.version = SubtitleIt::VERSION
7
7
  s.platform = Gem::Platform::RUBY
8
8
 
9
- s.authors = ["Marcos Piccinini"]
9
+ s.authors = ['Marcos Piccinini']
10
10
  s.email = 'x@nofxx.com'
11
11
 
12
- s.date = Time.now.strftime("%Y-%m-%d")
12
+ s.date = Time.now.strftime('%Y-%m-%d')
13
13
  s.default_executable = 'subtitle_it'
14
14
 
15
15
  s.homepage = 'http://github.com/nofxx/subtitle_it'
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
22
  s.require_paths = ['lib']
23
23
 
24
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
25
25
  # s.extra_rdoc_files = s.files.grep(%r{^(rdoc)/})
26
26
 
27
27
  s.add_dependency 'colorize'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subtitle_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Piccinini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-13 00:00:00.000000000 Z
11
+ date: 2017-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize