Batch torrents are torrents that have multiple files bundled within one torrent file. RealDebrid does support these, but it is difficult to get them to work. The main flow requires setting a specific combination in RealDebrid to allow for link generation. However, this is not intuitive to users and is bad API design on RealDebrid's part. Ferrite's implementation presents users with all the possible files from batches (duplicates deleted) and selects the user-chosen file to download. That way, only the user chosen file is presented to play on an external video player. This still needs work for optimization purposes, but this commit does produce a working build. Signed-off-by: kingbri <bdashore3@gmail.com>
46 lines
1.2 KiB
Swift
46 lines
1.2 KiB
Swift
//
|
|
// ContentView.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 7/1/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ContentView: View {
|
|
@EnvironmentObject var scrapingModel: ScrapingViewModel
|
|
@EnvironmentObject var debridManager: DebridManager
|
|
|
|
@AppStorage("RealDebrid.Enabled") var realDebridEnabled = false
|
|
|
|
var body: some View {
|
|
NavView {
|
|
VStack {
|
|
SearchResultsView()
|
|
}
|
|
.searchable(text: $scrapingModel.searchText)
|
|
.onSubmit(of: .search) {
|
|
Task {
|
|
for source in scrapingModel.sources {
|
|
guard let html = await scrapingModel.fetchWebsiteHtml(source: source) else {
|
|
continue
|
|
}
|
|
|
|
await scrapingModel.scrapeWebsite(source: source, html: html)
|
|
|
|
if realDebridEnabled {
|
|
await debridManager.populateDebridHashes(scrapingModel.searchResults)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("Search")
|
|
}
|
|
}
|
|
}
|
|
|
|
struct ContentView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
ContentView()
|
|
}
|
|
}
|