yts-ruby 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/lib/yts.rb +13 -0
- data/lib/yts/client.rb +33 -0
- data/lib/yts/document.rb +18 -0
- data/lib/yts/movie.rb +123 -0
- data/lib/yts/version.rb +3 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5982fb4c1daf7ece5296b8235a17ccd8727f0622
|
4
|
+
data.tar.gz: a86968dbe7f0162dbab7d99b48d5f7076376ce7c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5a6f4f347058c3cc5a3edb430701c0c0635b260ebaec3357c7c0a4cc41c8576025e9d4300c90e553c70b97b52a773a5844d36b4086bfa98884351d6ee293449b
|
7
|
+
data.tar.gz: a0f8a797145b32c90d9082df18caa1f3f7e0727b34d8d16ba814f62c2fef27e7b6952779bc50b584e7a7555cb7e25959ce36b7aeac51d0ae7c8d264856d82f27
|
data/lib/yts.rb
ADDED
data/lib/yts/client.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module YTS
|
2
|
+
module Client
|
3
|
+
include HTTParty
|
4
|
+
|
5
|
+
base_uri 'https://yts.ag/api/v2'
|
6
|
+
format :json
|
7
|
+
|
8
|
+
def self.convert_query_to_url(params)
|
9
|
+
params.map do |k,v|
|
10
|
+
"&#{k}=#{v}"
|
11
|
+
end.join
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.make_request(klass, endpoint, format, params = {}, method = 'get')
|
15
|
+
result = if method == 'get'
|
16
|
+
query_url = convert_query_to_url(params)
|
17
|
+
get("#{endpoint}.#{format}?#{query_url}")
|
18
|
+
else
|
19
|
+
post("#{endpoint}.#{format}", params)
|
20
|
+
end
|
21
|
+
parsed_result = JSON.parse(result.body) if format.downcase.eql?('json') || format.downcase.eql?('jsonp')
|
22
|
+
parsed_result = Nokogiri::XML(result.body) if format.downcase.eql?('xml')
|
23
|
+
parsed_result
|
24
|
+
end
|
25
|
+
|
26
|
+
class << self
|
27
|
+
def make_magnet(hash, encode_url)
|
28
|
+
magnets = ['udp://glotorrents.pw:6969/announce', 'udp://tracker.opentrackr.org:1337/announce', 'udp://torrent.gresille.org:80/announce', 'udp://tracker.openbittorrent.com:80', 'udp://tracker.coppersurfer.tk:6969', 'udp://tracker.leechers-paradise.org:6969', 'udp://p4p.arenabg.ch:1337', 'udp://tracker.internetwarriors.net:1337', 'udp://open.demonii.com:1337/announce', 'udp://p4p.arenabg.com:1337'].map{|t| "tr=#{t}"}.join('&')
|
29
|
+
"magnet:?xt=urn:btih:#{hash}&dn=#{encode_url}&#{magnets}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/yts/document.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module YTS
|
2
|
+
class Document < OpenStruct
|
3
|
+
|
4
|
+
def self.demodulize(class_name_in_module)
|
5
|
+
class_name_in_module.to_s.gsub(/^.*::/, '')
|
6
|
+
end
|
7
|
+
|
8
|
+
def fields
|
9
|
+
@table.keys.map{|k| k.to_s}
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(data = {})
|
13
|
+
raise ArgumentError, "Invalid data passed to Document.new: #{data.inspect}" unless data.is_a?(Hash)
|
14
|
+
super(data)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/yts/movie.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
module YTS
|
2
|
+
class Movie < Document
|
3
|
+
# List Movies
|
4
|
+
def self.list(format, params = {})
|
5
|
+
Client.make_request(Movie, "/list_movies", format, params)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Movie Details
|
9
|
+
def self.details(format, params = {})
|
10
|
+
Client.make_request(Movie, "/movie_details", format, params)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Movie Suggestions
|
14
|
+
def self.suggestions(format, params = {})
|
15
|
+
Client.make_request(Movie, "/movie_suggestions", format, params)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Movie Comments
|
19
|
+
def self.comments(format, params = {})
|
20
|
+
Client.make_request(Movie, "/movie_comments", format, params)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Movie Reviews
|
24
|
+
def self.reviews(format, params = {})
|
25
|
+
Client.make_request(Movie, "/movie_reviews", format, params)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Movie Parental Guides
|
29
|
+
def self.parental_guides(format, params = {})
|
30
|
+
Client.make_request(Movie, "/movie_parental_guides", format, params)
|
31
|
+
end
|
32
|
+
|
33
|
+
# List Upcoming
|
34
|
+
def self.upcoming(format, params = {})
|
35
|
+
Client.make_request(Movie, "/list_upcoming", format, params)
|
36
|
+
end
|
37
|
+
|
38
|
+
# User Details
|
39
|
+
def self.user_details(format, params = {})
|
40
|
+
Client.make_request(Movie, "/user_details", format, params)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Get User Key
|
44
|
+
def self.user_key(format, params = {}, 'post')
|
45
|
+
Client.make_request(Movie, "/user_get_key", format, params)
|
46
|
+
end
|
47
|
+
|
48
|
+
# User Profile
|
49
|
+
def self.user_profile(format, params = {})
|
50
|
+
Client.make_request(Movie, "/user_profile", format, params)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Edit User Settings
|
54
|
+
def self.user_edit_settings(format, params = {})
|
55
|
+
Client.make_request(Movie, "/user_edit_settings", format, params, 'post')
|
56
|
+
end
|
57
|
+
|
58
|
+
# Register User
|
59
|
+
def self.register_user(format, params = {})
|
60
|
+
Client.make_request(Movie, "/user_register", format, params, 'post')
|
61
|
+
end
|
62
|
+
|
63
|
+
# Forgot User Password
|
64
|
+
def self.forgot_password(format, params = {})
|
65
|
+
Client.make_request(Movie, "/user_forgot_password", format, params, 'post')
|
66
|
+
end
|
67
|
+
|
68
|
+
# Reset User Password
|
69
|
+
def self.reset_password(format, params = {})
|
70
|
+
Client.make_request(Movie, "/user_reset_password", format, params, 'post')
|
71
|
+
end
|
72
|
+
|
73
|
+
# Like Movie
|
74
|
+
def self.like_movie(format, params = {})
|
75
|
+
Client.make_request(Movie, "/like_movie", format, params, 'post')
|
76
|
+
end
|
77
|
+
|
78
|
+
# Get Movie Bookmarks
|
79
|
+
def self.get_bookmarks(format, params = {})
|
80
|
+
Client.make_request(Movie, "/get_movie_bookmarks", format, params)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Add Movie Bookmark
|
84
|
+
def self.add_bookmark(format, params = {})
|
85
|
+
Client.make_request(Movie, "/add_movie_bookmark", format, params, 'post')
|
86
|
+
end
|
87
|
+
|
88
|
+
# Delete Movie Bookmark
|
89
|
+
def self.delete_bookmark(format, params = {})
|
90
|
+
Client.make_request(Movie, "/delete_movie_bookmark", format, params, 'post')
|
91
|
+
end
|
92
|
+
|
93
|
+
# Make Comment
|
94
|
+
def self.make_comment(format, params = {})
|
95
|
+
Client.make_request(Movie, "/make_comment", format, params, 'post')
|
96
|
+
end
|
97
|
+
|
98
|
+
# Like Comment
|
99
|
+
def self.like_comment(format, params = {})
|
100
|
+
Client.make_request(Movie, "/like_comment", format, params, 'post')
|
101
|
+
end
|
102
|
+
|
103
|
+
# Report Comment
|
104
|
+
def self.report_comment(format, params = {})
|
105
|
+
Client.make_request(Movie, "/report_comment", format, params, 'post')
|
106
|
+
end
|
107
|
+
|
108
|
+
# Delete Comment
|
109
|
+
def self.delete_comment(format, params = {})
|
110
|
+
Client.make_request(Movie, "/delete_comment", format, params, 'post')
|
111
|
+
end
|
112
|
+
|
113
|
+
# Make Request
|
114
|
+
def self.make_request(format, params = {})
|
115
|
+
Client.make_request(Movie, "/make_request", format, params, 'post')
|
116
|
+
end
|
117
|
+
|
118
|
+
# Make Magnet
|
119
|
+
def self.make_magnet(hash, encode_url)
|
120
|
+
Client.make_magnet(hash, encode_url)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/lib/yts/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yts-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pravin Vaja
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
- - '='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.13.5
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- - '='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.13.5
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: nokogiri
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 1.6.8
|
40
|
+
- - '='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.6.8
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.6.8
|
50
|
+
- - '='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.6.8
|
53
|
+
description: A Ruby gem for accessing the YTS torrents api
|
54
|
+
email: vajapravin23@gmail.com
|
55
|
+
executables: []
|
56
|
+
extensions: []
|
57
|
+
extra_rdoc_files: []
|
58
|
+
files:
|
59
|
+
- lib/yts.rb
|
60
|
+
- lib/yts/client.rb
|
61
|
+
- lib/yts/document.rb
|
62
|
+
- lib/yts/movie.rb
|
63
|
+
- lib/yts/version.rb
|
64
|
+
homepage: https://github.com/vajapravin/yts-ruby
|
65
|
+
licenses:
|
66
|
+
- GNU
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- "."
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.4.8
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: A Ruby gem for accessing the YTS torrents api
|
88
|
+
test_files: []
|