Tree: Fix various bugs

- AllDebrid: Don't throw an empty error if cloud downloads/torrents
is empty
- Fix history not saving with the proper URLs
- Fix the HTMLParser looking at the incorrect term for seedLeech

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2024-06-13 23:09:39 -04:00
parent 80e966512a
commit 5223c60acd
3 changed files with 10 additions and 26 deletions

View file

@ -307,10 +307,6 @@ class AllDebrid: PollingDebridSource, ObservableObject {
let data = try await performRequest(request: &request, requestName: #function)
let rawResponse = try jsonDecoder.decode(ADResponse<MagnetStatusResponse>.self, from: data).data
if rawResponse.magnets.isEmpty {
throw DebridError.EmptyData
}
cloudTorrents = rawResponse.magnets.map { magnetResponse in
DebridCloudTorrent(
torrentId: String(magnetResponse.id),
@ -342,10 +338,6 @@ class AllDebrid: PollingDebridSource, ObservableObject {
let data = try await performRequest(request: &request, requestName: #function)
let rawResponse = try jsonDecoder.decode(ADResponse<SavedLinksResponse>.self, from: data).data
if rawResponse.links.isEmpty {
throw DebridError.EmptyData
}
// The link is also the ID
cloudDownloads = rawResponse.links.map { link in
DebridCloudDownload(

View file

@ -920,7 +920,7 @@ class ScrapingViewModel: ObservableObject {
)
}
if let leecherQuery = seederLeecher.seeders {
if let leecherQuery = seederLeecher.leechers {
leechers = try? runHtmlComplexQuery(
row: row,
query: leecherQuery,

View file

@ -28,15 +28,15 @@ struct SearchResultButtonView: View {
navModel.selectedTitle = result.title ?? ""
navModel.resultFromCloud = false
var historyEntry = HistoryEntryJson(
name: result.title,
source: result.source
)
switch debridIAStatus ?? debridManager.matchMagnetHash(result.magnet) {
case .full:
if debridManager.selectDebridResult(magnet: result.magnet) {
debridManager.currentDebridTask = Task {
let historyEntry = HistoryEntryJson(
name: result.title,
url: debridManager.downloadUrl,
source: result.source
)
await debridManager.fetchDebridDownload(magnet: result.magnet)
// Bump to batch
@ -48,6 +48,7 @@ struct SearchResultButtonView: View {
}
if !debridManager.downloadUrl.isEmpty {
historyEntry.url = debridManager.downloadUrl
PersistenceController.shared.createHistory(historyEntry, performSave: true)
pluginManager.runDefaultAction(
@ -63,21 +64,12 @@ struct SearchResultButtonView: View {
}
case .partial:
if debridManager.selectDebridResult(magnet: result.magnet) {
navModel.selectedHistoryInfo = HistoryEntryJson(
name: result.title,
source: result.source
)
navModel.selectedHistoryInfo = historyEntry
navModel.currentChoiceSheet = .batch
}
case .none:
PersistenceController.shared.createHistory(
HistoryEntryJson(
name: result.title,
url: result.magnet.link,
source: result.source
),
performSave: true
)
historyEntry.url = result.magnet.link
PersistenceController.shared.createHistory(historyEntry, performSave: true)
pluginManager.runDefaultAction(
urlString: result.magnet.link,