joolswills / plugin.video.iplayer

This plugin is broken.
10 stars 4 forks source link

Patch: Don't keep resume point during first 5% or last 5% of stream #148

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If you begin a stream and then end it immediately, a resume point will be 
created for 00:00:01.

Likewise, if you watch a stream all the way through to the end, the resume 
point will be created so that watching the stream again resumes at the very 
last second of the stream.

"Regular" XBMC streams only create a watched point when a certain percentage of 
the stream has been viewed or remains to be watched. This avoids the watch 
point being set when a video is viewed by mistake (and ended immediately) or 
watched all the way through to the end. The limits are actually configurable in 
advancedsettings.xml, however I'm not entirely sure how to access this 
information from a plugin.

For iplayer, I've chosen percentages of more than 5% watched and less than 5% 
remaining in order for the resume point to be saved. Outside of these limits, 
the resume point will not be saved (and if a resume point already exists it 
will be removed).

This is now more or less consistent with existing XBMC "watched" behaviour.

A few of other (related) changes:

1. I've added a "duration" property to IPlayer so that the run time of the 
current stream can be tracked (and therefore the "watched percentage" 
calculated). On more than a few occasions it wasn't successfully set 
onPlayBackStarted() so I've also added it to the heartbeat where it will only 
be set if it's not already set.

2. I've added a "has_resumepoint" property to IPlayer so that it isn't 
necessary to load the resume file in order to determine if there is a resume 
point to be deleted - now the object knows if it has a resume point that needs 
to be deleted and will only call delete_resume_point() when necessary.

3. The changes in read_item_node() eliminate the following warning that appears 
in the log (on OpenELEC, anyway):

FutureWarning: The behavior of this method will change in future versions.  Use 
specific 'len(elem)' or 'elem is not None' test instead.
if nf: self.service = nf.text and nf.get('id')

4. Apologies for my text editor once again messing with the white space

What is the expected output? What do you see instead?

Resume point creation behaviour consistent with the rest of XBMC.

What version of the plugin are you using? On what OS?

Latest (2.5.5, svn 162).

Please provide any additional information below.

Patch attached.

Original issue reported on code.google.com by n...@nmacleod.com on 30 Apr 2014 at 2:36

Attachments:

GoogleCodeExporter commented 9 years ago
applied in r165. I did a commit just before to strip trailing spaces from all 
the files, so I didn't include the whitespace changes as part of this commit.

Thanks for the improvements.

Original comment by exob...@gmail.com on 3 May 2014 at 6:05

GoogleCodeExporter commented 9 years ago
I've just been watching the Spanish Formula 1 Grand Prix on BBC1 which is a 
2h50m show, and it's made me realise that using percentages alone to determine 
when to save resume points isn't ideal, as 5% for this show equates to 8m30s.

This means a resume point won't be saved until at least 8.5 minutes into the 
show (for a 30 minute episode 5% is 90 seconds, and for a 1 hour it's 3 
minutes).

Consequently I'd like to revise this patch slightly to use a combination of 
percentages and fixed timings, ie. don't save before first 3 minutes or 5% 
(whichever is smallest), and don't save after last 3 minutes or 95% (whichever 
is greatest).

So on a 15 minute episode the resume point will not be saved during the first 
and last 45 seconds (5%/95%), on a 30 minute episode the resume point will not 
be saved during the first/last 90 seconds (again 5%/95%), but on one hour and 
longer episodes the resume point will not be saved during the first/last 3 
minutes.

What do you think?

Would you rather I open a new issue, or re-open/continue this one?

Original comment by n...@nmacleod.com on 12 May 2014 at 6:31

GoogleCodeExporter commented 9 years ago
The attached patch clamps the resume point limits at 180 seconds each, so that 
very long programmes do not use excessively large min/max resume point limits.

Original comment by n...@nmacleod.com on 12 May 2014 at 11:51

Attachments:

GoogleCodeExporter commented 9 years ago
looks good to me. Was about to commit, but googlecode svn is broken again (502 
bad gateway). useless.

Original comment by exob...@gmail.com on 12 May 2014 at 5:32

GoogleCodeExporter commented 9 years ago
applied in r172. thanks

Original comment by exob...@gmail.com on 12 May 2014 at 6:00