Hi Thomas and fellow gPodders.
For a while I have been wanting to be able to see at a glance how many
unplayed episodes there are for each of my podcasts. That way I would
know which ones I needed to catch up on!
The current version of gPodder did not provide me with this information
so my challenge was to see if I could make the changes myself (being
both new to Linux and Python this seemed impossible a few days ago).
Anyway I think that I have succeeded and have made some slight changes
to the combo list GUI which I would like your feedback on. If the
feedback is positive then perhaps Thomas would be willing to merge into
the SVN trunk?
Currently in the combo list if there are new episodes to download the
channel text is marked up in *bold* and the count of new episodes is on
the right. I felt that the count indication was redundant as the *bold
*text told me I had new episodes to download. I therefore set out to use
this field to tell me how many unread episodes I have out of the amount
I had downloaded.
The screenshot at http://www.thegithouse.com/files/Screenshot.jpg shows
the result, if we take the 'This American Life' podcast as an example,
this shows that I have 10 unread episodes out of a total of 12 that I
have downloaded....time for some serious listening!
I have also attached a patch file which you could apply to your own
source if you would like to try it!
Paul
Index: src/gpodder/libpodcasts.py
===================================================================
--- src/gpodder/libpodcasts.py (revision 466)
+++ src/gpodder/libpodcasts.py (working copy)
@@ -361,7 +361,42 @@
episodes.sort( reverse = True)
return episodes
+
+ def get_episode_stats( self):
+ added_urls = []
+ added_guids = []
+
+ available = 0
+ downloaded = 0
+ played = 0
+
+ # go through all episodes (both new and downloaded),
+ # prefer already-downloaded (in localdb)
+ for item in [] + self.load_downloaded_episodes() + self:
+ # skip items with the same guid (if it has a guid)
+ if item.guid and item.guid in added_guids:
+ continue
+
+ # skip items with the same download url
+ if item.url in added_urls:
+ continue
+
+ available = available + 1
+
+ if item.is_downloaded():
+ downloaded = downloaded + 1
+
+ if item.get_played_status() == 0:
+ played = played + 1
+
+ if item.guid:
+ added_guids.append( item.guid)
+
+ added_urls.append( item.url)
+
+ return (available,downloaded,played)
+
def force_update_tree_model( self):
self.__tree_model = None
@@ -654,6 +689,15 @@
return self.url == other_item.url
+ def get_played_status( self):
+ if self.is_downloaded():
+ if (self.channel.is_played( self)):
+ return 1
+ else:
+ log( 'Not Played %s', self.url )
+ return 0
+ return 1
+
def channelsToModel( channels):
@@ -662,14 +706,20 @@
for channel in channels:
new_episodes = channel.get_new_episodes()
+
+ stats = channel.get_episode_stats()
+
+ count_downloaded = stats[1]
+ count_unplayed = stats[2]
count = len(channel)
count_new = len(new_episodes)
-
+
new_iter = new_model.append()
new_model.set( new_iter, 0, channel.url)
new_model.set( new_iter, 1, channel.title)
new_model.set( new_iter, 2, count)
+
if count_new == 0:
new_model.set( new_iter, 3, '')
elif count_new == 1:
@@ -679,10 +729,10 @@
if count_new:
new_model.set( new_iter, 4, pango.WEIGHT_BOLD)
- new_model.set( new_iter, 5, str(count_new))
+ new_model.set( new_iter, 5, _('%d/%d') % (count_unplayed,count_downloaded))
else:
new_model.set( new_iter, 4, pango.WEIGHT_NORMAL)
- new_model.set( new_iter, 5, '')
+ new_model.set( new_iter, 5, _('%d/%d') % (count_unplayed,count_downloaded))
new_model.set( new_iter, 6, pos)
_______________________________________________
gpodder-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/gpodder-devel