saber 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +17 -0
- data/README.md +67 -75
- data/bin/saber +2 -5
- data/lib/saber/autofetcher/client.rb +1 -1
- data/lib/saber/autofetcher/server.rb +3 -0
- data/lib/saber/cli.rb +7 -0
- data/lib/saber/task/chd.rb +27 -0
- data/lib/saber/tracker/base.rb +2 -0
- data/lib/saber/tracker/chd.rb +88 -0
- data/lib/saber/version.rb +1 -1
- data/rutorrent/init.js +0 -0
- data/rutorrent/init.php +0 -0
- data/rutorrent/plugin.info +2 -2
- data/saber.gemspec +3 -3
- metadata +8 -6
- data/rutorrent/README.md +0 -34
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
We love pull requests. Here's a quick guide:
|
2
|
+
|
3
|
+
1. Fork the repo.
|
4
|
+
|
5
|
+
2. Create a topic branch from where you want to base your work.
|
6
|
+
|
7
|
+
3. Add a test for your change. Only refactoring and documentation changes
|
8
|
+
require no new tests. If you are adding functionality or fixing a bug, we need
|
9
|
+
a test!
|
10
|
+
|
11
|
+
4. Make the test pass with `rake test`.
|
12
|
+
|
13
|
+
5. Push to your fork and submit a pull request.
|
14
|
+
|
15
|
+
6. Coding Style Guide: https://gist.github.com/1105334
|
16
|
+
|
17
|
+
And in case we didn't emphasize it enough: we love tests!
|
data/README.md
CHANGED
@@ -1,78 +1,35 @@
|
|
1
|
-
Saber, a complete solution for PT users. [![Build Status](https://secure.travis-ci.org/
|
1
|
+
Saber, a complete solution for PT users. [![Build Status](https://secure.travis-ci.org/SaberSalv/saber.png)](http://travis-ci.org/SaberSalv/saber)
|
2
2
|
==========================================
|
3
3
|
|
4
4
|
| | |
|
5
5
|
|----------------|-----------------------------------------|
|
6
|
-
| Homepage: | https://github.com/
|
7
|
-
| Author: |
|
6
|
+
| Homepage: | https://github.com/SaberSalv/saber |
|
7
|
+
| Author: | Saber |
|
8
8
|
| License: | MIT-LICENSE |
|
9
|
-
| Documentation: | https://github.com/
|
10
|
-
| Issue Tracker: | https://github.com/
|
9
|
+
| Documentation: | https://github.com/SaberSalv/saber/wiki |
|
10
|
+
| Issue Tracker: | https://github.com/SaberSalv/saber/issues |
|
11
11
|
|
12
12
|
**Features:**
|
13
13
|
|
14
14
|
* Add Torrent: send a torrent file from website to rutorrent.
|
15
|
-
* Upload: upload a torrent file from command line to the site.
|
16
15
|
* Fetch: automatically/manually fetch files from seedbox to home-laptop.
|
16
|
+
* Upload: upload a torrent file from command line to the site.
|
17
17
|
* Other Tasks:
|
18
18
|
- Make: make a torrent file and copy it to local and remote watch directory.
|
19
19
|
- Send: send files from home-laptop to seedbox.
|
20
20
|
- Clean: remove files which are not seeded in rtorrent.
|
21
21
|
|
22
|
-
you can find more tools at [here](https://github.com/
|
22
|
+
you can find more tools at [here](https://github.com/SaberSalv/saber/wiki/Tools).
|
23
23
|
|
24
24
|
Getting Started
|
25
25
|
----------------
|
26
26
|
|
27
|
-
Create ~/.saberrc configuration file from [template](https://github.com/
|
27
|
+
Create ~/.saberrc configuration file from [template](https://github.com/SaberSalv/saber/blob/master/templates/_saberrc). More detail will be explained below.
|
28
28
|
|
29
29
|
### Add Torrent
|
30
30
|
|
31
|
-
See [saber-addtorrent](https://github.com/
|
32
|
-
|
33
|
-
### Upload
|
34
|
-
|
35
|
-
Because of lacking APIs in major PT sites, so I write this small script to help uploading a torrent from cmdline. Good news is BTN v2.0 will include API. And BTN already has an official autobot which grabs scene releases. :)
|
36
|
-
|
37
|
-
> Support sites: BIB
|
38
|
-
|
39
|
-
Configure ~/.saberrc
|
40
|
-
|
41
|
-
p:
|
42
|
-
watch = Pa("~/bt/watch")
|
43
|
-
remote_watch = Pa("bt/watch")
|
44
|
-
|
45
|
-
username = "foo"
|
46
|
-
bib:
|
47
|
-
username = "bar"
|
48
|
-
announce_url = "x"
|
49
|
-
|
50
|
-
server:
|
51
|
-
user = "x"
|
52
|
-
host = "y"
|
53
|
-
|
54
|
-
Fill \<info-data>.yml file and upload it.
|
55
|
-
|
56
|
-
$ saber.bib g magazine hello.pdf
|
57
|
-
> create hello.pdf.yml
|
58
|
-
$ vim hello.pdf.yml
|
59
|
-
|
60
|
-
type: magazines
|
61
|
-
Title: Hello
|
62
|
-
Description: Hello World
|
63
|
-
...
|
64
|
-
|
65
|
-
$ saber.bib upload hello.pdf.torrent
|
66
|
-
> Upload Complete
|
67
|
-
|
68
|
-
$ saber.bib upload hello.pdf # short cut
|
69
|
-
> make hello.pdf.torrent
|
70
|
-
> Upload Complete
|
31
|
+
See [saber-addtorrent](https://github.com/SaberSalv/saber-addtorrent) project.
|
71
32
|
|
72
|
-
Auto fill \<info-data>.yml file from isbn.
|
73
|
-
|
74
|
-
$ saber.bib g ebook hello.epub 1781100055
|
75
|
-
> create hello.epub.yml
|
76
33
|
|
77
34
|
### Fetch
|
78
35
|
|
@@ -115,7 +72,7 @@ Start saber-client at client side.
|
|
115
72
|
|
116
73
|
Test if it works
|
117
74
|
|
118
|
-
(server) $ saber drb_add <rtorrent_file_hash_id> saber
|
75
|
+
(server) $ saber drb_add <rtorrent_file_hash_id> saber -V
|
119
76
|
(client) > aria2 should begin download file from ftp://seedbox/bt/<file>
|
120
77
|
|
121
78
|
Automatically fetch: when a file is finished download in rutorrent with label 'saber', then it'll add to aria2.
|
@@ -142,8 +99,52 @@ Configure ~/.saberrc
|
|
142
99
|
Begin fetch a file from seedbox
|
143
100
|
|
144
101
|
$ saber fetch foo
|
145
|
-
> download ftp://seedbox/bt/foo/a.epub
|
146
|
-
> download ftp://seedbox/bt/foo/b.epub
|
102
|
+
> begin to download ftp://seedbox/bt/foo/a.epub via aria2
|
103
|
+
> begin to download ftp://seedbox/bt/foo/b.epub via aria2
|
104
|
+
|
105
|
+
### Upload
|
106
|
+
|
107
|
+
Because of lacking APIs in major PT sites, so I write this small script to help uploading a torrent from cmdline. Good news is BTN v2.0 will include API. And BTN already has an official autobot which grabs scene releases. :)
|
108
|
+
|
109
|
+
> Support sites: BIB
|
110
|
+
|
111
|
+
Configure ~/.saberrc
|
112
|
+
|
113
|
+
p:
|
114
|
+
watch = Pa("~/bt/watch")
|
115
|
+
remote_watch = Pa("bt/watch")
|
116
|
+
|
117
|
+
username = "foo"
|
118
|
+
bib:
|
119
|
+
username = "bar"
|
120
|
+
announce_url = "x"
|
121
|
+
|
122
|
+
server:
|
123
|
+
user = "x"
|
124
|
+
host = "y"
|
125
|
+
|
126
|
+
Fill \<info-data>.yml file and upload it.
|
127
|
+
|
128
|
+
$ saber.bib g magazine hello.pdf
|
129
|
+
> create hello.pdf.yml
|
130
|
+
$ vim hello.pdf.yml
|
131
|
+
|
132
|
+
type: magazines
|
133
|
+
Title: Hello
|
134
|
+
Description: Hello World
|
135
|
+
...
|
136
|
+
|
137
|
+
$ saber.bib upload hello.pdf.torrent
|
138
|
+
> Upload Complete
|
139
|
+
|
140
|
+
$ saber.bib upload hello.pdf # short cut
|
141
|
+
> make hello.pdf.torrent
|
142
|
+
> Upload Complete
|
143
|
+
|
144
|
+
Auto fill \<info-data>.yml file from isbn.
|
145
|
+
|
146
|
+
$ saber.bib g ebook hello.epub 1781100055
|
147
|
+
> create hello.epub.yml
|
147
148
|
|
148
149
|
### Tasks
|
149
150
|
|
@@ -198,45 +199,36 @@ use `saber help` to list all tasks.
|
|
198
199
|
Install
|
199
200
|
-------
|
200
201
|
|
201
|
-
_Main article_: [Install Saber](https://github.com/
|
202
|
+
_Main article_: [Install Saber](https://github.com/SaberSalv/saber/wiki/Install)
|
202
203
|
|
203
204
|
$ gem install saber
|
204
205
|
$ install it's dependencies
|
205
206
|
|
206
|
-
|
207
|
-
|
208
|
-
Resources
|
209
|
-
---------
|
210
|
-
|
211
|
-
* [Archlinux](http://www.archlinux.org): A simple, lightweight linux distribution.
|
212
|
-
* [pacaur](https://github.com/Spyhawk/pacaur): An AUR helper for ArchLinux.
|
213
|
-
* [YAAW](https://github.com/binux/yaaw): Yet Another Aria2 Web Frontend in pure HTML/CSS/Javascirpt.
|
214
|
-
|
215
|
-
Development [![Dependency Status](https://gemnasium.com/GutenYe/saber.png?branch=master)](https://gemnasium.com/GutenYe/saber) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/GutenYe/saber)
|
207
|
+
Development [![Dependency Status](https://gemnasium.com/SaberSalv/saber.png?branch=master)](https://gemnasium.com/SaberSalv/saber) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/SaberSalv/saber)
|
216
208
|
===========
|
217
209
|
|
218
210
|
Contributing
|
219
|
-
|
211
|
+
------------
|
220
212
|
|
221
213
|
* Submit any bugs/features/ideas to github issue tracker.
|
222
214
|
|
223
|
-
|
215
|
+
Please see [Contibution Documentation](https://github.com/SaberSalv/saber/blob/master/CONTRIBUTING.md).
|
224
216
|
|
225
|
-
|
226
|
-
* Make sure your patches are well tested.
|
227
|
-
* Coding Style Guide: https://gist.github.com/1105334
|
217
|
+
A list of [Contributors](https://github.com/SaberSalv/saber/contributors).
|
228
218
|
|
229
|
-
|
230
|
-
|
219
|
+
Resources
|
220
|
+
---------
|
231
221
|
|
232
|
-
[
|
222
|
+
* [Archlinux](http://www.archlinux.org): A simple, lightweight linux distribution.
|
223
|
+
* [pacaur](https://github.com/Spyhawk/pacaur): An AUR helper for ArchLinux.
|
224
|
+
* [YAAW](https://github.com/binux/yaaw): Yet Another Aria2 Web Frontend in pure HTML/CSS/Javascirpt.
|
233
225
|
|
234
226
|
Copyright
|
235
227
|
---------
|
236
228
|
|
237
229
|
(the MIT License)
|
238
230
|
|
239
|
-
Copyright (c) 2011-2012
|
231
|
+
Copyright (c) 2011-2012 Saber
|
240
232
|
|
241
233
|
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:
|
242
234
|
|
data/bin/saber
CHANGED
@@ -3,15 +3,12 @@ require_relative "../lib/saber"
|
|
3
3
|
|
4
4
|
begin
|
5
5
|
Saber::CLI.start
|
6
|
-
rescue Saber::Error => e
|
7
|
-
Saber.ui.error e.message
|
8
|
-
Saber.ui.debug e.backtrace.join("\n")
|
9
|
-
exit 1
|
10
6
|
rescue Interrupt => e
|
11
7
|
Saber.ui.error "\nQuitting..."
|
12
8
|
Saber.ui.debug e.backtrace.join("\n")
|
13
9
|
exit 1
|
14
10
|
rescue Exception => e
|
15
|
-
|
11
|
+
Saber.ui.error "#{e.class.name}: #{e.message}"
|
12
|
+
Saber.ui.debug e.backtrace.join("\n")
|
16
13
|
exit 1
|
17
14
|
end
|
data/lib/saber/cli.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Saber
|
2
|
+
module Task
|
3
|
+
class CHD < Base
|
4
|
+
|
5
|
+
desc "chd", "chd"
|
6
|
+
def chd(o={})
|
7
|
+
require "saber/tracker/chd"
|
8
|
+
t = Tracker["chd"].new
|
9
|
+
|
10
|
+
begin
|
11
|
+
t.login
|
12
|
+
Saber.ui.say "Begin to watch."
|
13
|
+
# mark all loaded.
|
14
|
+
t.update_cache(true)
|
15
|
+
|
16
|
+
while true
|
17
|
+
t.add_torrents
|
18
|
+
sleep Rc.chd.update_interval
|
19
|
+
end
|
20
|
+
rescue Errno::ETIMEDOUT, Mechanize::ResponseCodeError, SocketError
|
21
|
+
sleep 60
|
22
|
+
retry
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/saber/tracker/base.rb
CHANGED
@@ -0,0 +1,88 @@
|
|
1
|
+
module Saber
|
2
|
+
module Tracker
|
3
|
+
class CHD < Base
|
4
|
+
@@BASE_URL = "https://chdbits.org"
|
5
|
+
@@LOGIN_CHECK_PATH = "/messages.php"
|
6
|
+
CACHE_FILE = "#{ENV['HOME']}/.cache/saber.chd"
|
7
|
+
|
8
|
+
# cache {id: is_download}
|
9
|
+
attr_accessor :cache
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
|
14
|
+
if Pa.exists?(CACHE_FILE)
|
15
|
+
@cache = Marshal.load(File.read(CACHE_FILE))
|
16
|
+
else
|
17
|
+
@cache = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
at_exit {
|
21
|
+
Saber.ui.debug "Exit."
|
22
|
+
File.write(CACHE_FILE, Marshal.dump(cache))
|
23
|
+
}
|
24
|
+
|
25
|
+
agent.pluggable_parser["application/x-bittorrent"] = Mechanize::DirectorySaver.save_to(Rc.p.watch.p)
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_torrents
|
29
|
+
update_cache
|
30
|
+
|
31
|
+
cache.each {|k,v|
|
32
|
+
next if v
|
33
|
+
|
34
|
+
file = agent.get(build_download_link(k))
|
35
|
+
Saber.ui.debug "Download #{Time.now.strftime("%H:%M:%S")} #{file.filename}"
|
36
|
+
cache[k] = true
|
37
|
+
}
|
38
|
+
|
39
|
+
# limit to 60 counts
|
40
|
+
self.cache = Hash[cache.to_a[-60..-1]] if cache.length > 60
|
41
|
+
end
|
42
|
+
|
43
|
+
def update_cache(loaded=false)
|
44
|
+
agent.get("/torrents.php") {|p|
|
45
|
+
links = p.search("//*[@id='torrenttbale']//img[@class='pro_free']/preceding-sibling::a")
|
46
|
+
#links = p.search("//*[@id='torrenttbale']//img[@class='pro_free' or @class='pro_50pctdown']/preceding-sibling::a")
|
47
|
+
links.each {|link|
|
48
|
+
id = link["href"].match(/id=(\d+)/)[1].to_i
|
49
|
+
|
50
|
+
cache[id] = loaded unless cache.has_key?(id)
|
51
|
+
}
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
def build_download_link(id, passkey=nil)
|
58
|
+
"http://chdbits.org/download.php?id=#{id}&passkey=#{passkey || Rc.chd.passkey}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def do_login_with_username(username)
|
62
|
+
agent.get("/login.php") {|p|
|
63
|
+
ret = p.form_with(action: "takelogin.php" ) {|f|
|
64
|
+
# error. e.g. temporary disabled for failed logining exceed maxmium count.
|
65
|
+
unless f
|
66
|
+
# print error in red color and exit the program.
|
67
|
+
Saber.ui.error! p.at("//body").inner_text
|
68
|
+
end
|
69
|
+
|
70
|
+
f.username = username || ask("Username: ")
|
71
|
+
f.password = ask("Password: "){|q| q.echo = false}
|
72
|
+
}.submit
|
73
|
+
|
74
|
+
# error
|
75
|
+
if ret.uri.path == "/login"
|
76
|
+
msg = ret.at("//*[@id='nav_block']/form[2]/p[2]/b/font").inner_text
|
77
|
+
Saber.ui.error "Failed. You have #{msg} attempts remaining."
|
78
|
+
return false
|
79
|
+
else
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
}
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# vim: fdn=4
|
data/lib/saber/version.rb
CHANGED
data/rutorrent/init.js
CHANGED
File without changes
|
data/rutorrent/init.php
CHANGED
File without changes
|
data/rutorrent/plugin.info
CHANGED
data/saber.gemspec
CHANGED
@@ -8,9 +8,9 @@ spec = Gem::Specification.new do |s|
|
|
8
8
|
A complete solution for PT users.
|
9
9
|
EOF
|
10
10
|
|
11
|
-
s.author = "
|
12
|
-
s.email = "
|
13
|
-
s.homepage = "http://github.com/
|
11
|
+
s.author = "SaberSalv"
|
12
|
+
s.email = "sabersalv@gmail.com"
|
13
|
+
s.homepage = "http://github.com/SaberSalv/saber"
|
14
14
|
s.rubyforge_project = "xx"
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
-
|
8
|
+
- SaberSalv
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pd
|
@@ -190,7 +190,7 @@ dependencies:
|
|
190
190
|
description: ! 'A complete solution for PT users.
|
191
191
|
|
192
192
|
'
|
193
|
-
email:
|
193
|
+
email: sabersalv@gmail.com
|
194
194
|
executables:
|
195
195
|
- saber
|
196
196
|
extensions:
|
@@ -202,6 +202,7 @@ files:
|
|
202
202
|
- .rspec
|
203
203
|
- .travis.yml
|
204
204
|
- CHANGELOG.md
|
205
|
+
- CONTRIBUTING.md
|
205
206
|
- Gemfile
|
206
207
|
- Gemfile.lock
|
207
208
|
- Guardfile
|
@@ -224,6 +225,7 @@ files:
|
|
224
225
|
- lib/saber/rc.rb
|
225
226
|
- lib/saber/task.rb
|
226
227
|
- lib/saber/task/base.rb
|
228
|
+
- lib/saber/task/chd.rb
|
227
229
|
- lib/saber/task/clean.rb
|
228
230
|
- lib/saber/task/generate.rb
|
229
231
|
- lib/saber/task/make.rb
|
@@ -233,11 +235,11 @@ files:
|
|
233
235
|
- lib/saber/tracker/base.rb
|
234
236
|
- lib/saber/tracker/bb.rb
|
235
237
|
- lib/saber/tracker/bib.rb
|
238
|
+
- lib/saber/tracker/chd.rb
|
236
239
|
- lib/saber/tracker/ptp.rb
|
237
240
|
- lib/saber/tracker/what.rb
|
238
241
|
- lib/saber/ui.rb
|
239
242
|
- lib/saber/version.rb
|
240
|
-
- rutorrent/README.md
|
241
243
|
- rutorrent/init.js
|
242
244
|
- rutorrent/init.php
|
243
245
|
- rutorrent/plugin.info
|
@@ -285,7 +287,7 @@ files:
|
|
285
287
|
- templates/what/ebook.yml
|
286
288
|
- templates/what/music.yml
|
287
289
|
- templates/what/music_add.yml
|
288
|
-
homepage: http://github.com/
|
290
|
+
homepage: http://github.com/SaberSalv/saber
|
289
291
|
licenses: []
|
290
292
|
post_install_message:
|
291
293
|
rdoc_options: []
|
data/rutorrent/README.md
DELETED
@@ -1,34 +0,0 @@
|
|
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.
|