rutracker_api 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -16
- data/.rspec +2 -1
- data/.travis.yml +7 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -5
- data/Gemfile.lock +48 -27
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/lib/rutracker_api.rb +4 -76
- data/lib/rutracker_api/client.rb +74 -0
- data/lib/rutracker_api/version.rb +5 -0
- data/rutracker_api.gemspec +31 -18
- metadata +43 -66
- data/.rvmrc +0 -62
- data/LICENSE +0 -20
- data/README.rdoc +0 -22
- data/spec/rutracker_api_spec.rb +0 -33
- data/spec/spec_helper.rb +0 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7ebbe5ce803438f187646bec9e91f1fb33b0cbdb1b22ad72660f37fc29f8ef62
|
4
|
+
data.tar.gz: d0eb9dd241f5718ff22b45acd71c9028dd8e0d21b0a5fb922ac29c4497180874
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '0518e22637d474dfebd24e77bd899666fc78ee53bf8f9fe2b02e18695be62b27854e62418556970cabcdd74e24cb0c96a302933a0f1a735322aa96cea707dcbd'
|
7
|
+
data.tar.gz: 3267bfaed168195311ad9b2c4794cdf42258eb3a3fce8b8a6d87a76d62a13fe1c804b3a504c7f9697bc07124019d00a2dd459690a86df1b7fcd6734628d715f1
|
data/.gitignore
CHANGED
@@ -1,19 +1,14 @@
|
|
1
1
|
*.gem
|
2
2
|
*.rbc
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
pkg
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
test/version_tmp
|
13
|
-
tmp
|
3
|
+
/.bundle/
|
4
|
+
/.yardoc
|
5
|
+
/_yardoc/
|
6
|
+
/coverage/
|
7
|
+
/doc/
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/tmp/
|
11
|
+
.idea
|
14
12
|
|
15
|
-
#
|
16
|
-
.
|
17
|
-
_yardoc
|
18
|
-
doc/
|
19
|
-
.env
|
13
|
+
# rspec failure tracking
|
14
|
+
.rspec_status
|
data/.rspec
CHANGED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at 570757+deril@users.noreply.github.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in rutracker_api.gemspec
|
8
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,43 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rutracker_api (0.1.0)
|
5
|
+
mechanize (>= 2.7.6)
|
6
|
+
|
1
7
|
GEM
|
2
8
|
remote: https://rubygems.org/
|
3
9
|
specs:
|
4
|
-
|
5
|
-
|
10
|
+
connection_pool (2.2.2)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
domain_name (0.5.20180417)
|
6
13
|
unf (>= 0.0.5, < 1.0.0)
|
7
|
-
http-cookie (1.0.
|
14
|
+
http-cookie (1.0.3)
|
8
15
|
domain_name (~> 0.5)
|
9
|
-
mechanize (2.7.
|
16
|
+
mechanize (2.7.6)
|
10
17
|
domain_name (~> 0.5, >= 0.5.1)
|
11
|
-
http-cookie (~> 1.0
|
12
|
-
mime-types (
|
18
|
+
http-cookie (~> 1.0)
|
19
|
+
mime-types (>= 1.17.2)
|
13
20
|
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
14
|
-
net-http-persistent (
|
15
|
-
nokogiri (~> 1.
|
21
|
+
net-http-persistent (>= 2.5.2)
|
22
|
+
nokogiri (~> 1.6)
|
16
23
|
ntlm-http (~> 0.1, >= 0.1.1)
|
17
24
|
webrobots (>= 0.0.9, < 0.2)
|
18
|
-
mime-types (
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
25
|
+
mime-types (3.2.2)
|
26
|
+
mime-types-data (~> 3.2015)
|
27
|
+
mime-types-data (3.2018.0812)
|
28
|
+
mini_portile2 (2.3.0)
|
29
|
+
net-http-digest_auth (1.4.1)
|
30
|
+
net-http-persistent (3.0.0)
|
31
|
+
connection_pool (~> 2.2)
|
32
|
+
nokogiri (1.8.5)
|
33
|
+
mini_portile2 (~> 2.3.0)
|
24
34
|
ntlm-http (0.1.1)
|
25
|
-
|
26
|
-
|
27
|
-
rspec-
|
28
|
-
rspec-
|
29
|
-
|
30
|
-
rspec-
|
31
|
-
|
32
|
-
rspec-
|
33
|
-
|
35
|
+
rake (10.5.0)
|
36
|
+
rspec (3.8.0)
|
37
|
+
rspec-core (~> 3.8.0)
|
38
|
+
rspec-expectations (~> 3.8.0)
|
39
|
+
rspec-mocks (~> 3.8.0)
|
40
|
+
rspec-core (3.8.0)
|
41
|
+
rspec-support (~> 3.8.0)
|
42
|
+
rspec-expectations (3.8.2)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.8.0)
|
45
|
+
rspec-mocks (3.8.0)
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
+
rspec-support (~> 3.8.0)
|
48
|
+
rspec-support (3.8.0)
|
49
|
+
unf (0.1.4)
|
34
50
|
unf_ext
|
35
|
-
unf_ext (0.0.
|
36
|
-
webrobots (0.1.
|
51
|
+
unf_ext (0.0.7.5)
|
52
|
+
webrobots (0.1.2)
|
37
53
|
|
38
54
|
PLATFORMS
|
39
55
|
ruby
|
40
56
|
|
41
57
|
DEPENDENCIES
|
42
|
-
|
43
|
-
|
58
|
+
bundler (~> 1.17)
|
59
|
+
rake (~> 10.0)
|
60
|
+
rspec (~> 3.0)
|
61
|
+
rutracker_api!
|
62
|
+
|
63
|
+
BUNDLED WITH
|
64
|
+
1.17.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Dmytro Bignyak
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Rutracker API - gem for easy querying rutracker
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
Rutracker API is useful gem if you need to query some seeds on Rutracker.org
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'rutracker_api'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rutracker_api
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
You have to have registration on http://rutracker.org
|
26
|
+
In code:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# create client for parsing. Put there login and password from your account
|
30
|
+
client = RutrackerApi::Client.new('my_login', 'my_pass')
|
31
|
+
|
32
|
+
#create request ro rutracker
|
33
|
+
client.search(category: 7, sort: :ask, order_by: :date, term: 'Superman')
|
34
|
+
```
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/deril/rutracker_api. 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.
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
43
|
+
|
44
|
+
## Code of Conduct
|
45
|
+
|
46
|
+
Everyone interacting in the Rutracker API project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/deril/rutracker_api/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/lib/rutracker_api.rb
CHANGED
@@ -1,78 +1,6 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
require 'mechanize'
|
1
|
+
require 'rutracker_api/version'
|
2
|
+
require 'rutracker_api/client'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
LOGIN_PAGE = 'http://login.rutracker.org/forum/login.php'
|
9
|
-
SEARCH_PAGE = 'http://rutracker.org/forum/tracker.php'
|
10
|
-
|
11
|
-
ORDER_OPTIONS = { date: 1, name: 2, downloads: 4, shows: 6, seeders: 10,
|
12
|
-
leechers: 11, size: 7, last_post: 8, speed_up: 12,
|
13
|
-
speed_down: 13, message_count: 5, last_seed: 9 }
|
14
|
-
SORT_OPTIONS = {asc: 1, desc: 2}
|
15
|
-
|
16
|
-
def initialize(username, pass)
|
17
|
-
@agent = Mechanize.new
|
18
|
-
@agent.user_agent_alias = 'Mac Safari'
|
19
|
-
login(username, pass)
|
20
|
-
end
|
21
|
-
|
22
|
-
# Advance search throw rutracker
|
23
|
-
#
|
24
|
-
# @param option [Hash] the format type, `:category`, `:term`, `:sort`, `:order_by`
|
25
|
-
# @return [Hash] the options keys with search result
|
26
|
-
def search(options = {})
|
27
|
-
query = prepare_query_string options
|
28
|
-
@agent.get query
|
29
|
-
parse_search
|
30
|
-
end
|
31
|
-
|
32
|
-
def find_user(nick)
|
33
|
-
# TODO: add parser for user pages
|
34
|
-
@agent.get 'http://rutracker.org/forum/profile.php?mode=viewprofile&u=' + nick
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
def login(username, pass)
|
39
|
-
@agent.post(LOGIN_PAGE, login_username: username,
|
40
|
-
login_password: pass, login: 'Вход')
|
41
|
-
end
|
42
|
-
|
43
|
-
def prepare_query_string(options)
|
44
|
-
prepared = { f: options[:category], nm: options[:term],
|
45
|
-
s: SORT_OPTIONS[options[:sort]], o: ORDER_OPTIONS[options[:order_by]] }
|
46
|
-
|
47
|
-
query = SEARCH_PAGE + '?'
|
48
|
-
if prepared[:nm]
|
49
|
-
query.gsub! '&', ''
|
50
|
-
query << "nm=%22#{prepared[:nm]}%22"
|
51
|
-
end
|
52
|
-
query << "&f=#{prepared[:f]}" if prepared[:f]
|
53
|
-
query << "&f=#{prepared[:o]}" if prepared[:order_by]
|
54
|
-
query << "&f=#{prepared[:s]}" if prepared[:sort]
|
55
|
-
query
|
56
|
-
end
|
57
|
-
|
58
|
-
def parse_search
|
59
|
-
@agent.page.search("//table[@class='forumline tablesorter']/tbody/tr").map do |row|
|
60
|
-
if row.css(".row1").text =~ /Не найдено/
|
61
|
-
return {error: 'Not found'}
|
62
|
-
end
|
63
|
-
description = row.at("td[4]").text.strip
|
64
|
-
torrent_id = row.at("td[4]//a").attributes['data-topic_id'].text.to_i
|
65
|
-
size = row.at("td[6]/a").text.chomp(" ↓")
|
66
|
-
seeders = row.at("td[7]").text.to_i
|
67
|
-
leechers = row.at("td[8]").text.to_i
|
68
|
-
downloads = row.at("td[9]").text.to_i
|
69
|
-
date = DateTime.strptime(row.at("td[10]/u").text, '%s')
|
70
|
-
author = row.css(".u-name/a").text
|
71
|
-
user_id = row.css(".u-name/a")[0]['href'].scan(/\d+/)[0].to_i
|
72
|
-
|
73
|
-
{ description: description, torrent_id: torrent_id, size: size,
|
74
|
-
seeders: seeders, leechers: leechers, downloads: downloads,
|
75
|
-
date: date, author: author, user_id: user_id }
|
76
|
-
end
|
77
|
-
end
|
4
|
+
module RutrackerApi
|
5
|
+
# Good job!
|
78
6
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'mechanize'
|
5
|
+
|
6
|
+
module RutrackerApi
|
7
|
+
class Client
|
8
|
+
attr_accessor :agent
|
9
|
+
|
10
|
+
LOGIN_PAGE = 'https://rutracker.org/forum/login.php'.freeze
|
11
|
+
SEARCH_PAGE = 'https://rutracker.org/forum/tracker.php'.freeze
|
12
|
+
|
13
|
+
ORDER_OPTIONS = { date: 1, name: 2, downloads: 4, shows: 6, seeders: 10,
|
14
|
+
leechers: 11, size: 7, last_post: 8, speed_up: 12,
|
15
|
+
speed_down: 13, message_count: 5, last_seed: 9 }.freeze
|
16
|
+
SORT_OPTIONS = { asc: 1, desc: 2 }.freeze
|
17
|
+
|
18
|
+
def initialize(username, pass)
|
19
|
+
@agent = Mechanize.new
|
20
|
+
@agent.user_agent_alias = 'Mac Safari'
|
21
|
+
login(username, pass)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Advance search throw rutracker
|
25
|
+
#
|
26
|
+
# @param options [Hash] the format type, `:category`, `:term`, `:sort`, `:order_by`
|
27
|
+
# @return [Hash] the options keys with search result
|
28
|
+
def search(options = {})
|
29
|
+
query = prepare_query_string options
|
30
|
+
@agent.get query
|
31
|
+
parse_search
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def login(username, pass)
|
37
|
+
@agent.post(LOGIN_PAGE, login_username: username,
|
38
|
+
login_password: pass, login: 'Вход')
|
39
|
+
end
|
40
|
+
|
41
|
+
def prepare_query_string(options)
|
42
|
+
prepared = { f: options[:category], nm: options[:term],
|
43
|
+
s: SORT_OPTIONS[options[:sort]], o: ORDER_OPTIONS[options[:order_by]] }
|
44
|
+
|
45
|
+
StringIO.new.tap do |q|
|
46
|
+
q << "#{SEARCH_PAGE}?"
|
47
|
+
q << "nm=#{prepared[:nm]}" if prepared[:nm]
|
48
|
+
q << "&f=#{prepared[:f]}" if prepared[:f]
|
49
|
+
q << "&o=#{prepared[:o]}" if prepared[:o]
|
50
|
+
q << "&s=#{prepared[:s]}" if prepared[:s]
|
51
|
+
end.string
|
52
|
+
end
|
53
|
+
|
54
|
+
def parse_search
|
55
|
+
@agent.page.search("//table[@class='forumline tablesorter']/tbody/tr").map do |row|
|
56
|
+
return { error: 'Not found' } if row.css('.row1').text =~ /Не найдено/
|
57
|
+
|
58
|
+
description = row.at('td[4]').text.strip
|
59
|
+
torrent_id = row.at('td[4]//a').attributes['data-topic_id'].text.to_i
|
60
|
+
size = row.at('td[6]/a').text.chomp(' ↓')
|
61
|
+
seeders = row.at('td[7]').text.to_i
|
62
|
+
leechers = row.at('td[8]').text.to_i
|
63
|
+
downloads = row.at('td[9]').text.to_i
|
64
|
+
date = Time.strptime(row.at('td[10]/u').text, '%s')
|
65
|
+
author = row.css('.u-name/a').text
|
66
|
+
user_id = row.css('.u-name/a')[0]['href'].scan(/\d+/)[0].to_i
|
67
|
+
|
68
|
+
{ description: description, torrent_id: torrent_id, size: size,
|
69
|
+
seeders: seeders, leechers: leechers, downloads: downloads,
|
70
|
+
date: date, author: author, user_id: user_id }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/rutracker_api.gemspec
CHANGED
@@ -1,23 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
s.summary = "API for rutracker.org"
|
5
|
-
s.description = "Provide simple api for rutracker.org"
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'rutracker_api/version'
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'rutracker_api'
|
7
|
+
spec.version = RutrackerApi::VERSION
|
8
|
+
spec.authors = ['Dmytro Bihniak']
|
9
|
+
spec.email = '570757+deril@users.noreply.github.com'
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
spec.summary = 'Search API for rutracker.org'
|
12
|
+
spec.description = 'Provide simple search api for rutracker.org'
|
13
|
+
spec.homepage = 'https://github.com/deril/rutracker_api'
|
14
|
+
spec.license = 'MIT'
|
16
15
|
|
17
|
-
|
16
|
+
if spec.respond_to?(:metadata)
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/deril/rutracker_api'
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/deril/rutracker_api/blob/master/CHANGELOG.md'
|
20
|
+
else
|
21
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
22
|
+
end
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
24
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_dependency 'mechanize', '>=2.7.6'
|
32
|
+
|
33
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
34
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
35
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
23
36
|
end
|
metadata
CHANGED
@@ -1,139 +1,116 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rutracker_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
|
-
- Dmytro
|
7
|
+
- Dmytro Bihniak
|
9
8
|
autorequire:
|
10
|
-
bindir:
|
9
|
+
bindir: exe
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: mechanize
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.7.
|
19
|
+
version: 2.7.6
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.7.
|
26
|
+
version: 2.7.6
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: bundler
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.
|
33
|
+
version: '1.17'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.
|
40
|
+
version: '1.17'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
47
|
+
version: '10.0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
54
|
+
version: '10.0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
61
|
+
version: '3.0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
|
79
|
-
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
|
-
description: Provide simple api for rutracker.org
|
95
|
-
email: bignyak@bigmir.net
|
68
|
+
version: '3.0'
|
69
|
+
description: Provide simple search api for rutracker.org
|
70
|
+
email: 570757+deril@users.noreply.github.com
|
96
71
|
executables: []
|
97
72
|
extensions: []
|
98
|
-
extra_rdoc_files:
|
99
|
-
- README.rdoc
|
73
|
+
extra_rdoc_files: []
|
100
74
|
files:
|
101
|
-
- .gitignore
|
102
|
-
- .rspec
|
103
|
-
- .
|
75
|
+
- ".gitignore"
|
76
|
+
- ".rspec"
|
77
|
+
- ".travis.yml"
|
78
|
+
- CHANGELOG.md
|
79
|
+
- CODE_OF_CONDUCT.md
|
104
80
|
- Gemfile
|
105
81
|
- Gemfile.lock
|
106
|
-
- LICENSE
|
107
|
-
- README.
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
108
85
|
- lib/rutracker_api.rb
|
86
|
+
- lib/rutracker_api/client.rb
|
87
|
+
- lib/rutracker_api/version.rb
|
109
88
|
- rutracker_api.gemspec
|
110
|
-
- spec/rutracker_api_spec.rb
|
111
|
-
- spec/spec_helper.rb
|
112
89
|
homepage: https://github.com/deril/rutracker_api
|
113
90
|
licenses:
|
114
91
|
- MIT
|
92
|
+
metadata:
|
93
|
+
homepage_uri: https://github.com/deril/rutracker_api
|
94
|
+
source_code_uri: https://github.com/deril/rutracker_api
|
95
|
+
changelog_uri: https://github.com/deril/rutracker_api/blob/master/CHANGELOG.md
|
115
96
|
post_install_message:
|
116
97
|
rdoc_options: []
|
117
98
|
require_paths:
|
118
99
|
- lib
|
119
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
-
none: false
|
121
101
|
requirements:
|
122
|
-
- -
|
102
|
+
- - ">="
|
123
103
|
- !ruby/object:Gem::Version
|
124
104
|
version: '0'
|
125
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
-
none: false
|
127
106
|
requirements:
|
128
|
-
- -
|
107
|
+
- - ">="
|
129
108
|
- !ruby/object:Gem::Version
|
130
109
|
version: '0'
|
131
110
|
requirements: []
|
132
111
|
rubyforge_project:
|
133
|
-
rubygems_version:
|
112
|
+
rubygems_version: 2.7.6
|
134
113
|
signing_key:
|
135
|
-
specification_version:
|
136
|
-
summary: API for rutracker.org
|
137
|
-
test_files:
|
138
|
-
- spec/rutracker_api_spec.rb
|
139
|
-
- spec/spec_helper.rb
|
114
|
+
specification_version: 4
|
115
|
+
summary: Search API for rutracker.org
|
116
|
+
test_files: []
|
data/.rvmrc
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
-
# development environment upon cd'ing into the directory
|
5
|
-
|
6
|
-
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
-
# Only full ruby name is supported here, for short names use:
|
8
|
-
# echo "rvm use 2.0.0" > .rvmrc
|
9
|
-
environment_id="ruby-2.0.0-p247@rutracker_api"
|
10
|
-
|
11
|
-
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
-
# rvmrc_rvm_version="1.23.13 (stable)" # 1.10.1 seems like a safe start
|
13
|
-
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | __rvm_awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
-
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
-
# return 1
|
16
|
-
# }
|
17
|
-
|
18
|
-
# First we attempt to load the desired environment directly from the environment
|
19
|
-
# file. This is very fast and efficient compared to running through the entire
|
20
|
-
# CLI and selector. If you want feedback on which environment was used then
|
21
|
-
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
-
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
-
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
-
then
|
25
|
-
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
-
for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*
|
27
|
-
do
|
28
|
-
if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]
|
29
|
-
then \. "${__hook}" || true
|
30
|
-
fi
|
31
|
-
done
|
32
|
-
unset __hook
|
33
|
-
if (( ${rvm_use_flag:=1} >= 1 )) # display automatically
|
34
|
-
then
|
35
|
-
if [[ $- == *i* ]] # check for interactive shells
|
36
|
-
then printf "%b" "Using: $(tput setaf 2 2>/dev/null)$GEM_HOME$(tput sgr0 2>/dev/null)
|
37
|
-
" # show the user the ruby and gemset they are using in green
|
38
|
-
else printf "%b" "Using: $GEM_HOME
|
39
|
-
" # don't use colors in non-interactive shells
|
40
|
-
fi
|
41
|
-
fi
|
42
|
-
else
|
43
|
-
# If the environment file has not yet been created, use the RVM CLI to select.
|
44
|
-
rvm --create use "$environment_id" || {
|
45
|
-
echo "Failed to create RVM environment '${environment_id}'."
|
46
|
-
return 1
|
47
|
-
}
|
48
|
-
fi
|
49
|
-
|
50
|
-
# If you use bundler, this might be useful to you:
|
51
|
-
# if [[ -s Gemfile ]] && {
|
52
|
-
# ! builtin command -v bundle >/dev/null ||
|
53
|
-
# builtin command -v bundle | GREP_OPTIONS="" \grep $rvm_path/bin/bundle >/dev/null
|
54
|
-
# }
|
55
|
-
# then
|
56
|
-
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
57
|
-
# gem install bundler
|
58
|
-
# fi
|
59
|
-
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
60
|
-
# then
|
61
|
-
# bundle install | GREP_OPTIONS="" \grep -vE '^Using|Your bundle is complete'
|
62
|
-
# fi
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2013 Dmytro
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
-
this software and associated documentation files (the "Software"), to deal in
|
7
|
-
the Software without restriction, including without limitation the rights to
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
-
subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
= \Rutracker Api - gem for easy parsing rutracker
|
2
|
-
|
3
|
-
== Description
|
4
|
-
|
5
|
-
Rutracker Api is usefull gem if you need to parse some seeds on Rutracker.org
|
6
|
-
|
7
|
-
== Usage
|
8
|
-
|
9
|
-
$ gem install rutracker_api
|
10
|
-
or if you want to use with bundler
|
11
|
-
|
12
|
-
in Gemfile
|
13
|
-
gem 'rutracker_api'
|
14
|
-
than
|
15
|
-
$ bundle install
|
16
|
-
|
17
|
-
You have to have registration on http://rutracker.org
|
18
|
-
In code:
|
19
|
-
# create client for parsing. Put there login and password from your account
|
20
|
-
client = RutrackerApi.new('my_login', 'my_pass')
|
21
|
-
#create request ro rutracker
|
22
|
-
result = client.search(category: 7, sort: 'ack', order_by: 'date', term: 'Superman')
|
data/spec/rutracker_api_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'rutracker_api'
|
2
|
-
describe "Rutracker Api" do
|
3
|
-
before { @tracker = RutrackerApi.new('login', 'pass') }
|
4
|
-
subject { @tracker }
|
5
|
-
|
6
|
-
describe "#search" do
|
7
|
-
describe "with invalid params" do
|
8
|
-
xit "raise exeption with wrong search term" do
|
9
|
-
expect{@tracker.search(term: "&8")}.to raise_error("Wrong search term")
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "with valid params" do
|
14
|
-
|
15
|
-
xit "returns link with term" do
|
16
|
-
expect( @tracker.search(term: "Super Man") ).to eq('http://rutracker.org/forum/tracker.php?nm=Super Man')
|
17
|
-
end
|
18
|
-
xit "returns link with category" do
|
19
|
-
expect( @tracker.search(term: "Super Man", category: '2,5') )
|
20
|
-
.to eq('http://rutracker.org/forum/tracker.php?nm=Super Man&f[]=2&f[]=5')
|
21
|
-
end
|
22
|
-
xit "returns link with order_by key" do
|
23
|
-
expect( @tracker.search(term: "Super Man", order_by: 'name') )
|
24
|
-
.to eq('http://rutracker.org/forum/tracker.php?nm=Super Man&o=2')
|
25
|
-
end
|
26
|
-
xit "returns link with sort_by key" do
|
27
|
-
expect( @tracker.search(term: "Super Man", sort_by: 'asc') )
|
28
|
-
.to eq('http://rutracker.org/forum/tracker.php?nm=Super Man&s=1')
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
-
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
-
# loaded once.
|
5
|
-
#
|
6
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
-
RSpec.configure do |config|
|
8
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
-
config.run_all_when_everything_filtered = true
|
10
|
-
config.filter_run :focus
|
11
|
-
|
12
|
-
# Run specs in random order to surface order dependencies. If you find an
|
13
|
-
# order dependency and want to debug it, you can fix the order by providing
|
14
|
-
# the seed, which is printed after each run.
|
15
|
-
# --seed 1234
|
16
|
-
config.order = 'random'
|
17
|
-
end
|