fix charset problems when syncing to fs-based MP3 players
git-svn-id: svn://svn.berlios.de/gpodder/trunk@307 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
parent
004b86f256
commit
cae13e7c3c
|
@ -1,3 +1,10 @@
|
|||
Thu, 5 Apr 2007 09:09:01 +0200 <thp@perli.net>
|
||||
* src/gpodder/libipodsync.py: Only allow alphanumeric, space, dot,
|
||||
dash and underscore characters when syncing to filesystem-based
|
||||
MP3 players; this should get rid of a lot of problems with the
|
||||
restrictions of filesystems; thanks to Johann Uhrmann for bringing
|
||||
yet another problem with the charset problem to my attention :)
|
||||
|
||||
Thu, 5 Apr 2007 07:49:19 +0200 <thp@perli.net>
|
||||
* src/gpodder/libipodsync.py: Increment playcount from zero to one
|
||||
if we've played a podcast locally, but playcount is still zero on
|
||||
|
|
|
@ -87,6 +87,7 @@ import glob
|
|||
import shutil
|
||||
import sys
|
||||
import time
|
||||
import string
|
||||
import email.Utils
|
||||
|
||||
import liblocaldb
|
||||
|
@ -494,20 +495,28 @@ class gPodder_FSSync( gPodderSyncMethod):
|
|||
return gpl.can_write_directory( self.destination)
|
||||
|
||||
def add_episode_from_channel( self, channel, episode):
|
||||
replace_chars = ( '/', '?', ':', '!', '<', '>', '&', '*', '|', '"')
|
||||
allowed_chars = set( string.lowercase + string.uppercase + string.digits + ' _.-')
|
||||
|
||||
gPodderSyncMethod.add_episode_from_channel( self, channel, episode)
|
||||
|
||||
folder = channel.title
|
||||
for ch in replace_chars:
|
||||
folder = folder.replace( ch, '-')
|
||||
folder_src = channel.title
|
||||
folder = ''
|
||||
for ch in folder_src:
|
||||
if ch in allowed_chars:
|
||||
folder = folder + ch
|
||||
else:
|
||||
folder = folder + '_'
|
||||
folder = os.path.join( self.destination, folder)
|
||||
|
||||
from_file = channel.getPodcastFilename( episode.url)
|
||||
|
||||
to_file = episode.title + os.path.splitext( from_file)[1].lower()
|
||||
for ch in replace_chars:
|
||||
to_file = to_file.replace( ch, '-')
|
||||
to_file_src = episode.title + os.path.splitext( from_file)[1].lower()
|
||||
to_file = ''
|
||||
for ch in to_file_src:
|
||||
if ch in allowed_chars:
|
||||
to_file = to_file + ch
|
||||
else:
|
||||
to_file = to_file + '_'
|
||||
to_file = os.path.join( folder, to_file)
|
||||
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue