strike_api 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +2 -1
- data/README.md +16 -10
- data/Rakefile +7 -1
- data/lib/strike_api/torrent.rb +125 -121
- data/lib/strike_api/version.rb +2 -2
- data/lib/strike_api.rb +2 -2
- data/strike_api.gemspec +15 -15
- data/test/test_helper.rb +2 -2
- data/test/torrent/torrent_test.rb +248 -249
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1031c8008c91709432a93f169653e93f09c73c00
|
4
|
+
data.tar.gz: 0da2024794b5751dde0d152abf7e3556cc7f7eb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b479f836b0a0adc14d486161d0152cf6072a32ce7797dbdb37256feed7dc95224b1b40872971edfbdce381f0dc7a14514960bb59b24a7e39687a05d97ccd37
|
7
|
+
data.tar.gz: 29eafb2d367c71687548f5368cfdc61c85339901ab5cbbc70a40db0019df98d0ed5c63eb0235d73d221ff8fb960755e11712ba9c6667b0962c6930d0e67091d4
|
data/.editorconfig
CHANGED
data/README.md
CHANGED
@@ -27,7 +27,7 @@ Or install it yourself as:
|
|
27
27
|
```ruby
|
28
28
|
# Param 1: torrent hash string or array of torrent hash strings
|
29
29
|
# Returns: array of torrent objects (objects include file_info data)
|
30
|
-
|
30
|
+
torrent_info_Array = StrikeAPI::Torrent.find(yourTorrentHash)
|
31
31
|
```
|
32
32
|
|
33
33
|
### Search
|
@@ -35,18 +35,18 @@ torrentInfoArray = StrikeApi::Torrent.find(yourTorrentHash)
|
|
35
35
|
```ruby
|
36
36
|
# Param 1: search phrase, example: "ubuntu iso"
|
37
37
|
# Returns: array of torrent objects
|
38
|
-
|
38
|
+
search_results = StrikeAPI::Torrent.search(search_phrase)
|
39
39
|
|
40
40
|
# Param 1: search phrase, example: "ubuntu iso"
|
41
|
-
# Param 2: category or
|
41
|
+
# Param 2: category or subcategory, examples: "Music", "Documentary"
|
42
42
|
# Returns: array of torrent objects
|
43
|
-
|
43
|
+
search_results = StrikeAPI::Torrent.search(search_phrase, category_or_subcategory)
|
44
44
|
|
45
45
|
# Param 1: search phrase, example: "ubuntu iso"
|
46
46
|
# Param 2: category, example: "Applications"
|
47
|
-
# Param 3:
|
47
|
+
# Param 3: subcategory, example: "Windows"
|
48
48
|
# Returns: array of torrent objects
|
49
|
-
|
49
|
+
search_results = StrikeAPI::Torrent.search(search_phrase, category, subcategory)
|
50
50
|
```
|
51
51
|
|
52
52
|
### Top torrents
|
@@ -54,17 +54,17 @@ searchResults = StrikeApi::Torrent.search(yourSearchPhrase, yourCatagory, yourSu
|
|
54
54
|
```ruby
|
55
55
|
# Param 1: category, examples: "Books", "all"
|
56
56
|
# Returns: top 100 torrents
|
57
|
-
|
57
|
+
top_results = StrikeAPI::Torrent.top(category)
|
58
58
|
```
|
59
59
|
|
60
60
|
### Categories and sub categories
|
61
61
|
|
62
62
|
```ruby
|
63
63
|
# Returns: array of valid categories
|
64
|
-
|
64
|
+
category_array = StrikeAPI::Torrent.categories_available()
|
65
65
|
|
66
|
-
# Returns: array of valid
|
67
|
-
|
66
|
+
# Returns: array of valid subcategories
|
67
|
+
subcategory_array = StrikeAPI::Torrent.subcategories_available()
|
68
68
|
```
|
69
69
|
|
70
70
|
See tests for more usage examples.
|
@@ -74,6 +74,12 @@ See tests for more usage examples.
|
|
74
74
|
1. Better commenting
|
75
75
|
2. ~~Provide usage examples in readme~~
|
76
76
|
|
77
|
+
## Testing
|
78
|
+
|
79
|
+
```
|
80
|
+
rake test
|
81
|
+
```
|
82
|
+
|
77
83
|
## Contributing
|
78
84
|
|
79
85
|
1. Fork it ( https://github.com/marshallford/strike_api/fork )
|
data/Rakefile
CHANGED
data/lib/strike_api/torrent.rb
CHANGED
@@ -2,133 +2,137 @@ require 'httparty'
|
|
2
2
|
require 'json'
|
3
3
|
require 'cgi'
|
4
4
|
|
5
|
-
API_URL =
|
5
|
+
API_URL = 'https://getstrike.net/api/v2/torrents'
|
6
6
|
|
7
|
-
module
|
8
|
-
|
9
|
-
|
7
|
+
module StrikeAPI
|
8
|
+
class Torrent
|
9
|
+
attr_reader :hash, :title, :category, :subcategory, :seeds, :leeches, :file_count, :size, :download_count, :upload_date, :uploader_username, :magnet_uri, :file_info
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
11
|
+
# Constructor for torrent objects
|
12
|
+
def initialize(attributes)
|
13
|
+
@hash = attributes['torrent_hash']
|
14
|
+
@title = attributes['torrent_title']
|
15
|
+
@category = attributes['torrent_category']
|
16
|
+
@subcategory = attributes['sub_category']
|
17
|
+
@seeds = attributes['seeds']
|
18
|
+
@leeches = attributes['leeches']
|
19
|
+
@file_count = attributes['file_count']
|
20
|
+
@size = attributes['size']
|
21
|
+
# @download_count = attributes['download_count'] # Shown in API documentation, not implemented in the API.
|
22
|
+
@upload_date = attributes['upload_date']
|
23
|
+
@uploader_username = attributes['uploader_username']
|
24
|
+
@magnet_uri = attributes['magnet_uri']
|
25
|
+
# file info is only included in hash searches (the find method)
|
26
|
+
if(attributes.has_key?('file_info'))
|
27
|
+
file_names = attributes['file_info']['file_names'].to_a
|
28
|
+
file_lengths = attributes['file_info']['file_lengths'].to_a
|
29
|
+
@file_info = Array.new
|
30
|
+
file_names.each_with_index do |item, i|
|
31
|
+
@file_info[i] = [file_names[i],file_lengths[i]]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
36
|
+
# Allows for both a single torrent_hash via a string and multiple via an array of torrent_hash strings.
|
37
|
+
# Regardless of input, the output will be in the form of an array.
|
38
|
+
def self.find(torrent_hash)
|
39
|
+
hash_list_str = ''
|
40
|
+
torrent_hash = Array(torrent_hash)
|
41
|
+
if(torrent_hash.length > 50)
|
42
|
+
raise 'Strike API accepts a maximum of 50 hashes per query'
|
43
|
+
end
|
44
|
+
torrent_hash.length.times do |i|
|
45
|
+
hash_list_str += torrent_hash[i] + ','
|
46
|
+
end
|
47
|
+
response = HTTParty.get("#{API_URL}/info/?hashes=#{hash_list_str}")
|
48
|
+
error_checker(response)
|
49
|
+
torrents_json = JSON.parse(response.body)
|
50
|
+
torrents_json['torrents'].map { |attributes| new(attributes) }
|
51
|
+
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
53
|
+
def self.search(*input)
|
54
|
+
search_phrase = CGI::escape(input[0].strip)
|
55
|
+
case input.length
|
56
|
+
when 1
|
57
|
+
response = HTTParty.get("#{API_URL}/search/?phrase=#{search_phrase}")
|
58
|
+
when 2
|
59
|
+
if(category_checker(input[1]) == 'category') # second input is a category
|
60
|
+
response = HTTParty.get("#{API_URL}/search/?phrase=#{search_phrase}&category=#{input[1]}")
|
61
|
+
elsif(category_checker(input[1]) == 'subcategory') # second input is a sub category
|
62
|
+
response = HTTParty.get("#{API_URL}/search/?phrase=#{search_phrase}&subcategory=#{input[1]}")
|
63
|
+
else # second input is neither a category or sub category
|
64
|
+
raise 'The category/subcategory entered is not valid'
|
65
|
+
end
|
66
|
+
when 3 # assumes order is search_phrase,category,subcategory
|
67
|
+
if(category_checker(input[1]) != 'category')
|
68
|
+
raise 'The category is not valid'
|
69
|
+
elsif(category_checker(input[2]) != 'subcategory')
|
70
|
+
raise 'The subcategory is not valid'
|
71
|
+
end
|
72
|
+
response = HTTParty.get("#{API_URL}/search/?phrase=#{search_phrase}&category=#{input[1]}&subcategory=#{input[2]}")
|
73
|
+
else
|
74
|
+
raise 'Invalid number of parameters: input <= 3'
|
75
|
+
end
|
76
|
+
error_checker(response)
|
77
|
+
torrents_json = JSON.parse(response.body)
|
78
|
+
torrents_json['torrents'].map { |attributes| new(attributes) }
|
79
|
+
end
|
79
80
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
81
|
+
def self.top(input)
|
82
|
+
search_phrase = CGI::escape(input.strip)
|
83
|
+
if((category_checker(input) != 'category') && input.strip.downcase != 'all') # all is also a valid top category
|
84
|
+
raise 'The category is not valid'
|
85
|
+
end
|
86
|
+
response = HTTParty.get("#{API_URL}/top/?category=#{input}")
|
87
|
+
error_checker(response)
|
88
|
+
torrents_json = JSON.parse(response.body)
|
89
|
+
torrents_json['torrents'].map { |attributes| new(attributes) }
|
90
|
+
end
|
90
91
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
# Returns list of categories available
|
93
|
+
def self.categories_available
|
94
|
+
return ['Anime','Applications','Books','Games','Movies','Music','Other','TV','XXX']
|
95
|
+
end
|
95
96
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
97
|
+
# Returns list of sub categories available
|
98
|
+
def self.subcategories_available
|
99
|
+
return ['Highres Movies','Hentai','HD Video','Handheld','Games','Fiction','English-translated','Ebooks','Dubbed Movies','Documentary','Concerts','Comics','Books','Bollywood','Audio books','Asian','Anime Music Video','Animation','Android','Academic','AAC','3D Movies','XBOX360','Windows','Wii','Wallpapers','Video','Unsorted','UNIX','UltraHD','Tutorials','Transcode','Trailer','Textbooks','Subtitles','Soundtrack','Sound clips','Radio Shows','PSP','PS3','PS2','Poetry','Pictures','PC','Other XXX','Other TV','Other Music','Other Movies','Other Games','Other Books','Other Applications','Other Anime','Non-fiction','Newspapers','Music videos','Mp3','Movie clips','Magazines','Mac','Lossless','Linux','Karaoke','iOS']
|
100
|
+
end
|
100
101
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
102
|
+
def self.category_checker(str)
|
103
|
+
downcased_categories = categories_available().map(&:downcase)
|
104
|
+
downcased_subcategories = subcategories_available().map(&:downcase)
|
105
|
+
if(downcased_categories.include? str.strip.downcase)
|
106
|
+
return 'category'
|
107
|
+
elsif(downcased_subcategories.include? str.strip.downcase)
|
108
|
+
return 'subcategory'
|
109
|
+
else
|
110
|
+
return -1
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Checks for 4XX errors and onward. Examples: 404, 502, 522
|
115
|
+
def self.error_checker(response)
|
116
|
+
code = response.code
|
117
|
+
message = response.message
|
118
|
+
if (valid_json?(response.body) && JSON.parse(response.body)['message'])
|
119
|
+
message = JSON.parse(response.body)['message']
|
120
|
+
end
|
121
|
+
if(code >= 400)
|
122
|
+
raise "Strike API error: #{code} - #{message}"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Checks for valid json
|
127
|
+
def self.valid_json?(json)
|
128
|
+
begin
|
129
|
+
JSON.parse(json)
|
130
|
+
return true
|
131
|
+
rescue Exception => e
|
132
|
+
return false
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
private_class_method :error_checker, :category_checker, :valid_json?
|
137
|
+
end
|
134
138
|
end
|
data/lib/strike_api/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
|
1
|
+
module StrikeAPI
|
2
|
+
VERSION = '1.0.6'
|
3
3
|
end
|
data/lib/strike_api.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
1
|
+
require_relative 'strike_api/version'
|
2
|
+
require_relative 'strike_api/torrent'
|
data/strike_api.gemspec
CHANGED
@@ -4,25 +4,25 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'strike_api/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
-
spec.version =
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
7
|
+
spec.name = 'strike_api'
|
8
|
+
spec.version = StrikeAPI::VERSION
|
9
|
+
spec.authors = ['Marshall Ford','Brett Chastain']
|
10
|
+
spec.email = ['inbox@marshallford.me']
|
11
11
|
spec.summary = %q{Wrapper for the Strike API.}
|
12
|
-
spec.description = %q{
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
12
|
+
spec.description = %q{Wrapper for the Strike Search website/API (https://getstrike.net/torrents/)}
|
13
|
+
spec.homepage = 'https://github.com/marshallford/strike_api'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_dependency
|
27
|
-
spec.add_dependency
|
21
|
+
spec.add_development_dependency 'bundler'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'minitest'
|
24
|
+
spec.add_development_dependency 'vcr'
|
25
|
+
spec.add_development_dependency 'webmock'
|
26
|
+
spec.add_dependency 'httparty'
|
27
|
+
spec.add_dependency 'json'
|
28
28
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,275 +1,274 @@
|
|
1
1
|
require './test/test_helper'
|
2
2
|
|
3
3
|
class StrikeTorrentTest < Minitest::Test
|
4
|
+
def test_exists
|
5
|
+
assert StrikeAPI::Torrent
|
6
|
+
end
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
+
def test_find_single_torrent
|
9
|
+
VCR.use_cassette('test_find_single_torrent') do
|
10
|
+
result = StrikeAPI::Torrent.find('156B69B8643BD11849A5D8F2122E13FBB61BD041')[0]
|
11
|
+
assert_equal StrikeAPI::Torrent, result.class
|
12
|
+
assert_equal '156B69B8643BD11849A5D8F2122E13FBB61BD041', result.hash
|
13
|
+
assert_equal 'Slackware 14.1 x86_64 DVD ISO', result.title
|
14
|
+
assert_equal 'Applications', result.category
|
15
|
+
assert_equal '', result.subcategory
|
16
|
+
assert_equal 192, result.seeds
|
17
|
+
assert_equal 9, result.leeches
|
18
|
+
assert_equal 4, result.file_count
|
19
|
+
assert_equal 2437393940, result.size
|
20
|
+
# assert_equal 40, result.download_count
|
21
|
+
assert_equal 'Feb 24, 2014', result.upload_date
|
22
|
+
assert_equal 'Nusantara', result.uploader_username
|
23
|
+
assert_equal 'magnet:?xt=urn:btih:156B69B8643BD11849A5D8F2122E13FBB61BD041&dn=Slackware+14.1+x86_64+DVD+ISO&tr=udp://open.demonii.com:1337&tr=udp://tracker.coppersurfer.tk:6969&tr=udp://tracker.leechers-paradise.org:6969&tr=udp://exodus.desync.com:6969', result.magnet_uri
|
24
|
+
assert_equal 'slackware64-14.1-iso\\slackware64-14.1-install-dvd.iso', result.file_info[0][0] # first file, filename
|
25
|
+
assert_equal 2438987776, result.file_info[0][1] # first file, file length
|
26
|
+
end
|
27
|
+
end
|
8
28
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
def test_find_array
|
30
|
+
VCR.use_cassette('test_find_array') do
|
31
|
+
result = StrikeAPI::Torrent.find(['156B69B8643BD11849A5D8F2122E13FBB61BD041','B425907E5755031BDA4A8D1B6DCCACA97DA14C04'])
|
32
|
+
result1 = result[0]
|
33
|
+
result2 = result[1]
|
34
|
+
# Torrent 1: Slackware ISO
|
35
|
+
assert_equal StrikeAPI::Torrent, result1.class
|
36
|
+
assert_equal '156B69B8643BD11849A5D8F2122E13FBB61BD041', result1.hash
|
37
|
+
assert_equal 'Slackware 14.1 x86_64 DVD ISO', result1.title
|
38
|
+
assert_equal 'Applications', result1.category
|
39
|
+
assert_equal '', result1.subcategory
|
40
|
+
assert_equal 192, result1.seeds
|
41
|
+
assert_equal 9, result1.leeches
|
42
|
+
assert_equal 4, result1.file_count
|
43
|
+
assert_equal 2437393940, result1.size
|
44
|
+
# assert_equal 40, result1.download_count
|
45
|
+
assert_equal 'Feb 24, 2014', result1.upload_date
|
46
|
+
assert_equal 'Nusantara', result1.uploader_username
|
47
|
+
assert_equal 'magnet:?xt=urn:btih:156B69B8643BD11849A5D8F2122E13FBB61BD041&dn=Slackware+14.1+x86_64+DVD+ISO&tr=udp://open.demonii.com:1337&tr=udp://tracker.coppersurfer.tk:6969&tr=udp://tracker.leechers-paradise.org:6969&tr=udp://exodus.desync.com:6969', result1.magnet_uri
|
48
|
+
assert_equal 'slackware64-14.1-iso\\slackware64-14.1-install-dvd.iso', result1.file_info[0][0] # first file, filename
|
49
|
+
assert_equal 2438987776, result1.file_info[0][1] # first file, file length
|
50
|
+
# Torrent 2: Arch ISO
|
51
|
+
assert_equal StrikeAPI::Torrent, result2.class
|
52
|
+
assert_equal 'B425907E5755031BDA4A8D1B6DCCACA97DA14C04', result2.hash
|
53
|
+
assert_equal 'Arch Linux 2015.01.01 (x86/x64)', result2.title
|
54
|
+
assert_equal 'Applications', result2.category
|
55
|
+
assert_equal '', result2.subcategory
|
56
|
+
assert_equal 645, result2.seeds
|
57
|
+
assert_equal 13, result2.leeches
|
58
|
+
assert_equal 1, result2.file_count
|
59
|
+
assert_equal 615514112, result2.size
|
60
|
+
# assert_equal 40, result2.download_count
|
61
|
+
assert_equal 'Jan 6, 2015', result2.upload_date
|
62
|
+
assert_equal 'The_Doctor-', result2.uploader_username
|
63
|
+
assert_equal 'magnet:?xt=urn:btih:B425907E5755031BDA4A8D1B6DCCACA97DA14C04&dn=Arch+Linux+2015.01.01+%28x86%2Fx64%29&tr=udp://open.demonii.com:1337&tr=udp://tracker.coppersurfer.tk:6969&tr=udp://tracker.leechers-paradise.org:6969&tr=udp://exodus.desync.com:6969', result2.magnet_uri
|
64
|
+
assert_equal 'archlinux-2015.01.01-dual.iso', result2.file_info[0][0] # first file, filename
|
65
|
+
assert_equal 615514112, result2.file_info[0][1] # first file, file length
|
66
|
+
end
|
67
|
+
end
|
29
68
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
assert_equal "Applications", result1.category
|
40
|
-
assert_equal "", result1.sub_category
|
41
|
-
assert_equal 192, result1.seeds
|
42
|
-
assert_equal 9, result1.leeches
|
43
|
-
assert_equal 4, result1.file_count
|
44
|
-
assert_equal 2437393940, result1.size
|
45
|
-
# assert_equal 40, result1.download_count
|
46
|
-
assert_equal "Feb 24, 2014", result1.upload_date
|
47
|
-
assert_equal "Nusantara", result1.uploader_username
|
48
|
-
assert_equal "magnet:?xt=urn:btih:156B69B8643BD11849A5D8F2122E13FBB61BD041&dn=Slackware+14.1+x86_64+DVD+ISO&tr=udp:\/\/open.demonii.com:1337&tr=udp:\/\/tracker.coppersurfer.tk:6969&tr=udp:\/\/tracker.leechers-paradise.org:6969&tr=udp:\/\/exodus.desync.com:6969", result1.magnet_uri
|
49
|
-
assert_equal "slackware64-14.1-iso\\slackware64-14.1-install-dvd.iso", result1.file_info[0][0] # first file, filename
|
50
|
-
assert_equal 2438987776, result1.file_info[0][1] # first file, file length
|
51
|
-
# Torrent 2: Arch ISO
|
52
|
-
assert_equal StrikeApi::Torrent, result2.class
|
53
|
-
assert_equal "B425907E5755031BDA4A8D1B6DCCACA97DA14C04", result2.hash
|
54
|
-
assert_equal "Arch Linux 2015.01.01 (x86\/x64)", result2.title
|
55
|
-
assert_equal "Applications", result2.category
|
56
|
-
assert_equal "", result2.sub_category
|
57
|
-
assert_equal 645, result2.seeds
|
58
|
-
assert_equal 13, result2.leeches
|
59
|
-
assert_equal 1, result2.file_count
|
60
|
-
assert_equal 615514112, result2.size
|
61
|
-
# assert_equal 40, result2.download_count
|
62
|
-
assert_equal "Jan 6, 2015", result2.upload_date
|
63
|
-
assert_equal "The_Doctor-", result2.uploader_username
|
64
|
-
assert_equal "magnet:?xt=urn:btih:B425907E5755031BDA4A8D1B6DCCACA97DA14C04&dn=Arch+Linux+2015.01.01+%28x86%2Fx64%29&tr=udp:\/\/open.demonii.com:1337&tr=udp:\/\/tracker.coppersurfer.tk:6969&tr=udp:\/\/tracker.leechers-paradise.org:6969&tr=udp:\/\/exodus.desync.com:6969", result2.magnet_uri
|
65
|
-
assert_equal "archlinux-2015.01.01-dual.iso", result2.file_info[0][0] # first file, filename
|
66
|
-
assert_equal 615514112, result2.file_info[0][1] # first file, file length
|
67
|
-
end
|
68
|
-
end
|
69
|
+
def test_find_no_torrents
|
70
|
+
VCR.use_cassette('test_find_no_torrents') do
|
71
|
+
begin
|
72
|
+
result = StrikeAPI::Torrent.find('156B69B8643BD1184D041')[0]
|
73
|
+
rescue => e
|
74
|
+
assert_equal 'Strike API error: 404 - No torrents found with provided hashes', e.message
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
69
78
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
+
def test_find_empty
|
80
|
+
VCR.use_cassette('test_find_empty') do
|
81
|
+
begin
|
82
|
+
result = StrikeAPI::Torrent.find('')[0]
|
83
|
+
rescue => e
|
84
|
+
assert_equal 'Strike API error: 404 - No torrents found with provided hashes', e.message
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
79
88
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
+
def test_search_no_torrents
|
90
|
+
VCR.use_cassette('test_search_no_torrents') do
|
91
|
+
begin
|
92
|
+
result = StrikeAPI::Torrent.search('123456789abcdefg')[0]
|
93
|
+
rescue => e
|
94
|
+
assert_equal 'Strike API error: 404 - No torrents found.', e.message
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
89
98
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
+
def test_search_empty
|
100
|
+
VCR.use_cassette('test_search_empty') do
|
101
|
+
begin
|
102
|
+
result = StrikeAPI::Torrent.search('')[0]
|
103
|
+
rescue => e
|
104
|
+
assert_equal 'Strike API error: 404 - Please enter a phrease.', e.message
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
99
108
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
+
def test_search
|
110
|
+
VCR.use_cassette('test_search') do
|
111
|
+
result = StrikeAPI::Torrent.search('Slackware 14.1 x86_64 DVD ISO')
|
112
|
+
assert_equal 1, result.length
|
113
|
+
assert result.kind_of?(Array)
|
114
|
+
assert result.first.kind_of?(StrikeAPI::Torrent)
|
115
|
+
assert !result[0].file_info # file_info information is not given in search results
|
116
|
+
end
|
117
|
+
end
|
109
118
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
+
def test_search_category
|
120
|
+
VCR.use_cassette('test_search_category') do
|
121
|
+
result = StrikeAPI::Torrent.search('windows', 'Applications')
|
122
|
+
assert_equal 100, result.length
|
123
|
+
assert result.kind_of?(Array)
|
124
|
+
assert result.first.kind_of?(StrikeAPI::Torrent)
|
125
|
+
assert !result[0].file_info # file_info information is not given in search results
|
126
|
+
end
|
127
|
+
end
|
119
128
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
+
def test_search_subcategory
|
130
|
+
VCR.use_cassette('test_search_subCategory') do
|
131
|
+
result = StrikeAPI::Torrent.search('windows', 'Windows')
|
132
|
+
assert_equal 100, result.length
|
133
|
+
assert result.kind_of?(Array)
|
134
|
+
assert result.first.kind_of?(StrikeAPI::Torrent)
|
135
|
+
assert !result[0].file_info # file_info information is not given in search results
|
136
|
+
end
|
137
|
+
end
|
129
138
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
+
def test_search_category_subcategory
|
140
|
+
VCR.use_cassette('test_search_category_subCategory') do
|
141
|
+
result = StrikeAPI::Torrent.search('windows', 'Applications', 'Windows')
|
142
|
+
assert_equal 100, result.length
|
143
|
+
assert result.kind_of?(Array)
|
144
|
+
assert result.first.kind_of?(StrikeAPI::Torrent)
|
145
|
+
assert !result[0].file_info # file_info information is not given in search results
|
146
|
+
end
|
147
|
+
end
|
139
148
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
+
def test_search_more_than_three_params
|
150
|
+
VCR.use_cassette('test_search_more_than_three_params') do
|
151
|
+
begin
|
152
|
+
result = StrikeAPI::Torrent.search('windows', 'Applications', 'Windows','Test')
|
153
|
+
rescue => e
|
154
|
+
assert_equal 'Invalid number of parameters: input <= 3', e.message
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
149
158
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
+
def test_search_invalid_two_inputs
|
160
|
+
VCR.use_cassette('test_search_invalid_two_inputs') do
|
161
|
+
begin
|
162
|
+
result = StrikeAPI::Torrent.search('windows', 'asdasdasd')
|
163
|
+
rescue => e
|
164
|
+
assert_equal 'The category/subcategory entered is not valid', e.message
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
159
168
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
+
def test_search_invalid_category
|
170
|
+
VCR.use_cassette('test_search_invalid_category') do
|
171
|
+
begin
|
172
|
+
result = StrikeAPI::Torrent.search('windows', 'asdasdasd','Windows')
|
173
|
+
rescue => e
|
174
|
+
assert_equal 'The category is not valid', e.message
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
169
178
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
+
def test_search_invalid_subcategory
|
180
|
+
VCR.use_cassette('test_search_invalid_subcategory') do
|
181
|
+
begin
|
182
|
+
result = StrikeAPI::Torrent.search('windows', 'Applications','asdasdsdsa')
|
183
|
+
rescue => e
|
184
|
+
assert_equal 'The subcategory is not valid', e.message
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
179
188
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
+
def test_site_down_cloudflare
|
190
|
+
VCR.use_cassette('test_site_down_cloudflare') do
|
191
|
+
begin
|
192
|
+
result = StrikeAPI::Torrent.search('Slackware 14.1 x86_64 DVD ISO')
|
193
|
+
rescue => e
|
194
|
+
assert_equal 'Strike API error: 522 - Origin Connection Time-out', e.message
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
189
198
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
+
def test_filter_string
|
200
|
+
VCR.use_cassette('test_filter_string') do
|
201
|
+
flag = true
|
202
|
+
result = StrikeAPI::Torrent.search('windows -windows8', 'Applications', 'Windows')
|
203
|
+
assert_equal 100, result.length
|
204
|
+
assert result.kind_of?(Array)
|
205
|
+
assert result.first.kind_of?(StrikeAPI::Torrent)
|
206
|
+
filteredStr = 'windows 8'
|
207
|
+
result.each do |torrent|
|
208
|
+
if(torrent.title.strip.downcase.include? filteredStr.strip.downcase)
|
209
|
+
flag = false
|
210
|
+
end
|
211
|
+
end
|
212
|
+
assert_equal true, flag
|
213
|
+
end
|
214
|
+
end
|
199
215
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
+
def test_filter_string_no_filter
|
217
|
+
VCR.use_cassette('test_filter_string_no_filter') do
|
218
|
+
flag = true
|
219
|
+
result = StrikeAPI::Torrent.search('windows', 'Applications', 'Windows')
|
220
|
+
assert_equal 100, result.length
|
221
|
+
assert result.kind_of?(Array)
|
222
|
+
assert result.first.kind_of?(StrikeAPI::Torrent)
|
223
|
+
filteredStr = 'windows 8'
|
224
|
+
result.each do |torrent|
|
225
|
+
if(torrent.title.strip.downcase.include? filteredStr.strip.downcase)
|
226
|
+
flag = false
|
227
|
+
end
|
228
|
+
end
|
229
|
+
assert_equal false, flag
|
230
|
+
end
|
231
|
+
end
|
216
232
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
if(torrent.title.strip.downcase.include? filteredStr.strip.downcase)
|
227
|
-
flag = false
|
228
|
-
end
|
229
|
-
end
|
230
|
-
assert_equal false, flag
|
231
|
-
end
|
232
|
-
end
|
233
|
+
def test_top
|
234
|
+
VCR.use_cassette('test_top') do
|
235
|
+
result = StrikeAPI::Torrent.top('Books')
|
236
|
+
assert_equal 100, result.length
|
237
|
+
assert result.kind_of?(Array)
|
238
|
+
assert result.first.kind_of?(StrikeAPI::Torrent)
|
239
|
+
assert !result[0].file_info
|
240
|
+
end
|
241
|
+
end
|
233
242
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
+
def test_top_invalid_category
|
244
|
+
VCR.use_cassette('test_top_invalid_category') do
|
245
|
+
begin
|
246
|
+
result = StrikeAPI::Torrent.top('abc123')
|
247
|
+
rescue => e
|
248
|
+
assert_equal 'The category is not valid', e.message
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
243
252
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
+
def test_top_all_category
|
254
|
+
VCR.use_cassette('test_top_all_category') do
|
255
|
+
result = StrikeAPI::Torrent.top('all')
|
256
|
+
assert_equal 100, result.length
|
257
|
+
assert result.kind_of?(Array)
|
258
|
+
assert result.first.kind_of?(StrikeAPI::Torrent)
|
259
|
+
assert !result[0].file_info
|
260
|
+
end
|
261
|
+
end
|
253
262
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
assert result.first.kind_of?(StrikeApi::Torrent)
|
260
|
-
assert !result[0].file_info
|
261
|
-
end
|
262
|
-
end
|
263
|
+
def test_categories_available
|
264
|
+
result = StrikeAPI::Torrent.categories_available
|
265
|
+
assert result.kind_of?(Array)
|
266
|
+
assert result.first.kind_of?(String)
|
267
|
+
end
|
263
268
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
def test_subCatagoriesAvailable
|
271
|
-
result = StrikeApi::Torrent.subCatagoriesAvailable
|
272
|
-
assert result.kind_of?(Array)
|
273
|
-
assert result.first.kind_of?(String)
|
274
|
-
end
|
269
|
+
def test_subcategories_available
|
270
|
+
result = StrikeAPI::Torrent.subcategories_available
|
271
|
+
assert result.kind_of?(Array)
|
272
|
+
assert result.first.kind_of?(String)
|
273
|
+
end
|
275
274
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strike_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marshall Ford
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-09-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
|
-
description:
|
112
|
+
description: Wrapper for the Strike Search website/API (https://getstrike.net/torrents/)
|
113
113
|
email:
|
114
114
|
- inbox@marshallford.me
|
115
115
|
executables: []
|
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
165
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.4.
|
166
|
+
rubygems_version: 2.4.8
|
167
167
|
signing_key:
|
168
168
|
specification_version: 4
|
169
169
|
summary: Wrapper for the Strike API.
|