Adds support for website APIs both complex and simple. This commit only supports GET requests to APIs. POST request support can be added on request. Client IDs and secrets are also supported. They can be added via source settings or automatically set by a website endpoint. Also fetch sources for scraping using the backgroundContext and remove some functions from using the main actor. Signed-off-by: kingbri <bdashore3@gmail.com>
59 lines
1.5 KiB
Swift
59 lines
1.5 KiB
Swift
//
|
|
// SearchResultRDView.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 7/26/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct SearchResultRDView: View {
|
|
@EnvironmentObject var debridManager: DebridManager
|
|
|
|
@AppStorage("RealDebrid.Enabled") var realDebridEnabled = false
|
|
|
|
var result: SearchResult
|
|
|
|
var body: some View {
|
|
HStack {
|
|
Text(result.source)
|
|
|
|
Spacer()
|
|
|
|
if let seeders = result.seeders {
|
|
Text("S: \(seeders)")
|
|
}
|
|
|
|
if let leechers = result.leechers {
|
|
Text("L: \(leechers)")
|
|
}
|
|
|
|
if let size = result.size {
|
|
Text(size)
|
|
}
|
|
|
|
if realDebridEnabled {
|
|
Text("RD")
|
|
.fontWeight(.bold)
|
|
.padding(2)
|
|
.background {
|
|
switch debridManager.matchSearchResult(result: result) {
|
|
case .full:
|
|
Color.green
|
|
.cornerRadius(4)
|
|
.opacity(0.5)
|
|
case .partial:
|
|
Color.orange
|
|
.cornerRadius(4)
|
|
.opacity(0.5)
|
|
case .none:
|
|
Color.red
|
|
.cornerRadius(4)
|
|
.opacity(0.5)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.font(.caption)
|
|
}
|
|
}
|