saber 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -2
- data/Gemfile.lock +2 -3
- data/README.md +47 -19
- data/bin/saber +2 -3
- data/doc/Development.md +3 -0
- data/lib/saber.rb +7 -4
- data/lib/saber/cli.rb +15 -2
- data/lib/saber/client.rb +11 -4
- data/lib/saber/downloader.rb +2 -0
- data/lib/saber/server.rb +4 -3
- data/lib/saber/version.rb +1 -1
- data/rutorrent/README.md +34 -0
- data/rutorrent/init.js +28 -0
- data/rutorrent/init.php +5 -0
- data/rutorrent/plugin.info +4 -0
- data/saber.gemspec +1 -2
- data/spec/spec_helper.rb +2 -2
- metadata +20 -26
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
net-ssh (2.3.0)
|
11
11
|
optimism (3.1.2)
|
12
12
|
hike (~> 1.2.0)
|
13
|
-
pa (1.2.
|
13
|
+
pa (1.2.3)
|
14
14
|
rag (1.2.1)
|
15
15
|
optimism (~> 3.1.0)
|
16
16
|
pa (~> 1.2.0)
|
@@ -38,11 +38,10 @@ PLATFORMS
|
|
38
38
|
DEPENDENCIES
|
39
39
|
net-ssh (~> 2.3.0)
|
40
40
|
optimism (~> 3.1.2)
|
41
|
-
pa (~> 1.2.
|
41
|
+
pa (~> 1.2.3)
|
42
42
|
rag
|
43
43
|
retort (~> 0.0.6)
|
44
44
|
rspec
|
45
|
-
tagen (~> 1.1.5)
|
46
45
|
thor (~> 0.14.6)
|
47
46
|
watchr
|
48
47
|
xmpp4r (~> 0.5)
|
data/README.md
CHANGED
@@ -3,13 +3,10 @@ Saber, a complete solution for PT users.
|
|
3
3
|
|
4
4
|
| Homepage: | https://github.com/GutenYe/saber |
|
5
5
|
|----------------|-----------------------------------------|
|
6
|
-
| Author: | Guten
|
6
|
+
| Author: | Guten |
|
7
7
|
| License: | MIT-LICENSE |
|
8
|
-
| Documentation: | http://rubydoc.info/gems/saber/frames |
|
9
8
|
| Issue Tracker: | https://github.com/GutenYe/saber/issues |
|
10
9
|
|
11
|
-
the saber.
|
12
|
-
|
13
10
|
### Is It Good?
|
14
11
|
|
15
12
|
Yes.
|
@@ -18,30 +15,60 @@ Yes.
|
|
18
15
|
|
19
16
|
No.
|
20
17
|
|
18
|
+
What saber can do for you?
|
19
|
+
|
20
|
+
* addtorrent: send torrent file to rutorrent in a PT website directly.
|
21
|
+
* download:
|
22
|
+
1. manually download a file to home laptop in rutorrent web ui.
|
23
|
+
2. automatically downlad files to home laptop when files are completed in seedbox.
|
24
|
+
* task:
|
25
|
+
1. cleanup files not in rtorrent.
|
26
|
+
|
21
27
|
Usage
|
22
28
|
-----
|
23
29
|
|
24
|
-
|
30
|
+
### addtorrent
|
25
31
|
|
26
|
-
|
27
|
-
$ ~/etc/rc.d/aria2 start
|
28
|
-
$ saber download "Prison Break"
|
29
|
-
# aria2 will begin download.
|
32
|
+
see https://github.com/Gutenye/saber-addtorrent
|
30
33
|
|
31
|
-
Task: clean up undownload files, all files remains in disk, but don't in rtorrent client.
|
32
34
|
|
33
|
-
|
35
|
+
### download
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
+
# server side
|
38
|
+
# start rtorrent
|
39
|
+
$ /etc/rc.d/saber-server start # start saber server daemon.
|
37
40
|
|
38
|
-
|
41
|
+
# client side
|
42
|
+
$ ~/etc/rc.d/aria2 start # start aria2 daemon.
|
43
|
+
$ ~/etc/rc.d/saber-client start # start saber client daemon.
|
44
|
+
|
45
|
+
# manually download
|
46
|
+
right click 'Saber Download' in rutorrent web ui, then it adds to aria2.
|
39
47
|
|
40
|
-
|
48
|
+
# automatically download
|
49
|
+
when a file is finished download in rutorrent with label 'saber', then it adds to aria2.
|
41
50
|
|
42
|
-
|
51
|
+
|
52
|
+
### task
|
53
|
+
|
54
|
+
clean up undownload files, all files remains in disk, but don't in rtorrent client.
|
55
|
+
|
56
|
+
# server side
|
57
|
+
$ saber clean
|
58
|
+
|
59
|
+
Install
|
60
|
+
--------
|
43
61
|
|
44
|
-
|
62
|
+
# server side
|
63
|
+
$ gem install saber
|
64
|
+
$ pacaur -S rutorrent-saber-git
|
65
|
+
$ pacaur -S saber-server-daemon-git
|
66
|
+
|
67
|
+
# client side
|
68
|
+
$ gem install saber
|
69
|
+
$ pacaur -S user-aria2-daemon-git # an aria2 daemon
|
70
|
+
$ pacaur -S thebear-git # optional. a web front end to aria2.
|
71
|
+
$ pacaur -S user-saber-client-daemon-git
|
45
72
|
|
46
73
|
Contributing
|
47
74
|
-------------
|
@@ -58,14 +85,15 @@ Credits
|
|
58
85
|
Resources
|
59
86
|
---------
|
60
87
|
|
61
|
-
|
88
|
+
* [pacaur](https://github.com/Spyhawk/pacaur): An AUR installer for ArchLinux.
|
89
|
+
* [TheBear](http://sourceforge.net/projects/thebear/): a web front end to aria2.
|
62
90
|
|
63
91
|
Copyright
|
64
92
|
---------
|
65
93
|
|
66
94
|
(the MIT License)
|
67
95
|
|
68
|
-
Copyright (c) 2011 Guten
|
96
|
+
Copyright (c) 2011 Guten
|
69
97
|
|
70
98
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
71
99
|
|
data/bin/saber
CHANGED
data/doc/Development.md
ADDED
data/lib/saber.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
libdir = File.dirname(__FILE__)
|
2
|
-
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
|
3
|
-
|
4
1
|
ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
|
5
2
|
require "bundler/setup"
|
6
|
-
Bundler.require
|
3
|
+
#Bundler.require
|
4
|
+
require "pa"
|
5
|
+
require "optimism"
|
6
|
+
require "retort"
|
7
|
+
|
8
|
+
libdir = File.dirname(__FILE__)
|
9
|
+
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
|
7
10
|
|
8
11
|
Retort::Service.configure do |c|
|
9
12
|
c.url = "http://localhost/RPC2"
|
data/lib/saber/cli.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require "
|
1
|
+
require "thor"
|
2
|
+
require "drb"
|
2
3
|
|
3
4
|
module Saber
|
4
5
|
class CLI < Thor
|
@@ -6,12 +7,16 @@ module Saber
|
|
6
7
|
|
7
8
|
class_option "no-color", :type => :boolean, :banner => "Disable colorization in output"
|
8
9
|
class_option "verbose", :aliases => "-V", :type => :boolean, :banner => "Enable verbose output mode"
|
10
|
+
class_option "log", :banner => "log file", :type => :string
|
11
|
+
|
12
|
+
attr_reader :o
|
9
13
|
|
10
14
|
def initialize(*)
|
11
15
|
super
|
16
|
+
o = @o = options.dup
|
12
17
|
the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
|
13
18
|
Saber.ui = UI::Shell.new(the_shell)
|
14
|
-
Saber.ui.debug! if
|
19
|
+
Saber.ui.debug! if o["verbose"]
|
15
20
|
end
|
16
21
|
|
17
22
|
desc "clean", "clean up files doesn't in rtorrent client"
|
@@ -26,11 +31,19 @@ module Saber
|
|
26
31
|
|
27
32
|
desc "server", "start saber-server daemon"
|
28
33
|
def server
|
34
|
+
require "logger"
|
35
|
+
o["log"] ||= "/var/log/saber-server.log"
|
36
|
+
|
37
|
+
$log = Logger.new options["verbose"] ? STDOUT : o["log"]
|
29
38
|
Server.start
|
30
39
|
end
|
31
40
|
|
32
41
|
desc "client", "start saber-client daemon"
|
33
42
|
def client
|
43
|
+
require "logger"
|
44
|
+
o["log"] ||= "/var/log/saber-client.log"
|
45
|
+
|
46
|
+
$log = Logger.new options["verbose"] ? STDOUT : o["log"]
|
34
47
|
Client.start
|
35
48
|
end
|
36
49
|
|
data/lib/saber/client.rb
CHANGED
@@ -5,7 +5,9 @@ module Saber
|
|
5
5
|
class Client
|
6
6
|
class << self
|
7
7
|
def start
|
8
|
-
Client.new
|
8
|
+
client = Client.new
|
9
|
+
client.start
|
10
|
+
|
9
11
|
sleep
|
10
12
|
end
|
11
13
|
end
|
@@ -25,14 +27,18 @@ module Saber
|
|
25
27
|
pd msg.from.bare
|
26
28
|
if msg.from.bare == Rc.server.xmpp.jid
|
27
29
|
files = msg.body.split("\n")
|
28
|
-
|
29
|
-
|
30
|
+
$log.debug "::recv::\n #{files.join("\n")}\n\n"
|
31
|
+
downloader.add *files
|
30
32
|
end
|
31
33
|
}
|
32
34
|
|
33
35
|
client.send Jabber::Presence.new
|
34
36
|
Saber.ui.say ">> Connected to xmpp with #{Rc.client.xmpp.jid}"
|
35
37
|
end
|
38
|
+
|
39
|
+
def stop
|
40
|
+
@client.close!
|
41
|
+
end
|
36
42
|
end
|
37
43
|
|
38
44
|
class DRbClient
|
@@ -41,10 +47,11 @@ module Saber
|
|
41
47
|
def initialize
|
42
48
|
DRb.start_service
|
43
49
|
@server = DRbObject.new_with_uri(Rc.drb_uri)
|
44
|
-
Saber.ui.
|
50
|
+
Saber.ui.say ">> DRbClient connected to #{Rc.drb_uri}"
|
45
51
|
end
|
46
52
|
|
47
53
|
def add(*names)
|
54
|
+
Saber.ui.say "::add::\n#{names.join("\n")}"
|
48
55
|
server.add(*names)
|
49
56
|
end
|
50
57
|
end
|
data/lib/saber/downloader.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "xmlrpc/client"
|
2
|
+
require "net/ssh"
|
2
3
|
|
3
4
|
module Saber
|
4
5
|
class Downloader
|
@@ -13,6 +14,7 @@ module Saber
|
|
13
14
|
def add(*files)
|
14
15
|
files.each { |file|
|
15
16
|
uri = "#{Rc.server.ftp}/#{file}"
|
17
|
+
$log.debug "::add_url:: #{uri}"
|
16
18
|
gid = aria2_add([uri], :dir => Pa.dir2("#{Rc.p.download}/#{file}"))
|
17
19
|
Saber.ui.say "DOWNLOAD #{gid}:: #{uri}"
|
18
20
|
}
|
data/lib/saber/server.rb
CHANGED
@@ -8,8 +8,9 @@ module Saber
|
|
8
8
|
Retort::Service.call("system.method.set_key", "event.download.closed", "saber-download", "execute= /usr/bin/saber-drb_add, $d.get_hash=, $d.get_custom1=")
|
9
9
|
|
10
10
|
s = Server.new
|
11
|
-
s.start
|
12
11
|
DRbServer.start(s)
|
12
|
+
s.start
|
13
|
+
|
13
14
|
DRb.thread.join
|
14
15
|
end
|
15
16
|
|
@@ -27,7 +28,7 @@ module Saber
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def send(files)
|
30
|
-
|
31
|
+
$log.debug %~::send::\n #{files.join("\n")}\n\n~
|
31
32
|
client.send Jabber::Message.new(Rc.client.xmpp.jid, files.join("\n"))
|
32
33
|
end
|
33
34
|
end
|
@@ -53,7 +54,7 @@ module Saber
|
|
53
54
|
|
54
55
|
# drb. add a complete torrent.
|
55
56
|
def add(*names)
|
56
|
-
|
57
|
+
$log.debug "::DRbServer add:: #{names.inspect}"
|
57
58
|
files = build_files(*names)
|
58
59
|
|
59
60
|
saber_server.send(files)
|
data/lib/saber/version.rb
CHANGED
data/rutorrent/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
rutorrent-saber-download, a rutorrent plugin to auto download files into home laptop.
|
2
|
+
==========================================================================
|
3
|
+
|
4
|
+
| Homepage: | https://github.com/GutenYe/rutorrent-saber-download |
|
5
|
+
|----------------|------------------------------------------------------ |
|
6
|
+
| Author: | Guten |
|
7
|
+
| License: | MIT-LICENSE |
|
8
|
+
| Issue Tracker: | https://github.com/GutenYe/saber-download/issues |
|
9
|
+
|
10
|
+
This is a part of the [Saber](https://github.com/GutenYe/saber) project.
|
11
|
+
|
12
|
+
Install
|
13
|
+
-------
|
14
|
+
|
15
|
+
gem install saber-download
|
16
|
+
|
17
|
+
|
18
|
+
Resources
|
19
|
+
---------
|
20
|
+
|
21
|
+
some related resources to help each other.
|
22
|
+
|
23
|
+
Copyright
|
24
|
+
---------
|
25
|
+
|
26
|
+
(the MIT License)
|
27
|
+
|
28
|
+
Copyright (c) 2011 Guten
|
29
|
+
|
30
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
31
|
+
|
32
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
33
|
+
|
34
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/rutorrent/init.js
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
pd = console.log;
|
2
|
+
|
3
|
+
if(plugin.canChangeMenu())
|
4
|
+
{
|
5
|
+
theWebUI.saberDownload = function(id){
|
6
|
+
theWebUI.perform("saberDownload");
|
7
|
+
}
|
8
|
+
|
9
|
+
plugin.createMenu = theWebUI.createMenu;
|
10
|
+
theWebUI.createMenu = function( e, id )
|
11
|
+
{
|
12
|
+
plugin.createMenu.call(this, e, id);
|
13
|
+
if(plugin.enabled)
|
14
|
+
{
|
15
|
+
var el = theContextMenu.get("Update trackers")
|
16
|
+
if( el )
|
17
|
+
theContextMenu.add( el, ["Saber Download", "theWebUI.saberDownload('"+id+"')"]);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
rTorrentStub.prototype.saberDownload = function()
|
23
|
+
{
|
24
|
+
var cmd = new rXMLRPCCommand("execute");
|
25
|
+
cmd.addParameter("string", "/usr/bin/saber-drb_add");
|
26
|
+
cmd.addParameter("string", this.hashes.join(","));
|
27
|
+
this.commands.push(cmd);
|
28
|
+
}
|
data/rutorrent/init.php
ADDED
data/saber.gemspec
CHANGED
@@ -18,9 +18,8 @@ the saber
|
|
18
18
|
s.executables = ["saber"]
|
19
19
|
s.extensions << "extconf.rb"
|
20
20
|
|
21
|
-
s.add_dependency "tagen", "~>1.1.5"
|
22
21
|
s.add_dependency "optimism", "~>3.1.2"
|
23
|
-
s.add_dependency "pa", "~>1.2.
|
22
|
+
s.add_dependency "pa", "~>1.2.3"
|
24
23
|
s.add_dependency "retort","~>0.0.6"
|
25
24
|
s.add_dependency "thor", "~>0.14.6"
|
26
25
|
s.add_dependency "net-ssh", "~>2.3.0"
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "saber"
|
2
|
+
require "logger"
|
2
3
|
|
3
4
|
$spec_dir = File.expand_path("..", __FILE__)
|
4
5
|
$spec_data = File.expand_path("../data", __FILE__)
|
@@ -17,6 +18,7 @@ port = 8914
|
|
17
18
|
token = "token"
|
18
19
|
drb_uri = "druby://localhost:8915"
|
19
20
|
EOF
|
21
|
+
$log = Logger.new(StringIO.new)
|
20
22
|
|
21
23
|
RSpec.configure do |config|
|
22
24
|
def capture(stream)
|
@@ -56,5 +58,3 @@ private
|
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
59
|
-
|
60
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: tagen
|
16
|
-
requirement: &17018160 !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 1.1.5
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: *17018160
|
25
14
|
- !ruby/object:Gem::Dependency
|
26
15
|
name: optimism
|
27
|
-
requirement: &
|
16
|
+
requirement: &14540700 !ruby/object:Gem::Requirement
|
28
17
|
none: false
|
29
18
|
requirements:
|
30
19
|
- - ~>
|
@@ -32,21 +21,21 @@ dependencies:
|
|
32
21
|
version: 3.1.2
|
33
22
|
type: :runtime
|
34
23
|
prerelease: false
|
35
|
-
version_requirements: *
|
24
|
+
version_requirements: *14540700
|
36
25
|
- !ruby/object:Gem::Dependency
|
37
26
|
name: pa
|
38
|
-
requirement: &
|
27
|
+
requirement: &14540200 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
29
|
requirements:
|
41
30
|
- - ~>
|
42
31
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.2.
|
32
|
+
version: 1.2.3
|
44
33
|
type: :runtime
|
45
34
|
prerelease: false
|
46
|
-
version_requirements: *
|
35
|
+
version_requirements: *14540200
|
47
36
|
- !ruby/object:Gem::Dependency
|
48
37
|
name: retort
|
49
|
-
requirement: &
|
38
|
+
requirement: &14539720 !ruby/object:Gem::Requirement
|
50
39
|
none: false
|
51
40
|
requirements:
|
52
41
|
- - ~>
|
@@ -54,10 +43,10 @@ dependencies:
|
|
54
43
|
version: 0.0.6
|
55
44
|
type: :runtime
|
56
45
|
prerelease: false
|
57
|
-
version_requirements: *
|
46
|
+
version_requirements: *14539720
|
58
47
|
- !ruby/object:Gem::Dependency
|
59
48
|
name: thor
|
60
|
-
requirement: &
|
49
|
+
requirement: &14539240 !ruby/object:Gem::Requirement
|
61
50
|
none: false
|
62
51
|
requirements:
|
63
52
|
- - ~>
|
@@ -65,10 +54,10 @@ dependencies:
|
|
65
54
|
version: 0.14.6
|
66
55
|
type: :runtime
|
67
56
|
prerelease: false
|
68
|
-
version_requirements: *
|
57
|
+
version_requirements: *14539240
|
69
58
|
- !ruby/object:Gem::Dependency
|
70
59
|
name: net-ssh
|
71
|
-
requirement: &
|
60
|
+
requirement: &14538780 !ruby/object:Gem::Requirement
|
72
61
|
none: false
|
73
62
|
requirements:
|
74
63
|
- - ~>
|
@@ -76,10 +65,10 @@ dependencies:
|
|
76
65
|
version: 2.3.0
|
77
66
|
type: :runtime
|
78
67
|
prerelease: false
|
79
|
-
version_requirements: *
|
68
|
+
version_requirements: *14538780
|
80
69
|
- !ruby/object:Gem::Dependency
|
81
70
|
name: xmpp4r
|
82
|
-
requirement: &
|
71
|
+
requirement: &14538320 !ruby/object:Gem::Requirement
|
83
72
|
none: false
|
84
73
|
requirements:
|
85
74
|
- - ~>
|
@@ -87,7 +76,7 @@ dependencies:
|
|
87
76
|
version: '0.5'
|
88
77
|
type: :runtime
|
89
78
|
prerelease: false
|
90
|
-
version_requirements: *
|
79
|
+
version_requirements: *14538320
|
91
80
|
description: ! 'the saber
|
92
81
|
|
93
82
|
'
|
@@ -106,6 +95,7 @@ files:
|
|
106
95
|
- Ragfile
|
107
96
|
- bin/saber
|
108
97
|
- bin/saber-drb_add
|
98
|
+
- doc/Development.md
|
109
99
|
- extconf.rb
|
110
100
|
- lib/saber.rb
|
111
101
|
- lib/saber/cli.rb
|
@@ -116,6 +106,10 @@ files:
|
|
116
106
|
- lib/saber/task.rb
|
117
107
|
- lib/saber/ui.rb
|
118
108
|
- lib/saber/version.rb
|
109
|
+
- rutorrent/README.md
|
110
|
+
- rutorrent/init.js
|
111
|
+
- rutorrent/init.php
|
112
|
+
- rutorrent/plugin.info
|
119
113
|
- saber.gemspec
|
120
114
|
- saber.watchr
|
121
115
|
- spec/data/bt/lost.mkv
|