feat: ajout du ratio, upload speed, etc dans les activités
This commit is contained in:
1 parent
9b4dc4f782
commit
71961eb998
7 files changed
+146
-53
No files matched your search
@@ -41,7 +41,10 @@ export interface TorrentInfo {
|
||||
progress : number
|
||||
size : number
|
||||
downloaded: number
|
||||
uploaded : number
|
||||
ratio : number
|
||||
speed : number
|
||||
upspeed : number
|
||||
eta : number
|
||||
save_path : string
|
||||
category : string
|
||||
|
||||
@@ -93,7 +93,10 @@ const QB: TorrentClientDriver = {
|
||||
progress : Math.round(t.progress * 100),
|
||||
size : t.size,
|
||||
downloaded: t.downloaded,
|
||||
uploaded : t.uploaded ?? 0,
|
||||
ratio : Math.round((t.ratio ?? 0) * 100) / 100,
|
||||
speed : t.dlspeed,
|
||||
upspeed : t.upspeed ?? 0,
|
||||
eta : t.eta ?? -1,
|
||||
save_path : t.save_path,
|
||||
category : t.category ?? '',
|
||||
|
||||
@@ -178,11 +178,13 @@ const RT: TorrentClientDriver = {
|
||||
'd.complete',
|
||||
'd.size_bytes',
|
||||
'd.bytes_done',
|
||||
'd.up.total', // total uploadé
|
||||
'd.ratio', // ratio x1000
|
||||
'd.down.rate',
|
||||
'd.up.rate',
|
||||
'd.left_bytes',
|
||||
'd.down.rate',
|
||||
'd.directory',
|
||||
'd.custom1', // label rTorrent
|
||||
'd.custom1',
|
||||
]
|
||||
|
||||
const rows = await d_multicall(config, 'main', methods)
|
||||
@@ -190,10 +192,11 @@ const RT: TorrentClientDriver = {
|
||||
return rows
|
||||
.map(r => {
|
||||
const [hash, name, isOpen, isActive, isChecking, isComplete,
|
||||
size, downloaded, speed, leftBytes, , directory, label] = r
|
||||
size, downloaded, uploadedTotal, ratioRaw,
|
||||
dlSpeed, ulSpeed, leftBytes, directory, label] = r
|
||||
|
||||
const progress = size > 0 ? Math.min(100, Math.round(((size - leftBytes) / size) * 100)) : 0
|
||||
const eta = speed > 0 && leftBytes > 0 ? Math.round(leftBytes / speed) : -1
|
||||
const eta = Number(dlSpeed) > 0 && Number(leftBytes) > 0 ? Math.round(Number(leftBytes) / Number(dlSpeed)) : -1
|
||||
|
||||
return {
|
||||
hash : String(hash).toLowerCase(),
|
||||
@@ -202,7 +205,10 @@ const RT: TorrentClientDriver = {
|
||||
progress,
|
||||
size : Number(size),
|
||||
downloaded: Number(downloaded),
|
||||
speed : Number(speed),
|
||||
uploaded : Number(uploadedTotal ?? 0),
|
||||
ratio : Math.round((Number(ratioRaw ?? 0) / 1000) * 100) / 100,
|
||||
speed : Number(dlSpeed),
|
||||
upspeed : Number(ulSpeed ?? 0),
|
||||
eta,
|
||||
save_path : String(directory),
|
||||
category : String(label ?? ''),
|
||||
|
||||
@@ -108,11 +108,6 @@ const DS: TorrentClientDriver = {
|
||||
const tasks: any[] = data?.tasks ?? []
|
||||
|
||||
return tasks
|
||||
.filter(t => {
|
||||
if (!category) return true
|
||||
// Synology n'a pas de labels natifs — on filtre par destination si elle contient la catégorie
|
||||
return (t.additional?.detail?.destination as string)?.includes(String(category))
|
||||
})
|
||||
.map(t => {
|
||||
const transfer = t.additional?.transfer ?? {}
|
||||
const size = t.size ?? 0
|
||||
@@ -124,10 +119,13 @@ const DS: TorrentClientDriver = {
|
||||
progress : size > 0 ? Math.min(100, Math.round((dl / size) * 100)) : 0,
|
||||
size,
|
||||
downloaded: dl,
|
||||
uploaded : transfer.size_uploaded ?? 0,
|
||||
ratio : size > 0 ? Math.round(((transfer.size_uploaded ?? 0) / size) * 100) / 100 : 0,
|
||||
speed : transfer.speed_download ?? 0,
|
||||
upspeed : transfer.speed_upload ?? 0,
|
||||
eta : -1,
|
||||
save_path : t.additional?.detail?.destination ?? '',
|
||||
category : '',
|
||||
category : category ?? '',
|
||||
} satisfies TorrentInfo
|
||||
})
|
||||
},
|
||||
|
||||
@@ -94,7 +94,8 @@ const TR: TorrentClientDriver = {
|
||||
async list(config, category) {
|
||||
const fields = [
|
||||
'hashString', 'name', 'status', 'percentDone', 'totalSize',
|
||||
'downloadedEver', 'rateDownload', 'eta', 'downloadDir', 'labels',
|
||||
'downloadedEver', 'uploadedEver', 'uploadRatio',
|
||||
'rateDownload', 'rateUpload', 'eta', 'downloadDir', 'labels',
|
||||
]
|
||||
const data = await trRequest(config, 'torrent-get', { fields })
|
||||
const torrents: any[] = data.arguments?.torrents ?? []
|
||||
@@ -111,7 +112,10 @@ const TR: TorrentClientDriver = {
|
||||
progress : Math.round(t.percentDone * 100),
|
||||
size : t.totalSize,
|
||||
downloaded: t.downloadedEver,
|
||||
uploaded : t.uploadedEver ?? 0,
|
||||
ratio : Math.round((t.uploadRatio ?? 0) * 100) / 100,
|
||||
speed : t.rateDownload,
|
||||
upspeed : t.rateUpload ?? 0,
|
||||
eta : t.eta ?? -1,
|
||||
save_path : t.downloadDir,
|
||||
category : t.labels?.[0] ?? '',
|
||||
|
||||
@@ -62,7 +62,7 @@ function mapTorrent(t: any[]): TorrentInfo {
|
||||
// [hash, status, name, size, progress, downloaded, uploaded, ratio,
|
||||
// ul_speed, dl_speed, eta, label, peers_connected, peers_swarm,
|
||||
// seeds_connected, seeds_swarm, availability, queue_order, remaining]
|
||||
const [hash, status, name, size, progress, downloaded, , , , dlSpeed, eta, label] = t
|
||||
const [hash, status, name, size, progress, downloaded, uploaded, ratio, ulSpeed, dlSpeed, eta, label] = t
|
||||
return {
|
||||
hash : hash.toLowerCase(),
|
||||
name,
|
||||
@@ -70,9 +70,12 @@ function mapTorrent(t: any[]): TorrentInfo {
|
||||
progress : Math.min(100, Math.round(progress / 10)),
|
||||
size,
|
||||
downloaded,
|
||||
uploaded : uploaded ?? 0,
|
||||
ratio : Math.round(((ratio ?? 0) / 1000) * 100) / 100, // uTorrent ratio est x1000
|
||||
speed : dlSpeed ?? 0,
|
||||
upspeed : ulSpeed ?? 0,
|
||||
eta : eta ?? -1,
|
||||
save_path : '', // récupéré séparément via torrent properties si besoin
|
||||
save_path : '',
|
||||
category : label ?? '',
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user