Skip to content

Commit

Permalink
Use Transmission RPC table mode (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
6c65726f79 committed Feb 17, 2023
1 parent c40a6f5 commit befd148
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/services/TransmissionRPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class TRPC {
let result: Record<string,Array<any>>={};
let loadPersistent=false;
const args: Record<string,any> = {
format: 'table',
fields: [
'id',
'name',
Expand Down Expand Up @@ -250,7 +251,16 @@ class TRPC {
const response = await this.rpcCall("torrent-get", args, true, true);

if(response.arguments){
result=response.arguments
result=response.arguments;

// Parse table mode
if(result.torrents.length>0 && Array.isArray(result.torrents[0])){
const header = result.torrents[0];
result.torrents.shift();
result.torrents = result.torrents.map(t => {
return header.reduce((a, v, i) => ({...a, [v]:t[i]}), {});
})
}

if(loadPersistent){
this.readPersitentData(result);
Expand Down

0 comments on commit befd148

Please sign in to comment.