strike_api 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d65c3d617a9e1b60ef55e43e18c632b27aeebe9
4
- data.tar.gz: c3d400eac4086e10ca10b7b54bda254fc8da84d5
3
+ metadata.gz: cfe5f4a17f2aaf0d99b6696601d1b2a563920692
4
+ data.tar.gz: 3f2534d86c091777a31c03d4f38aced81ca29adf
5
5
  SHA512:
6
- metadata.gz: f8deea23f0301bba66030b33ead8db225b5d28883566d4990893061aaf7e74becdcde975dbce2db37c22499f649d9177c3c3bf549dd548cb583529260aeace7d
7
- data.tar.gz: 330163ad930bc5a8338f335d8ecdae7ccda51e07de234dd75b5874c75d597abbea7883b05134ca7a823c1dbb26beeaea642acc166afd421dc90b7cca76a1f960
6
+ metadata.gz: 6c5f3779ea342bbb198979becea5c796747ca816c7581e154d2b196381440ff9754acf489fee78c6d6305e927406bdc835cfdd0a8f35294a83388ae8c11637b1
7
+ data.tar.gz: 0b99a3ddf1c18a7ac2c5b329423a36ca8ef41c50f963409c45e7eb8df92c6ddfa8d454c83bcf20b67f376fb57468b40a2d083cc2d62851cf386643ecc6da30ac
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Strike API
2
2
 
3
- API wrapper for the Strike Search website (http://getstrike.net)
3
+ [![Gem Version](https://img.shields.io/gem/v/strike_api.svg)](https://rubygems.org/gems/strike_api)
4
+
5
+ API wrapper for the Strike Search website (https://getstrike.net/torrents/)
4
6
 
5
7
  ## Installation
6
8
 
@@ -20,12 +22,61 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
23
- See tests for usage examples.
25
+ ### Find
26
+
27
+ * Param 1: torrent hash string, array of torrent hash strings
28
+ * Returns: array of torrent objects (objects include file_info data)
29
+
30
+ ```
31
+ result = StrikeApi::Torrent.find(yourTorrentHash)
32
+ ```
33
+
34
+ ### Search
35
+
36
+ * Param 1: search phrase, example: "ubuntu iso"
37
+ * Returns: array of torrent objects
38
+
39
+ ```
40
+ result = StrikeApi::Torrent.search(yourSearchPhrase)
41
+ ```
42
+
43
+ * Param 1: search phrase, example: "ubuntu iso"
44
+ * Param 2: Category or sub category, examples: "Music", "Documentary"
45
+ * Returns: array of torrent objects
46
+
47
+ ```
48
+ result = StrikeApi::Torrent.search(yourSearchPhrase, yourCatagoryOrSubCategory)
49
+ ```
50
+
51
+ * Param 1: search phrase, example: "ubuntu iso"
52
+ * Param 2: Category, example: "Applications"
53
+ * Param 3: Sub category, example: "Windows"
54
+ * Returns: array of torrent objects
55
+
56
+ ```
57
+ result = StrikeApi::Torrent.search(yourSearchPhrase, yourCatagory, yourSubCategory)
58
+ ```
59
+
60
+ ### Categories and sub categories
61
+
62
+ * Returns: array of valid categories
63
+
64
+ ```
65
+ result = StrikeApi::Torrent.catagoriesAvailable()
66
+ ```
67
+
68
+ * Returns: array of valid sub categories
69
+
70
+ ```
71
+ result = StrikeApi::Torrent.subCatagoriesAvailable()
72
+ ```
73
+
74
+ See tests for more usage examples.
24
75
 
25
76
  ## TODO
26
77
 
27
78
  1. Better commenting
28
- 2. Provide usage examples in readme
79
+ 2. ~~Provide usage examples in readme~~
29
80
 
30
81
  ## Contributing
31
82
 
@@ -6,7 +6,7 @@ API_URL = "https://getstrike.net/api/v2/torrents"
6
6
 
7
7
  module StrikeApi
8
8
  class Torrent
9
- attr_reader :hash, :title, :category, :sub_category, :seeds, :leeches, :file_count, :size, :download_count, :upload_date, :uploader_username, :magnet_uri
9
+ attr_reader :hash, :title, :category, :sub_category, :seeds, :leeches, :file_count, :size, :download_count, :upload_date, :uploader_username, :magnet_uri, :file_info
10
10
 
11
11
  # Constructor for torrent objects
12
12
  def initialize(attributes)
@@ -22,6 +22,14 @@ module StrikeApi
22
22
  @upload_date = attributes["upload_date"]
23
23
  @uploader_username = attributes["uploader_username"]
24
24
  @magnet_uri = attributes["magnet_uri"]
25
+ if(attributes.has_key?("file_info")) # file info is only included in hash searches (the find method)
26
+ file_names = attributes["file_info"]["file_names"].to_a
27
+ file_lengths = attributes["file_info"]["file_lengths"].to_a
28
+ @file_info = Array.new
29
+ file_names.each_with_index do |item, i|
30
+ @file_info[i] = [file_names[i],file_lengths[i]]
31
+ end
32
+ end
25
33
  end
26
34
 
27
35
  # Allows for both a single torrentHash via a string and multiple via an array of torrentHash strings.
@@ -29,8 +37,11 @@ module StrikeApi
29
37
  def self.find(torrentHash)
30
38
  hashListStr = ""
31
39
  torrentHash = Array(torrentHash)
40
+ if(torrentHash.length > 50)
41
+ raise "Strike API accepts a maximum of 50 hashes per query"
42
+ end
32
43
  torrentHash.length.times do |i|
33
- hashListStr = hashListStr + torrentHash[i] + ","
44
+ hashListStr += torrentHash[i] + ","
34
45
  end
35
46
  response = HTTParty.get("#{API_URL}/info/?hashes=#{hashListStr}")
36
47
  errorChecker(response)
@@ -1,3 +1,3 @@
1
1
  module StrikeApi
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
data/strike_api.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Marshall Ford","Brett Chastain"]
10
10
  spec.email = ["inbox@marshallford.me"]
11
11
  spec.summary = %q{Wrapper for the Strike API.}
12
- spec.description = %q{API wrapper for the Strike Search website (http://getstrike.net)}
12
+ spec.description = %q{API wrapper for the Strike Search website (https://getstrike.net/torrents/)}
13
13
  spec.homepage = "https://github.com/marshallford/strike_api"
14
14
  spec.license = "MIT"
15
15
 
@@ -22,6 +22,8 @@ class StrikeTorrentTest < Minitest::Test
22
22
  assert_equal "Feb 24, 2014", result.upload_date
23
23
  assert_equal "Nusantara", result.uploader_username
24
24
  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
25
+ assert_equal "slackware64-14.1-iso\\slackware64-14.1-install-dvd.iso", result.file_info[0][0] # first file, filename
26
+ assert_equal 2438987776, result.file_info[0][1] # first file, file length
25
27
  end
26
28
  end
27
29
 
@@ -44,6 +46,8 @@ class StrikeTorrentTest < Minitest::Test
44
46
  assert_equal "Feb 24, 2014", result1.upload_date
45
47
  assert_equal "Nusantara", result1.uploader_username
46
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
47
51
  # Torrent 2: Arch ISO
48
52
  assert_equal StrikeApi::Torrent, result2.class
49
53
  assert_equal "B425907E5755031BDA4A8D1B6DCCACA97DA14C04", result2.hash
@@ -58,6 +62,8 @@ class StrikeTorrentTest < Minitest::Test
58
62
  assert_equal "Jan 6, 2015", result2.upload_date
59
63
  assert_equal "The_Doctor-", result2.uploader_username
60
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
61
67
  end
62
68
  end
63
69
 
@@ -107,6 +113,7 @@ class StrikeTorrentTest < Minitest::Test
107
113
  assert_equal 1, result.length
108
114
  assert result.kind_of?(Array)
109
115
  assert result.first.kind_of?(StrikeApi::Torrent)
116
+ assert !result[0].file_info # file_info information is not given in search results
110
117
  end
111
118
  end
112
119
 
@@ -116,6 +123,7 @@ class StrikeTorrentTest < Minitest::Test
116
123
  assert_equal 100, result.length
117
124
  assert result.kind_of?(Array)
118
125
  assert result.first.kind_of?(StrikeApi::Torrent)
126
+ assert !result[0].file_info # file_info information is not given in search results
119
127
  end
120
128
  end
121
129
 
@@ -125,6 +133,7 @@ class StrikeTorrentTest < Minitest::Test
125
133
  assert_equal 100, result.length
126
134
  assert result.kind_of?(Array)
127
135
  assert result.first.kind_of?(StrikeApi::Torrent)
136
+ assert !result[0].file_info # file_info information is not given in search results
128
137
  end
129
138
  end
130
139
 
@@ -134,6 +143,7 @@ class StrikeTorrentTest < Minitest::Test
134
143
  assert_equal 100, result.length
135
144
  assert result.kind_of?(Array)
136
145
  assert result.first.kind_of?(StrikeApi::Torrent)
146
+ assert !result[0].file_info # file_info information is not given in search results
137
147
  end
138
148
  end
139
149
 
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.2
4
+ version: 1.0.3
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-04-12 00:00:00.000000000 Z
12
+ date: 2015-04-16 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: API wrapper for the Strike Search website (http://getstrike.net)
112
+ description: API wrapper for the Strike Search website (https://getstrike.net/torrents/)
113
113
  email:
114
114
  - inbox@marshallford.me
115
115
  executables: []