suby 0.4.5 → 0.4.6

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: f2450f15d4c3f770a02867f5c1dc54bb8915e43b
4
- data.tar.gz: 045ac1448b914694be439bfac694f333bdd2b19a
3
+ metadata.gz: ea64dff7ca20833220712ab314cac127bfa30585
4
+ data.tar.gz: 0b151066baa804a8530e5def830e45300716d2d9
5
5
  SHA512:
6
- metadata.gz: d6c0f45255828fd26d204914d9f165e8f2219fc90c6f025256a482cbb7545d10e3bfb868a43df6b7d69bd70bcbf58985c565773a4bf5c050a5e711efe890a522
7
- data.tar.gz: fc136a2f6561b4b1ca95615d8ca2b3351031a39ea534664397799c3891ea6608e030eb67672e5974e166661830506029fc062a614786938c6da5254ad506d35e
6
+ metadata.gz: f3813065dedd61305cd15d0df468177c392de5d638b3bb8597fe69910112a9edb58e4066f871e7f3cad775791b11a660e1c148a5b3d0c5b02928ccb259dcac52
7
+ data.tar.gz: 1fa64946d1d8be0ba23eb056370c36f8c336ca548a64961df835a8d4923fb2f2fcedd6aa685444cae5b56fad8c8d5bd9098b3be5bf7678e6915bc62212f97a9a
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # suby
1
+ # suby [![Build Status](https://travis-ci.org/eregon/suby.svg?branch=master)](https://travis-ci.org/eregon/suby)
2
2
 
3
3
  Find and download subtitles
4
4
 
@@ -15,7 +15,8 @@ module Suby
15
15
  "Filter ignored"
16
16
 
17
17
  def subtitles_url
18
- "/serie/#{CGI.escape show}/#{season}/#{episode}/#{LANG_IDS[lang]}"
18
+ encoded_show = CGI.escape show.tr(' ','_')
19
+ "/serie/#{encoded_show}/#{season}/#{episode}/#{LANG_IDS[lang]}"
19
20
  end
20
21
 
21
22
  def subtitles_response
@@ -1,7 +1,7 @@
1
1
  module Suby
2
2
  # Based on https://github.com/byroot/ruby-osdb/blob/master/lib/osdb/server.rb
3
3
  class Downloader::OpenSubtitles < Downloader
4
- SITE = 'dl.opensubtitles.net'
4
+ SITE = 'dl.opensubtitles.org'
5
5
  FORMAT = :gz
6
6
  XMLRPC_HOST = 'api.opensubtitles.org'
7
7
  XMLRPC_PATH = '/xml-rpc'
@@ -30,17 +30,22 @@ module Suby
30
30
 
31
31
  def download_url
32
32
  SEARCH_QUERIES_ORDER.find(lambda { raise NotFoundError, "no subtitles available" }) { |type|
33
- if subs = search_subtitles(search_query(type))['data']
33
+ subs = search_subtitles(search_query(type))
34
+ if subs && !subs.empty?
34
35
  @type = type
35
36
  break subs
36
37
  end
37
- }.first['SubDownloadLink']
38
+ }.sample['SubDownloadLink']
38
39
  end
39
40
 
40
41
  def search_subtitles(query)
41
- return {} unless query
42
- query = [query] unless query.kind_of? Array
43
- xmlrpc.call('SearchSubtitles', token, query)
42
+ return [] unless query
43
+ response = xmlrpc.call('SearchSubtitles', token, [query])
44
+ data = response["data"]
45
+ return [] unless data
46
+ data.select { |sub|
47
+ sub["SubDownloadLink"] and sub["SubLanguageID"] == query[:sublanguageid]
48
+ }
44
49
  end
45
50
 
46
51
  def token
@@ -12,10 +12,10 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.required_ruby_version = '>= 1.9.2'
14
14
  s.add_dependency 'path', '~> 1.3'
15
- s.add_dependency 'nokogiri', '~> 1.6'
15
+ s.add_dependency 'nokogiri', '~> 1.6.7'
16
16
  s.add_dependency 'rubyzip', '~> 1.1'
17
17
  s.add_dependency 'term-ansicolor', '~> 1.2'
18
18
  s.add_dependency 'mime-types', '~> 1.19'
19
19
 
20
- s.version = '0.4.5'
20
+ s.version = '0.4.6'
21
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - eregon
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.6'
33
+ version: 1.6.7
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.6'
40
+ version: 1.6.7
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubyzip
43
43
  requirement: !ruby/object:Gem::Requirement