osdb 0.1.3 → 0.2.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: 92d5c8afe4f667570f34fc70eb58f92fc18b8992
4
- data.tar.gz: e9d13b0eef33b5575c8c3e7cf0e63f856331587e
3
+ metadata.gz: 979dfb4d31ea0378b76781add14375369b33845d
4
+ data.tar.gz: 7f0ad3167832f4bb0ae34b2ecdb32d2d60620627
5
5
  SHA512:
6
- metadata.gz: 5ab8e63b010b4351cbf20b678456d5ae68a41e240eafc6ee6444d5102b8378b19886374b8ea342a6d9398f8a40401dce341e608dc25e8df8310aa37a06e9a80d
7
- data.tar.gz: 4d3db1f8c1e04e7adc99e490f7d8bba4d5df4d889ef76f310649f85f105e8e1fbbc17c3a31a75d7ff417c86bd9044fac63189e858f6eacbf4af2aca29e400432
6
+ metadata.gz: 82f15527f5291e19ec795775e27609e8664508f49fa97bd7751635073df2936babe06a278f302251fe59a4007c6c70cc55f32a91998040942489534bc1592b3a
7
+ data.tar.gz: c1bd1ce6031cfcb2da4ab1d427bc413762115afac38c674390c9ae4b669704f4208275818938b0035f008b2819fde6eefb5cd9799bdf068fcbcb30d0cefda4da
@@ -1,9 +1,9 @@
1
1
  rvm:
2
- - 1.8.7 # (current default)
2
+ - 1.8.7
3
3
  - 1.9.2
4
4
  - 1.9.3
5
+ - 2.0.0
5
6
  - rbx
6
7
  - jruby
7
- - ruby-head
8
8
  - ree
9
9
 
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jean Boussier
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -4,6 +4,7 @@ Client library for the [OSDb protocol](http://trac.opensubtitles.org/projects/op
4
4
  Currently the implentation is limited to movie identification and subtitles search
5
5
 
6
6
  [![Build Status](https://secure.travis-ci.org/byroot/ruby-osdb.png)](http://travis-ci.org/byroot/ruby-osdb)
7
+ [![Gem Version](https://badge.fury.io/rb/osdb.png)](http://badge.fury.io/rb/osdb)
7
8
 
8
9
  ## Examples
9
10
 
data/bin/getsub CHANGED
@@ -8,7 +8,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'osdb'))
8
8
  class GetSub
9
9
 
10
10
  def initialize
11
- @options = {:language => env_lang.to_iso639_2b, :force => false, :dir => nil, :methods => 'h'}
11
+ @options = {:language => OSDb.default_language.to_iso639_2b, :force => false, :dir => nil, :methods => 'h', :language_extension => false }
12
12
  @parser ||= OptionParser.new do |opts|
13
13
  opts.banner = "Automatically download subs for your video files using opensubtitle.org"
14
14
  opts.separator ""
@@ -18,7 +18,7 @@ class GetSub
18
18
 
19
19
  opts.on("-a", "--auto", "Do not ask user to resolve hash conflicts.") { @options[:auto] = true }
20
20
 
21
- opts.on("-l", "--language LANGUAGE", "Sub language ISO 639-2 code like fre or eng. Default: env $LANG (#{env_lang.to_iso639_2b})") do |language|
21
+ opts.on("-l", "--language LANGUAGE", "Sub language ISO 639-2 code like fre or eng. Default: env $LANG (#{OSDb.default_language.to_iso639_2b})") do |language|
22
22
  if language.to_s.length != 3
23
23
  STDERR.puts "Invalid argument: Language should specified as ISO 639-2 (ie, 3 letters, like 'eng' or 'fre')"
24
24
  exit 1
@@ -30,6 +30,8 @@ class GetSub
30
30
 
31
31
  opts.on("-t", "--type FORMATS", "Select only subtitles in specified formats. e.g -t srt,sub") { |formats| @options[:formats] = formats.to_s.split(',') }
32
32
 
33
+ opts.on("-L", "--language-extension", "Add the ISO 639-2 in the subtitle's file extension. e.g filename.eng.srt" ) { @options[:language_extension] = true }
34
+
33
35
  methods_help = "Ordered list of search methods. h: by movie hash, i: by name on IMDB, n: by name on OSDb, p: by filename on OSDb. e.g -s hi . Default: h"
34
36
  opts.on("-s", "--search-by METHODS", methods_help) do |methods|
35
37
  unless methods =~ /^[hinp]+$/
@@ -42,14 +44,11 @@ class GetSub
42
44
  end
43
45
  end
44
46
 
45
- def env_lang
46
- OSDb::Language.from_locale(ENV['LANG'])
47
- end
48
-
49
47
  def run!(files)
50
48
  @parser.parse!
49
+ language = @options[:language] if @options[:language_extension]
51
50
 
52
- movie_files = glob(files).map{ |path| OSDb::MovieFile.new(path) }
51
+ movie_files = glob(files).map{ |path| OSDb::MovieFile.new(path, language) }
53
52
 
54
53
  movie_files.each do |movie_file|
55
54
  begin
@@ -13,4 +13,9 @@ module OSDb
13
13
  autoload :Server, "#{base_path}/server"
14
14
  autoload :Sub, "#{base_path}/sub"
15
15
  autoload :SubtitleFinder, "#{base_path}/subtitle_finder"
16
+
17
+ def self.default_language
18
+ OSDb::Language.from_locale(ENV['LANG'] || 'en_US.UTF-8')
19
+ end
20
+
16
21
  end
@@ -3,20 +3,26 @@ module OSDb
3
3
 
4
4
  EXTENSIONS = %w(avi mpg m4v mkv mov ogv mp4)
5
5
 
6
- attr_reader :path
6
+ attr_reader :path, :language
7
7
 
8
- def initialize(path)
8
+ def initialize(path, language = OSDb.default_language)
9
9
  @path = path
10
+ @language = language
10
11
  end
11
12
 
12
13
  def has_sub?
13
14
  exist = false
14
- %w(.srt .sub).each{ |ext| exist ||= File.exist?(path.gsub(File.extname(path), ext)) }
15
+ %w(srt sub).each{ |ext| exist ||= File.exist?(sub_path(ext)) }
15
16
  exist
16
17
  end
17
18
 
18
19
  def sub_path(format)
19
- path.gsub(File.extname(path), ".#{format}")
20
+ extension = if @language
21
+ ".#{@language}.#{format}"
22
+ else
23
+ ".#{format}"
24
+ end
25
+ path.gsub(File.extname(path), extension)
20
26
  end
21
27
 
22
28
  def hash
@@ -1,3 +1,3 @@
1
1
  module OSDb
2
- VERSION = '0.1.3'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -16,9 +16,11 @@ Gem::Specification.new do |s|
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
+ s.license = 'MIT'
19
20
 
20
21
  s.add_development_dependency 'rake'
21
22
  s.add_development_dependency 'rspec'
23
+ s.add_development_dependency 'rspec-its'
22
24
  s.add_development_dependency 'webmock', '~> 1.8.11'
23
25
  s.add_development_dependency 'vcr', '~> 2.3.0'
24
26
  end
@@ -1,5 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../lib/osdb'
2
2
  require 'rspec'
3
+ require 'rspec/its'
3
4
 
4
5
  require 'webmock/rspec'
5
6
  require 'vcr'
metadata CHANGED
@@ -1,69 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-14 00:00:00.000000000 Z
11
+ date: 2014-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-its
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: webmock
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ~>
59
+ - - "~>"
46
60
  - !ruby/object:Gem::Version
47
61
  version: 1.8.11
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ~>
66
+ - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: 1.8.11
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: vcr
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ~>
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
75
  version: 2.3.0
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ~>
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: 2.3.0
69
83
  description:
@@ -74,10 +88,11 @@ executables:
74
88
  extensions: []
75
89
  extra_rdoc_files: []
76
90
  files:
77
- - .gitignore
78
- - .rspec
79
- - .travis.yml
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
80
94
  - Gemfile
95
+ - LICENSE.txt
81
96
  - README.md
82
97
  - Rakefile
83
98
  - bin/getsub
@@ -118,7 +133,8 @@ files:
118
133
  - spec/osdb/sub_spec.rb
119
134
  - spec/spec_helper.rb
120
135
  homepage: http://github.com/byroot/ruby-osdb
121
- licenses: []
136
+ licenses:
137
+ - MIT
122
138
  metadata: {}
123
139
  post_install_message:
124
140
  rdoc_options: []
@@ -126,17 +142,17 @@ require_paths:
126
142
  - lib
127
143
  required_ruby_version: !ruby/object:Gem::Requirement
128
144
  requirements:
129
- - - '>='
145
+ - - ">="
130
146
  - !ruby/object:Gem::Version
131
147
  version: '0'
132
148
  required_rubygems_version: !ruby/object:Gem::Requirement
133
149
  requirements:
134
- - - '>='
150
+ - - ">="
135
151
  - !ruby/object:Gem::Version
136
152
  version: '0'
137
153
  requirements: []
138
154
  rubyforge_project: osdb
139
- rubygems_version: 2.0.3
155
+ rubygems_version: 2.2.2
140
156
  signing_key:
141
157
  specification_version: 4
142
158
  summary: Ruby library to access OSDb services like OpenSubtitles.org