Class: Deluge

Inherits:
Object
  • Object
show all
Defined in:
lib/deluge.rb,
lib/deluge/protocol/v3.rb

Instance Method Summary collapse

Constructor Details

#initialize(host = 'localhost', port = '58846', protocol = 3) ⇒ Deluge

Returns a new instance of Deluge.



6
7
8
9
10
11
12
13
14
# File 'lib/deluge.rb', line 6

def initialize host='localhost', port='58846', protocol=3
  @protocol = protocol

  if protocol == 3
    @con = Protocol::V3.new(host, port)
  else
    raise "Unsupported protocol #{protocol}"
  end
end

Instance Method Details

#add_torrent_file(filename, filedump, options = {}) ⇒ Object

Available options: max_connections max_upload_slots max_upload_speed max_download_speed prioritize_first_last_pieces file_priorities compact_allocation download_location auto_managed stop_at_ratio stop_ratio remove_at_ratio move_completed move_completed_path add_paused



39
40
41
42
# File 'lib/deluge.rb', line 39

def add_torrent_file filename, filedump, options={}
  filedump_enc = Base64.encode64(filedump)
  @con.call 'core.add_torrent_file', filename, filedump_enc, options, {}
end

#add_torrent_magnet(uri, options = {}) ⇒ Object

Available options: max_connections max_upload_slots max_upload_speed max_download_speed prioritize_first_last_pieces file_priorities compact_allocation download_location auto_managed stop_at_ratio stop_ratio remove_at_ratio move_completed move_completed_path add_paused



52
53
54
# File 'lib/deluge.rb', line 52

def add_torrent_magnet uri, options={}
  @con.call 'core.add_torrent_magnet', uri, options, {}
end

#add_torrent_url(url, options = {}) ⇒ Object

Available options: max_connections max_upload_slots max_upload_speed max_download_speed prioritize_first_last_pieces file_priorities compact_allocation download_location auto_managed stop_at_ratio stop_ratio remove_at_ratio move_completed move_completed_path add_paused



46
47
48
# File 'lib/deluge.rb', line 46

def add_torrent_url url, options={}
  @con.call 'core.add_torrent_url', url, options, {}
end

#call(*args) ⇒ Object



16
17
18
# File 'lib/deluge.rb', line 16

def call *args
  @con.call *args
end

#connect_peer(torrent_id, ip, port) ⇒ Object



81
82
83
# File 'lib/deluge.rb', line 81

def connect_peer torrent_id, ip, port
  @con.call 'core.connect_peer', torrent_id, ip, port, {}
end

#create_torrent(path, tracker, piece_length, comment, target, webseeds, privat, created_by, trackers, add_to_session) ⇒ Object



214
215
216
# File 'lib/deluge.rb', line 214

def create_torrent path, tracker, piece_length, comment, target, webseeds, privat, created_by, trackers, add_to_session
  @con.call 'core.create_torrent', path, tracker, piece_length, comment, target, webseeds, privat, created_by, trackers, add_to_session, {}
end

#disable_plugin(plugin) ⇒ Object



145
146
147
# File 'lib/deluge.rb', line 145

def disable_plugin plugin
  @con.call 'core.disable_plugin', plugin, {}
end

#enable_plugin(plugin) ⇒ Object



141
142
143
# File 'lib/deluge.rb', line 141

def enable_plugin plugin
  @con.call 'core.enable_plugin', plugin, {}
end

#force_reannounce(*torrent_ids) ⇒ Object



73
74
75
# File 'lib/deluge.rb', line 73

def force_reannounce *torrent_ids
  @con.call 'core.force_reannounce', torrent_ids, {}
end

#force_recheck(*torrent_ids) ⇒ Object



149
150
151
# File 'lib/deluge.rb', line 149

def force_recheck *torrent_ids
  @con.call 'core.force_recheck', torrent_ids, {}
end

#get_available_pluginsObject



133
134
135
# File 'lib/deluge.rb', line 133

def get_available_plugins
  @con.call 'core.get_available_plugins', {}
end

#get_cache_statusObject



69
70
71
# File 'lib/deluge.rb', line 69

def get_cache_status
  @con.call 'core.get_cache_status', {}
end

#get_configObject



113
114
115
# File 'lib/deluge.rb', line 113

def get_config
  @con.call 'core.get_config', {}
end

#get_config_values(*keys) ⇒ Object



117
118
119
# File 'lib/deluge.rb', line 117

def get_config_values *keys
  @con.call 'core.get_config_values', keys, {}
end

#get_enabled_pluginsObject



137
138
139
# File 'lib/deluge.rb', line 137

def get_enabled_plugins
  @con.call 'core.get_enabled_plugins', {}
end

#get_filter_tree(show_zero_hits = true, hide_cat = nil) ⇒ Object



105
106
107
# File 'lib/deluge.rb', line 105

