PerfectlyNormal-Torrage 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/LICENSE +20 -0
- data/README.markdown +7 -0
- data/bin/torrage +15 -0
- data/lib/torrage.rb +40 -0
- data/torrage.gemspec +18 -0
- metadata +58 -0
data/CHANGELOG
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Per Christian B. Viken <perchr@northblue.org>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Torrage is a free service for caching torrent files online.
|
2
|
+
[http://torrage.com](http://torrage.com)
|
3
|
+
|
4
|
+
This is in no way officially affiliated with Torrage the site, but merely a client and
|
5
|
+
a library using the [API](http://torrage.com/automation.php) they have published.
|
6
|
+
|
7
|
+
Torrage the library is published under the MIT license, and copyrighted (c) 2009 Per Christian B. Viken <perchr@northblue.org>
|
data/bin/torrage
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'torrage'
|
3
|
+
|
4
|
+
unless ARGV[0]
|
5
|
+
$stderr.puts "Usage: #{$0} file"
|
6
|
+
exit 1
|
7
|
+
end
|
8
|
+
|
9
|
+
begin
|
10
|
+
puts "Uploading file..."
|
11
|
+
hash = Torrage.cache_torrent(File.expand_path(ARGV[0]))
|
12
|
+
puts "Success! Info hash is #{hash}"
|
13
|
+
rescue TorrageException => e
|
14
|
+
puts "Failed! Torrage says: #{e.to_s}"
|
15
|
+
end
|
data/lib/torrage.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
class Torrage
|
4
|
+
BOUNDARY = "349832898984244898448024464570528145"
|
5
|
+
|
6
|
+
# This method takes the full path to a torrent file,
|
7
|
+
# posts it to Torrage, and returns the info hash on
|
8
|
+
# success.
|
9
|
+
#
|
10
|
+
# Remember to use File.expand_path if neccessary
|
11
|
+
# before calling this method
|
12
|
+
def self.cache_torrent(file)
|
13
|
+
params = [
|
14
|
+
Torrage.file_to_multipart(file.split("/")[-1], File.read(file))
|
15
|
+
]
|
16
|
+
|
17
|
+
query = params.collect { |p| "--" + BOUNDARY + "\r\n" + p }
|
18
|
+
query = query.join("") + "--" + BOUNDARY + "--\r\n"
|
19
|
+
|
20
|
+
uri = URI.parse("http://torrage.com/autoupload.php")
|
21
|
+
http = Net::HTTP.start(uri.host, uri.port)
|
22
|
+
res = http.request_post(uri.path, query, {"Content-Type" => "multipart/form-data; boundary="+ BOUNDARY})
|
23
|
+
|
24
|
+
err = res["X-Torrage-Error-Msg"]
|
25
|
+
hash = res["X-Torrage-Infohash"]
|
26
|
+
raise TorrageException, err if err
|
27
|
+
hash
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.file_to_multipart(filename, content)
|
31
|
+
return "Content-Disposition: form-data; name=\"torrent\"; filename=\"#{filename}\"\r\n" +
|
32
|
+
"Content-Transfer-Encoding: binary\r\n" +
|
33
|
+
"Content-Type: application/x-bittorrent\r\n" +
|
34
|
+
"\r\n" +
|
35
|
+
"#{content}\r\n"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class TorrageException < RuntimeError
|
40
|
+
end
|
data/torrage.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "Torrage"
|
3
|
+
s.version = "0.1.1"
|
4
|
+
s.date = "2009-08-07"
|
5
|
+
s.author = "Per Christian B. Viken"
|
6
|
+
s.email = "perchr@northblue.org"
|
7
|
+
s.homepage = "http://eastblue.org/projects/torrage/"
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.summary = "A simple client and library for Torrage"
|
10
|
+
s.files = ["README.markdown",
|
11
|
+
"CHANGELOG",
|
12
|
+
"LICENSE",
|
13
|
+
"torrage.gemspec",
|
14
|
+
"lib/torrage.rb"
|
15
|
+
]
|
16
|
+
s.executables << 'torrage'
|
17
|
+
s.has_rdoc = true
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: PerfectlyNormal-Torrage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Per Christian B. Viken
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-07 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: perchr@northblue.org
|
18
|
+
executables:
|
19
|
+
- torrage
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- README.markdown
|
26
|
+
- CHANGELOG
|
27
|
+
- LICENSE
|
28
|
+
- torrage.gemspec
|
29
|
+
- lib/torrage.rb
|
30
|
+
has_rdoc: true
|
31
|
+
homepage: http://eastblue.org/projects/torrage/
|
32
|
+
licenses:
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: "0"
|
43
|
+
version:
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
version:
|
50
|
+
requirements: []
|
51
|
+
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.3.5
|
54
|
+
signing_key:
|
55
|
+
specification_version: 2
|
56
|
+
summary: A simple client and library for Torrage
|
57
|
+
test_files: []
|
58
|
+
|