pirata 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.
@@ -21,11 +21,10 @@ module Pirata
21
21
  end
22
22
 
23
23
  # Perform a search and return an array of Torrent objects
24
- # Requires a query string.
25
24
  def search(page = 0)
26
25
  #build URL ex: http://thepiratebay.se/search/cats/0/99/0
27
26
  url = Pirata::Config::BASE_URL + "/search/#{URI.escape(@query)}" + "/#{page.to_s}" + "/#{@sort_type}" + "/#{@category}"
28
- html = Nokogiri::HTML(open(url))
27
+ p html = Nokogiri::HTML(open(url))
29
28
  Pirata::Search::parse_search_page(html, self)
30
29
  end
31
30
 
@@ -61,7 +60,11 @@ module Pirata
61
60
  # into an array
62
61
  def self.parse_search_page(html, search_object = nil)
63
62
  results = []
64
- search_object.pages = html.css('#content div a')[-2].text.to_i unless search_object.nil?
63
+
64
+ begin
65
+ search_object.pages = html.css('#content div a')[-2].text.to_i
66
+ rescue
67
+ end
65
68
 
66
69
  html.css('#searchResult tr').each do |row|
67
70
  title = row.search('.detLink').text
@@ -76,7 +79,7 @@ module Pirata
76
79
  h[:magnet] = row.search('td a')[3]['href']
77
80
  h[:seeders] = row.search('td')[2].text.to_i
78
81
  h[:leechers] = row.search('td')[3].text.to_i
79
- h[:uploader] = Pirata::User.new(row.search('td a')[5].text, Pirata::Config::BASE_URL)
82
+ h[:uploader] = Pirata::User.new(row.search('td a')[5].text)
80
83
  rescue
81
84
  #puts "not found"
82
85
  end
@@ -1,12 +1,13 @@
1
+ require 'config'
2
+
1
3
  module Pirata
2
4
  class User
3
5
 
4
6
  attr_reader :profile_url, :username
5
7
 
6
- def initialize(username, base_url)
8
+ def initialize(username)
7
9
  @username = username
8
- @base_url = base_url
9
- @profile_url = "#{@base_url}/user/#{@username}"
10
+ @profile_url = "#{Pirata::Config::BASE_URL}/user/#{@username}"
10
11
  end
11
12
 
12
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pirata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2014-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &17736960 !ruby/object:Gem::Requirement
16
+ requirement: &9635980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *17736960
24
+ version_requirements: *9635980
25
25
  description: A Ruby gem that exposes an API for using The Pirate Bay torrent tracker
26
26
  service.
27
27
  email: clindsay107@gmail.com