RealDebrid saves a user's unrestricted links and "torrents" (magnet links in this case). Add the ability to see and queue a user's RD library in Ferrite itself. This required a further abstraction of the debrid manager to allow for more types other than search results to be passed to various functions. Deleting an item from RD's cloud list deletes the item from RD as well. NOTE: This does not track download progress, but it does show if a magnet is currently being downloaded or not. Signed-off-by: kingbri <bdashore3@proton.me>
51 lines
1.8 KiB
Swift
51 lines
1.8 KiB
Swift
//
|
|
// String.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 8/31/22.
|
|
//
|
|
//
|
|
|
|
import Foundation
|
|
|
|
extension String {
|
|
// From https://www.hackingwithswift.com/example-code/strings/how-to-capitalize-the-first-letter-of-a-string
|
|
func capitalizingFirstLetter() -> String {
|
|
return prefix(1).capitalized + dropFirst()
|
|
}
|
|
|
|
mutating func capitalizeFirstLetter() {
|
|
self = self.capitalizingFirstLetter()
|
|
}
|
|
|
|
// From https://stackoverflow.com/a/59307884
|
|
private func compare(toVersion targetVersion: String) -> ComparisonResult {
|
|
let versionDelimiter = "."
|
|
var result: ComparisonResult = .orderedSame
|
|
var versionComponents = components(separatedBy: versionDelimiter)
|
|
var targetComponents = targetVersion.components(separatedBy: versionDelimiter)
|
|
|
|
while versionComponents.count < targetComponents.count {
|
|
versionComponents.append("0")
|
|
}
|
|
|
|
while targetComponents.count < versionComponents.count {
|
|
targetComponents.append("0")
|
|
}
|
|
|
|
for (version, target) in zip(versionComponents, targetComponents) {
|
|
result = version.compare(target, options: .numeric)
|
|
if result != .orderedSame {
|
|
break
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
static func == (lhs: String, rhs: String) -> Bool { lhs.compare(toVersion: rhs) == .orderedSame }
|
|
static func < (lhs: String, rhs: String) -> Bool { lhs.compare(toVersion: rhs) == .orderedAscending }
|
|
static func <= (lhs: String, rhs: String) -> Bool { lhs.compare(toVersion: rhs) != .orderedDescending }
|
|
static func > (lhs: String, rhs: String) -> Bool { lhs.compare(toVersion: rhs) == .orderedDescending }
|
|
static func >= (lhs: String, rhs: String) -> Bool { lhs.compare(toVersion: rhs) != .orderedAscending }
|
|
}
|