Hi,

I'm currently ripping my CDs with freevo and I encountered some problems when 
either the cddb-query failed (my router was powered off and freevo showed 
"Unknown CD" or wrong results from cddb) or I had to choose a cover from a 
list of amazon-hits and choosed the wrong one (should buy a keyboard with 
larger keys...) ;-)....

In both cases I had to ssh my freevo-box, delete the *.mmpython/*.jpg file 
manually and restart freevo. 

To make this work easier I added the following funcs:

- delete metadata for audio-cd's
- delete image for audio-cd's

and for those working with neither an IR remote or a bluetooth mobile (and 
therefore not having an "EJECT" button):

- eject for cd/dvd-drives 

All diffs are against 1.5.3 tarball release. These are my first python (and 
OO) steps, maybe it's not the best and cleanest solution, but it works for 
me. Feel free to integrate.

Regards
        Georg
   

-- 
Mein oeffentlicher Schluessel fuer PGP/GPG - Verschluesselung:

pub  1024D/63EB55CA 2002-11-27 Georg Kuenzel <[EMAIL PROTECTED]>
Key fingerprint = 8DA9 55C6 91FA D92D 89C3  7C22 0A1D 790C 63EB 55CA
--- patch/coversearch.py	2005-03-28 13:03:22.000000000 +0200
+++ ../../usr/lib/python2.3/site-packages/freevo/audio/plugins/coversearch.py	2005-03-28 23:22:48.102139880 +0200
@@ -70,7 +70,7 @@
 from xml.dom import minidom # ParseError used by amazon module
 
 from gui.PopupBox import PopupBox
-from gui.AlertBox import AlertBox
+from gui.ConfirmBox import ConfirmBox
 
 from util import amazon
 
@@ -128,7 +128,7 @@
 
         # do don't call this when we have an image
         if item.type == 'audiocd' and item.image:
-            return []
+            return [ ( self.cover_delete_file, _( 'Delete image' ), '') ]
 
         # do don't call this when we have an image
         if item.type == 'audio' and item.filename and \
@@ -168,6 +168,30 @@
                           String(_( "Unknown CD, cover searching is disabled" ))
         return []
 
+		
+    def cover_delete_file(self, arg=None, menuw=None):
+        """
+        confirm metadata deletion
+        """
+	self.menuw = menuw
+	ConfirmBox(text=_('Do you wish to delete cover\n \'%s\'?') % self.item.info['title'],
+        	handler=self.delete_file, default_choice=1,
+        	handler_message=_('Deleting...')).show()
+	
+        
+    def delete_file(self):
+        """
+        delete metadata file
+        """
+        menuw=self.menuw
+        filename = '%s/disc/metadata/%s.jpg' % (config.OVERLAY_DIR, self.item.info['id'])
+        try:
+                os.unlink (filename)
+                self.item.image = ''
+        except:
+                print ('cover file not found, check path')
+        menuw.delete_menu()
+
 
     def cover_search_file(self, arg=None, menuw=None):
         """
--- home/georg/patch/audiodiskitem.py	2005-03-28 13:03:39.000000000 +0200
+++ usr/lib/python2.3/site-packages/freevo/audio/audiodiskitem.py	2005-03-27 21:27:03.000000000 +0200
@@ -45,8 +45,9 @@
 from audioitem import AudioItem
 from playlist import Playlist
 from directory import DirItem
+from gui.ConfirmBox import ConfirmBox
 
-class AudioDiskItem(Playlist):
+class AudioDiskItem(Playlist, DirItem):
     """
     class for handling audio disks
     """
@@ -74,10 +75,42 @@
         """
         return a list of actions for this item
         """
-        items = [ ( self.cwd, _('Browse disc') ) ]
+        items = [ ( self.cwd, _('Browse disc') ),
+	 	  ( self.metadata_delete_file, _('Delete metadata')),
+		  ( self.eject, _('Eject drive')) ]
         return items
 
+	
+    def metadata_delete_file(self, arg=None, menuw=None):
+        """
+        confirm metadata deletion 
+        """
+	self.menuw = menuw
+	ConfirmBox(text=_('Do you wish to delete metadata about\n \'%s\'?') % self.name,
+        	handler=self.delete_file, default_choice=1,
+        	handler_message=_('Deleting...')).show()
+	
+		
+    def delete_file(self, arg=None, menuw=None):
+	"""
+        delete metadata file
+        """
+	filename = ('%s/disc/metadata/%s.mmpython') % (config.OVERLAY_DIR, self.disc_id)
+	menuw = self.menuw
+	try:
+		os.unlink (filename)
+	except:
+		menuw.delete_menu()
+		return
+	self.name = _('Unknown CD Album')
+        number = len(self.info['tracks'])
+        if hasattr(self.info, 'mixed'):
+            number -= 1
+        for i in range(0, number):
+           self.info['tracks'][i]['title'] = 'Track %s' % (i+1)
+	menuw.delete_menu()
     
+	
     def cwd(self, arg=None, menuw=None):
         """
         make a menu item for each file in the directory
--- home/georg/patch/directory.py	2005-03-28 13:03:07.000000000 +0200
+++ usr/lib/python2.3/site-packages/freevo/directory.py	2005-03-28 23:58:48.960639456 +0200
@@ -420,6 +420,10 @@
 
         items = [ ( self.cwd, _('Browse directory')) ]
 
+        if self.media:
+            if not self.media.tray_open:
+                items.append((self.eject, _('Eject drive')))
+
         if self['num_%s_items' % display_type]:
             items.append((self.play, _('Play all files in directory')))
 
@@ -441,7 +445,16 @@
             self.media.umount()
 
         return items
-    
+
+
+    def eject(self, arg=None, menuw=None):
+        """
+        eject the drive
+        """
+        item = self.media
+        item.move_tray(dir='open', notify=0)
+        # go back
+        menuw.delete_menu()
 
 
     def cwd(self, arg=None, menuw=None):
--- home/georg/patch/videoitem.py	2005-03-28 13:03:54.000000000 +0200
+++ usr/lib/python2.3/site-packages/freevo/video/videoitem.py	2005-03-29 00:02:29.840060680 +0200
@@ -87,11 +87,12 @@
 import configure
 import plugin
 
+from directory import DirItem
 from gui   import PopupBox, AlertBox, ConfirmBox
 from item  import Item, FileInformation
 from event import *
 
-class VideoItem(Item):
+class VideoItem(DirItem):
     def __init__(self, url, parent, info=None, parse=True):
         self.autovars = [ ('deinterlace', 0) ]
         Item.__init__(self, parent)
@@ -330,7 +331,11 @@
         if self.mode == 'file' and not self.variants and not self.subitems and \
                (not self.image or not self.image.endswith('raw')):
             items.append((self.create_thumbnail, _('Create Thumbnail'), 'create_thumbnail'))
-            
+        
+        if self.media:
+            if not self.media.tray_open:
+                items.append((self.eject, _('Eject drive')))
+
         return items
 
 

Reply via email to