def get_filter_tree show_zero_hits=true, hide_cat=nil
  @con.call 'core.get_filter_tree', show_zero_hits, hide_cat, {}
end

#get_free_space(path = nil) ⇒ Object



258
259
260
# File 'lib/deluge.rb', line 258

def get_free_space path=nil
  @con.call 'core.get_free_space', path, {}
end

#get_libtorrent_versionObject



262
263
264
# File 'lib/deluge.rb', line 262

def get_libtorrent_version
  @con.call 'core.get_libtorrent_version'
end

#get_listen_portObject



125
126
127
# File 'lib/deluge.rb', line 125

def get_listen_port
  @con.call 'core.get_listen_port', {}
end

#get_method_listObject



33
34
35
# File 'lib/deluge.rb', line 33

def get_method_list
  @con.call 'daemon.get_method_list'
end

#get_num_connectionsObject



129
130
131
# File 'lib/deluge.rb', line 129

def get_num_connections
  @con.call 'core.get_num_connections', {}
end

#get_path_size(path) ⇒ Object



210
211
212
# File 'lib/deluge.rb', line 210

def get_path_size path
  @con.call 'core.get_path_size', path, {}
end

#get_session_stateObject



109
110
111
# File 'lib/deluge.rb', line 109

def get_session_state
  @con.call 'core.get_session_state', {}
end

#get_session_status(keys) ⇒ Object



65
66
67
# File 'lib/deluge.rb', line 65

def get_session_status keys
  @con.call 'core.get_session_status', keys, {}
end

#get_torrent_status(torrent_id, keys, diff = false) ⇒ Object



101
102
103
# File 'lib/deluge.rb', line 101

def get_torrent_status torrent_id, keys, diff=false
  @con.call 'core.get_torrent_status', torrent_id, keys, diff, {}
end

#glob(path) ⇒ Object



250
251
252
# File 'lib/deluge.rb', line 250

def glob path
  @con.call 'core.glob', path, {}
end

#infoObject



29
30
31
# File 'lib/deluge.rb', line 29

def info
  @con.call 'daemon.info'
end

#login(username, password) ⇒ Object



20
21
22
# File 'lib/deluge.rb', line 20

def  username, password
  @con.call 'daemon.login', username, password
end

#move_storage(*torrent_ids, dest) ⇒ Object



85
86
87
# File 'lib/deluge.rb', line 85

def move_storage *torrent_ids, dest
  @con.call 'core.move_storage', torrent_ids, dest, {}
end

#pause_all_torrentsObject



89
90
91
# File 'lib/deluge.rb', line 89

def pause_all_torrents
  @con.call 'core.pause_all_torrents', {}
end

#pause_torrent(*torrent_ids) ⇒ Object



77
78
79
# File 'lib/deluge.rb', line 77

def pause_torrent *torrent_ids
  @con.call 'core.pause_torrent', torrent_ids, {}
end

#queue_bottom(*torrent_ids) ⇒ Object



246
247
248
# File 'lib/deluge.rb', line 246

def queue_bottom *torrent_ids
  @con.call 'core.queue_bottom', torrent_ids, {}
end

#queue_down(*torrent_ids) ⇒ Object



242
243
244
# File 'lib/deluge.rb', line 242

def queue_down *torrent_ids
  @con.call 'core.queue_down', torrent_ids, {}
end

#queue_top(*torrent_ids) ⇒ Object



234
235
236
# File 'lib/deluge.rb', line 234

def queue_top *torrent_ids
  @con.call 'core.queue_top', torrent_ids, {}
end

#queue_up(*torrent_ids) ⇒ Object



238
239
240
# File 'lib/deluge.rb', line 238

def queue_up *torrent_ids
  @con.call 'core.queue_up', torrent_ids, {}
end

#remove_torrent(torrent_id, remove_data: false) ⇒ Object



56
57
58
# File 'lib/deluge.rb', line 56

def remove_torrent torrent_id, remove_data: false
  @con.call 'core.remove_torrent', torrent_id, remove_data
end

#rename_files(torrent_id, filenames) ⇒ Object



226
227
228
# File 'lib/deluge.rb', line 226

def rename_files torrent_id, filenames
  @con.call 'core.rename_files', torrent_id, filenames, {}
end

#rename_folder(torrent_id, folder, new_folder) ⇒ Object



230
231
232
# File 'lib/deluge.rb', line 230

def rename_folder torrent_id, folder, new_folder
  @con.call 'core.rename_folder', torrent_id, folder, new_folder, {}
end

#rescan_pluginsObject



222
223
224
# File 'lib/deluge.rb', line 222

def rescan_plugins
  @con.call 'core.rescan_plugins', {}
end

#resume_all_torrentsObject



93
94
95
# File 'lib/deluge.rb', line 93

def resume_all_torrents
  @con.call 'core.resume_all_torrents', {}
end

#resume_torrent(*torrent_ids) ⇒ Object



97
98
99
# File 'lib/deluge.rb', line 97

