Update of /cvsroot/freevo/freevo/src/audio
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28445

Modified Files:
        audioitem.py fxdhandler.py interface.py 
Log Message:
switch to new mediainfo module, remove old code now in mediadb

Index: interface.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/audio/interface.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** interface.py        27 Nov 2004 14:59:04 -0000      1.8
--- interface.py        10 Apr 2005 17:49:46 -0000      1.9
***************
*** 14,17 ****
--- 14,20 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.9  2005/04/10 17:49:46  dischi
+ # switch to new mediainfo module, remove old code now in mediadb
+ #
  # Revision 1.8  2004/11/27 14:59:04  dischi
  # bugfix
***************
*** 86,110 ****
  
  
!     def get(self, parent, files):
          """
          return a list of items based on the files
          """
          items = []
! 
!         for file in util.find_matches(files, config.AUDIO_SUFFIX):
!             a = AudioItem(file, parent)
!             items.append(a)
!             files.remove(file)
! 
          return items
  
  
-     def _cover_filter(self, x):
-         """
-         filter function to get valid cover names
-         """
-         return re.search(config.AUDIO_COVER_REGEXP, x, re.IGNORECASE)
- 
- 
      def dirinfo(self, diritem):
          """
--- 89,102 ----
  
  
!     def get(self, parent, listing):
          """
          return a list of items based on the files
          """
          items = []
!         for file in listing.match_suffix(config.AUDIO_SUFFIX):
!             items.append(AudioItem(file, parent))
          return items
  
  
      def dirinfo(self, diritem):
          """
***************
*** 112,132 ****
          """
          if not diritem.image:
!             timestamp = os.stat(diritem.dir)[stat.ST_MTIME]
!             if not diritem['coversearch_timestamp'] or \
!                    timestamp > diritem['coversearch_timestamp']:
!                 # Pick an image if it is the only image in this dir, or it
!                 # matches the configurable regexp
!                 listing = vfs.listdir(diritem.dir, include_overlay=True)
!                 files = util.find_matches(listing, ('jpg', 'gif', 'png' ))
!                 if len(files) == 1:
!                     diritem.image = os.path.join(diritem.dir, files[0])
!                 elif len(files) > 1:
!                     covers = filter(self._cover_filter, files)
!                     if covers:
!                         diritem.image = os.path.join(diritem.dir, covers[0])
!                 diritem.store_info('coversearch_timestamp', timestamp)
!                 diritem.store_info('coversearch_result', diritem.image)
!             else:
!                 diritem.image = diritem['coversearch_result']
                  
          if not diritem.info.has_key('title') and diritem.parent:
--- 104,108 ----
          """
          if not diritem.image:
!             diritem.image = diritem.info['audiocover']
                  
          if not diritem.info.has_key('title') and diritem.parent:

Index: audioitem.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/audio/audioitem.py,v
retrieving revision 1.64
retrieving revision 1.65
diff -C2 -d -r1.64 -r1.65
*** audioitem.py        20 Nov 2004 18:23:00 -0000      1.64
--- audioitem.py        10 Apr 2005 17:49:46 -0000      1.65
***************
*** 13,16 ****
--- 13,19 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.65  2005/04/10 17:49:46  dischi
+ # switch to new mediainfo module, remove old code now in mediadb
+ #
  # Revision 1.64  2004/11/20 18:23:00  dischi
  # use python logger module for debug
***************
*** 80,105 ****
  log = logging.getLogger('audio')
  
- def _image_filter(x):
-     """
-     filter used to find cover images
-     """
-     return re.match('.*(jpg|png)$', x, re.IGNORECASE)
- 
- def _cover_filter(x):
-     """
-     filter used to find cover images
-     """
-     return re.search(config.AUDIO_COVER_REGEXP, x, re.IGNORECASE)
- 
- 
  class AudioItem(MediaItem):
      """
      This is the common class to get information about audiofiles.
      """
!     def __init__(self, url, parent, name=None, scan=True):
          MediaItem.__init__(self, 'audio', parent)
!         self.set_url(url, info=scan)
!         if name:
!             self.name   = name
          self.start      = 0
          self.elapsed    = 0
--- 83,93 ----
  log = logging.getLogger('audio')
  
  class AudioItem(MediaItem):
      """
      This is the common class to get information about audiofiles.
      """
!     def __init__(self, url, parent):
          MediaItem.__init__(self, 'audio', parent)
