strike_api 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7c2c24fdb4010467147a194ed774ff1238bcc9b9
4
+ data.tar.gz: a1d8a0fa4f87a0064e53669ae9df8edb1d0224c4
5
+ SHA512:
6
+ metadata.gz: 18c2a4079bfe160db4809bebc927ea5b4e8800cfeb211a29af0aba967b69ec75860c43df7b254d93afea92cfee1a822d17f8c5e90851fbcbff3c3900e18697d1
7
+ data.tar.gz: 39affb8b45c5633054e60352d0f49b625e94cc9ecddd74e771f1410e50fa3fe8e2c8e80cdcaec36579d80ee9aa7166437f1252e2a08039600effa5ec09dcba72
data/.editorconfig ADDED
@@ -0,0 +1,9 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = tab
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in strike_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Marshall Ford
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Strike API
2
+
3
+ API wrapper for the Strike Search website (http://getstrike.net)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'strike_api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install strike_api
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/marshallford/strike_api/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,86 @@
1
+ require 'httparty'
2
+ require 'json'
3
+ require 'cgi'
4
+
5
+ API_URL = "https://getstrike.net/api/v2/torrents"
6
+
7
+ module StrikeApi
8
+ class Torrent
9
+ attr_reader :hash, :title, :category, :sub_category, :seeds, :leeches, :file_count, :size, :download_count, :upload_date, :uploader_username, :magnet_uri
10
+ def initialize(attributes)
11
+ @hash = attributes["torrent_hash"]
12
+ @title = attributes["torrent_title"]
13
+ @category = attributes["torrent_category"]
14
+ @sub_category = attributes["sub_category"]
15
+ @seeds = attributes["seeds"]
16
+ @leeches = attributes["leeches"]
17
+ @file_count = attributes["file_count"]
18
+ @size = attributes["size"]
19
+ # @download_count = attributes["download_count"] # Shown in documentation, not implemented in the API.
20
+ @upload_date = attributes["upload_date"]
21
+ @uploader_username = attributes["uploader_username"]
22
+ @magnet_uri = attributes["magnet_uri"]
23
+ end
24
+
25
+ def self.find(torrentHash)
26
+ hashListStr = ""
27
+ torrentHash = Array(torrentHash)
28
+ torrentHash.length.times do |i|
29
+ hashListStr = hashListStr + torrentHash[i] + ","
30
+ end
31
+ response = HTTParty.get("#{API_URL}/info/?hashes=#{hashListStr}")
32
+ errorChecker(response)
33
+ torrentsJSON = JSON.parse(response.body)
34
+ torrentsJSON["torrents"].map { |attributes| new(attributes) }
35
+ end
36
+
37
+ def self.search(input)
38
+ input = CGI::escape(input)
39
+ response = HTTParty.get("#{API_URL}/search/?phrase=#{input}")
40
+ errorChecker(response)
41
+ torrentsJSON = JSON.parse(response.body)
42
+ torrentsJSON["torrents"].map { |attributes| new(attributes) }
43
+ end
44
+
45
+ def self.searchCat(input, category)
46
+ input = CGI::escape(input)
47
+ response = HTTParty.get("#{API_URL}/search/?phrase=#{input}&category=#{category}")
48
+ errorChecker(response)
49
+ torrentsJSON = JSON.parse(response.body)
50
+ torrentsJSON["torrents"].map { |attributes| new(attributes) }
51
+ end
52
+
53
+ def self.searchSubCat(input,sub_category)
54
+ input = CGI::escape(input)
55
+ response = HTTParty.get("#{API_URL}/search/?phrase=#{input}&subcategory=#{sub_category}")
56
+ errorChecker(response)
57
+ torrentsJSON = JSON.parse(response.body)
58
+ torrentsJSON["torrents"].map { |attributes| new(attributes) }
59
+ end
60
+
61
+ def self.searchCatSubCat(input, category, sub_category)
62
+ input = CGI::escape(input)
63
+ response = HTTParty.get("#{API_URL}/search/?phrase=#{input}&category=#{category}&subcategory=#{sub_category}")
64
+ errorChecker(response)
65
+ torrentsJSON = JSON.parse(response.body)
66
+ torrentsJSON["torrents"].map { |attributes| new(attributes) }
67
+ end
68
+
69
+ def self.catagoriesAvailable
70
+ return ["Anime","Applications","Books","Games","Movies","Music","Other","TV","XXX"]
71
+ end
72
+
73
+ def self.subCatagoriesAvailable
74
+ 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"]
75
+ end
76
+
77
+ def self.errorChecker(response)
78
+ code = response.code
79
+ message = JSON.parse(response.body)["message"]
80
+ if(code >= 400)
81
+ raise "Strike API error: #{code} - #{message}"
82
+ end
83
+ end
84
+ private_class_method :errorChecker
85
+ end
86
+ end
@@ -0,0 +1,3 @@
1
+ module StrikeApi
2
+ VERSION = "1.0.1"
3
+ end
data/lib/strike_api.rb ADDED
@@ -0,0 +1,2 @@
1
+ require_relative "strike_api/version"
2
+ require_relative "strike_api/torrent"
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'strike_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "strike_api"
8
+ spec.version = StrikeApi::VERSION
9
+ spec.authors = ["Marshall Ford","Brett Chastain"]
10
+ spec.email = ["inbox@marshallford.me"]
11
+ spec.summary = %q{Wrapper for the Strike API.}
12
+ spec.description = %q{API wrapper for the Strike Search website (http://getstrike.net)}
13
+ spec.homepage = "https://github.com/marshallford/strike_api"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
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
+ end
@@ -0,0 +1,53 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://getstrike.net/api/v2/torrents/info/?hashes=156B69B8643BD11849A5D8F2122E13FBB61BD041,B425907E5755031BDA4A8D1B6DCCACA97DA14C04,
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - cloudflare-nginx
23
+ Date:
24
+ - Sat, 11 Apr 2015 16:21:03 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - __cfduid=d4c67e9acea6bc97066b0c9a02ef2f04f1428769263; expires=Sun, 10-Apr-16
33
+ 16:21:03 GMT; path=/; domain=.getstrike.net; HttpOnly
34
+ Access-Control-Allow-Origin:
35
+ - "*"
36
+ Access-Control-Allow-Methods:
37
+ - GET
38
+ X-Clacks-Overhead:
39
+ - GNU Terry Pratchett
40
+ Cf-Ray:
41
+ - 1d5805b9947005d5-WAW
42
+ body:
43
+ encoding: UTF-8
44
+ string: '{"results":2,"statuscode":200,"responsetime":0.002,"torrents":[{"torrent_hash":"156B69B8643BD11849A5D8F2122E13FBB61BD041","torrent_title":"Slackware
45
+ 14.1 x86_64 DVD ISO","torrent_category":"Applications","sub_category":"","seeds":192,"leeches":9,"file_count":4,"size":2437393940,"upload_date":"Feb
46
+ 24, 2014","uploader_username":"Nusantara","file_info":{"file_names":["slackware64-14.1-iso\\slackware64-14.1-install-dvd.iso","
47
+ slackware64-14.1-iso\\slackware64-14.1-install-dvd.iso.asc"," slackware64-14.1-iso\\slackware64-14.1-install-dvd.iso.md5","
48
+ slackware64-14.1-iso\\slackware64-14.1-install-dvd.iso.txt"],"file_lengths":[2438987776,198,67,231925]},"magnet_uri":"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"},{"torrent_hash":"B425907E5755031BDA4A8D1B6DCCACA97DA14C04","torrent_title":"Arch
49
+ Linux 2015.01.01 (x86\/x64)","torrent_category":"Applications","sub_category":"","seeds":645,"leeches":13,"file_count":1,"size":615514112,"upload_date":"Jan 6,
50
+ 2015","uploader_username":"The_Doctor-","file_info":{"file_names":["archlinux-2015.01.01-dual.iso"],"file_lengths":[615514112]},"magnet_uri":"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"}]}'
51
+ http_version:
52
+ recorded_at: Sat, 11 Apr 2015 16:21:03 GMT
53
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://getstrike.net/api/v2/torrents/info/?hashes=156B69B8643BD1184D041,
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 404
19
+ message: Not Found
20
+ headers:
21
+ Server:
22
+ - cloudflare-nginx
23
+ Date:
24
+ - Sat, 11 Apr 2015 17:26:35 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - __cfduid=da0595fb2242297c4dee501a779c6f9d91428773195; expires=Sun, 10-Apr-16
33
+ 17:26:35 GMT; path=/; domain=.getstrike.net; HttpOnly
34
+ Access-Control-Allow-Origin:
35
+ - "*"
36
+ Access-Control-Allow-Methods:
37
+ - GET
38
+ X-Clacks-Overhead:
39
+ - GNU Terry Pratchett
40
+ Cf-Ray:
41
+ - 1d5865b9c6b10ae4-WAW
42
+ body:
43
+ encoding: UTF-8
44
+ string: '{"statuscode":404,"message":"No torrents found with provided hashes"}'
45
+ http_version:
46
+ recorded_at: Sat, 11 Apr 2015 17:26:35 GMT
47
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://getstrike.net/api/v2/torrents/info/?hashes=156B69B8643BD11849A5D8F2122E13FBB61BD041,
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - cloudflare-nginx
23
+ Date:
24
+ - Sat, 11 Apr 2015 16:21:04 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - __cfduid=dd403a5537bf7e5daa7170d1281c20c281428769264; expires=Sun, 10-Apr-16
33
+ 16:21:04 GMT; path=/; domain=.getstrike.net; HttpOnly
34
+ Access-Control-Allow-Origin:
35
+ - "*"
36
+ Access-Control-Allow-Methods:
37
+ - GET
38
+ X-Clacks-Overhead:
39
+ - GNU Terry Pratchett
40
+ Cf-Ray:
41
+ - 1d5805be50450afc-WAW
42
+ body:
43
+ encoding: UTF-8
44
+ string: '{"results":1,"statuscode":200,"responsetime":0.0017,"torrents":[{"torrent_hash":"156B69B8643BD11849A5D8F2122E13FBB61BD041","torrent_title":"Slackware
45
+ 14.1 x86_64 DVD ISO","torrent_category":"Applications","sub_category":"","seeds":192,"leeches":9,"file_count":4,"size":2437393940,"upload_date":"Feb
46
+ 24, 2014","uploader_username":"Nusantara","file_info":{"file_names":["slackware64-14.1-iso\\slackware64-14.1-install-dvd.iso","
47
+ slackware64-14.1-iso\\slackware64-14.1-install-dvd.iso.asc"," slackware64-14.1-iso\\slackware64-14.1-install-dvd.iso.md5","
48
+ slackware64-14.1-iso\\slackware64-14.1-install-dvd.iso.txt"],"file_lengths":[2438987776,198,67,231925]},"magnet_uri":"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"}]}'
49
+ http_version:
50
+ recorded_at: Sat, 11 Apr 2015 16:21:04 GMT
51
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://getstrike.net/api/v2/torrents/search/?phrase=Slackware%2014.1%20x86_64%20DVD%20ISO
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - cloudflare-nginx
23
+ Date:
24
+ - Sat, 11 Apr 2015 16:21:01 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - __cfduid=d5faff69c5438e616b6e7beb45d8701dd1428769260; expires=Sun, 10-Apr-16
33
+ 16:21:00 GMT; path=/; domain=.getstrike.net; HttpOnly
34
+ Access-Control-Allow-Origin:
35
+ - "*"
36
+ Access-Control-Allow-Methods:
37
+ - GET
38
+ X-Clacks-Overhead:
39
+ - GNU Terry Pratchett
40
+ Cf-Ray:
41
+ - 1d5805a899b405db-WAW
42
+ body:
43
+ encoding: UTF-8
44
+ string: '{"results":1,"statuscode":200,"responsetime":0.0969,"torrents":[{"torrent_hash":"156B69B8643BD11849A5D8F2122E13FBB61BD041","torrent_title":"Slackware
45
+ 14.1 x86_64 DVD ISO","torrent_category":"Applications","sub_category":"","seeds":192,"leeches":9,"file_count":4,"size":2437393940,"download_count":40,"upload_date":"Feb
46
+ 24, 2014","uploader_username":"Nusantara","page":"https:\/\/getstrike.net\/torrents\/156B69B8643BD11849A5D8F2122E13FBB61BD041","rss_feed":"https:\/\/getstrike.net\/torrents\/156B69B8643BD11849A5D8F2122E13FBB61BD041?rss=1","magnet_uri":"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"}]}'
47
+ http_version:
48
+ recorded_at: Sat, 11 Apr 2015 16:21:01 GMT
49
+ recorded_with: VCR 2.9.3