def resume_torrent *torrent_ids
  @con.call 'core.resume_torrent', torrent_ids, {}
end

#set_config(config) ⇒ Object



121
122
123
# File 'lib/deluge.rb', line 121

def set_config config
  @con.call 'core.set_config', config, {}
end

#set_torrent_auto_managed(torrent_id, value) ⇒ Object



186
187
188
# File 'lib/deluge.rb', line 186

def set_torrent_auto_managed torrent_id, value
  @con.call 'core.set_torrent_auto_managed', torrent_id, value, {}
end

#set_torrent_file_priorities(torrent_id, priorities) ⇒ Object



178
179
180
# File 'lib/deluge.rb', line 178

def set_torrent_file_priorities torrent_id, priorities
  @con.call 'core.set_torrent_file_priorities', torrent_id, priorities, {}
end

#set_torrent_max_connections(torrent_id, value) ⇒ Object



162
163
164
# File 'lib/deluge.rb', line 162

def set_torrent_max_connections torrent_id, value
  @con.call 'core.set_torrent_max_connections', torrent_id, value, {}
end

#set_torrent_max_download_speed(torrent_id, value) ⇒ Object



174
175
176
# File 'lib/deluge.rb', line 174

def set_torrent_max_download_speed torrent_id, value
  @con.call 'core.set_torrent_max_download_speed', torrent_id, value, {}
end

#set_torrent_max_upload_slots(torrent_id, value) ⇒ Object



166
167
168
# File 'lib/deluge.rb', line 166

def set_torrent_max_upload_slots torrent_id, value
  @con.call 'core.set_torrent_max_upload_stats', torrent_id, value, {}
end

#set_torrent_max_upload_speed(torrent_id, value) ⇒ Object



170
171
172
# File 'lib/deluge.rb', line 170

def set_torrent_max_upload_speed torrent_id, value
  @con.call 'core.set_torrent_max_upload_speed', torrent_id, value, {}
end

#set_torrent_move_completed(torrent_id, value) ⇒ Object



202
203
204
# File 'lib/deluge.rb', line 202

def set_torrent_move_completed torrent_id, value
  @con.call 'core.set_torrent_move_completed', torrent_id, value, {}
end

#set_torrent_move_completed_path(torrent_id, value) ⇒ Object



206
207
208
# File 'lib/deluge.rb', line 206

def set_torrent_move_completed_path torrent_id, value
  @con.call 'core.set_torrent_move_completed_path', torrent_id, value, {}
end

#set_torrent_options(torrent_ids, options = {}) ⇒ Object



153
154
155
156
# File 'lib/deluge.rb', line 153

def set_torrent_options torrent_ids, options={}
  torrent_ids = [torrent_ids] unless torrent_ids.kind_of?(Array)
  @con.call 'core.set_torrent_options',torrent_ids, options, {}
end

#set_torrent_prioritize_first_last(torrent_id, value) ⇒ Object



182
183
184
# File 'lib/deluge.rb', line 182

def set_torrent_prioritize_first_last torrent_id, value
  @con.call 'core.set_torrent_prioritize_first_last', torrent_id, value, {}
end

#set_torrent_remove_at_ratio(torrent_id, value) ⇒ Object



198
199
200
# File 'lib/deluge.rb', line 198

def set_torrent_remove_at_ratio torrent_id, value
  @con.call 'core.set_torrent_remove_at_ratio', torrent_id, value, {}
end

#set_torrent_stop_at_ratio(torrent_id, value) ⇒ Object



190
191
192
# File 'lib/deluge.rb', line 190

def set_torrent_stop_at_ratio torrent_id, value
  @con.call 'core.set_torrent_stop_at_ratio', torrent_id, value, {}
end

#set_torrent_stop_ratio(torrent_id, value) ⇒ Object



194
195
196
# File 'lib/deluge.rb', line 194

def set_torrent_stop_ratio torrent_id, value
  @con.call 'core.set_torrent_stop_ratio', torrent_id, value, {}
end

#set_torrent_trackers(torrent_id, *trackers) ⇒ Object



158
159
160
# File 'lib/deluge.rb', line 158

def set_torrent_trackers torrent_id, *trackers
  @con.call 'core.set_torrent_trackers', torrent_id, trackers, {}
end

#shutdown(args, kwargs = {}) ⇒ Object



24
25
26
27
# File 'lib/deluge.rb', line 24

def shutdown args, kwargs={}
  args = [args] unless args.is_a?(Array)
  @con.call 'daemon.shutdown', args, kwargs
end

#test_listen_portObject



254
255
256
# File 'lib/deluge.rb', line 254

def test_listen_port
  @con.call 'core.test_listen_port', {}
end

#upload_plugin(filename, filedump) ⇒ Object



218
219
220
# File 'lib/deluge.rb', line 218

def upload_plugin filename, filedump
  @con.call 'core.upload_plugin', filename, filedump, {}
end