Deluge

1.0.2

A Combine powered Deluge JSON-RPC API client.
jameshurst/Deluge-Swift

What's New

2020-10-30T19:48:15Z

Deluge

A Combine powered Deluge JSON-RPC API client.

Usage

import Combine
import Deluge

var cancellables = Set<AnyCancellable>()

let client = Deluge(baseURL: URL(string: "https://my.torrent.server")!, password: "secret!")
client.request(.authenticate)
    .sink(receiveCompletion: { _ in }, receiveValue: { _ in
        print("Authenticated!")
    })
    .store(in: &cancellables)

Requests

A Request describes an RPC method, its arguments, and a function to transform the API response in to a new representation.

There are many requests already built-in. To see the available requests you can can take a look at the Requests directory or browse through the autocomplete menu when typing client.request(..

let addMagnetURL = Request<String>(
    method: "core.add_torrent_magnet",
    args: [magnetURL, [String: Any]()],
    transform: { response in
        guard let hash = response["result"] as? String else { return .failure(.unexpectedResponse) }
        return .success(hash)
    }
)

Installation

Xcode 11+

  • Select File > Swift Packages > Add Package Dependency...
  • Enter the package repository URL: https://github.com/jameshurst/Deluge-Swift.git
  • Confirm the version and let Xcode resolve the package

License

This library is released under the MIT license. See LICENSE for details.

Description

  • Swift Tools 5.2.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Nov 21 2024 04:31:53 GMT-1000 (Hawaii-Aleutian Standard Time)