[PATCH] Support hh:mm:ss format for --start and --stop

dinkypumpkin dinkypumpkin at gmail.com
Fri Jul 27 09:42:56 EDT 2012


This may be helpful with Olympics coverage and save a few seconds
of mental arithmetic in the bargain.  Remember that --start and
--stop are relative offsets, not absolute values.  Also allow for
some variance (~5 mins) between the time marks in web video players
and the values you supply to --start and --stop.  h/t Mark Rogers
for the suggestion.

This patch has been incorporated into the get_iplayer Git repo.
Instructions for updating are here:

https://github.com/dinkypumpkin/get_iplayer/wiki/githead

Commit message and patch follow.

User may enter --start and --stop option values in hh:mm:ss format, with
seconds optional.  Values are converted to integral number of seconds as
expected by rtmpdump.
---
 get_iplayer   |   11 +++++++++--
 get_iplayer.1 |    4 ++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/get_iplayer b/get_iplayer
index 937b94f..15029d5 100755
--- a/get_iplayer
+++ b/get_iplayer
@@ -130,8 +130,8 @@ my $opt_format = {
 	pidrecursive	=> [ 1, "pidrecursive|pid-recursive!", 'Recording', '--pid-recursive', "When used with --pid record all the embedded pids if the pid is a series or brand pid."],
 	proxy		=> [ 0, "proxy|p=s", 'Recording', '--proxy, -p <url>', "Web proxy URL e.g. 'http://USERNAME:PASSWORD\@SERVER:PORT' or 'http://SERVER:PORT'"],
 	raw		=> [ 0, "raw!", 'Recording', '--raw', "Don't transcode or change the recording/stream in any way (i.e. radio/realaudio, rtmp/flv)"],
-	start		=> [ 1, "start=s", 'Recording', '--start <secs>', "Recording/streaming start offset (rtmp and realaudio only)"],
-	stop		=> [ 1, "stop=s", 'Recording', '--stop <secs>', "Recording/streaming stop offset (can be used to limit live rtmp recording length) rtmp and realaudio only"],
+	start		=> [ 1, "start=s", 'Recording', '--start <secs|hh:mm:ss>', "Recording/streaming start offset (rtmp and realaudio only)"],
+	stop		=> [ 1, "stop=s", 'Recording', '--stop <secs|hh:mm:ss>', "Recording/streaming stop offset (can be used to limit live rtmp recording length) rtmp and realaudio only"],
 	suboffset	=> [ 1, "suboffset=n", 'Recording', '--suboffset <offset>', "Offset the subtitle timestamps by the specified number of milliseconds"],
 	subtitles	=> [ 2, "subtitles|subs!", 'Recording', '--subtitles', "Download subtitles into srt/SubRip format if available and supported"],
 	subsonly	=> [ 1, "subtitlesonly|subsonly|subtitles-only|subs-only!", 'Recording', '--subtitles-only', "Only download the subtitles, not the programme"],
@@ -535,6 +535,13 @@ if ( $opt->{webrequest} ) {
 	delete $opt_cmdline->{webrequest};
 }
 
+# process --start and --stop if necessary
+foreach ('start', 'stop') {
+	if ($opt->{$_} && $opt->{$_} =~ /(\d\d):(\d\d)(:(\d\d))?/) {
+		$opt->{$_} = $1 * 3600 +  $2 * 60 + $4;
+	}
+}
+
 # Add --search option to @search_args if specified
 if ( defined $opt->{search} ) {
 	push @search_args, $opt->{search};
diff --git a/get_iplayer.1 b/get_iplayer.1
index f4f2dda..df563e2 100644
--- a/get_iplayer.1
+++ b/get_iplayer.1
@@ -235,10 +235,10 @@ Add custom options to flvstreamer for tv
 \fB\-\-rtmpport <port>
 Override the RTMP port (e.g. 443)
 .TP
-\fB\-\-start <secs>
+\fB\-\-start <secs|hh:mm:ss>
 Recording/streaming start offset (rtmp and realaudio only)
 .TP
-\fB\-\-stop <secs>
+\fB\-\-stop <secs|hh:mm:ss>
 Recording/streaming stop offset (can be used to limit live rtmp recording length) rtmp and realaudio only
 .TP
 \fB\-\-suboffset <offset>
-- 
1.7.9.6 (Apple Git-31.1)




More information about the get_iplayer mailing list