Fri, 13 Jun 2008 14:27:30 +0200 <thp@perli.net>

Merge patch from Justin Forest to speed up pubDate detection

	* src/gpodder/gui.py: Add Justin Forest to the list of contributors
	and make sure we clear the pubDate cache in the channel when changing
	episode downloaded status manually
	* src/gpodder/libpodcasts.py: Merge patch from Justin Forest to speed
	up the newest_pubdate_downloaded() function by caching its value
	instead of re-calculating it on every call



git-svn-id: svn://svn.berlios.de/gpodder/trunk@735 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
Thomas Perl 2008-06-13 12:30:42 +00:00
parent 905014fc1b
commit ed11f1eef9
3 changed files with 59 additions and 11 deletions

View file

@ -1,3 +1,13 @@
Fri, 13 Jun 2008 14:27:30 +0200 <thp@perli.net>
Merge patch from Justin Forest to speed up pubDate detection
* src/gpodder/gui.py: Add Justin Forest to the list of contributors
and make sure we clear the pubDate cache in the channel when changing
episode downloaded status manually
* src/gpodder/libpodcasts.py: Merge patch from Justin Forest to speed
up the newest_pubdate_downloaded() function by caching its value
instead of re-calculating it on every call
Fri, 13 Jun 2008 09:37:45 +0200 <thp@perli.net>
Merge patch from Nick to add support for deleting played files on sync

View file

@ -84,7 +84,7 @@ app_authors = [
'Jérôme Chabod', 'Jerry Moss',
'Jessica Henline', 'João Trindade', 'Joel Calado', 'John Ferguson',
'José Luis Fustel', 'Joseph Bleau', 'Julio Acuña', 'Junio C Hamano',
'Jürgen Schinker',
'Jürgen Schinker', 'Justin Forest',
'Konstantin Ryabitsev', 'Leonid Ponomarev', 'Marcos Hernández', 'Mark Alford', 'Michael Salim',
'Mika Leppinen', 'Mike Coulson', 'Mykola Nikishov', 'narf at inode.at',
'Nick L.', 'Nicolas Quienot', 'Ondrej Vesely',
@ -1371,6 +1371,10 @@ class gPodder(GladeWidget):
self.for_each_selected_episode_url( callback)
if self.active_channel:
# Reset the cache for newest_pubdate_downloaded
self.active_channel.reset_pubdate_cache()
def on_item_toggle_played_activate( self, widget, toggle = True, new_value = False):
if toggle:
callback = lambda url: gl.history_mark_played(url, not gl.history_is_played(url))

View file

@ -216,6 +216,7 @@ class podcastChannel(list):
self.image = None
self.pubDate = ''
self.parse_error = None
self.newest_pubdate_cached = None
# should this channel be synced to devices? (ex: iPod)
self.sync_to_devices = True
@ -294,17 +295,43 @@ class podcastChannel(list):
ChannelSettings.set_settings_by_url( self.url, settings)
def newest_pubdate_downloaded( self):
# Try DownloadHistory's entries first
for episode in self:
if gl.history_is_downloaded( episode.url):
return episode.pubDate
def reset_pubdate_cache(self):
self.newest_pubdate_cached = None
# If nothing found, do pubDate comparison
pubdate = None
for episode in self.load_downloaded_episodes():
pubdate = episode.newer_pubdate( pubdate)
return pubdate
def newest_pubdate_downloaded(self):
"""
Returns the most recent pubDate value of all downloaded episodes, or
None if the pubDate cannot be determined.
This value is cached for speedup. You can call reset_pubdate_cache()
to clear the cached value and re-calculate the newest pubDate.
"""
if self.newest_pubdate_cached == 0:
return None
elif self.newest_pubdate_cached is None:
# Try DownloadHistory's entries first
for episode in self:
if gl.history_is_downloaded( episode.url):
self.newest_pubdate_cached = episode.pubDate
return episode.pubDate
# If nothing found, do pubDate comparison
pubdate = None
for episode in self.load_downloaded_episodes():
pubdate = episode.newer_pubdate( pubdate)
if pubdate is None:
# Zero value is used when there are episodes in the channel,
# but none of them are downloaded.
self.newest_pubdate_cached = 0
else:
self.newest_pubdate_cached = pubdate
return pubdate
return self.newest_pubdate_cached
def episode_is_new(self, episode, last_pubdate = None):
if last_pubdate is None:
@ -386,6 +413,13 @@ class podcastChannel(list):
except:
log('Error while calling update_metadata_on_file() :(')
# Update the cached newest_pubdate_downloaded() result.
newest = self.newest_pubdate_downloaded()
if newest is None:
self.newest_pubdate_cached = item.pubDate
else:
self.newest_pubdate_cached = item.newer_pubdate(newest)
gl.history_mark_downloaded(item.url)
self.update_m3u_playlist(downloaded_episodes)