Opened 10 years ago

Closed 9 years ago

#4657 closed Enhancement (fixed)

transmission-remote: display times (e.g. Seeding Time) (optionally) in seconds

Reported by: blueyed Owned by: jordan
Priority: Normal Milestone: 2.70
Component: CLI Version: 2.42
Severity: Normal Keywords:


I would like to parse the output from transmission-remote in regard to the seeding time, but the current output format is rounded/trimmed and also not easily to pare (e.g. "4 days" or "10 hours").

I would like an option to transmission-remote which would output all times in seconds instead.

Another idea would be to have the exact time (seconds) in brackets after the human readable time.

It might make sense to keep the option generic like "--parsable" and use it for other similar issues, too.

Change History (8)

comment:1 Changed 10 years ago by jordan

  • Keywords patch-needed added

I have mixed feelings about this.

On one hand, transmission-remote is already really bloated and suffers badly from trying to be too many things to too many people.

On the other hand... this could be a really useful feature for scripters. :)

If someone wants to submit a transmission-remote patch for this that doesn't clutter up the code too much more than it already is, I'd happily review it for inclusion.

comment:2 Changed 10 years ago by blueyed

Here's a generic approach, which patches tr_strltime itself.

Please forgive me for any stupidities - I am not a C programmer.

I have tried to find placed in e.g. transmission-gtk where this might look strange, but could not find any at all..

I would be glad to work with your feedback, and maybe even only patch transmission-remote explicitly.


Index: daemon/remote.c
--- daemon/remote.c	(revision 13103)
+++ daemon/remote.c	(working copy)
@@ -89,12 +89,15 @@
 static char*
 tr_strltime( char * buf, int seconds, size_t buflen )
-    int  days, hours, minutes;
+    int  days, hours, minutes, total_seconds;
     char d[128], h[128], m[128], s[128];
+    char bufcpy[buflen];
     if( seconds < 0 )
         seconds = 0;
+    total_seconds = seconds;
     days = seconds / 86400;
     hours = ( seconds % 86400 ) / 3600;
     minutes = ( seconds % 3600 ) / 60;
@@ -128,6 +131,9 @@
     else tr_strlcpy( buf, s, buflen );
+    tr_strlcpy( bufcpy, buf, buflen );
+    tr_snprintf( buf, buflen, "%s (%d seconds)", bufcpy, total_seconds );
     return buf;

comment:3 Changed 10 years ago by blueyed

And here's a quick'n'dirty attempt at parsing this information into a grand total (outputting the total seconds of seeding time):

transmission-remote -tall --info | awk 'BEGIN {c=0}
/Seeding Time/ { c=c+substr($(NF-1),2) }
END {print c}'

comment:4 Changed 9 years ago by blueyed

  • Keywords patch-needed removed

@jordan: what do you think about the patch above?

While it's certainly improvable, it shows how easily this could get fixed.

comment:5 Changed 9 years ago by jordan

  • Milestone changed from None Set to 2.70
  • Owner set to jordan
  • Status changed from new to assigned

I've added this feature in r13443.

comment:6 Changed 9 years ago by blueyed


Looking at the patch, it should be changed a bit:

- tr_snprintf( t, sizeof( t ), "%d %s", total_seconds, total_seconds==1?"seconds":"seconds" ); 
+ tr_snprintf( t, sizeof( t ), "%d %s", total_seconds, total_seconds==1?"second":"seconds" ); 

comment:7 Changed 9 years ago by jordan

Fixed in r13444, thanks :)

comment:8 Changed 9 years ago by jordan

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.