Since 1.7.0 (versions up to 1.7.0-rc2 worked almost fine) audio items
without song information (eg id3 tags) are displayed as "unknown" in
the directory listing.

Furthermore, disabling the use of mediaid tags didn't make a difference.
Files with tags were always shown with the tag info, files without
tags were always displayed as "unknown".

This problem is caused by the format_track function in audioitem.py.
It doesn't check if it should use the mediaid tags and tries to
format the tag info using the configured format string. This can
lead to an empty string or something like " - ", depending on the
format string.

Here's a patch that tries to resolve this issue. I changed format_track
so that at first it checks if mediaid tags should be used at all.
If that's the case, it also checks if the formatted track info
contained any information at all (by comparing it with the formatted
track info of an empty song_info).

If building the formatted info didn't succeed, or if mediaid tags
are disabled, the current name (self.name) is returned.

In case self.name is empty for some reasons it returns the
filename (similar to 1.7.0-rc2).

BTW: the diff is against svn tag REL-1_7_0

so long,

Hias
Index: REL-1_7_0/freevo/src/audio/audioitem.py
===================================================================
--- REL-1_7_0/freevo/src/audio/audioitem.py     (revision 9302)
+++ REL-1_7_0/freevo/src/audio/audioitem.py     (working copy)
@@ -186,24 +186,40 @@
         # strip it out first, when we see the only thing that can be
         # a number.
 
+        if self.parent and hasattr(self.parent, 
'DIRECTORY_USE_MEDIAID_TAG_NAMES') and \
+            self.parent.DIRECTORY_USE_MEDIAID_TAG_NAMES:
 
-        # Before we begin, make sure track is an integer
-    
-        if self['trackno']:
-            try:
-                mytrack = ('%0.2d' % int(self['trackno']))
-            except ValueError:
+            # Before we begin, make sure track is an integer
+            if self['trackno']:
+                try:
+                    mytrack = ('%0.2d' % int(self['trackno']))
+                except ValueError:
+                    mytrack = '  '
+            else:
                 mytrack = '  '
-        else:
-            mytrack = '  '
 
-        song_info = {  'a'  : self['artist'],
-                       'l'  : self['album'],
-                       'n'  : mytrack,
-                       't'  : self['title'],
-                       'y'  : self['year'],
-                       'f'  : self['name'] }
+            song_info = {  'a'  : self['artist'],
+                           'l'  : self['album'],
+                           'n'  : mytrack,
+                           't'  : self['title'],
+                           'y'  : self['year'],
+                           'f'  : self['name'] }
 
-        if self.parent and hasattr(self.parent, 'AUDIO_FORMAT_STRING'):
-            return self.parent.DIRECTORY_AUDIO_FORMAT_STRING % song_info
-        return config.DIRECTORY_AUDIO_FORMAT_STRING % song_info
+            if hasattr(self.parent, 'AUDIO_FORMAT_STRING'):
+                formatstring = self.parent.DIRECTORY_AUDIO_FORMAT_STRING
+            else:
+                formatstring = config.DIRECTORY_AUDIO_FORMAT_STRING
+
+            formatted_info = formatstring % song_info
+
+            # check if the song info was not empty
+            if formatted_info != (formatstring % { 'a' : '', 'l' : '', 'n' : ' 
 ', 't' : '', 'y' : '', 'f' : '' }):
+                return formatted_info
+
+        # fallback to current song name
+        if self.name:
+            return self.name
+
+        # last fallback: return filename
+        return os.path.split(self.filename)[1]
+
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to