support for mp3 player cleanup
git-svn-id: svn://svn.berlios.de/gpodder/trunk@253 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
parent
c05fe187d4
commit
bbd3128da2
|
@ -1,3 +1,9 @@
|
||||||
|
Sat, 3 Mar 2007 14:08:18 +0100 <thp@perli.net>
|
||||||
|
* src/gpodder/libgpodder.py: Added can_write_directory() function
|
||||||
|
* src/gpodder/libipodsync.py: Add support for MP3 player cleanup
|
||||||
|
* src/gpodder/gpodder.py: Add support for MP3 player cleanup
|
||||||
|
* bin/gpodder: version + svn release date push
|
||||||
|
|
||||||
Tue, 27 Feb 2007 21:11:47 +0100 <thp@perli.net>
|
Tue, 27 Feb 2007 21:11:47 +0100 <thp@perli.net>
|
||||||
* data/po/es.po: Updated Spanish translation by
|
* data/po/es.po: Updated Spanish translation by
|
||||||
José Luis Fustel (dr_psy terra.es)
|
José Luis Fustel (dr_psy terra.es)
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
# PLEASE DO NOT CHANGE FORMAT OF __version__ LINE (setup.py reads this)
|
# PLEASE DO NOT CHANGE FORMAT OF __version__ LINE (setup.py reads this)
|
||||||
|
|
||||||
__author__ = "Thomas Perl <thp@perli.net>"
|
__author__ = "Thomas Perl <thp@perli.net>"
|
||||||
__version__ = "0.8.9+svn20070227"
|
__version__ = "0.8.9+svn20070303"
|
||||||
__date__ = "2007-02-27"
|
__date__ = "2007-03-03"
|
||||||
__copyright__ = "Copyright (c) 2005-2007 %s. All rights reserved." % __author__
|
__copyright__ = "Copyright (c) 2005-2007 %s. All rights reserved." % __author__
|
||||||
__licence__ = "GPL"
|
__licence__ = "GPL"
|
||||||
|
|
||||||
|
|
|
@ -354,6 +354,13 @@ class Gpodder(SimpleGladeApp):
|
||||||
def sync_to_fs_proc( self, sync_win):
|
def sync_to_fs_proc( self, sync_win):
|
||||||
gpl = gPodderLib()
|
gpl = gPodderLib()
|
||||||
gpl.loadConfig()
|
gpl.loadConfig()
|
||||||
|
|
||||||
|
if not gpl.can_write_directory( gpl.mp3_player_folder):
|
||||||
|
gobject.idle_add( self.showMessage, _('Cannot write to %s.\nMake sure your MP3 player is connected.') % ( gpl.mp3_player_folder, ))
|
||||||
|
if sync_win.close:
|
||||||
|
sync_win.close()
|
||||||
|
return False
|
||||||
|
|
||||||
sync = gPodder_FSSync( destination = gpl.mp3_player_folder, callback_status = sync_win.set_status, callback_progress = sync_win.set_progress, callback_done = sync_win.close)
|
sync = gPodder_FSSync( destination = gpl.mp3_player_folder, callback_status = sync_win.set_status, callback_progress = sync_win.set_progress, callback_done = sync_win.close)
|
||||||
|
|
||||||
for channel in self.ldb.channel_list:
|
for channel in self.ldb.channel_list:
|
||||||
|
@ -374,6 +381,21 @@ class Gpodder(SimpleGladeApp):
|
||||||
sync.clean_playlist()
|
sync.clean_playlist()
|
||||||
sync.close()
|
sync.close()
|
||||||
|
|
||||||
|
def fs_cleanup_proc( self, sync_win):
|
||||||
|
gpl = gPodderLib()
|
||||||
|
gpl.loadConfig()
|
||||||
|
|
||||||
|
if not gpl.can_write_directory( gpl.mp3_player_folder):
|
||||||
|
gobject.idle_add( self.showMessage, _('Cannot write to %s.\nMake sure your MP3 player is connected.') % ( gpl.mp3_player_folder, ))
|
||||||
|
if sync_win.close:
|
||||||
|
sync_win.close()
|
||||||
|
return False
|
||||||
|
|
||||||
|
sync = gPodder_FSSync( destination = gpl.mp3_player_folder, callback_status = sync_win.set_status, callback_progress = sync_win.set_progress, callback_done = sync_win.close)
|
||||||
|
|
||||||
|
sync.clean_playlist()
|
||||||
|
sync.close()
|
||||||
|
|
||||||
def update_feed_cache_callback( self, progressbar, position, count):
|
def update_feed_cache_callback( self, progressbar, position, count):
|
||||||
try:
|
try:
|
||||||
progressbar.set_text( _("Updating: %s") % ( self.channels[position].title, ))
|
progressbar.set_text( _("Updating: %s") % ( self.channels[position].title, ))
|
||||||
|
@ -526,19 +548,24 @@ class Gpodder(SimpleGladeApp):
|
||||||
#-- Gpodder.on_cleanup_ipod_activate {
|
#-- Gpodder.on_cleanup_ipod_activate {
|
||||||
def on_cleanup_ipod_activate(self, widget, *args):
|
def on_cleanup_ipod_activate(self, widget, *args):
|
||||||
gl = gPodderLib()
|
gl = gPodderLib()
|
||||||
|
target_function = None
|
||||||
|
|
||||||
if gl.device_type == 'none':
|
if gl.device_type == 'none':
|
||||||
self.showMessage( _('Configure your device in the preferences dialog first.'))
|
self.showMessage( _('Configure your device in the preferences dialog first.'))
|
||||||
elif gl.device_type == 'ipod':
|
elif gl.device_type == 'ipod':
|
||||||
if not self.showConfirmation( _('Do you really want to truncate the Podcasts playlist on your iPod?')):
|
if self.showConfirmation( _('Do you really want to truncate the Podcasts playlist on your iPod?')):
|
||||||
return
|
target_function = self.ipod_cleanup_proc
|
||||||
|
elif gl.device_type == 'filesystem':
|
||||||
|
if self.showConfirmation( _('Do you really want to delete all Podcasts from your MP3 player?')):
|
||||||
|
target_function = self.fs_cleanup_proc
|
||||||
|
|
||||||
|
if target_function:
|
||||||
sync_win = Gpoddersync()
|
sync_win = Gpoddersync()
|
||||||
while gtk.events_pending():
|
while gtk.events_pending():
|
||||||
gtk.main_iteration( False)
|
gtk.main_iteration( False)
|
||||||
args = ( sync_win, )
|
args = ( sync_win, )
|
||||||
thread = Thread( target = self.ipod_cleanup_proc, args = args)
|
thread = Thread( target = target_function, args = args)
|
||||||
thread.start()
|
thread.start()
|
||||||
elif gl.device_type == 'filesystem':
|
|
||||||
self.showMessage( _('Cleanup of %s currently not supported.') % ( gl.mp3_player_folder, ))
|
|
||||||
#-- Gpodder.on_cleanup_ipod_activate }
|
#-- Gpodder.on_cleanup_ipod_activate }
|
||||||
|
|
||||||
#-- Gpodder.on_itemPreferences_activate {
|
#-- Gpodder.on_itemPreferences_activate {
|
||||||
|
|
|
@ -56,6 +56,8 @@ from os import environ
|
||||||
from os import system
|
from os import system
|
||||||
from os import unlink
|
from os import unlink
|
||||||
from os import listdir
|
from os import listdir
|
||||||
|
from os import access
|
||||||
|
from os import W_OK
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
# for the desktop symlink stuff:
|
# for the desktop symlink stuff:
|
||||||
|
@ -253,6 +255,9 @@ class gPodderLibClass( object):
|
||||||
def history_mark_downloaded( self, url):
|
def history_mark_downloaded( self, url):
|
||||||
self.__download_history.mark_downloaded( url)
|
self.__download_history.mark_downloaded( url)
|
||||||
|
|
||||||
|
def can_write_directory( self, directory):
|
||||||
|
return isdir( directory) and access( directory, W_OK)
|
||||||
|
|
||||||
def history_is_downloaded( self, url):
|
def history_is_downloaded( self, url):
|
||||||
return (url in self.__download_history)
|
return (url in self.__download_history)
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,7 @@ except:
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
import glob
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
@ -435,4 +436,17 @@ class gPodder_FSSync( gPodderSyncMethod):
|
||||||
os.system('sync')
|
os.system('sync')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def clean_playlist( self):
|
||||||
|
folders = glob.glob( os.path.join( self.destination, '*'))
|
||||||
|
for folder in range( len( folders)):
|
||||||
|
self.set_progress( folder+1, len( folders))
|
||||||
|
self.set_status( channel = os.path.basename( folders[folder]), progressbar_text = _('%d of %d') % ( folder+1, len(folders), ))
|
||||||
|
log( 'deleting: %s', folders[folder])
|
||||||
|
shutil.rmtree( folders[folder])
|
||||||
|
try:
|
||||||
|
os.system('sync')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue