undertexter 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- undertexter (0.1.4)
4
+ undertexter (0.1.6)
5
5
  levenshteinish
6
6
  mimer_plus
7
7
  nokogiri
@@ -32,5 +32,5 @@ PLATFORMS
32
32
  ruby
33
33
 
34
34
  DEPENDENCIES
35
- rspec
35
+ rspec (= 2.4.0)
36
36
  undertexter!
data/README.markdown CHANGED
@@ -16,7 +16,7 @@ This is how to use it in `irb`.
16
16
  # => true
17
17
 
18
18
  $ subtite = Undertexter.find("tt0840361").first
19
- => #<Container::Subtitle:0x1020fff98 @downloads=8328, @movie_title="The Town", @title="The.Town.2010....BRRip", @url="http://www.undertexter.se/?p=undertext&id=23711", @cds=1>
19
+ => #<SContainer::Subtitle:0x1020fff98 @downloads=8328, @movie_title="The Town", @title="The.Town.2010....BRRip", @url="http://www.undertexter.se/?p=undertext&id=23711", @cds=1>
20
20
  $ subtitle.downloads
21
21
  => 8328
22
22
  $ subtitle.movie_title
@@ -58,7 +58,7 @@ This is how to use it in `irb`.
58
58
  ### Find the right subtitle based on the **release name** of the movie
59
59
 
60
60
  $ Undertexter.find("tt0840361").based_on("The Town EXTENDED 2010 480p BRRip XviD AC3 FLAWL3SS")
61
- => #<Container::Subtitle:0x00000101b739d0 @cds=1, @downloads=1644, @title="The.Town.EXTENDED.2010.480p.BRRip.XviD.AC3-FLAWL3SS", @details="http://www.undertexter.se/?p=undertext&id=23752", @movie_title="The Town", @language=:swedish>
61
+ => #<SContainer::Subtitle:0x00000101b739d0 @cds=1, @downloads=1644, @title="The.Town.EXTENDED.2010.480p.BRRip.XviD.AC3-FLAWL3SS", @details="http://www.undertexter.se/?p=undertext&id=23752", @movie_title="The Town", @language=:swedish>
62
62
 
63
63
  ### Specify how sensitive the `based_on` method should be, from `0.0` to `1.0`
64
64
 
@@ -66,14 +66,14 @@ This is how to use it in `irb`.
66
66
  => nil
67
67
 
68
68
  $ Undertexter.find("tt0840361").based_on("The Town EXTENDED 2010 480p BRRip XviD AC3 FLAWL3SS", limit: 0.4)
69
- => #<Container::Subtitle:0x00000101b8d808 @cds=1, @downloads=1644, @title="The.Town.EXTENDED.2010.480p.BRRip.XviD.AC3-FLAWL3SS", @details="http://www.undertexter.se/?p=undertext&id=23752", @movie_title="The Town", @language=:swedish>
69
+ => #<SContainer::Subtitle:0x00000101b8d808 @cds=1, @downloads=1644, @title="The.Town.EXTENDED.2010.480p.BRRip.XviD.AC3-FLAWL3SS", @details="http://www.undertexter.se/?p=undertext&id=23752", @movie_title="The Town", @language=:swedish>
70
70
 
71
71
  $ Undertexter.find("tt0840361").based_on("The.Town.EXTENDED.2010.480p.BRRip.XviD.AC3-FLAWL3SS", limit: 0.0)
72
- => #<Container::Subtitle:0x00000101b8d718 @cds=1, @downloads=1644, @title="The.Town.EXTENDED.2010.480p.BRRip.XviD.AC3-FLAWL3SS", @details="http://www.undertexter.se/?p=undertext&id=23752", @movie_title="The Town", @language=:swedish>
72
+ => #<SContainer::Subtitle:0x00000101b8d718 @cds=1, @downloads=1644, @title="The.Town.EXTENDED.2010.480p.BRRip.XviD.AC3-FLAWL3SS", @details="http://www.undertexter.se/?p=undertext&id=23752", @movie_title="The Town", @language=:swedish>
73
73
 
74
74
  ## What is being returned?
75
75
 
76
- The find method returns an `Array` with zero or more `Container::Subtitle` instances. Every object provides some basic accessors.
76
+ The find method returns an `Array` with zero or more `SContainer::Subtitle` instances. Every object provides some basic accessors.
77
77
 
78
78
  - `movie_title` (String) The official name of the movie.
79
79
  - `cds` (Integer) The amount of cds that the release should contain.
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
1
  require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+
2
4
  Bundler::GemHelper.install_tasks
5
+
6
+ desc 'Default: run specs.'
7
+ task :default => :spec
8
+
9
+ desc "Run specs"
10
+ RSpec::Core::RakeTask.new(:spec)
data/lib/subtitle.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'fileutils'
2
2
  require 'mimer_plus'
3
3
 
4
- module Container
4
+ module SContainer
5
5
  class Subtitle
6
6
  attr_accessor :details, :downloads, :cds, :title, :movie_title, :url
7
7
 
data/lib/undertexter.rb CHANGED
@@ -48,29 +48,27 @@ class Undertexter
48
48
  doc = Nokogiri::HTML(@raw_data)
49
49
  @block = []
50
50
 
51
- # Trying to find the {tbody} that does not contain any tbody's
52
- tbody = doc.css("tbody").to_a.reject do |inner, index|
53
- not inner.content.match(/Nedladdningar/i)
51
+ tbody = doc.css("table").to_a.reject do |i|
52
+ ! i.content.match(/Nedladdningar/i) or i.css('table').any?
54
53
  end.sort_by do |inner|
55
- inner.css('tbody').count
54
+ inner.css('table').count
56
55
  end.first
