Debrid: Add description field and cleanup

Allow for overriding of the default description in the settings UI.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2024-06-14 00:02:44 -04:00
parent 0d39fd481a
commit c5a08cc725
5 changed files with 24 additions and 7 deletions

View file

@ -14,9 +14,12 @@ import Foundation
// Delete torrent (website URL, not API URL): /cloud/remove/\(torrentId)
class OffCloud: DebridSource, ObservableObject {
var id: String = "OffCloud"
var abbreviation: String = "OC"
var website: String = "https://offcloud.com"
let id = "OffCloud"
let abbreviation = "OC"
let website = "https://offcloud.com"
let description = "OffCloud is a debrid service that is used for downloads and media playback. " +
"You must pay to access this service. \n\n" +
"This service does not inform if a torrent is a batch before downloading."
@Published var authProcessing: Bool = false
var isLoggedIn: Bool {

View file

@ -11,6 +11,8 @@ class Premiumize: OAuthDebridSource, ObservableObject {
let id = "Premiumize"
let abbreviation = "PM"
let website = "https://premiumize.me"
let description = "Premiumize is a debrid service that is used for downloads and media playback with seeding. " +
"You must pay to access the service."
@Published var authProcessing: Bool = false
var isLoggedIn: Bool {

View file

@ -14,9 +14,12 @@ import Foundation
// Unrestrict: /torrents/requestdl
class TorBox: DebridSource, ObservableObject {
var id: String = "TorBox"
var abbreviation: String = "TB"
var website: String = "https://torbox.app"
let id = "TorBox"
let abbreviation = "TB"
let website = "https://torbox.app"
let description = "TorBox is a debrid service that is used for downloads and media playback with seeding. " +
"Both free and paid plans are available. \n\n" +
"This service does not inform if a torrent is a batch before downloading."
@Published var authProcessing: Bool = false
var isLoggedIn: Bool {

View file

@ -13,6 +13,7 @@ protocol DebridSource: AnyObservableObject {
var id: String { get }
var abbreviation: String { get }
var website: String { get }
var description: String? { get }
// Auth variables
var authProcessing: Bool { get set }
@ -54,6 +55,12 @@ protocol DebridSource: AnyObservableObject {
func deleteTorrent(torrentId: String?) async throws
}
extension DebridSource {
var description: String? {
nil
}
}
protocol PollingDebridSource: DebridSource {
// Task reference for polling
var authTask: Task<Void, Error>? { get set }

View file

@ -18,7 +18,9 @@ struct SettingsDebridInfoView: View {
List {
Section(header: InlineHeader("Description")) {
VStack(alignment: .leading, spacing: 10) {
Text("\(debridSource.id) is a debrid service that is used for unrestricting downloads and media playback. You must pay to access the service.")
Text(debridSource.description ??
"\(debridSource.id) is a debrid service that is used for downloads and media playback. You must pay to access the service."
)
Link("Website", destination: URL(string: debridSource.website) ?? URL(string: "https://kingbri.dev/ferrite")!)
}