mirror of
https://github.com/Ferrite-iOS/Ferrite.git
synced 2026-05-16 15:02:05 +00:00
Premiumize: Fix DDL fetching and debrid IA handling
Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
parent
46e0687bd7
commit
13a40a237a
2 changed files with 46 additions and 39 deletions
|
|
@ -45,11 +45,9 @@ public extension Premiumize {
|
||||||
let path: String
|
let path: String
|
||||||
let size: Int
|
let size: Int
|
||||||
let link: String
|
let link: String
|
||||||
let streamLink: String
|
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case path, size, link
|
case path, size, link
|
||||||
case streamLink = "stream_link"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,6 @@ public class DebridManager: ObservableObject {
|
||||||
|
|
||||||
// Common function to populate hashes for debrid services
|
// Common function to populate hashes for debrid services
|
||||||
public func populateDebridIA(_ resultMagnets: [Magnet]) async {
|
public func populateDebridIA(_ resultMagnets: [Magnet]) async {
|
||||||
do {
|
|
||||||
let now = Date()
|
let now = Date()
|
||||||
|
|
||||||
// If a hash isn't found in the IA, update it
|
// If a hash isn't found in the IA, update it
|
||||||
|
|
@ -225,18 +224,28 @@ public class DebridManager: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't exit the function if the API fetch errors
|
||||||
if !sendMagnets.isEmpty {
|
if !sendMagnets.isEmpty {
|
||||||
if enabledDebrids.contains(.realDebrid) {
|
if enabledDebrids.contains(.realDebrid) {
|
||||||
|
do {
|
||||||
let fetchedRealDebridIA = try await realDebrid.instantAvailability(magnets: sendMagnets)
|
let fetchedRealDebridIA = try await realDebrid.instantAvailability(magnets: sendMagnets)
|
||||||
realDebridIAValues += fetchedRealDebridIA
|
realDebridIAValues += fetchedRealDebridIA
|
||||||
|
} catch {
|
||||||
|
await sendDebridError(error, prefix: "RealDebrid IA fetch error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if enabledDebrids.contains(.allDebrid) {
|
if enabledDebrids.contains(.allDebrid) {
|
||||||
|
do {
|
||||||
let fetchedAllDebridIA = try await allDebrid.instantAvailability(magnets: sendMagnets)
|
let fetchedAllDebridIA = try await allDebrid.instantAvailability(magnets: sendMagnets)
|
||||||
allDebridIAValues += fetchedAllDebridIA
|
allDebridIAValues += fetchedAllDebridIA
|
||||||
|
} catch {
|
||||||
|
await sendDebridError(error, prefix: "AllDebrid IA fetch error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if enabledDebrids.contains(.premiumize) {
|
if enabledDebrids.contains(.premiumize) {
|
||||||
|
do {
|
||||||
// Only strip magnets that don't have an associated link for PM
|
// Only strip magnets that don't have an associated link for PM
|
||||||
let strippedResultMagnets: [Magnet] = resultMagnets.compactMap {
|
let strippedResultMagnets: [Magnet] = resultMagnets.compactMap {
|
||||||
if let magnetLink = $0.link {
|
if let magnetLink = $0.link {
|
||||||
|
|
@ -254,10 +263,10 @@ public class DebridManager: ObservableObject {
|
||||||
|
|
||||||
premiumizeIAValues += tempIA
|
premiumizeIAValues += tempIA
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
await sendDebridError(error, prefix: "Hash population error")
|
await sendDebridError(error, prefix: "Premiumize IA fetch error")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue