bathyscaphe 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (C) 2012 Ilia Zemskov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -7,7 +7,9 @@ Subtitles are searched based on tv-show file name. Only english subtitles with h
7
7
 
8
8
  Existing solutions such as [Periscope](http://code.google.com/p/periscope/) and [Submarine](https://github.com/blazt/submarine) are more powerfull then bathyscaphe, they're using file hashes to search subtitles with API-powered services (Podnapisi, Opensubtitles, etc). And frankly, I use periscope myself most of the time. But they don't work for recently released episodes of tv-shows. And having to go to addic7ed.com every time new episode comes out is a pain in the butt. So *bathyscaphe* to the rescue.
9
9
 
10
- Be aware: there is a limit of 30 subs per day set by addic7ed.com.
10
+ Be aware: there is a limit of 30 subs per day set by addic7ed.com.
11
+
12
+ Tell me if your show wasn't recognized by bathyscaphe. Or change Bathyscaphe::TVDB and make pull request.
11
13
 
12
14
  ### INSTALL
13
15
 
@@ -34,4 +36,12 @@ or just
34
36
 
35
37
  ### Authors
36
38
 
37
- - Ilia Zemskov (http://nbspace.ru) ilzoff@gmail.com
39
+ - Ilia Zemskov (http://nbspace.ru) ilzoff@gmail.com
40
+
41
+ ### License
42
+
43
+ I don't care.
44
+
45
+ Copyright © 2012 Ilia Zemskov
46
+
47
+ MIT License. See LICENSE
@@ -11,6 +11,8 @@ Gem::Specification.new do |s|
11
11
  s.summary = %q{Simple gem to download subtitles from addic7ed.com}
12
12
  s.description = %q{Simple gem to download subtitles for tv-show episodes from addic7ed.com. Subtitles are searched based on file name.}
13
13
 
14
+ s.license = 'MIT'
15
+
14
16
  s.rubyforge_project = "bathyscaphe"
15
17
 
16
18
  s.files = `git ls-files`.split("\n")
@@ -21,4 +23,4 @@ Gem::Specification.new do |s|
21
23
  # specify any dependencies here; for example:
22
24
  # s.add_development_dependency "rspec"
23
25
  s.add_runtime_dependency "nokogiri"
24
- end
26
+ end
@@ -47,7 +47,32 @@ module Bathyscaphe
47
47
  end
48
48
 
49
49
  def sub_link
50
- html = Nokogiri::HTML(open(show_page(:lang)))
50
+ begin
51
+ io_html = open(show_page(:lang))
52
+ html = Nokogiri::HTML(io_html)
53
+ rescue URI::InvalidURIError => e
54
+ # STDERR.puts e
55
+ puts "We think we didn't parse your TV-Show's name right (#{@tv_show}). Correct us:"
56
+ name = STDIN.gets
57
+ @tv_show = name.strip
58
+ retry
59
+ end
60
+ if io_html.status[0] == "200" && html.text.empty?
61
+ puts "We beliewe addic7ed don't have subtitles for your episode. Check yourself:"
62
+ puts "http://www.addic7ed.com/search.php?search=#{URI::escape(@tv_show)}"
63
+ exit
64
+ end
65
+
66
+ search_result = html.xpath("//form[@action='/search.php']").children.xpath("./b")
67
+ if search_result.any?
68
+ if results = search_result.first.text.match(/(\d*) result.{0,1} found/)
69
+ puts "Suddenly our bathyscaphe crashed into 'Search results page'"
70
+ puts "They've found #{results[1]} results. Go check yourself:"
71
+ puts "http://www.addic7ed.com/search.php?search=#{URI::escape(@tv_show)}"
72
+ exit
73
+ end
74
+ end
75
+
51
76
  subtitles = {}
52
77
  html.css(".tabel95 .newsDate").each do |td|
53
78
  if downloads = td.text.match(/\s(\d*)\sDownloads/i)
@@ -65,6 +90,13 @@ module Bathyscaphe
65
90
  end
66
91
 
67
92
  subtitles = subtitles.sort
93
+ if subtitles.empty?
94
+ puts "We didn't find your subtitles for some reason."
95
+ puts "Try to find them manually:"
96
+ puts "http://www.addic7ed.com/search.php?search=#{URI::escape(@tv_show)}"
97
+ puts show_page(:lang)
98
+ exit
99
+ end
68
100
  puts "Found subtitles with #{subtitles.last[0]} downloads: http://www.addic7ed.com#{subtitles.last[1]}"
69
101
  subtitles.last[1]
70
102
  end
@@ -9,6 +9,8 @@ module Bathyscaphe
9
9
  def initialize filename
10
10
  if md = filename.match(TVREGEXP1) || md = filename.match(TVREGEXP2)
11
11
  @name = md[1].gsub(".", " ").strip
12
+ @name = "Castle" if @name =~ /Castle 2009/i
13
+ @name = "Missing (2012)" if @name =~ /Missing 2012/i
12
14
  @season = md[2].to_i.to_s
13
15
  @episode = md[3].to_i.to_s
14
16
  else
@@ -1,3 +1,3 @@
1
1
  module Bathyscaphe
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ilia Zemskov
@@ -41,6 +41,7 @@ extra_rdoc_files: []
41
41
  files:
42
42
  - .gitignore
43
43
  - Gemfile
44
+ - LICENSE
44
45
  - README.md
45
46
  - Rakefile
46
47
  - bathyscaphe.gemspec
@@ -52,8 +53,8 @@ files:
52
53
  - lib/bathyscaphe/version.rb
53
54
  has_rdoc: true
54
55
  homepage: https://github.com/ilzoff/bathyscaphe
55
- licenses: []
56
-
56
+ licenses:
57
+ - MIT
57
58
  post_install_message:
58
59
  rdoc_options: []
59
60