saber 0.0.7 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +4 -0
  3. data/CHANGELOG.md +3 -0
  4. data/Gemfile +18 -8
  5. data/Gemfile.lock +72 -33
  6. data/Guardfile +4 -0
  7. data/README.md +192 -52
  8. data/Rakefile +46 -0
  9. data/bin/1saber +5 -3
  10. data/bin/saber +4 -0
  11. data/bin/saber.bib +3 -0
  12. data/bin/saber.what +3 -0
  13. data/extconf.rb +4 -1
  14. data/lib/saber.rb +7 -13
  15. data/lib/saber/autofetcher.rb +8 -0
  16. data/lib/saber/autofetcher/client.rb +66 -0
  17. data/lib/saber/autofetcher/server.rb +78 -0
  18. data/lib/saber/cli.rb +65 -26
  19. data/lib/saber/{downloader.rb → fetcher.rb} +9 -11
  20. data/lib/saber/mechanize_ext.rb +136 -0
  21. data/lib/saber/rc.rb +3 -21
  22. data/lib/saber/task.rb +26 -11
  23. data/lib/saber/task/base.rb +18 -0
  24. data/lib/saber/task/clean.rb +18 -0
  25. data/lib/saber/task/generate.rb +38 -0
  26. data/lib/saber/task/make.rb +44 -0
  27. data/lib/saber/task/send.rb +21 -0
  28. data/lib/saber/task/upload.rb +37 -0
  29. data/lib/saber/tracker.rb +28 -0
  30. data/lib/saber/tracker/base.rb +115 -2
  31. data/lib/saber/tracker/bb.rb +244 -0
  32. data/lib/saber/tracker/bib.rb +225 -0
  33. data/lib/saber/tracker/ptp.rb +100 -0
  34. data/lib/saber/tracker/what.rb +55 -7
  35. data/lib/saber/ui.rb +65 -22
  36. data/lib/saber/version.rb +1 -1
  37. data/rutorrent/init.js +8 -9
  38. data/rutorrent/plugin.info +1 -1
  39. data/saber.gemspec +14 -10
  40. data/spec/data/_saber/.gitkeep +0 -0
  41. data/spec/saber/downloader_spec.rb +5 -2
  42. data/spec/saber/task_spec.rb +16 -0
  43. data/spec/saber/tracker/bib_spec.rb +24 -0
  44. data/spec/spec_helper.rb +25 -0
  45. data/templates/_saberrc +36 -0
  46. data/templates/bb/anime.yml +6 -0
  47. data/templates/bb/application.yml +7 -0
  48. data/templates/bb/audiobook.yml +12 -0
  49. data/templates/bb/comic.yml +7 -0
  50. data/templates/bb/documentary.yml +26 -0
  51. data/templates/bb/ebook.yml +8 -0
  52. data/templates/bb/elearning_video.yml +7 -0
  53. data/templates/bb/game_console.yml +6 -0
  54. data/templates/bb/game_pc.yml +6 -0
  55. data/templates/bb/magazine.yml +6 -0
  56. data/templates/bb/misc.yml +6 -0
  57. data/templates/bb/movie.yml +26 -0
  58. data/templates/bb/music.yml +21 -0
  59. data/templates/bb/tv.yml +6 -0
  60. data/templates/bib/application.yml +9 -0
  61. data/templates/bib/article.yml +18 -0
  62. data/templates/bib/audiobook.yml +17 -0
  63. data/templates/bib/comic.yml +22 -0
  64. data/templates/bib/ebook.yml +20 -0
  65. data/templates/bib/journal.yml +18 -0
  66. data/templates/bib/magazine.yml +18 -0
  67. data/templates/ptp/movie.yml +63 -0
  68. data/templates/ptp/movie_add.yml +35 -0
  69. data/templates/what/ebook.yml +6 -0
  70. data/templates/what/music.yml +2 -0
  71. data/templates/what/music_add.yml +2 -0
  72. metadata +182 -26
  73. data/doc/Development.md +0 -3
  74. data/lib/saber/client.rb +0 -58
  75. data/lib/saber/server.rb +0 -70
  76. data/saber.watchr +0 -23
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  /rfrom/
2
2
  /*.gem
3
+ /test
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ script: bundle exec rspec spec
@@ -0,0 +1,3 @@
1
+ ## 1.0.0 (xx)
2
+
3
+ - first version.
data/Gemfile CHANGED
@@ -1,17 +1,27 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
 
3
- gem "optimism", "~>3.1.2"
4
- gem "pa", "~>1.2.3"
3
+ gem "pd"
4
+ gem "tagen", "~>2.0.1"
5
+ #gem "tagen", path: "/home/guten/dev/one/tagen"
6
+ gem "optimism", "~>3.3.1"
7
+ #gem "optimism", path: "/home/guten/dev/one/optimism"
8
+ gem "pa", "~>1.3.2"
9
+ #gem "pa", path: "/home/guten/dev/one/pa"
5
10
  gem "retort", "~>0.0.6"
6
- gem "thor", "~>0.14.6"
7
- gem "net-ssh", "~>2.3.0"
11
+ gem "thor", "~>0.16.0"
12
+ gem "net-ssh", "~>2.5.2"
8
13
  gem "xmpp4r", "~>0.5"
9
- gem "httparty"
14
+ gem "mechanize", "~>2.5.1"
15
+ gem "highline", "~>1.6.14"
16
+ gem "reverse_markdown", "~>0.3.0"
10
17
 
11
18
  group :development do
12
19
  gem "rspec"
13
- gem "watchr"
14
- gem "rag"
20
+ gem "vcr"
21
+ gem "webmock"
22
+ gem "guard"
23
+ gem "guard-rspec"
24
+ #gem "rag", path: "/home/guten/dev/one/rag"
15
25
  end
16
26
 
17
27
  # gemspec
@@ -1,47 +1,86 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (3.1.3)
4
+ activesupport (3.2.8)
5
+ i18n (~> 0.6)
5
6
  multi_json (~> 1.0)
7
+ addressable (2.3.2)
8
+ crack (0.3.1)
6
9
  diff-lcs (1.1.3)
7
- hike (1.2.1)
8
- i18n (0.6.0)
9
- multi_json (1.0.4)
10
- net-ssh (2.3.0)
11
- optimism (3.1.2)
12
- hike (~> 1.2.0)
13
- pa (1.2.3)
14
- rag (1.2.1)
15
- optimism (~> 3.1.0)
16
- pa (~> 1.2.0)
17
- tagen (~> 1.1.0)
18
- thor
10
+ domain_name (0.5.3)
11
+ unf (~> 0.0.3)
12
+ guard (1.3.2)
13
+ listen (>= 0.4.2)
14
+ thor (>= 0.14.6)
15
+ guard-rspec (1.2.1)
16
+ guard (>= 1.1)
17
+ highline (1.6.14)
18
+ i18n (0.6.1)
19
+ json (1.7.5)
20
+ listen (0.5.0)
21
+ mechanize (2.5.1)
22
+ domain_name (~> 0.5, >= 0.5.1)
23
+ mime-types (~> 1.17, >= 1.17.2)
24
+ net-http-digest_auth (~> 1.1, >= 1.1.1)
25
+ net-http-persistent (~> 2.5, >= 2.5.2)
26
+ nokogiri (~> 1.4)
27
+ ntlm-http (~> 0.1, >= 0.1.1)
28
+ webrobots (~> 0.0, >= 0.0.9)
29
+ mime-types (1.19)
30
+ multi_json (1.3.6)
31
+ net-http-digest_auth (1.2.1)
32
+ net-http-persistent (2.7)
33
+ net-ssh (2.5.2)
34
+ nokogiri (1.5.5)
35
+ ntlm-http (0.1.1)
36
+ optimism (3.3.1)
37
+ json
38
+ pd
39
+ pa (1.3.2)
40
+ pd
41
+ pd (1.1.0)
19
42
  retort (0.0.6)
20
- rspec (2.8.0)
21
- rspec-core (~> 2.8.0)
22
- rspec-expectations (~> 2.8.0)
23
- rspec-mocks (~> 2.8.0)
24
- rspec-core (2.8.0)
25
- rspec-expectations (2.8.0)
26
- diff-lcs (~> 1.1.2)
27
- rspec-mocks (2.8.0)
28
- tagen (1.1.5)
29
- activesupport (~> 3.1.0)
30
- i18n
31
- thor (0.14.6)
32
- watchr (0.7)
43
+ reverse_markdown (0.3.0)
44
+ nokogiri
45
+ rspec (2.11.0)
46
+ rspec-core (~> 2.11.0)
47
+ rspec-expectations (~> 2.11.0)
48
+ rspec-mocks (~> 2.11.0)
49
+ rspec-core (2.11.1)
50
+ rspec-expectations (2.11.2)
51
+ diff-lcs (~> 1.1.3)
52
+ rspec-mocks (2.11.2)
53
+ tagen (2.0.1)
54
+ activesupport
55
+ pd
56
+ thor (0.16.0)
57
+ unf (0.0.5)
58
+ unf_ext
59
+ unf_ext (0.0.5)
60
+ vcr (2.2.4)
61
+ webmock (1.8.9)
62
+ addressable (>= 2.2.7)
63
+ crack (>= 0.1.7)
64
+ webrobots (0.0.13)
33
65
  xmpp4r (0.5)
34
66
 
35
67
  PLATFORMS
36
68
  ruby
37
69
 
38
70
  DEPENDENCIES
39
- net-ssh (~> 2.3.0)
40
- optimism (~> 3.1.2)
41
- pa (~> 1.2.3)
42
- rag
71
+ guard
72
+ guard-rspec
73
+ highline (~> 1.6.14)
74
+ mechanize (~> 2.5.1)
75
+ net-ssh (~> 2.5.2)
76
+ optimism (~> 3.3.1)
77
+ pa (~> 1.3.2)
78
+ pd
43
79
  retort (~> 0.0.6)
80
+ reverse_markdown (~> 0.3.0)
44
81
  rspec
45
- thor (~> 0.14.6)
46
- watchr
82
+ tagen (~> 2.0.1)
83
+ thor (~> 0.16.0)
84
+ vcr
85
+ webmock
47
86
  xmpp4r (~> 0.5)
@@ -0,0 +1,4 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ end
data/README.md CHANGED
@@ -1,98 +1,238 @@
1
- Saber, a complete solution for PT users.
2
- ========================================
1
+ Saber, a complete solution for PT users. [![Build Status](https://secure.travis-ci.org/GutenYe/saber.png)](http://travis-ci.org/GutenYe/saber)
2
+ ==========================================
3
3
 
4
- | Homepage: | https://github.com/GutenYe/saber |
4
+ | | |
5
5
  |----------------|-----------------------------------------|
6
+ | Homepage: | https://github.com/GutenYe/saber |
6
7
  | Author: | Guten |
7
8
  | License: | MIT-LICENSE |
9
+ | Documentation: | https://github.com/GutenYe/saber/wiki |
8
10
  | Issue Tracker: | https://github.com/GutenYe/saber/issues |
9
11
 
10
- ### Is It Good?
12
+ **Features:**
11
13
 
12
- Yes.
14
+ * Add Torrent: send a torrent file from website to rutorrent.
15
+ * Upload: upload a torrent file from command line to the site.
16
+ * Fetch: automatically/manually fetch files from seedbox to home-laptop.
17
+ * Other Tasks:
18
+ - Make: make a torrent file and copy it to local and remote watch directory.
19
+ - Send: send files from home-laptop to seedbox.
20
+ - Clean: remove files which are not seeded in rtorrent.
13
21
 
14
- ### Is It "Production Ready™"?
22
+ you can find more tools at [here](https://github.com/GutenYe/saber/wiki/Tools).
15
23
 
16
- No.
24
+ Getting Started
25
+ ----------------
17
26
 
18
- What saber can do for you?
27
+ Create ~/.saberrc configuration file from [template](https://github.com/GutenYe/saber/blob/master/templates/_saberrc). More detail will be explained below.
19
28
 
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.
29
+ ### Add Torrent
26
30
 
27
- Usage
28
- -----
31
+ See [saber-addtorrent](https://github.com/GutenYe/saber-addtorrent) project.
29
32
 
30
- ### addtorrent
33
+ ### Upload
31
34
 
32
- see https://github.com/Gutenye/saber-addtorrent
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. :)
33
36
 
37
+ > Support sites: BIB
34
38
 
35
- ### download
39
+ Configure ~/.saberrc
36
40
 
37
- # server side
38
- # start rtorrent
39
- $ /etc/rc.d/saber-server start # start saber server daemon.
41
+ p:
42
+ watch = Pa("~/bt/watch")
43
+ remote_watch = Pa("bt/watch")
40
44
 
41
- # client side
42
- $ ~/etc/rc.d/aria2 start # start aria2 daemon.
43
- $ ~/etc/rc.d/saber-client start # start saber client daemon.
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
71
+
72
+ Auto fill \<info-data>.yml file from isbn.
73
+
74
+ $ saber.bib g ebook hello.epub 1781100055
75
+ > create hello.epub.yml
76
+
77
+ ### Fetch
78
+
79
+ #### AutoFetch
80
+
81
+ Configure ~/.saberrc
82
+
83
+ p:
84
+ fetcher_download = Pa("~/download")
85
+
86
+ server:
87
+ ftp = "ftp://seedbox/bt"
88
+
89
+ xmpp:
90
+ jid = "x1@gmail.com" # need register a gtalk account.
91
+ password = "y1"
92
+ host = nil
93
+ port = nil
94
+
95
+ client:
96
+ xmpp:
97
+ jid = "x2@gmail.com"
98
+ password = "y2"
99
+ host = nil
100
+ port = nil
101
+
102
+ And ~/.netrc, for ftp authenticate.
103
+
104
+ machine seedbox
105
+ login x
106
+ password y
107
+
108
+ Start saber-server at server side.
109
+
110
+ # ~/.rtorrent.rc
111
+
112
+ method.set_key = event.download.finished, saber-fetch, "execute= saber-drb_add, (d.get_hash), (d.get_custom1)"
113
+
114
+ $ saber server -V
115
+
116
+ Start saber-client at client side.
117
+
118
+ $ aria2c --enable-rpc --save-session session.lock -i session.lock
119
+
120
+ $ saber client -V
121
+
122
+ Automatically fetch: when a file is finished download in rutorrent with label 'saber', then it'll add to aria2.
123
+
124
+ Manually fetch: right click 'Saber Fetch' in rutorrent web ui, then it'll add to aria2.
44
125
 
45
- # manually download
46
- right click 'Saber Download' in rutorrent web ui, then it adds to aria2.
126
+ For ArchLinux, you can install `saber-server-daemon`, `user-saber-client-daemon`, `user-aria2-daemon` packages.
127
+
128
+ #### ManualFetch
129
+
130
+ Configure ~/.saberrc
131
+
132
+ p:
133
+ fetcher_download = Pa("~/download")
134
+ remote_download = Pa("~/bt")
47
135
 
48
- # automatically download
49
- when a file is finished download in rutorrent with label 'saber', then it adds to aria2.
136
+ server:
137
+ user = "x"
138
+ host = "seedbox"
139
+ ftp = "ftp://seedbox/bt"
50
140
 
141
+ Begin fetch a file from seedbox
142
+
143
+ $ saber fetch foo
144
+ > download ftp://seedbox/bt/foo/a.epub
145
+ > download ftp://seedbox/bt/foo/b.epub
146
+
147
+ ### Tasks
148
+
149
+ #### Make
150
+
151
+ Configure ~/.saberrc
152
+
153
+ p:
154
+ watch = Pa("~/bt/watch")
155
+ remote_watch = Pa("bt/watch")
156
+
157
+ bib:
158
+ announce_url = "x"
159
+
160
+ server:
161
+ user = "x"
162
+ host = "y"
163
+
164
+ Make a torrent
165
+
166
+ $ saber make hello.epub
167
+ > mktorrent -p -a x hello.epub
168
+ > cp hello.epub.torrent ~/bt/watch
169
+ > rsync -Phr hello.epub.torrent user@host:bt/watch
170
+
171
+ #### Send
172
+
173
+ Configure ~/.saberrc
174
+
175
+ server:
176
+ user = "x"
177
+ host = "y"
178
+
179
+ Send files to seedbox
180
+
181
+ $ saber send hello.epub bt
182
+ > rsync -Phr hello.epub user@host:bt
183
+
184
+ #### Clean
185
+
186
+ Configure ~/.saberrc
51
187
 
52
- ### task
188
+ p:
189
+ download = Pa("~/bt")
53
190
 
54
- clean up undownload files, all files remains in disk, but don't in rtorrent client.
191
+ Clean up unseeded files in rtorrent.
55
192
 
56
- # server side
57
193
  $ saber clean
58
194
 
195
+ use `saber help` to list all tasks.
196
+
59
197
  Install
60
- --------
198
+ -------
61
199
 
62
- ### download
200
+ _Main article_: [Install Saber](https://github.com/GutenYe/saber/wiki/Install)
63
201
 
64
- # server side
65
- $ gem install saber
66
- $ pacaur -S rutorrent-saber-git saber-server-daemon
67
-
68
- # client side
69
- $ gem install saber
70
- $ pacaur -S user-aria2-daemon user-saber-client-daemon
202
+ $ [sudo] gem install saber
203
+
204
+ Resources
205
+ ---------
206
+
207
+ * [Archlinux](http://www.archlinux.org): A simple, lightweight linux distribution.
208
+ * [pacaur](https://github.com/Spyhawk/pacaur): An AUR helper for ArchLinux.
209
+ * [YAAW](https://github.com/binux/yaaw): Yet Another Aria2 Web Frontend in pure HTML/CSS/Javascirpt.
210
+
211
+ 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)
212
+ ===========
71
213
 
72
214
  Contributing
73
215
  -------------
74
216
 
75
- * Feel free to join the project and make contributions (by submitting a pull request)
76
- * Submit any bugs/features/ideas to issue tracker
77
- * Coding Style Guide: https://gist.github.com/1105334
217
+ * Submit any bugs/features/ideas to github issue tracker.
78
218
 
79
- Credits
80
- --------
219
+ Pull requests are very welcome! Please try to follow these simple rules if applicable:
81
220
 
82
- * [Contributors](https://github.com/GutenYe/saber/contributors)
221
+ * Please create a topic branch for every separate change you make.
222
+ * Make sure your patches are well tested.
223
+ * Coding Style Guide: https://gist.github.com/1105334
83
224
 
84
- Resources
85
- ---------
225
+ Contributors
226
+ ------------
86
227
 
87
- * [pacaur](https://github.com/Spyhawk/pacaur): An AUR installer for ArchLinux.
88
- * [TheBear](http://sourceforge.net/projects/thebear/): a web front end to aria2.
228
+ [https://github.com/GutenYe/saber/contributors](https://github.com/GutenYe/saber/contributors)
89
229
 
90
230
  Copyright
91
231
  ---------
92
232
 
93
233
  (the MIT License)
94
234
 
95
- Copyright (c) 2011 Guten
235
+ Copyright (c) 2011-2012 Guten
96
236
 
97
237
  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:
98
238