t411 0.0.2 → 0.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: 5463017e4e3a26a52007c92e223a8959ae1493b4
4
- data.tar.gz: bad58108d76a6e772e30ede373411e2abd18d166
3
+ metadata.gz: 1548f4ad06a7ad5b88053f3729f2cf2d7659012e
4
+ data.tar.gz: 0301a3e3a4b13d324333820c6ce565c448802808
5
5
  SHA512:
6
- metadata.gz: 039922895724c6038afb2335b02896006e2128506e6a16db65dc18d2b9250b686a913b7b5d87e50d93b8771d2250a6f2d56947c5adf06490ae3678b14cafd3cd
7
- data.tar.gz: f0048b85ac401a0a8bf77b0318e83b296518d7d03f9e6998791645884fa55eaf1fc4ad87d377c954babd254e17eefacad319123a9c6e70ed937ed48d3019fbec
6
+ metadata.gz: dd6079549621efd9625523665dddd52ededaaad43758222b6429b9d90637fe012242db867162ab453f1be771548822275173595619079b82adedf59fb8299d6b
7
+ data.tar.gz: 3eee0b343bd8628e109cf02381b21371f32371f65e404e3f2d105ce38c0e06ce4df138e46d28f5742049c6bdb40d5ef66c32be4af473f214b8cfdd805213cd92
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in t411.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Christophe Augello
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,101 @@
1
+ # T411
2
+
3
+ A Ruby wrapper for the t411.me API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 't411'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install t411
18
+
19
+ ## Usage
20
+
21
+ ### Authenticate
22
+
23
+ T411.authenticate(username,password)
24
+
25
+ ### User
26
+
27
+ ####details
28
+ Get user details based on the id
29
+
30
+ T411::Users.details(447571)
31
+ {"username":"Rainstorm","gender":"Male","age":"999","avatar":"\/images\/avatar\/71\/447571_Rainstorm.gif?99287","downloaded":"23508433352","uploaded":"3253599763263"}
32
+
33
+ ### Torrents
34
+
35
+ #### Categories
36
+ Get all categories
37
+
38
+ T411::Torrents.categories
39
+ {"210":{"id":"210","pid":"0","name":"Film\/Vid\u00e9o","cats":{"402":{"id":"402","pid":"210","name":"Vid\u00e9o-clips"},"433":{"id":"433","pid":"210","name":"S\u00e9rie TV"},"455":{"id":"455","pid":"21`
40
+
41
+ #### Terms
42
+ Get all terms
43
+
44
+ T411::Torrents.terms
45
+ {"234":{"11":{"type":"Application - Genre","mode":"single","terms":{"152":"Contr\u00f4le parental","184":"Science","1062":"Permis","163":"G\u00e9n\u00e9alogie","131":"Anonymat","174":"Nettoyage et Opti
46
+
47
+ #### Search
48
+ Search a torrent based on name, limit is optional. Default = 100
49
+
50
+ T411::Torrents.search('debian',25)
51
+ {"query":"debian","offset":0,"limit":"25","total":"13","torrents":[{"id":"4856719","name":"Debian 7.0 - \"Wheezy\" - amd64-netinst LITE","category":"234","rewritename":"debian-7-0-wheezy-amd64-netinst-
52
+
53
+ T411::Torrents.search_with_category_id('debian',234)
54
+ {"query":"debian","offset":0,"limit":"50","total":"9","torrents":[{"id":"4856719","name":"Debian 7.0 - \"Wheezy\" - amd64-netinst LITE","category":"234","rewritename":"debian-7-0-wheezy-amd64-netinst-l
55
+
56
+ #### Details
57
+ Details of a torrent
58
+
59
+ T411::Torrents.details(4856719)
60
+ {"id":"4856719","name":"Debian 7.0 - \"Wheezy\" - amd64-netinst LITE","category":"234","categoryname":"Linux","categoryimage":"t411-micro.png","rewritename":"debian-7-0-wheezy-amd64-netinst-lite","owne
61
+
62
+ #### Download
63
+ Download the torrent file. Path is optional, default = current working directory
64
+
65
+ T411::Torrents.download(4856719, "/path/to/directory")
66
+
67
+ #### Top lists
68
+
69
+ T411::Torrents.top100
70
+
71
+ T411::Torrents.today
72
+
73
+ T411::Torrents.month
74
+
75
+ ### Bookmarks
76
+
77
+ #### Save
78
+ Save a bookmark
79
+
80
+ T411::Bookmarks.save('4856719')
81
+ {"id":"11803087"}
82
+
83
+
84
+ #### List
85
+ List all bookmarks
86
+
87
+ T411::Bookmarks.list
88
+ [{"id":"4856719","name":"Debian 7.0 - \"Wheezy\" - amd64-netinst LITE","category":"234","rewritename":"debian-7-0-wheezy-amd64-netinst-lite","seeders":"11","leechers":"1","comments":"5","isVerified":"1
89
+
90
+ #### Delete
91
+ Delete 1 or more bookmarks
92
+
93
+ T411::Bookmarks.delete('4856719,4536589')
94
+
95
+ ## Contributing
96
+
97
+ 1. Fork it
98
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
99
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
100
+ 4. Push to the branch (`git push origin my-new-feature`)
101
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/t411.rb ADDED
@@ -0,0 +1,46 @@
1
+ =begin
2
+ Copyright (c) 2014 Christophe Augello
3
+
4
+ MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+
25
+ A Ruby wrapper for the t411.me API.
26
+ Supports all API methods
27
+ =end
28
+
29
+ require 't411/version'
30
+ require 't411/api'
31
+ require 't411/users'
32
+ require 't411/torrents'
33
+ require 't411/bookmarks'
34
+
35
+ module T411
36
+ include Api
37
+ include Users
38
+ include Torrents
39
+ include Bookmarks
40
+
41
+ class << self
42
+ def authenticate(username,password)
43
+ T411::Api.connect(username,password)
44
+ end
45
+ end
46
+ end
data/lib/t411/api.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'net/http'
2
+ require 'open-uri'
3
+ require 'json'
4
+
5
+ module T411
6
+ module Api
7
+ extend self
8
+ attr_accessor :token
9
+ $t411_base_url = 'http://api.t411.me'
10
+
11
+ def self.connect(username,password)
12
+ uri = URI.parse($t411_base_url + "/auth")
13
+ response = Net::HTTP.post_form(uri, {username: username, password: password})
14
+ @token = JSON.parse(response.body)['token']
15
+ end
16
+
17
+ def self.request_data(uri,token = @token)
18
+ http = Net::HTTP.new(uri.host, uri.port)
19
+ req = Net::HTTP::Get.new(uri.path)
20
+ req['Authorization'] = token
21
+ http.request(req).body
22
+ end
23
+
24
+ def self.shared_token
25
+ @token
26
+ end
27
+
28
+
29
+
30
+ end
31
+ end
32
+
@@ -0,0 +1,16 @@
1
+ module T411
2
+ module Bookmarks
3
+ extend self
4
+ def self.list
5
+ T411::Api.request_data(URI.parse($t411_base_url + '/bookmarks'))
6
+ end
7
+
8
+ def self.save(id)
9
+ T411::Api.request_data(URI.parse($t411_base_url + "/bookmarks/save/#{id}"))
10
+ end
11
+
12
+ def self.delete(id)
13
+ T411::Api.request_data(URI.parse($t411_base_url + "/bookmarks/delete/#{id}"))
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,53 @@
1
+ module T411
2
+ module Torrents
3
+ extend self
4
+ def self.categories
5
+ T411::Api.request_data(URI.parse($t411_base_url + '/categories/tree'))
6
+ end
7
+
8
+ def self.terms
9
+ T411::Api.request_data(URI.parse($t411_base_url + '/terms/tree'))
10
+ end
11
+
12
+ def self.search(query, limit = 100)
13
+ uri = URI.join($t411_base_url, '/torrents/','search/',"#{query.gsub(' ','+')}","?&limit=#{limit}")
14
+ http = Net::HTTP.new(uri.host, uri.port)
15
+ req = Net::HTTP::Get.new("/torrents/search/#{query.gsub(' ','+')}?&limit=#{limit}")
16
+ req['Authorization'] = T411::Api.shared_token
17
+ http.request(req).body
18
+ end
19
+
20
+ def self.search_with_category_id(query,cid,limit = 100)
21
+ uri = URI.join($t411_base_url, '/torrents/','search/',"#{query.gsub(' ','+')}","?&cid=#{cid}&limit=#{limit}")
22
+ http = Net::HTTP.new(uri.host, uri.port)
23
+ req = Net::HTTP::Get.new("/torrents/search/#{query.gsub(' ','+')}?&cid=#{cid}&limit=#{limit}")
24
+ req['Authorization'] = T411::Api.shared_token
25
+ http.request(req).body
26
+ end
27
+
28
+ def self.details(id)
29
+ T411::Api.request_data(URI.parse($t411_base_url + "/torrents/details/#{id}"))
30
+ end
31
+
32
+ def self.download(id,path = Dir.pwd)
33
+ File.open("#{path}/#{id}.torrent", 'a+') do |line|
34
+ line.puts T411::Api.request_data(URI.parse($t411_base_url + "/torrents/download/#{id}"))
35
+ end
36
+ end
37
+
38
+ def self.top100
39
+ T411::Api.request_data(URI.parse($t411_base_url + '/torrents/top/100'))
40
+ end
41
+
42
+ def self.today
43
+ T411::Api.request_data(URI.parse($t411_base_url + '/torrents/top/today'))
44
+ end
45
+
46
+ def self.month
47
+ T411::Api.request_data(URI.parse($t411_base_url + '/torrents/top/month'))
48
+ end
49
+
50
+ end
51
+ end
52
+
53
+
data/lib/t411/users.rb ADDED
@@ -0,0 +1,8 @@
1
+ module T411
2
+ module Users
3
+ extend self
4
+ def details(id)
5
+ T411::Api.request_data(URI.parse($t411_base_url + "/users/profile/#{id}"))
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module T411
2
+ VERSION = "0.0.3"
3
+ end
data/t411.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 't411/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "t411"
8
+ spec.version = T411::VERSION
9
+ spec.authors = ["Christophe Augello"]
10
+ spec.email = ["christophe@augello.be"]
11
+ spec.description = "Ruby wrapper for the t411.me API"
12
+ spec.summary = "Ruby wrapper for the t411.me API"
13
+ spec.homepage = "https://www.github.com/kartouch/t411"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: t411
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christophe Augello
@@ -44,7 +44,19 @@ email:
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
- files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/t411.rb
54
+ - lib/t411/api.rb
55
+ - lib/t411/bookmarks.rb
56
+ - lib/t411/torrents.rb
57
+ - lib/t411/users.rb
58
+ - lib/t411/version.rb
59
+ - t411.gemspec
48
60
  homepage: https://www.github.com/kartouch/t411
49
61
  licenses:
50
62
  - MIT