hail_hydra 0.2.3 → 1.0.0
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.
- checksums.yaml +5 -5
- data/Gemfile.lock +48 -50
- data/README.md +3 -9
- data/bin/thepiratebay.rb +3 -4
- data/hail_hydra.gemspec +3 -3
- data/lib/client.rb +47 -50
- data/lib/hail_hydra/version.rb +1 -1
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 04c83ffc08ca929f1f599298dab744399f0f3944394a2d5c9d4abb491d270acb
|
4
|
+
data.tar.gz: ae11202df9131ed6fb05af82a729f94e3c2c812e4c7969390aee58ef9000f98d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 810794625e6ca4ca08f16406b840eebec75f2fc7ecdb217809509fbc85d48a2d7d4ae265086fdb21f3631d87523026105fd48cff17ec21e2c0861bf181cb8eb2
|
7
|
+
data.tar.gz: 9bd784f01de609a744d04bdc7e6ecb0e514c112f00aebd599394924dd71318b1ef2abb9793d12fc916018cfce39c44f9bd46194c5e8b37f32759de560afe9a38
|
data/Gemfile.lock
CHANGED
@@ -1,50 +1,48 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
hail_hydra (0.2.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
mime-types
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
rspec-
|
27
|
-
|
28
|
-
rspec-
|
29
|
-
rspec-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
BUNDLED WITH
|
50
|
-
1.16.1
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hail_hydra (0.2.3)
|
5
|
+
addressable
|
6
|
+
httparty
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
diff-lcs (1.4.4)
|
14
|
+
httparty (0.18.0)
|
15
|
+
mime-types (~> 3.0)
|
16
|
+
multi_xml (>= 0.5.2)
|
17
|
+
mime-types (3.3.1)
|
18
|
+
mime-types-data (~> 3.2015)
|
19
|
+
mime-types-data (3.2020.0425)
|
20
|
+
multi_xml (0.6.0)
|
21
|
+
public_suffix (4.0.5)
|
22
|
+
rake (13.0.1)
|
23
|
+
rspec (3.9.0)
|
24
|
+
rspec-core (~> 3.9.0)
|
25
|
+
rspec-expectations (~> 3.9.0)
|
26
|
+
rspec-mocks (~> 3.9.0)
|
27
|
+
rspec-core (3.9.2)
|
28
|
+
rspec-support (~> 3.9.3)
|
29
|
+
rspec-expectations (3.9.2)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.9.0)
|
32
|
+
rspec-mocks (3.9.1)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.9.0)
|
35
|
+
rspec-support (3.9.3)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
ruby
|
39
|
+
x64-mingw32
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
bundler (~> 2.1)
|
43
|
+
hail_hydra!
|
44
|
+
rake (~> 13.0)
|
45
|
+
rspec (~> 3.9)
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
2.1.4
|
data/README.md
CHANGED
@@ -29,21 +29,15 @@ $ thepiratebay totallynotillegal
|
|
29
29
|
|
30
30
|
From code
|
31
31
|
```ruby
|
32
|
-
s = HailHydra::TPB.new("https://
|
32
|
+
s = HailHydra::TPB.new("https://apibay.org")
|
33
33
|
|
34
34
|
res = s.search('totallynotillegal')
|
35
35
|
res.each do |torrent|
|
36
|
-
puts torrent.name + " " + torrent.
|
36
|
+
puts torrent.name + " " + torrent.size
|
37
37
|
end
|
38
38
|
|
39
39
|
```
|
40
40
|
|
41
|
-
## Future releases
|
42
|
-
1. Scrape more info about the torrents
|
43
|
-
2. Add functionality to allow uploading torrents
|
44
|
-
3. Add user auth?
|
45
|
-
4. Add ability to comment
|
46
|
-
|
47
41
|
## Contributing
|
48
42
|
|
49
43
|
Bug reports and pull requests are welcome on GitHub at https://github.com/Gr3atWh173/hail_hydra. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
@@ -57,4 +51,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
57
51
|
Everyone interacting in the HailHydra project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Gr3atWh173/hail_hydra/blob/master/CODE_OF_CONDUCT.md).
|
58
52
|
|
59
53
|
## DISCLAIMER
|
60
|
-
Neither this project
|
54
|
+
Neither this project nor its author are related to ThePirateBay in any way.
|
data/bin/thepiratebay.rb
CHANGED
@@ -2,14 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'hail_hydra'
|
4
4
|
|
5
|
-
domain = "https://
|
5
|
+
domain = "https://apibay.org"
|
6
6
|
search = ARGV[0]
|
7
|
-
pages = 1
|
8
7
|
|
9
|
-
HailHydra::TPB.new(domain).search(search
|
8
|
+
HailHydra::TPB.new(domain).search(search).each do |result|
|
10
9
|
puts ""
|
11
10
|
puts "NAME: " + result.name
|
12
|
-
puts "
|
11
|
+
puts "SIZE: " + result.size
|
13
12
|
puts "SEEDERS: " + result.seeders
|
14
13
|
puts "LEECHERS: " + result.leechers
|
15
14
|
puts "MAGNET: " + result.magnet_link
|
data/hail_hydra.gemspec
CHANGED
@@ -20,10 +20,10 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler", "~> 1
|
23
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
24
24
|
spec.add_development_dependency "rake", "~> 13.0"
|
25
|
-
spec.add_development_dependency "rspec", "~> 3.
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.9"
|
26
26
|
|
27
|
-
spec.add_dependency "
|
27
|
+
spec.add_dependency "addressable"
|
28
28
|
spec.add_dependency "httparty"
|
29
29
|
end
|
data/lib/client.rb
CHANGED
@@ -1,77 +1,74 @@
|
|
1
1
|
require "httparty"
|
2
|
-
require "
|
2
|
+
require "json"
|
3
|
+
require "addressable/uri"
|
4
|
+
require "cgi"
|
3
5
|
require_relative "torrent.rb"
|
4
6
|
|
5
7
|
module HailHydra
|
6
8
|
# The TPB class provides the main client to connect to and scrape the
|
7
|
-
# results.
|
9
|
+
# results.
|
8
10
|
class TPB
|
9
11
|
# remember the domain name and get the cookie to use from the TPB server
|
10
|
-
def initialize
|
11
|
-
@domain =
|
12
|
-
@headers = get_query_headers
|
12
|
+
def initialize domain="https://apibay.org"
|
13
|
+
@domain = domain
|
13
14
|
end
|
14
15
|
|
15
16
|
# search torrents
|
16
|
-
def search
|
17
|
-
get = make_search_request
|
17
|
+
def search query
|
18
|
+
get = make_search_request query
|
18
19
|
raise "Invalid response: #{get.response.code}" unless get.response.code == "200"
|
19
|
-
return parse_search_results(get.response.body)
|
20
|
+
return parse_search_results JSON.parse(get.response.body)
|
20
21
|
end
|
21
22
|
|
22
23
|
private
|
23
24
|
|
24
|
-
def parse_search_results
|
25
|
-
nodes = Nokogiri::HTML(html_text)
|
26
|
-
cells = []
|
27
|
-
table = nodes.search('table')
|
28
|
-
|
29
|
-
table.search('tr').each do |tr|
|
30
|
-
cells.push(tr.search('th, td'))
|
31
|
-
end
|
32
|
-
|
25
|
+
def parse_search_results json_results
|
33
26
|
torrents = []
|
34
|
-
|
35
|
-
|
36
|
-
torrent
|
37
|
-
|
38
|
-
torrent.
|
39
|
-
torrent.
|
40
|
-
torrent.
|
41
|
-
torrent.
|
42
|
-
torrent.
|
43
|
-
|
44
|
-
# extracting the uploaded by, at and size is a bit trickier
|
45
|
-
info_line = descriptions[i-1].text.gsub("\u00A0", "---").split(",").map(&:strip)
|
46
|
-
|
47
|
-
torrent.uploaded_at = info_line[0].split(" ")[1].gsub("---", " ")
|
48
|
-
torrent.size = info_line[1].split(" ")[1].gsub("---", " ")
|
49
|
-
torrent.uploaded_by = info_line[2].split(" ")[2]
|
50
|
-
|
27
|
+
json_results.each do |result|
|
28
|
+
torrent = HailHydra::Torrent.new
|
29
|
+
torrent.name = result["name"]
|
30
|
+
torrent.seeders = result["seeders"]
|
31
|
+
torrent.leechers = result["leechers"]
|
32
|
+
torrent.uploaded_by = result["username"]
|
33
|
+
torrent.uploaded_at = Time.at(result["added"].to_i).to_s
|
34
|
+
torrent.size = make_size(result["size"].to_i)
|
35
|
+
torrent.magnet_link = make_magnet_link(result["info_hash"], result["name"])
|
51
36
|
torrents.push torrent
|
52
37
|
end
|
53
38
|
return torrents
|
54
39
|
end
|
55
40
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}
|
41
|
+
private
|
42
|
+
|
43
|
+
def make_magnet_link info_hash, name
|
44
|
+
# used CGI.escape because URI.encode now throws a warning and Addressable doesn't seem to
|
45
|
+
# support not-URL strings
|
46
|
+
return "magnet:?xt=urn:btih:#{info_hash}&dn=#{CGI.escape(name)}#{trackers}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def trackers
|
50
|
+
tr = '&tr=' + Addressable::URI.encode('udp://tracker.coppersurfer.tk:6969/announce')
|
51
|
+
tr += '&tr=' + Addressable::URI.encode('udp://9.rarbg.to:2920/announce')
|
52
|
+
tr += '&tr=' + Addressable::URI.encode('udp://tracker.opentrackr.org:1337')
|
53
|
+
tr += '&tr=' + Addressable::URI.encode('udp://tracker.internetwarriors.net:1337/announce')
|
54
|
+
tr += '&tr=' + Addressable::URI.encode('udp://tracker.leechers-paradise.org:6969/announce')
|
55
|
+
tr += '&tr=' + Addressable::URI.encode('udp://tracker.coppersurfer.tk:6969/announce')
|
56
|
+
tr += '&tr=' + Addressable::URI.encode('udp://tracker.pirateparty.gr:6969/announce')
|
57
|
+
tr += '&tr=' + Addressable::URI.encode('udp://tracker.cyberia.is:6969/announce')
|
58
|
+
return tr
|
59
|
+
end
|
62
60
|
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
def make_size size
|
62
|
+
return ((size / 1125899906842624).round(3)).to_s + "PiB" if size >= 1125899906842624
|
63
|
+
return ((size / 1099511627776).round(3)).to_s + "TiB" if size >= 1099511627776
|
64
|
+
return ((size / 1073741824).round(3)).to_s + "GiB" if size >= 1073741824
|
65
|
+
return ((size / 1048576).round(3)).to_s + "MiB" if size >= 1048576
|
66
|
+
return ((size / 1024).round(3)).to_s + "KiB" if size >= 1024
|
66
67
|
end
|
67
68
|
|
68
|
-
def
|
69
|
-
|
70
|
-
|
71
|
-
'User-Agent' => 'Mozilla/5.0 (Windows 10; WOW64; rv:10.0) Gecko/20100101 Firefox/10.0',
|
72
|
-
'Referer' => @domain,
|
73
|
-
'Cookie' => cookie
|
74
|
-
}
|
69
|
+
def make_search_request query
|
70
|
+
encoded_uri = Addressable::URI.encode(@domain + "/q.php?q=" + query)
|
71
|
+
HTTParty.get encoded_uri
|
75
72
|
end
|
76
73
|
end
|
77
74
|
end
|
data/lib/hail_hydra/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hail_hydra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gr3atWh173
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.9'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.9'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: addressable
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: httparty
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
|
-
|
128
|
-
rubygems_version: 2.6.14.1
|
127
|
+
rubygems_version: 3.1.2
|
129
128
|
signing_key:
|
130
129
|
specification_version: 4
|
131
130
|
summary: Unofficial pseudo-API for ThePirateBay
|