Debrid: Add source to all models

Gives an ID of where the struct came from.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2024-06-03 16:24:07 -04:00
parent f902142fee
commit c641fdf300
4 changed files with 12 additions and 3 deletions

View file

@ -169,6 +169,7 @@ public class AllDebrid: PollingDebridSource {
return DebridIA( return DebridIA(
magnet: Magnet(hash: magnetResp.hash, link: magnetResp.magnet), magnet: Magnet(hash: magnetResp.hash, link: magnetResp.magnet),
source: self.id,
expiryTimeStamp: Date().timeIntervalSince1970 + 300, expiryTimeStamp: Date().timeIntervalSince1970 + 300,
files: files files: files
) )
@ -274,6 +275,7 @@ public class AllDebrid: PollingDebridSource {
let torrents = rawResponse.magnets.map { magnetResponse in let torrents = rawResponse.magnets.map { magnetResponse in
DebridCloudTorrent( DebridCloudTorrent(
torrentId: String(magnetResponse.id), torrentId: String(magnetResponse.id),
source: self.id,
fileName: magnetResponse.filename, fileName: magnetResponse.filename,
status: magnetResponse.status, status: magnetResponse.status,
hash: magnetResponse.hash, hash: magnetResponse.hash,
@ -306,7 +308,7 @@ public class AllDebrid: PollingDebridSource {
// The link is also the ID // The link is also the ID
let downloads = rawResponse.links.map { link in let downloads = rawResponse.links.map { link in
DebridCloudDownload( DebridCloudDownload(
downloadId: link.link, fileName: link.filename, link: link.link downloadId: link.link, source: self.id, fileName: link.filename, link: link.link
) )
} }

View file

@ -190,6 +190,7 @@ public class Premiumize: OAuthDebridSource {
return DebridIA( return DebridIA(
magnet: magnet, magnet: magnet,
source: self.id,
expiryTimeStamp: Date().timeIntervalSince1970 + 300, expiryTimeStamp: Date().timeIntervalSince1970 + 300,
files: files files: files
) )
@ -294,7 +295,7 @@ public class Premiumize: OAuthDebridSource {
// The "link" is the ID for Premiumize // The "link" is the ID for Premiumize
let downloads = rawResponse.files.map { file in let downloads = rawResponse.files.map { file in
DebridCloudDownload(downloadId: file.id, fileName: file.name, link: file.id) DebridCloudDownload(downloadId: file.id, source: self.id, fileName: file.name, link: file.id)
} }
return downloads return downloads

View file

@ -272,6 +272,7 @@ public class RealDebrid: PollingDebridSource {
availableHashes.append( availableHashes.append(
DebridIA( DebridIA(
magnet: Magnet(hash: hash, link: nil), magnet: Magnet(hash: hash, link: nil),
source: self.id,
expiryTimeStamp: Date().timeIntervalSince1970 + 300, expiryTimeStamp: Date().timeIntervalSince1970 + 300,
files: files files: files
) )
@ -280,6 +281,7 @@ public class RealDebrid: PollingDebridSource {
availableHashes.append( availableHashes.append(
DebridIA( DebridIA(
magnet: Magnet(hash: hash, link: nil), magnet: Magnet(hash: hash, link: nil),
source: self.id,
expiryTimeStamp: Date().timeIntervalSince1970 + 300, expiryTimeStamp: Date().timeIntervalSince1970 + 300,
files: [] files: []
) )
@ -395,6 +397,7 @@ public class RealDebrid: PollingDebridSource {
let torrents = rawResponse.map { response in let torrents = rawResponse.map { response in
DebridCloudTorrent( DebridCloudTorrent(
torrentId: response.id, torrentId: response.id,
source: self.id,
fileName: response.filename, fileName: response.filename,
status: response.status, status: response.status,
hash: response.hash, hash: response.hash,
@ -420,7 +423,7 @@ public class RealDebrid: PollingDebridSource {
let data = try await performRequest(request: &request, requestName: #function) let data = try await performRequest(request: &request, requestName: #function)
let rawResponse = try jsonDecoder.decode([UserDownloadsResponse].self, from: data) let rawResponse = try jsonDecoder.decode([UserDownloadsResponse].self, from: data)
let downloads = rawResponse.map { response in let downloads = rawResponse.map { response in
DebridCloudDownload(downloadId: response.id, fileName: response.filename, link: response.download) DebridCloudDownload(downloadId: response.id, source: self.id, fileName: response.filename, link: response.download)
} }
return downloads return downloads

View file

@ -9,6 +9,7 @@ import Foundation
public struct DebridIA: Hashable, Sendable { public struct DebridIA: Hashable, Sendable {
let magnet: Magnet let magnet: Magnet
let source: String
let expiryTimeStamp: Double let expiryTimeStamp: Double
var files: [DebridIAFile] var files: [DebridIAFile]
} }
@ -29,12 +30,14 @@ public struct DebridIAFile: Hashable, Sendable {
public struct DebridCloudDownload: Hashable, Sendable { public struct DebridCloudDownload: Hashable, Sendable {
let downloadId: String let downloadId: String
let source: String
let fileName: String let fileName: String
let link: String let link: String
} }
public struct DebridCloudTorrent: Hashable, Sendable { public struct DebridCloudTorrent: Hashable, Sendable {
let torrentId: String let torrentId: String
let source: String
let fileName: String let fileName: String
let status: String let status: String
let hash: String let hash: String