Fix bug that caused two channels to collide when having the same title

Removed "shortname" property on channel


git-svn-id: svn://svn.berlios.de/gpodder/trunk@152 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
Thomas Perl 2006-08-07 14:03:12 +00:00
parent 37001e9069
commit 6dbb972fa8
4 changed files with 35 additions and 13 deletions

View File

@ -1,3 +1,11 @@
Mon, 07 Aug 2006 13:57:59 +0200 <thomas@wilson>
* src/gpodder/libpodcasts.py: Improvements in get_filename
* src/gpodder/libgpodder.py: Generate new filenames when
different URL channels have same "filename" property, so
these don't collide (thanks to ubunt2@gmail.com for reporting)
* src/gpodder/gpodder.py: Removed shortname property references
* Clean-up: Removed orphaned "shortname" property on channel
Wed, 02 Aug 2006 20:21:49 +0200 <thp@perli.net>
* src/gpodder/libpodcasts.py: strip channel and episode title
when changing it (so titles with a trailing newline don't mess

View File

@ -339,7 +339,6 @@ class Gpodder(SimpleGladeApp):
print ("Will add channel :%s") % result
self.statusLabel.set_text( _("Fetching channel index..."))
channel_new = podcastChannel( result)
channel_new.shortname = "__unknown__"
self.channels.append( channel_new)
# download changed channels
@ -521,7 +520,6 @@ class Gpodder(SimpleGladeApp):
print 'Changing ID %d from "%s" to "%s"' % (active, channel.url, result)
self.statusLabel.set_text( _("Fetching channel index..."))
channel_new = podcastChannel( result)
channel_new.shortname = "__unknown__"
new_channels = self.channels[0:active]
new_channels.append( channel_new)
new_channels.extend( self.channels[active+1:])

View File

@ -326,6 +326,16 @@ class gPodderChannelReader( DefaultHandler):
def __init__( self):
None
def channel_filename_exists( self, url, filename):
for c in self.channels:
if filename == c.filename and url == c.url:
# we've reached the position of the channel
# we're checking, so bug out here :)
return False
if filename == c.filename and url != c.url:
return True
return False
def read( self, force_update = False, callback_proc = None):
# callback proc should be like cb( pos, count), where pos is
@ -351,10 +361,17 @@ class gPodderChannelReader( DefaultHandler):
# check if download was a success
if cachefile != None:
reader.parseXML(channel.url, cachefile)
if channel.filename != "" and channel.filename != "__unknown__":
reader.channel.shortname = channel.filename
if channel.filename != '__unknown__':
proposed_filename = channel.filename
if isDebugging():
print 'First proposed fn: %s' % ( proposed_filename )
i = 2
while self.channel_filename_exists( channel.url, proposed_filename):
proposed_filename = '%s%d' % ( channel.filename, i )
if isDebugging():
print 'New proposed fn: %s' % ( proposed_filename )
i = i+1
reader.channel.filename = proposed_filename
input_channels.append( reader.channel)
position = position + 1
@ -370,7 +387,7 @@ class gPodderChannelReader( DefaultHandler):
if name == "channel":
self.current_item = podcastChannel()
self.current_item.filename = attrs.get( "name", "")
self.current_item.filename = attrs.get( 'name', '')
def endElement( self, name):
if self.current_item != None:

View File

@ -64,7 +64,6 @@ class podcastChannel(ListType):
self.language = ''
self.copyright = ''
self.webMaster = ''
self.shortname = None
self.downloaded = None
self.__filename = None
self.__download_dir = None
@ -77,15 +76,15 @@ class podcastChannel(ListType):
# Create all the properties
def get_filename(self):
if self.__filename == None:
self.__filename = ""
if self.__filename == None or (self.__filename == '__unknown__' and self.title != None):
self.__filename = ''
for char in self.title.lower():
if (char >= 'a' and char <= 'z') or (char >= 'A' and char <= 'Z') or (char >= '1' and char <= '9'):
self.__filename = self.__filename + char
if self.__filename == "":
self.__filename = "__unknown__"
if self.__filename == '':
self.__filename = '__unknown__'
return self.__filename
@ -393,7 +392,7 @@ class podcastItem(object):
try:
size = int( self.length)
except ValueError:
return '?? MB'
return 'n/a'
kilobyte = 1024
megabyte = kilobyte * 1024