Sat, 29 Mar 2008 16:30:02 +0100 <thp@perli.net>
Report errors in parsing/loading an already-added channel in the navigator * src/gpodder/gui.py: Show the error from feedparser in the channel's tooltip if there has been an error loading the channel * src/gpodder/libpodcasts.py: Make sure we can load a default title when using get_by_url(); save the parse_error variable for each channel (it defaults to None if there is no error); mark the description text for the channel navigator in red color if there has been a parser error and add the parse_error variable to the liststore model * src/gpodder/util.py: Strip whitespace before and after the string in remove_html_tags() git-svn-id: svn://svn.berlios.de/gpodder/trunk@647 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
parent
3b95b15e69
commit
452c5d396d
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
Sat, 29 Mar 2008 16:30:02 +0100 <thp@perli.net>
|
||||
Report errors in parsing/loading an already-added channel in the navigator
|
||||
|
||||
* src/gpodder/gui.py: Show the error from feedparser in the channel's
|
||||
tooltip if there has been an error loading the channel
|
||||
* src/gpodder/libpodcasts.py: Make sure we can load a default title
|
||||
when using get_by_url(); save the parse_error variable for each
|
||||
channel (it defaults to None if there is no error); mark the
|
||||
description text for the channel navigator in red color if there has
|
||||
been a parser error and add the parse_error variable to the liststore
|
||||
model
|
||||
* src/gpodder/util.py: Strip whitespace before and after the string in
|
||||
remove_html_tags()
|
||||
|
||||
Sat, 29 Mar 2008 16:18:59 +0100 <thp@perli.net>
|
||||
Add support for Rockbox' AudioScrobbler logfile to update played status
|
||||
|
||||
|
|
|
@ -340,7 +340,11 @@ class gPodder(GladeWidget):
|
|||
self.last_tooltip_channel = channel
|
||||
tooltip.set_icon(channel.get_cover_pixbuf())
|
||||
diskspace_str = _('Used disk space: %s') % util.format_filesize(channel.save_dir_size)
|
||||
tooltip.set_markup( '<b>%s</b>\n<small><i>%s</i></small>\n%s\n\n<small>%s</small>' % (saxutils.escape(channel.title), saxutils.escape(channel.url), saxutils.escape(channel.description), diskspace_str))
|
||||
error_str = model.get_value(iter, 6)
|
||||
if error_str:
|
||||
error_str = _('Feedparser error: %s') % saxutils.escape(error_str.strip())
|
||||
error_str = '<span foreground="#ff0000">%s</span>\n' % error_str
|
||||
tooltip.set_markup( '<b>%s</b>\n<small><i>%s</i></small>\n%s%s\n\n<small>%s</small>' % (saxutils.escape(channel.title), saxutils.escape(channel.url), error_str, saxutils.escape(channel.description), diskspace_str))
|
||||
return True
|
||||
|
||||
self.last_tooltip_channel = None
|
||||
|
|
|
@ -130,18 +130,24 @@ class podcastChannel(ListType):
|
|||
del cls.storage[url]
|
||||
|
||||
@classmethod
|
||||
def get_by_url( cls, url, force_update = False, offline = False):
|
||||
def get_by_url(cls, url, force_update=False, offline=False, default_title=None):
|
||||
if isinstance( url, unicode):
|
||||
url = url.encode('utf-8')
|
||||
|
||||
c = cls.fc.fetch( url, force_update, offline)
|
||||
channel = podcastChannel( url)
|
||||
channel.parse_error = c.get('bozo_exception', None)
|
||||
channel.load_settings()
|
||||
channel.title = c.feed.title
|
||||
if hasattr(c.feed, 'title'):
|
||||
channel.title = c.feed.title
|
||||
elif default_title is not None:
|
||||
channel.title = default_title
|
||||
else:
|
||||
channel.title = url
|
||||
if hasattr( c.feed, 'link'):
|
||||
channel.link = c.feed.link
|
||||
if hasattr( c.feed, 'subtitle'):
|
||||
channel.description = util.remove_html_tags( c.feed.subtitle)
|
||||
channel.description = util.remove_html_tags(c.feed.subtitle)
|
||||
|
||||
if hasattr(c.feed, 'updated_parsed') and c.feed.updated_parsed is not None:
|
||||
channel.pubDate = util.updated_parsed_to_rfc2822(c.feed.updated_parsed)
|
||||
|
@ -177,10 +183,13 @@ class podcastChannel(ListType):
|
|||
def create_from_dict( d, load_items = True, force_update = False, callback_error = None, offline = False):
|
||||
if load_items:
|
||||
try:
|
||||
return podcastChannel.get_by_url( d['url'], force_update = force_update, offline= offline)
|
||||
default_title = None
|
||||
if 'title' in d:
|
||||
default_title = d['title']
|
||||
return podcastChannel.get_by_url(d['url'], force_update=force_update, offline=offline, default_title=default_title)
|
||||
except:
|
||||
callback_error and callback_error( _('Could not load channel feed from URL: %s') % d['url'])
|
||||
log( 'Cannot load podcastChannel from URL: %s', d['url'])
|
||||
log( 'Cannot load podcastChannel from URL: %s', d['url'], traceback=True)
|
||||
|
||||
c = podcastChannel()
|
||||
for key in ( 'url', 'title', 'description' ):
|
||||
|
@ -197,6 +206,7 @@ class podcastChannel(ListType):
|
|||
self.description = util.remove_html_tags( description)
|
||||
self.image = None
|
||||
self.pubDate = ''
|
||||
self.parse_error = None
|
||||
|
||||
# should this channel be synced to devices? (ex: iPod)
|
||||
self.sync_to_devices = True
|
||||
|
@ -761,7 +771,7 @@ class podcastItem(object):
|
|||
|
||||
|
||||
def channels_to_model(channels):
|
||||
new_model = gtk.ListStore(str, str, str, gtk.gdk.Pixbuf, int, gtk.gdk.Pixbuf)
|
||||
new_model = gtk.ListStore(str, str, str, gtk.gdk.Pixbuf, int, gtk.gdk.Pixbuf, str)
|
||||
|
||||
for channel in channels:
|
||||
(count_available, count_downloaded, count_new, count_unplayed) = channel.get_episode_stats()
|
||||
|
@ -772,7 +782,14 @@ def channels_to_model(channels):
|
|||
|
||||
title_markup = saxutils.escape(channel.title)
|
||||
description_markup = saxutils.escape(util.get_first_line(channel.description))
|
||||
new_model.set(new_iter, 2, '%s\n<small>%s</small>' % (title_markup, description_markup))
|
||||
description = '%s\n<small>%s</small>' % (title_markup, description_markup)
|
||||
if channel.parse_error is not None:
|
||||
description = '<span foreground="#ff0000">%s</span>' % description
|
||||
new_model.set(new_iter, 6, channel.parse_error)
|
||||
else:
|
||||
new_model.set(new_iter, 6, '')
|
||||
|
||||
new_model.set(new_iter, 2, description)
|
||||
|
||||
if count_unplayed > 0 or count_downloaded > 0:
|
||||
new_model.set(new_iter, 3, draw.draw_pill_pixbuf(str(count_unplayed), str(count_downloaded)))
|
||||
|
|
|
@ -321,7 +321,7 @@ def remove_html_tags(html):
|
|||
# Convert named HTML entities to their unicode character
|
||||
result = re_html_entities.sub(lambda x: unicode(entitydefs.get(x.group(1),''), 'iso-8859-1'), result)
|
||||
|
||||
return result
|
||||
return result.strip()
|
||||
|
||||
|
||||
def torrent_filename( filename):
|
||||
|
|
Loading…
Reference in New Issue