georgboe-ucli 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/README.md +29 -1
  2. data/Rakefile +1 -1
  3. data/bin/ucli +24 -3
  4. data/lib/torrent.rb +5 -0
  5. metadata +2 -2
data/README.md CHANGED
@@ -46,7 +46,7 @@ add the label "MISC" all of them.
46
46
 
47
47
  #### Remove torrents
48
48
 
49
- You can remove torrents with the `ucli -r` command.
49
+ You can remove torrents with the `ucli -r` or `ucli --remove` command.
50
50
  You can specify a name or regex to match.
51
51
  It will show you all the matches along with their shareratio and will not delete anything before you have confirmed it.
52
52
 
@@ -59,6 +59,20 @@ It will show you all the matches along with their shareratio and will not delete
59
59
 
60
60
  In this case there was only on matching torrent, but you can remove large amount of torrents using regexes.
61
61
 
62
+ #### Remove torrents and downloaded data
63
+
64
+ This action removes the specified torrent job(s) from the torrent jobs list and removes the corresponding torrent contents (data) from disk.
65
+ You can remove torrents and the downloaded data with the `ucli -e` or `ucli --removedata` command. You can specify a name or regex to match.
66
+ It will show you all the matches along with their shareratio and will not delete anything before you have confirmed it.
67
+
68
+ % ucli -e server
69
+ Found the following torrents
70
+ ============================
71
+ ubuntu-8.10-server-i386.iso (0.06)
72
+
73
+ THIS ACTION WILL REMOVE ALL THE DOWNLOADED DATA!
74
+ Are you sure you want to remove these torrents? (y or n):
75
+
62
76
  #### Removing old tv episodes
63
77
 
64
78
  `ucli --oldepisodes` looks for torrents of the same tv show. If you have two episode of the same show, it will suggest remove the oldest.
@@ -80,6 +94,20 @@ Now we try to run the command.
80
94
 
81
95
  Do you want to remove them? (y or n):
82
96
 
97
+ #### Removing torrents based on ratio
98
+
99
+ `ucli --ratioremove` will let you remove all torrents with a higher ratio than the value you specify.
100
+
101
+ ~% ucli --ratioremove 13.4
102
+ Found the following torrents with ratio above 13.4
103
+ ==================================================
104
+ ubuntu-8.10-desktop-i386.iso (16.64)
105
+ ubuntu-8.10-server-i386.iso (19.16)
106
+
107
+ Are you sure you want to remove these torrents? (y or n):
108
+
109
+
110
+
83
111
  #### Listing files in torrents
84
112
 
85
113
  `ucli --ls` command will show you all the files with filesizes in the torrents matching you input.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake'
5
5
  require 'rake/gempackagetask'
6
6
 
7
7
  GEM = "ucli"
8
- GEM_VERSION = "0.2.2"
8
+ GEM_VERSION = "0.2.3"
9
9
  SUMMARY = "Commandline interface to uTorrent WebUI 0.361"
10
10
  AUTHOR = "Georg Alexander Bøe"
11
11
  EMAIL = "georg.boe@gmail.com"
data/bin/ucli CHANGED
@@ -10,7 +10,7 @@ require 'lsfile.rb'
10
10
  require 'torrent.rb'
11
11
  require 'utilities.rb'
12
12
 
13
- PROGRAM_VERSION = '0.2.2'
13
+ PROGRAM_VERSION = '0.2.3'
14
14
 
15
15
  begin
16
16
 
@@ -37,11 +37,12 @@ opts = Trollop::options do
37
37
  opt :category, "Category for uploaded file", :type => :string, :default => nil
38
38
  opt :oldepisodes, "Show and remove old tv episodes"
39
39
  opt :remove, "Remove torrents by name", :type => :strings
40
- opt :ratioremove, "Removes torrent with ratio high than input", :type => :float
40
+ opt :removedata, "Remove torrents and downloaded data", :type => :strings
41
+ opt :ratioremove, "Remove torrents with ratio high than input", :type => :float
41
42
  opt :ls, "Show files for a given torrent", :type => :string
42
43
  end
43
44
 
44
- has_selected_options = [:list, :upload, :oldepisodes, :remove, :ratioremove, :ls].inject(false) { |result, x| opts[x] ? true : result }
45
+ has_selected_options = [:list, :upload, :oldepisodes, :remove, :removedata, :ratioremove, :ls].inject(false) { |result, x| opts[x] ? true : result }
45
46
  Trollop.die("No option selected") unless has_selected_options
46
47
  Trollop.die("Category is required for uploaded torrent") if opts[:upload] and !opts[:category]
47
48
 
@@ -126,7 +127,27 @@ elsif opts[:remove]
126
127
  end
127
128
  end
128
129
 
130
+ elsif opts[:removedata]
131
+ torrents = opts[:removedata].inject([]) { |sum, x| sum += Torrent.find_by_name(x) }
129
132
 
133
+ if torrents.length == 0
134
+ puts "No torrents mached #{opts[:removedata]}"
135
+ exit 1
136
+ end
137
+
138
+ puts "Found the following torrents"
139
+ puts "============================"
140
+ torrents.each { |torrent| puts "#{torrent.name} (#{torrent.ratio})" }
141
+ puts
142
+ puts "THIS ACTION WILL REMOVE ALL THE DOWNLOADED DATA!"
143
+ should_remove = Utilities.agree?("Are you sure you want to remove these torrents?")
144
+
145
+ if should_remove
146
+ torrents.each do |torrent|
147
+ torrent.removedata
148
+ puts "#{torrent.name} removed."
149
+ end
150
+ end
130
151
 
131
152
  elsif opts[:ratioremove]
132
153
  torrents = Torrent.all.reject { |torrent| torrent.ratio.to_f < opts[:ratioremove] }
@@ -20,6 +20,11 @@ class Torrent
20
20
  open(template % @hash, :http_basic_authentication => [@@settings.username, @@settings.password]) {|f| f.read }
21
21
  end
22
22
 
23
+ def removedata
24
+ template = "http://#{@@settings.host}:#{@@settings.port}/gui/?action=removedata&hash=%s"
25
+ open(template % @hash, :http_basic_authentication => [@@settings.username, @@settings.password]) {|f| f.read }
26
+ end
27
+
23
28
  def self.all
24
29
  json = JSON.parse(open("http://#{@@settings.host}:#{@@settings.port}/gui/?list=1", :http_basic_authentication => [@@settings.username, @@settings.password]).read)
25
30
  torrents = Array.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: georgboe-ucli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Georg Alexander B\xC3\xB8e"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-25 00:00:00 -07:00
12
+ date: 2009-06-12 00:00:00 -07:00
13
13
  default_executable: ucli
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency