From 6f60142580cc81691b875191f6327bd97f7684f3 Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Thu, 30 Sep 2010 12:37:06 +0200 Subject: [PATCH] Better classification of "finished" episodes --- src/gpodder/model.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gpodder/model.py b/src/gpodder/model.py index 9f926484..8592c9f3 100644 --- a/src/gpodder/model.py +++ b/src/gpodder/model.py @@ -1212,9 +1212,20 @@ class PodcastEpisode(PodcastModelObject): except: log( 'Could not get filesize for %s.', self.url) + def is_finished(self): + """Return True if this episode is considered "finished playing" + + An episode is considered "finished" when there is a + current position mark on the track, and when the + current position is greater than 99 percent of the + total time or inside the last 10 seconds of a track. + """ + return self.current_position > 0 and \ + (self.current_position + 10 >= self.total_time or \ + self.current_position >= self.total_time*.99) + def get_play_info_string(self): - if self.current_position > 0 and \ - self.total_time <= self.current_position: + if self.is_finished(): return '%s (%s)' % (_('Finished'), self.get_duration_string(),) if self.current_position > 0: return '%s / %s' % (self.get_position_string(), \ -- 2.11.4.GIT