the_pirate_bay 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,19 +21,19 @@ module ThePirateBay
21
21
  end
22
22
 
23
23
  def id
24
- @id ||= html.css('td')[1].css('div.detName').inner_html.match(/\/torrent\/(\d+)\//)[1]
24
+ @id ||= html.css('td div.detName').inner_html.match(/\/torrent\/(\d+)\//)[1]
25
25
  end
26
26
 
27
27
  def name
28
- @name ||= html.css('td')[2].css('div.detName a').text
28
+ @name ||= html.css('td div.detName a').text
29
29
  end
30
30
 
31
31
  def type
32
- @type ||= html.css('td').css('a').map(&:text).join(" > ")
32
+ @type ||= html.css('td[1] a').map(&:text).join(" > ")
33
33
  end
34
34
 
35
35
  def size
36
- @size ||= html.css('td')[1].css('font.detDesc').text.match(/Size (.*),/)[1].gsub('i', '')
36
+ @size ||= html.css('td font.detDesc').text.match(/Size (.*),/)[1].gsub('i', '')
37
37
  end
38
38
 
39
39
  def seeders
@@ -46,7 +46,8 @@ module ThePirateBay
46
46
  #
47
47
  # Returns an array of ThePirateBay::Torrent::Collection objects.
48
48
  def search(query)
49
- html = request("search/#{query}") # Returns search html
49
+ uri = "search/" + CGI::escape(query)
50
+ html = request(uri) # Returns search html
50
51
 
51
52
  # Get torrents table rows from html
52
53
  # and return as ruby objects
@@ -121,6 +122,11 @@ module ThePirateBay
121
122
  @description ||= html.css("div.nfo").text.strip
122
123
  end
123
124
 
125
+ def imdb_id
126
+ @imdb_id ||= html.css("#details dd a[title=IMDB]").attribute("href").value.
127
+ match(/\/(\w+)\/$/)[1]
128
+ end
129
+
124
130
  private
125
131
 
126
132
  def attributes_map
@@ -1,3 +1,3 @@
1
1
  module ThePirateBay
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -137,7 +137,7 @@
137
137
  <div id="main-content">
138
138
  <div>
139
139
  <div id="detailsouterframe">
140
-
140
+
141
141
  <div id="detailsframe">
142
142
  <div id="title">
143
143
  Fringe S05E03 HDTV x264-LOL [eztv] </div>
@@ -155,10 +155,23 @@ if (filelist &lt; 1) {
155
155
  }; toggleFilelist(); return false;">1</a></dd>
156
156
 
157
157
  <dt>Size:</dt>
158
- <dd>288.87&nbsp;MiB&nbsp;(302897843&nbsp;Bytes)</dd>
158
+ <dd>288.87 MiB (302897843 Bytes)</dd>
159
+
160
+ <br />
161
+
162
+ <dt>Info:</dt>
163
+ <dd><a href="http://www.imdb.com/title/tt1985966/" target="_blank" title="IMDB" rel="nofollow">IMDB</a></dd>
164
+
165
+ <dt>Spoken language(s):</dt>
166
+ <dd>English</dd>
167
+
168
+ <dt>Texted language(s):</dt>
169
+ <dd>French</dd>
159
170
 
171
+ <dt>Tag(s):</dt>
172
+ <dd><a href="/tag/YIFY">YIFY</a> <a href="/tag/720p">720p</a> <a href="/tag/1080p">1080p</a> <a href="/tag/movies">movies</a> <a href="/tag/x264">x264</a> <a href="/tag/Bluray">Bluray</a> <a href="/tag/BrRip">BrRip</a> </dd>
173
+ <br />
160
174
 
161
-
162
175
  </dl>
163
176
  <dl class="col2">
164
177
  <dt>Quality:</dt>
@@ -205,7 +218,7 @@ if (filelist &lt; 1) {
205
218
 
206
219
  <a href="http://cdn1.adexprt.com/lp/2.php?name=Fringe_S05E03_HDTV_x264-LOL_%5Beztv%5D"><img src="http://static.thepiratebay.org/img/bar.gif" border="0"></a>
207
220
  <br /><br /> <div class="download">
208
- <a style='background-image: url("//static.thepiratebay.se/img/icons/icon-magnet.gif");' href="magnet:?xt=urn:btih:84c153e4064d1ac1cc151a09070c8740c318d271&dn=Fringe+S05E03+HDTV+x264-LOL+%5Beztv%5D&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.istole.it%3A6969&tr=udp%3A%2F%2Ftracker.ccc.de%3A80" title="Get this torrent">&nbsp;Get this torrent</a>
221
+ <a style='background-image: url("//static.thepiratebay.se/img/icons/icon-magnet.gif");' href="magnet:?xt=urn:btih:84c153e4064d1ac1cc151a09070c8740c318d271&dn=Fringe+S05E03+HDTV+x264-LOL+%5Beztv%5D&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.istole.it%3A6969&tr=udp%3A%2F%2Ftracker.ccc.de%3A80" title="Get this torrent">&nbsp;Get this torrent</a>
209
222
  </div>
210
223
  <div>(Problems with magnets links are fixed by upgrading your <a href="http://lp.torchbrowser.com/?sysid=448&appid=144" target="_blank">torrent client</a>!)</div>
211
224
  <div class="nfo">
@@ -280,8 +293,8 @@ am dyinnnnnnnnnnnnnnnnng here lol cant wait till u upload the next episode pffff
280
293
 
281
294
  <iframe src="http://cdn1.adexprt.com/clkads/bottom.html" width="728" height="90" frameborder="0" scrolling="no" ></iframe>
282
295
  <p>
283
- <a href="/login" title="Login">Login</a> |
284
- <a href="/register" title="Register">Register</a> |
296
+ <a href="/login" title="Login">Login</a> |
297
+ <a href="/register" title="Register">Register</a> |
285
298
  <a href="/language" title="Select language">Language / Select language</a> |
286
299
  <a href="/about" title="About">About</a> |
287
300
  <a href="/legal" title="Legal threats">Legal threats</a> |
@@ -320,4 +333,4 @@ am dyinnnnnnnnnnnnnnnnng here lol cant wait till u upload the next episode pffff
320
333
  <script type="text/javascript" src="http://cdn1.adexprt.com/clkads/pop.js"></script>
321
334
  <!-- abc: MX 0 -->
322
335
  </body>
323
- </html>
336
+ </html>
@@ -18,8 +18,18 @@ describe ThePirateBay::Torrent do
18
18
  @torrents.first.class.should == ThePirateBay::Torrent::Collection
19
19
  end
20
20
 
21
- it "assigns torrents attributes" do
22
- @torrents.first.id.should == "7810640"
21
+ it "parses torrents attributes correctly" do
22
+ torrent = @torrents.first
23
+ torrent.id.should == "7810640"
24
+ torrent.name.should == "Fringe S05E06 Season 5 Episode 6 HDTV x264 [GlowGaze]"
25
+ torrent.type.should == "Video > TV shows"
26
+ torrent.size == "303.89 MB"
27
+ torrent.seeders == "413"
28
+ torrent.leechers == "117"
29
+ torrent.magnet_uri == "magnet:?xt=urn:btih:0f4e3c1a4618b6d9658427e7778c602cd7c05ea0&dn=Fringe+S05E06+Season+5+Episode+6+HDTV+x264+%5BGlowGaze%5D&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.istole.it%3A6969&tr=udp%3A%2F%2Ftracker.ccc.de%3A8"
30
+ torrent.uploaded_at == "Today 04:11"
31
+ torrent.uploaded_by == "GlowGaze"
32
+ torrent.comments_count == "2"
23
33
  end
24
34
  end
25
35
 
@@ -27,8 +37,25 @@ describe ThePirateBay::Torrent do
27
37
  it "returns a particular torrent" do
28
38
  stub_get("torrent/7723168").
29
39
  to_return(:status => 200, :body => fixture("torrent/find.html"))
40
+
30
41
  torrent = api.torrents.find("7723168")
42
+ torrent.id.should == "7723168"
31
43
  torrent.name.should == "Fringe S05E03 HDTV x264-LOL [eztv]"
44
+ torrent.description.should == "#EZTV @ EFNet -&gt; To avoid fakes, ALWAYS check that the torrent was added by eztv. \nhttp://eztv.it/\n\nEpisode: Fringe S05E03 HDTV x264-LOL\nScreenshots:"
45
+ torrent.seeders.should == "2461"
46
+ torrent.leechers.should == "118"
47
+ torrent.quality.should == "+4 / -0 (+4)"
48
+ torrent.size.should == "288.87 MiB (302897843 Bytes)"
49
+ torrent.type.should == "Video > TV shows"
50
+ torrent.hash.should == "84C153E4064D1AC1CC151A09070C8740C318D271"
51
+ torrent.uploaded_at.should == "2012-10-13 12:33:16 GMT"
52
+ torrent.uploaded_by.should == "eztv"
53
+ torrent.comments_count.should == "6"
54
+ torrent.files_count.should == "1"
55
+ torrent.spoken_language.should == "English"
56
+ torrent.written_language.should == "French"
57
+ torrent.tags.should == "YIFY 720p 1080p movies x264 Bluray BrRip"
58
+ torrent.imdb_id.should == "tt1985966"
32
59
  end
33
60
  end
34
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the_pirate_bay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-20 00:00:00.000000000 Z
12
+ date: 2014-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday