undertexter 0.1.0 → 0.1.1
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/README.markdown +37 -24
- data/spec/array_spec.rb +10 -0
- data/undertexter.gemspec +1 -1
- metadata +3 -3
data/README.markdown
CHANGED
@@ -1,16 +1,20 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Undertexter
|
2
|
+
## What is Undertexter?
|
3
3
|
|
4
4
|
Undertexter provides a basic search client that makes it possible to search for swedish and english subtitles on [Undertexter.se](http://undertexter.se)
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
*Support for other subtitles sites will be added in the future. Follow this project to know when*
|
7
|
+
|
8
|
+
## How to use
|
9
|
+
|
10
|
+
### Find a subtitle based on any string
|
8
11
|
|
9
12
|
The find methods takes any string, including an IMDB id.
|
10
|
-
This is how to use it in irb
|
13
|
+
This is how to use it in `irb`.
|
11
14
|
|
12
15
|
$ require 'undertexter'
|
13
16
|
# => true
|
17
|
+
|
14
18
|
$ subtite = Undertexter.find("tt0840361").first
|
15
19
|
=> #<Subtitle:0x1020fff98 @downloads=8328, @movie_title="The Town", @title="The.Town.2010....BRRip", @url="http://www.undertexter.se/?p=undertext&id=23711", @cds=1>
|
16
20
|
$ subtitle.downloads
|
@@ -23,24 +27,25 @@ This is how to use it in irb.
|
|
23
27
|
= "http://www.undertexter.se/utext.php?id=23711"
|
24
28
|
$ subtitle.details
|
25
29
|
=> "http://www.undertexter.se/?p=undertext&id=23711"
|
30
|
+
|
26
31
|
$ Undertexter.find("die hard").count
|
27
32
|
=> 41
|
28
33
|
|
29
|
-
|
34
|
+
### Find a subtitle with in centrain language
|
30
35
|
|
31
36
|
$ Undertexter.find("tt0840361", :language => :english).count
|
32
37
|
=> 48
|
33
38
|
$ Undertexter.find("tt0840361", :language => :swedish).count
|
34
39
|
=> 8
|
35
40
|
|
36
|
-
Download the subtitle to disk
|
41
|
+
### Download the subtitle to disk
|
37
42
|
|
38
43
|
$ Undertexter.find("tt0840361").first.download!
|
39
44
|
=> "/tmp/The.Town.2010.EXTENDED.480p.BRRip.XviD-NYDIC.rar"
|
40
45
|
$ File.exists?("/tmp/The.Town.2010.EXTENDED.480p.BRRip.XviD-NYDIC.rar")
|
41
46
|
=> true
|
42
47
|
|
43
|
-
|
48
|
+
### Download the subtitle to a specified destination folder, both relative and absolute
|
44
49
|
|
45
50
|
$ Undertexter.find("tt0840361").first.download!(:to => /some/dir)
|
46
51
|
=> "/some/dir/The.Town.2010.EXTENDED.480p.BRRip.XviD-NYDIC.rar"
|
@@ -50,14 +55,14 @@ You can also specify a destination folder to download the file, both relative an
|
|
50
55
|
$ Undertexter.find("tt0840361").first.download!(:to => 'my_dir')
|
51
56
|
=> "/Users/linus/Downloads/my_dir/The.Town.2010.EXTENDED.480p.BRRip.XviD-NYDIC.rar"
|
52
57
|
|
53
|
-
Find the right subtitle based on the release name of the movie
|
58
|
+
### Find the right subtitle based on the **release name** of the movie
|
54
59
|
|
55
60
|
$ Undertexter.find("tt0840361").based_on("The Town EXTENDED 2010 480p BRRip XviD AC3 FLAWL3SS")
|
56
61
|
=> #<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>
|
57
62
|
|
58
|
-
Specify how sensitive the `based_on` method should be,
|
63
|
+
### Specify how sensitive the `based_on` method should be, from `0.0` to `1.1`
|
59
64
|
|
60
|
-
$ Undertexter.find("tt0840361").based_on("The Town EXTENDED 2010 480p BRRip XviD AC3 FLAWL3SS", limit: 0)
|
65
|
+
$ Undertexter.find("tt0840361").based_on("The Town EXTENDED 2010 480p BRRip XviD AC3 FLAWL3SS", limit: 0.0)
|
61
66
|
=> nil
|
62
67
|
|
63
68
|
$ Undertexter.find("tt0840361").based_on("The Town EXTENDED 2010 480p BRRip XviD AC3 FLAWL3SS", limit: 0.4)
|
@@ -65,11 +70,8 @@ Specify how sensitive the `based_on` method should be, where `0` is a perfect ma
|
|
65
70
|
|
66
71
|
$ Undertexter.find("tt0840361").based_on("The.Town.EXTENDED.2010.480p.BRRip.XviD.AC3-FLAWL3SS", limit: 0.0)
|
67
72
|
=> #<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>
|
68
|
-
|
69
|
-
If no language option is being passed to find, it will fall back to swedish
|
70
73
|
|
71
|
-
What is being returned
|
72
|
-
===============
|
74
|
+
## What is being returned?
|
73
75
|
|
74
76
|
The find method returns an `Array` with zero or more subtitles. Every subtitle provides some basic accessors.
|
75
77
|
|
@@ -79,26 +81,37 @@ The find method returns an `Array` with zero or more subtitles. Every subtitle p
|
|
79
81
|
- `downloads` (Integer) The amount of downloads for this particular subtitle.
|
80
82
|
- `url` (String) A direct link to the subtitle file, a rar file for example
|
81
83
|
- `details` (String) A link to the details page for the subtitle
|
84
|
+
- `download!` (String) The absolut path to the downloaded subtitle
|
85
|
+
|
86
|
+
## Some optional options
|
87
|
+
|
88
|
+
### The `find` method
|
89
|
+
|
90
|
+
- **:language** (Symbol) The language of the subtitle. Default is `:swedish`, the other option is `:english`.
|
91
|
+
|
92
|
+
### The `download!` method on the subtitle object
|
93
|
+
|
94
|
+
- **:to** (String) The absolut or relative path to where the downloaded file will be placed. Default is `/tmp`
|
95
|
+
|
96
|
+
### The `based_on` method on any array that is being returned from `Undertexter`
|
97
|
+
|
98
|
+
- **:limit** (Float) The sensitivity of the method, where `0.0` is a perfect match and `1.0` is don't care. If this is set to high the method will return nil. Default is `0.4`. Read more about the [levenshtein](http://en.wikipedia.org/wiki/Levenshtein_distance) algorithm that is being used [here](http://www.erikveen.dds.nl/levenshtein/doc/index.html).
|
82
99
|
|
83
|
-
How to install
|
84
|
-
===============
|
100
|
+
## How to install
|
85
101
|
|
86
|
-
sudo gem install undertexter
|
102
|
+
[sudo] gem install undertexter
|
87
103
|
|
88
|
-
How to use it in a rails 3 project
|
89
|
-
===============
|
104
|
+
## How to use it in a rails 3 project
|
90
105
|
|
91
106
|
Add `gem 'undertexter'` to your Gemfile and run `bundle`.
|
92
107
|
|
93
|
-
How to help
|
94
|
-
===============
|
108
|
+
## How to help
|
95
109
|
|
96
110
|
- Start by copying the project or make your own branch.
|
97
111
|
- Navigate to the root path of the project and run `bundle`.
|
98
112
|
- Start by running all tests using rspec, `rspec spec/undertexter_spec.rb`.
|
99
113
|
- Implement your own code, write some tests, commit and do a pull request.
|
100
114
|
|
101
|
-
Requirements
|
102
|
-
===============
|
115
|
+
## Requirements
|
103
116
|
|
104
117
|
Undertexter is tested in OS X 10.6.6 using Ruby 1.8.7.
|
data/spec/array_spec.rb
CHANGED
@@ -30,4 +30,14 @@ describe Array do
|
|
30
30
|
it "should return nil if trying to fetch an non existing imdb id" do
|
31
31
|
Undertexter.find("tt123456789").based_on("some random argument").should be_nil
|
32
32
|
end
|
33
|
+
|
34
|
+
it "should raise an exception when the array does not contain any subtitle objects" do
|
35
|
+
lambda {
|
36
|
+
[1,2,2,3].based_on("some args")
|
37
|
+
}.should raise_error(NoMethodError)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should be an array" do
|
41
|
+
@subtitles.should be_an_instance_of(Array)
|
42
|
+
end
|
33
43
|
end
|
data/undertexter.gemspec
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Linus Oleander
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-31 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|