-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 62fe1fd
Showing
39 changed files
with
1,642 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# .github/workflows/documentation.yml | ||
name: Documentation | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Generate Documentation | ||
uses: SwiftDocOrg/swift-doc@master | ||
with: | ||
inputs: "./Sources" | ||
module-name: "qBittorrentKit" | ||
output: "./.build/documentation" | ||
- name: Upload Documentation to Wiki | ||
uses: SwiftDocOrg/github-wiki-publish-action@v1 | ||
with: | ||
path: "./.build/documentation" | ||
env: | ||
GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
.DS_Store | ||
|
||
# qBittorrent Docker | ||
Resources/config/qBittorrent/rss/ | ||
Resources/config/qBittorrent/GeoDB/ | ||
Resources/config/qBittorrent/qBittorrent-data.conf | ||
Resources/config/qBittorrent/lockfile | ||
Resources/config/qBittorrent/BT_backup/ | ||
Resources/config/qBittorrent/logs/ | ||
|
||
## User settings | ||
xcuserdata/ | ||
|
||
## App packaging | ||
*.ipa | ||
*.dSYM.zip | ||
*.dSYM | ||
|
||
# Swift Package Manager | ||
Packages/ | ||
Package.pins | ||
Package.resolved | ||
*.xcodeproj | ||
.swiftpm | ||
|
||
.build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Adam Borbas | ||
|
||
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: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// swift-tools-version:5.3 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "qBittorrent", | ||
platforms: [ | ||
.macOS(.v10_15), | ||
.iOS(.v13) | ||
], | ||
products: [ | ||
.library( | ||
name: "qBittorrent", | ||
targets: ["qBittorrent"]), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.4.0")), | ||
], | ||
targets: [ | ||
.target( | ||
name: "qBittorrent", | ||
dependencies: ["Alamofire"], | ||
exclude: ["Resources"]), | ||
.testTarget( | ||
name: "UnitTests", | ||
dependencies: ["qBittorrent"]), | ||
.testTarget( | ||
name: "IntegrationTests", | ||
dependencies: ["qBittorrent"], | ||
resources: [ | ||
.process("Resources") | ||
]), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# qBittorrentKit | ||
|
||
qBittorrentKit is a light-weight [qBittorrent](https://www.qbittorrent.org) client for iOS/macOS. | ||
|
||
## Getting started | ||
|
||
1. Initialize the client | ||
|
||
```swift | ||
let qBittorrent = qBittorrentWebAPI(scheme: .http, | ||
host: "myservice.local", | ||
authentication: .bypassed) | ||
``` | ||
|
||
2. Call any of the supported features | ||
|
||
```swift | ||
qBittorrent.sink { completion in | ||
print("torrents received") | ||
} receiveValue: { torrents in | ||
print(torrents) | ||
} | ||
``` | ||
|
||
## Features | ||
|
||
[WebAPI methods of qBittorrent](https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-v3.2.0-v4.0.4)) | ||
|
||
### Torrent properties | ||
|
||
- List torrents | ||
- Get torrent generic parameters | ||
- Set file priority | ||
- Get torrent content | ||
|
||
### Manage torrents | ||
|
||
- Add torrent | ||
- Delete torrent | ||
|
||
### qBittorent config | ||
|
||
- List categories | ||
- Get app preferences | ||
- Get webAPIVersion | ||
|
||
## Install via SPM | ||
|
||
1. Using Xcode go to File > Add Packages... | ||
1. Paste the project URL: `https://github.com/adborbas/qBittorrentKit` | ||
1. Click on next and select the project target | ||
|
||
## Running tests | ||
|
||
### Unit tests | ||
|
||
1. Just run the test target. | ||
|
||
### Integration tests | ||
|
||
1. Have [qBittorrent](https://www.qbittorrent.org/download.php) installed somewhere. | ||
1. Add your qBittorent credentials to `Tests/qBittorentTests/SECRET_SERVICE.swift`. Exmaple: | ||
|
||
```swift | ||
import Foundation | ||
import qBittorrent | ||
|
||
extension qBittorrentWebAPITests { | ||
func givenService() -> qBittorrentWebAPI { | ||
return qBittorrentWebAPI(scheme: .http, | ||
host: "<YOUR-qBittorent-ADDRESS>", | ||
authentication: .basicAuth(BasicAuthCredentials(username: "<USERNAME>", password: "<PASSWORD>"))) | ||
} | ||
} | ||
``` | ||
|
||
3. Start tests in `qBittorrentWebAPITests`. | ||
4. ⚠️ Note that that some tests require a torrent added to qBittorrent. To make these tests reproducible a `test.torrent` torrent will be added and then removed from the client. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"category1": { | ||
"save_path": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
[AutoRun] | ||
enabled=false | ||
program= | ||
|
||
[BitTorrent] | ||
Session\DefaultSavePath=/downloads/ | ||
Session\Port=6881 | ||
Session\QueueingSystemEnabled=true | ||
Session\TempPath=/downloads/incomplete/ | ||
|
||
[Core] | ||
AutoDeleteAddedTorrentFile=Never | ||
|
||
[LegalNotice] | ||
Accepted=true | ||
|
||
[Meta] | ||
MigrationVersion=3 | ||
|
||
[Network] | ||
Cookies=@Invalid() | ||
PortForwardingEnabled=false | ||
Proxy\OnlyForTorrents=false | ||
|
||
[Preferences] | ||
Advanced\RecheckOnCompletion=false | ||
Advanced\trackerPort=9000 | ||
Connection\PortRangeMin=6881 | ||
Connection\ResolvePeerCountries=true | ||
Connection\UPnP=false | ||
Downloads\SavePath=/downloads/ | ||
Downloads\TempPath=/downloads/incomplete/ | ||
DynDNS\DomainName=changeme.dyndns.org | ||
DynDNS\Enabled=false | ||
DynDNS\Password= | ||
DynDNS\Service=DynDNS | ||
DynDNS\Username= | ||
General\Locale= | ||
MailNotification\email= | ||
MailNotification\enabled=false | ||
MailNotification\password= | ||
MailNotification\req_auth=true | ||
MailNotification\req_ssl=false | ||
MailNotification\sender=qBittorrent_notification@example.com | ||
MailNotification\smtp_server=smtp.changeme.com | ||
MailNotification\username= | ||
WebUI\Address=* | ||
WebUI\AlternativeUIEnabled=false | ||
WebUI\AuthSubnetWhitelist=@Invalid() | ||
WebUI\AuthSubnetWhitelistEnabled=false | ||
WebUI\BanDuration=3600 | ||
WebUI\CSRFProtection=true | ||
WebUI\ClickjackingProtection=true | ||
WebUI\CustomHTTPHeaders= | ||
WebUI\CustomHTTPHeadersEnabled=false | ||
WebUI\HTTPS\CertificatePath= | ||
WebUI\HTTPS\Enabled=false | ||
WebUI\HTTPS\KeyPath= | ||
WebUI\HostHeaderValidation=true | ||
WebUI\LocalHostAuth=false | ||
WebUI\MaxAuthenticationFailCount=5 | ||
WebUI\Port=24560 | ||
WebUI\ReverseProxySupportEnabled=false | ||
WebUI\RootFolder= | ||
WebUI\SecureCookie=true | ||
WebUI\ServerDomains=* | ||
WebUI\SessionTimeout=3600 | ||
WebUI\TrustedReverseProxiesList= | ||
WebUI\UseUPnP=true | ||
WebUI\Username=admin | ||
|
||
[RSS] | ||
AutoDownloader\DownloadRepacks=true | ||
AutoDownloader\SmartEpisodeFilter=s(\\d+)e(\\d+), (\\d+)x(\\d+), "(\\d{4}[.\\-]\\d{1,2}[.\\-]\\d{1,2})", "(\\d{1,2}[.\\-]\\d{1,2}[.\\-]\\d{4})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: "3.8" | ||
|
||
services: | ||
qbittorrent: | ||
image: linuxserver/qbittorrent | ||
container_name: qbittorrent | ||
environment: | ||
- PUID=1000 | ||
- PGID=1000 | ||
- UMASK_SET=022 | ||
- WEBUI_PORT=24560 | ||
volumes: | ||
- ./config:/config | ||
ports: | ||
- 6881:6881 | ||
- 6881:6881/udp | ||
- 24560:24560 |
43 changes: 43 additions & 0 deletions
43
Sources/qBittorrent/Public/Model/AddTorrentConfiguration.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// AddTorrentConfiguration.swift | ||
// | ||
// | ||
// Created by Adam Borbas on 2021. 10. 07.. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Configuration for adding a new torrent. | ||
public struct AddTorrentConfiguration { | ||
|
||
/// Torrent Management | ||
public enum Management { | ||
/// Automatic torrent management with category. | ||
case auto(category: String) | ||
|
||
/// Manual torrent management with save path. | ||
case manual(savePath: String) | ||
} | ||
|
||
/// Torrent Management. | ||
public let management: Management | ||
|
||
/// Add torrents in the paused state. | ||
public let paused: Bool | ||
|
||
/// Enable sequential download | ||
public let sequentialDownload: Bool | ||
|
||
/// Prioritize download first last piece | ||
public let firstLastPiecePrio: Bool | ||
|
||
public init(management: Management = .manual(savePath: ""), | ||
paused: Bool = false, | ||
sequentialDownload: Bool = false, | ||
firstLastPiecePrio: Bool = false) { | ||
self.management = management | ||
self.paused = paused | ||
self.sequentialDownload = sequentialDownload | ||
self.firstLastPiecePrio = firstLastPiecePrio | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// AppPreferences.swift | ||
// | ||
// | ||
// Created by Adam Borbas on 2021. 10. 07.. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Application preferences. | ||
public struct AppPreferences: Codable { | ||
enum CodingKeys: String, CodingKey { | ||
case isAutoTorrentManagementEnabled = "auto_tmm_enabled" | ||
case isStartPausedEnabled = "start_paused_enabled" | ||
case defaultSavePath = "save_path" | ||
|
||
} | ||
|
||
/// `true` if Automatic Torrent Management is enabled by default. | ||
public let isAutoTorrentManagementEnabled: Bool | ||
|
||
/// `true` if torrents should be added in a Paused state | ||
public let isStartPausedEnabled: Bool | ||
|
||
/// Default save path for torrents, separated by slashes. | ||
public let defaultSavePath: String | ||
} |
Oops, something went wrong.