Module: QBittorrent::WebApi::Torrent
- Included in:
- Api
- Defined in:
- lib/qbittorrent/web_api/torrent.rb
Instance Method Summary collapse
- #add_torrents(url_or_file_path, **options) ⇒ Object
- #delete_torrents(hashes, delete_files = false) ⇒ Object
- #get_torrents(**options) ⇒ Object
- #reannounce(hashes = 'all') ⇒ Object
Instance Method Details
#add_torrents(url_or_file_path, **options) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/qbittorrent/web_api/torrent.rb', line 10 def add_torrents(url_or_file_path, **) send_request('/torrents/add') do |api_url| url_or_file_path.gsub!(/^\s+|\s+$/, '') if %r{^http://|https://|magnet://}i =~ url_or_file_path .merge!(urls: url_or_file_path) else .merge!(torrents: HTTP::FormData::File.new(url_or_file_path)) end api_client.post(api_url, form: ) end end |
#delete_torrents(hashes, delete_files = false) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/qbittorrent/web_api/torrent.rb', line 22 def delete_torrents(hashes, delete_files = false) send_request("/torrents/delete") do |api_url| api_client.post(api_url, form: { hashes: hashes, deleteFiles: delete_files }) end end |
#get_torrents(**options) ⇒ Object
4 5 6 7 8 |
# File 'lib/qbittorrent/web_api/torrent.rb', line 4 def get_torrents(**) send_request('/torrents/info') do |api_url| api_client.get(api_url, params: ) end end |
#reannounce(hashes = 'all') ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/qbittorrent/web_api/torrent.rb', line 31 def reannounce(hashes = 'all') send_request("/torrents/reannounce") do |api_url| api_client.post(api_url, form: { hashes: hashes }) end end |