API: add a "dateFinished" field to TorrentProperties

This commit is contained in:
Jesse Chan
2021-05-17 21:17:28 +08:00
parent f8ea2b5d71
commit 4e6d4136cb
7 changed files with 15 additions and 1 deletions
@@ -286,6 +286,7 @@ class DelugeClientGatewayService extends ClientGatewayService {
'download_location',
'download_payload_rate',
'eta',
'finished_time',
'message',
'name',
'num_peers',
@@ -310,6 +311,8 @@ class DelugeClientGatewayService extends ClientGatewayService {
.then(async (torrentsStatus) => {
this.emit('PROCESS_TORRENT_LIST_START');
const dateNowSeconds = Math.ceil(Date.now() / 1000);
const torrentList: TorrentList = Object.assign(
{},
...(await Promise.all(
@@ -320,6 +323,8 @@ class DelugeClientGatewayService extends ClientGatewayService {
bytesDone: status.total_done,
dateAdded: status.time_added,
dateCreated: 0,
dateFinished:
status.finished_time > 0 ? Math.ceil((dateNowSeconds - status.finished_time) / 10) * 10 : 0,
directory: status.download_location,
downRate: status.download_payload_rate,
downTotal: status.total_payload_download,
@@ -104,7 +104,7 @@ export type DelugeCoreTorrentStorageMode = 'sparse' | 'allocate';
export interface DelugeCoreTorrentStatuses {
active_time: unknown;
seeding_time: unknown;
finished_time: unknown;
finished_time: number;
all_time_download: unknown;
storage_mode: DelugeCoreTorrentStorageMode;
distributed_copies: unknown;
@@ -331,6 +331,7 @@ class TransmissionClientGatewayService extends ClientGatewayService {
'haveValid',
'addedDate',
'dateCreated',
'doneDate',
'rateDownload',
'rateUpload',
'downloadedEver',
@@ -365,6 +366,7 @@ class TransmissionClientGatewayService extends ClientGatewayService {
bytesDone: torrent.haveValid,
dateAdded: torrent.addedDate,
dateCreated: torrent.dateCreated,
dateFinished: torrent.doneDate,
directory: torrent.downloadDir,
downRate: torrent.rateDownload,
downTotal: torrent.downloadedEver,
@@ -362,6 +362,7 @@ class QBittorrentClientGatewayService extends ClientGatewayService {
bytesDone: info.completed,
dateAdded: info.added_on,
dateCreated,
dateFinished: info.completion_on,
directory: info.save_path,
downRate: info.dlspeed,
downTotal: info.downloaded,
@@ -651,6 +651,7 @@ class RTorrentClientGatewayService extends ClientGatewayService {
bytesDone: response.bytesDone,
dateAdded: response.dateAdded,
dateCreated: response.dateCreated,
dateFinished: response.dateFinished,
directory: response.directory,
downRate: response.downRate,
downTotal: response.downTotal,
@@ -94,6 +94,10 @@ const torrentListMethodCallConfigs = {
methodCall: 'd.creation_date=',
transformValue: numberTransformer,
},
dateFinished: {
methodCall: 'd.timestamp.finished=',
transformValue: numberTransformer,
},
tags: {
methodCall: 'd.custom1=',
transformValue: (value: unknown): string[] => {
+1
View File
@@ -20,6 +20,7 @@ export interface TorrentProperties {
bytesDone: number;
dateAdded: number;
dateCreated: number;
dateFinished: number;
directory: string;
downRate: number;
downTotal: number;