undertexter 0.1.5 → 0.1.6
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.
- data/Gemfile.lock +2 -2
- data/README.markdown +5 -5
- data/Rakefile +8 -0
- data/lib/subtitle.rb +1 -1
- data/lib/undertexter.rb +15 -17
- data/spec/subtitle_spec.rb +1 -1
- data/spec/undertexter_spec.rb +2 -2
- data/undertexter.gemspec +6 -6
- metadata +32 -4
data/Gemfile.lock
CHANGED
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
|
-
=> #<
|
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
|
-
=> #<
|
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
|
-
=> #<
|
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
|
-
=> #<
|
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 `
|
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
data/lib/subtitle.rb
CHANGED
data/lib/undertexter.rb
CHANGED
@@ -48,29 +48,27 @@ class Undertexter
|
|
48
48
|
doc = Nokogiri::HTML(@raw_data)
|
49
49
|
@block = []
|
50
50
|
|
51
|
-
|
52
|
-
|
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('
|
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(
|
62
|
-
|
63
|
-
|
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 =
|
68
|
-
value =
|
69
|
-
|
70
|
-
@block[length] << line[
|
71
|
-
@block[length] << line[
|
72
|
-
@block[length] <<
|
73
|
-
@block[length] << value.
|
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 <<
|
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],
|
data/spec/subtitle_spec.rb
CHANGED
data/spec/undertexter_spec.rb
CHANGED
@@ -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
|
88
|
-
@use.each { |subtitle| subtitle.should be_instance_of(
|
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.
|
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(
|
22
|
-
s.add_dependency(
|
23
|
-
s.add_dependency(
|
24
|
-
s.add_dependency(
|
25
|
-
s.add_development_dependency(
|
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
|
-
|
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-
|
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
|
-
|
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
|
|