57
56
 
58
- # Nothing found, okey!
59
57
  return if tbody.nil?
60
58
 
61
- tbody = tbody.css('tr').drop(3)
62
-
63
- tbody.each_with_index do |value, index|
64
- next unless index % 3 == 0
59
+ tbody = tbody.css("tr").select do |tr|
60
+ tr.to_s.match(/id=\d+/) or tr.to_s.match(/Nedladdningar/i)
61
+ end.each_slice(2) do |first, last|
65
62
  length = @block.length
66
63
  @block[length] = [] if @block[length].nil?
67
- line = tbody[index + 1].content.split(/\n/).map(&:strip)
68
- value = value.css('a')
69
- @block[length] << line[1]
70
- @block[length] << line[3]
71
- @block[length] << line[4]
72
- @block[length] << value.last.attr('href')
73
- @block[length] << value.last.attr('title')
64
+ line = last.content.split(/\n/).map(&:strip)
65
+ value = first.at_css('a')
66
+
67
+ @block[length] << line[1] # (cd 1)
68
+ @block[length] << line[3] # Nedladdningar: 11891
69
+ @block[length] << line[4] # "Avatar (2009) PROPER DVDSCR XviD-MAXSPEED"
70
+ @block[length] << value.attr('href') # http://www.undertexter.se/?p=undertext&id=19751
71
+ @block[length] << value.attr('title') # Avatar
74
72
  @block[length].map!(&:strip)
75
73
  end
76
74
  end
@@ -78,7 +76,7 @@ class Undertexter
78
76
  def build!
79
77
  @block.each do |movie|
80
78
  next unless movie.count == 5
81
- @subtitles << Container::Subtitle.new({
79
+ @subtitles << SContainer::Subtitle.new({
82
80
  :cds => movie[0].match(/\d+/)[0].to_i,
83
81
  :downloads => movie[1].match(/\d+$/)[0].to_i,
84
82
  :title => movie[2],
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- include Container
2
+ include SContainer
3
3
 
4
4
  describe Subtitle do
5
5
  before(:each) do
@@ -84,8 +84,8 @@ describe Undertexter, "trying to search for a movie using a title" do
84
84
  end
85
85
  end
86
86
 
87
- it "should only contain Container::Subtitle instances" do
88
- @use.each { |subtitle| subtitle.should be_instance_of(Container::Subtitle) }
87
+ it "should only contain SContainer::Subtitle instances" do
88
+ @use.each { |subtitle| subtitle.should be_instance_of(SContainer::Subtitle) }
89
89
  end
90
90
 
91
91
  it "should not contain any attributes that contain any html tags" do
data/undertexter.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "undertexter"
6
- s.version = "0.1.5"
6
+ s.version = "0.1.6"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Linus Oleander"]
9
9
  s.email = ["linus@oleander.nu"]
@@ -18,9 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_dependency('rest-client')
22
- s.add_dependency('nokogiri')
23
- s.add_dependency('mimer_plus')
24
- s.add_dependency('levenshteinish')
25
- s.add_development_dependency('rspec')
21
+ s.add_dependency("rest-client")
22
+ s.add_dependency("nokogiri")
23
+ s.add_dependency("mimer_plus")
24
+ s.add_dependency("levenshteinish")
25
+ s.add_development_dependency("rspec", "2.4.0")
26
26
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: undertexter
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease:
5
- version: 0.1.5
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 6
10
+ version: 0.1.6
6
11
  platform: ruby
7
12
  authors:
8
13
  - Linus Oleander
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-02-14 00:00:00 +01:00
18
+ date: 2011-03-13 00:00:00 +01:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
@@ -21,6 +26,9 @@ dependencies:
21
26
  requirements:
22
27
  - - ">="
23
28
  - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
24
32
  version: "0"
25
33
  type: :runtime
26
34
  version_requirements: *id001
@@ -32,6 +40,9 @@ dependencies:
32
40
  requirements:
33
41
  - - ">="
34
42
  - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
35
46
  version: "0"
36
47
  type: :runtime
37
48
  version_requirements: *id002
@@ -43,6 +54,9 @@ dependencies:
43
54
  requirements:
44
55
  - - ">="
45
56
  - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
46
60
  version: "0"
47
61
  type: :runtime
48
62
  version_requirements: *id003
@@ -54,6 +68,9 @@ dependencies:
54
68
  requirements:
55
69
  - - ">="
56
70
  - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
57
74
  version: "0"
58
75
  type: :runtime
59
76
  version_requirements: *id004
@@ -63,9 +80,14 @@ dependencies:
63
80
  requirement: &id005 !ruby/object:Gem::Requirement
64
81
  none: false
65
82
  requirements:
66
- - - ">="
83
+ - - "="
67
84
  - !ruby/object:Gem::Version
68
- version: "0"
85
+ hash: 31
86
+ segments:
87
+ - 2
88
+ - 4
89
+ - 0
90
+ version: 2.4.0
69
91
  type: :development
70
92
  version_requirements: *id005
71
93
  description: A subtitle search client to search for swedish subtitles on undertexter.se
@@ -107,12 +129,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
129
  requirements:
108
130
  - - ">="
109
131
  - !ruby/object:Gem::Version
132
+ hash: 3
133
+ segments:
134
+ - 0
110
135
  version: "0"
111
136
  required_rubygems_version: !ruby/object:Gem::Requirement
112
137
  none: false
113
138
  requirements:
114
139
  - - ">="
115
140
  - !ruby/object:Gem::Version
141
+ hash: 3
142
+ segments:
143
+ - 0
116
144
  version: "0"
117
145
  requirements: []
118
146