torrents 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -24,37 +24,52 @@ Download and get information like:
24
24
 
25
25
  ### Search for torrents
26
26
 
27
- >> Torrents.the_pirate_bay.search("chuck").results
28
-
27
+ ```` ruby
28
+ Torrents.the_pirate_bay.search("chuck").results
29
+ ````
30
+
29
31
  ### List recent torrents
30
32
 
31
- >> Torrents.the_pirate_bay.results
32
-
33
+ ```` ruby
34
+ Torrents.the_pirate_bay.results
35
+ ````
36
+
33
37
  ### List recent torrents - with category
34
38
 
35
- >> Torrents.the_pirate_bay.category(:movies).results
36
-
39
+ ```` ruby
40
+ Torrents.the_pirate_bay.category(:movies).results
41
+ ````
42
+
37
43
  ### Specify a page
38
44
 
39
45
  The `page` method can be places anywhere before the `results` method.
40
46
 
41
47
  It starts counting from `1` and goes up, no matter what is used on the site it self.
42
48
 
43
- $ Torrents.the_pirate_bay.page(6).results
49
+ ```` ruby
50
+ Torrents.the_pirate_bay.page(6).results
51
+ ````
44
52
 
45
53
  ### Specify some cookies
46
54
 
47
55
  Some trackers requires cookies to work, even though [The Pirate Bay](http://thepiratebay.org/) is not one of them.
48
56
 
49
- $ Torrents.the_pirate_bay.cookies(user_id: "123", hash: "c4656002ce46f9b418ce72daccfa5424").results
57
+ ```` ruby
58
+ Torrents.the_pirate_bay.cookies({
59
+ user_id: "123",
60
+ hash: "c4656002ce46f9b418ce72daccfa5424"
61
+ }).results
62
+ ````
50
63
 
51
64
  ### Step through torrents
52
65
 
53
66
  Here is an example of how to step through the 10 first pages.
54
-
55
- $ torrents = Torrents.the_pirate_bay.step
56
- $ 10.times { torrents.results }
57
-
67
+
68
+ ```` ruby
69
+ torrents = Torrents.the_pirate_bay.step
70
+ 10.times { torrents.results }
71
+ ````
72
+
58
73
  You just add the step method and it will increment `page` everytime you apply the `results` method.
59
74
 
60
75
  ## What methods to work with
@@ -63,9 +78,11 @@ You just add the step method and it will increment `page` everytime you apply th
63
78
 
64
79
  As soon as you apply the `results` method on the query it will try to execute your request.
65
80
  If you for example want to activate the debugger, define some cookies or specify a page, then you might do something like this.
66
-
67
- $ Torrents.the_pirate_bay.page(5).debug(true).cookies(:my_cookie => "value").results
68
-
81
+
82
+ ```` ruby
83
+ Torrents.the_pirate_bay.page(5).debug(true).cookies(:my_cookie => "value").results
84
+ ````
85
+
69
86
  It will return a list of `Container::Torrent` object if the request was sucessfull, otherwise an empty list.
70
87
 
71
88
  ### The find_by_details method
@@ -74,7 +91,9 @@ If you have access to a single details link and want to get some useful data fro
74
91
 
75
92
  The method takes the url as an argument and returns a single `Container::Torrent` object.
76
93
 
77
- $ Torrents.the_pirate_bay.find_by_details("http://thepiratebay.org/torrent/6173093/")
94
+ ```` ruby
95
+ Torrents.the_pirate_bay.find_by_details("http://thepiratebay.org/torrent/6173093/")
96
+ ````
78
97
 
79
98
  ## What data to work with
80
99
 
@@ -101,8 +120,14 @@ The class has some nice accessors that might be useful.
101
120
 
102
121
  Here is an example
103
122
 
104
- $ Torrents.torrentleech.cookies({:member_id => "123", :pass_hash => "value", :PHPSESSID => "value"}).results
105
-
123
+ ```` ruby
124
+ Torrents.torrentleech.cookies({
125
+ :member_id => "123",
126
+ :pass_hash => "value",
127
+ :PHPSESSID => "value"
128
+ }).results
129
+ ````
130
+
106
131
  All values you pass to `cookies` must be of type string, like in the example above.
107
132
 
108
133
  - Torrentleech
@@ -137,13 +162,17 @@ The easiest way to solve it was to just isolate the tracker, if it raised an err
137
162
  You can read errors in two ways.
138
163
 
139
164
  Activate the debugger by adding the `debug` method to your query. The errors will be printed as warnings in the console.
140
-
141
- $ Torrents.the_pirate_bay.debug(true).results
165
+
166
+ ```` ruby
167
+ Torrents.the_pirate_bay.debug(true).results
168
+ ````
142
169
 
143
170
  Request a list of errors using the `errors` method.
144
171
 
145
- $ Torrents.the_pirate_bay.errors
146
- >> ["...undefined method `attr' for nil:NilClass>...", "32 torrents where found, 2 where not valid", "..."]
172
+ ```` ruby
173
+ p Torrents.the_pirate_bay.errors
174
+ # => ["...undefined method `attr' for nil:NilClass>...", "32 torrents where found, 2 where not valid", "..."]
175
+ ````
147
176
 
148
177
  ## How do access tracker X
149
178
 
@@ -154,7 +183,9 @@ The Pirate Bay becomes `the_pirate_bay`, TTI becomes `tti` and Torrentleech `tor
154
183
 
155
184
  Here is an example.
156
185
 
157
- $ Torrents.torrentleech.cookies({:my_cookie => "value"}).results
186
+ ```` ruby
187
+ Torrents.torrentleech.cookies({:my_cookie => "value"}).results
188
+ ````
158
189
 
159
190
  Take a look at the [tests](https://github.com/oleander/Torrents/tree/master/spec/trackers) for all trackers to get to know more.
160
191
 
@@ -219,7 +219,11 @@ module Container
219
219
  # Read more about it here: https://github.com/oleander/MovieSearcher
220
220
  # Return type: A MovieSearcher object or nil
221
221
  def movie
222
- self.imdb_id.nil? ? MovieSearcher.find_by_release_name(self.title, :options => {:details => true}) : MovieSearcher.find_movie_by_id(self.imdb_id)
222
+ if imdb_id
223
+ @_movie ||= MovieSearcher.find_movie_by_id(imdb_id)
224
+ else
225
+ @_movie ||= MovieSearcher.find_by_release_name(title, :options => {:details => true})
226
+ end
223
227
  end
224
228
 
225
229
  # Returns the title for the torrent
@@ -235,7 +239,9 @@ module Container
235
239
  # Return type: A single Undertexter object or nil
236
240
  def subtitle(option = :english)
237
241
  @subtitle = {} unless @subtitle
238
- @subtitle[option] ||= Undertexter.find(self.imdb_id, language: option).based_on(self.title)
242
+ term = imdb_id
243
+ term ||= movie.imdb_id if movie
244
+ @subtitle[option] ||= Undertexter.find(term, language: option).based_on(title)
239
245
  end
240
246
 
241
247
  # Returns the torrent for the torrent
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "torrents"
6
- s.version = "1.0.12"
6
+ s.version = "1.0.13"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Linus Oleander"]
9
9
  s.email = ["linus@oleander.nu"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: torrents
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.12
5
+ version: 1.0.13
6
6
  platform: ruby
7
7
  authors:
8
8
  - Linus Oleander
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-23 00:00:00 +01:00
13
+ date: 2011-04-28 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  requirements: []
167
167
 
168
168
  rubyforge_project: torrents
169
- rubygems_version: 1.5.0
169
+ rubygems_version: 1.6.2
170
170
  signing_key:
171
171
  specification_version: 3
172
172
  summary: Search and download torrents from your favorite bittorrent tracker using Ruby 1.9