!         self.set_url(url)
          self.start      = 0
          self.elapsed    = 0
***************
*** 107,141 ****
          self.pause      = 0
          self.mplayer_options = ''
              
-         try:
-             self.length = int(self.info['length'])
-         except:
-             self.length = 0
-             
-         # Let's try to find if there is any image in the current directory
-         # that could be used as a cover
-         if self.filename and not self.image and not \
-            (self.parent and self.parent.type == 'dir'):
-             images = ()
-             covers = ()
-             files =()
- 
-             # Pick an image if it is the only image in this dir, or it matches
-             # the configurable regexp
-             dirname = os.path.dirname(self.filename)
-             try:
-                 files = os.listdir(dirname)
-             except OSError:
-                 log.error('os.listdir() error')
-             images = filter(_image_filter, files)
-             image = None
-             if len(images) == 1:
-                 image = os.path.join(dirname, images[0])
-             elif len(images) > 1:
-                 covers = filter(_cover_filter, images)
-                 if covers:
-                     image = os.path.join(dirname, covers[0])
-             self.image = image
- 
  
      def sort(self, mode=None):
--- 95,100 ----
          self.pause      = 0
          self.mplayer_options = ''
+         self.length     = 0
              
  
      def sort(self, mode=None):
***************
*** 157,161 ****
  
  
!     def set_url(self, url, info=True):
          """
          Sets a new url to the item. Always use this function and not set 'url'
--- 116,120 ----
  
  
!     def set_url(self, url):
          """
          Sets a new url to the item. Always use this function and not set 'url'
***************
*** 163,181 ****
          filename, mode and network_play
          """
!         MediaItem.set_url(self, url, info)
!         if url.startswith('cdda://'):
              self.network_play = False
              self.mimetype = 'cdda'
  
  
      def __getitem__(self, key):
          """
          return the specific attribute as string or an empty string
          """
!         if key  == 'length' and self.length:
!             # maybe the length was wrong
!             if self.length < self.elapsed:
!                 self.length = self.elapsed
!             return '%d:%02d' % (int(self.length / 60), int(self.length % 60))
  
          if key  == 'elapsed':
--- 122,150 ----
          filename, mode and network_play
          """
!         MediaItem.set_url(self, url)
!         if self.url.startswith('cdda://'):
              self.network_play = False
              self.mimetype = 'cdda'
  
  
+     def __calc_length(self):
+         try:
+             self.length = int(self.info['length'])
+         except:
+             self.length = 0
+ 
+         
      def __getitem__(self, key):
          """
          return the specific attribute as string or an empty string
          """
!         if key  == 'length':
!             if not self.length:
!                 self.__calc_length()
!             if self.length:
!                 # maybe the length was wrong
!                 if self.length < self.elapsed:
!                     self.length = self.elapsed
!                 return '%d:%02d' % (int(self.length / 60), int(self.length % 
60))
  
          if key  == 'elapsed':
***************
*** 189,192 ****
--- 158,163 ----
          return a list of possible actions on this item
          """
+         if not self.length:
+             self.__calc_length()
          return [ ( self.play, 'Play' ) ]
  
***************
*** 196,199 ****
--- 167,172 ----
          Start playing the item
          """
+         if not self.length:
+             self.__calc_length()
          self.parent.current_item = self
          self.elapsed = 0

Index: fxdhandler.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/audio/fxdhandler.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** fxdhandler.py       13 Sep 2004 19:34:24 -0000      1.1
--- fxdhandler.py       10 Apr 2005 17:49:46 -0000      1.2
***************
*** 37,40 ****
--- 37,43 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.2  2005/04/10 17:49:46  dischi
+ # switch to new mediainfo module, remove old code now in mediadb
+ #
  # Revision 1.1  2004/09/13 19:34:24  dischi
  # move interface/fxdhandler into extra file
***************
*** 70,74 ****
      parse audio specific stuff from fxd files
      """
!     a = AudioItem('', fxd.getattr(None, 'parent', None), scan=False)
  
      a.name     = fxd.getattr(node, 'title', a.name)
--- 73,78 ----
      parse audio specific stuff from fxd files
      """
!     # XXX MEDIAINFO UPDATE XXX no parsing????
!     a = AudioItem('', fxd.getattr(None, 'parent', None))
  
      a.name     = fxd.getattr(node, 'title', a.name)



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to