Hi,

With the attched patch libtagupdate won't write the genre tag if an
option called clear_genre_tag is true. I prevented writing the tag at
all in libtagupdate just to be sure. It might be enough to pass genre=''
in libpodcasts, but that way at least the ogg files would actually have
an empty genre tag, whereas with this patch there won't be one at all.

The reason I wrote this patch is that the Sandisk Sansa players'
firmware handles files tagged with "podcast" differently from any others
and I want to be able to prevent that.

Here are the bugs (or features) of the firmware's podcast tag handling
I'm trying to avoid:
 - If the album tags of the media files differ, you specifically have to
choose an album to play, you can't just select all the podcasts at once.
 - The files are played in such an order that the files which have a
"higher alphanumeric order" get played first. For example foocast2.ogg
is played before foocast1.ogg and I really don't like that, I want to
play the podcasts in the order they were recorded.
 - Both of these bugs can be avoided by using a playlist, but the device
won't show any files on the playlist which have been tagged with the
"podcast" genre, because the special podcast handling takes precedence.
This is why I'd like to be able to remove the genre tag altogether and
make a playlist with the gPodder device playlist feature so I can
control which files are played and in which order.

If needed, I could make a bug report about this patch and we could
discuss this more there, the mailing list is fine too. If you think this
patch isn't that useful in general, I could maintain it just for myself
as well.


-- 
Ville-Pekka Vainio


diff --git a/src/gpodder/config.py b/src/gpodder/config.py
index 7eeb0db..44546d1 100644
--- a/src/gpodder/config.py
+++ b/src/gpodder/config.py
@@ -125,6 +125,7 @@ gPodderSettings = {
     'color_updating_feeds': (str, '#7db023'),
     'log_sqlite': (bool, False),
     'enable_html_shownotes': (bool, True),
+    'clear_genre_tag': ( bool, False ),
 
     # Hide the cover/pill from the podcast sidebar when it gets too small
     'podcast_sidebar_save_space': (bool, False),
diff --git a/src/gpodder/libpodcasts.py b/src/gpodder/libpodcasts.py
index 8f48dae..0e1d80c 100644
--- a/src/gpodder/libpodcasts.py
+++ b/src/gpodder/libpodcasts.py
@@ -335,7 +335,10 @@ class podcastChannel(object):
             if gl.config.update_tags and libtagupdate.tagging_supported():
                 filename = item.local_filename()
                 try:
-                    libtagupdate.update_metadata_on_file(filename, title=item.title, artist=self.title, genre='Podcast')
+                    if (gl.config.clear_genre_tag):
+                        libtagupdate.update_metadata_on_file(filename, title=item.title, artist=self.title, genre='')
+                    else:
+                        libtagupdate.update_metadata_on_file(filename, title=item.title, artist=self.title, genre='Podcast')
                 except Exception, e:
                     log('Error while calling update_metadata_on_file(): %s', e)
 
diff --git a/src/gpodder/libtagupdate.py b/src/gpodder/libtagupdate.py
index fadabff..2aff574 100644
--- a/src/gpodder/libtagupdate.py
+++ b/src/gpodder/libtagupdate.py
@@ -64,7 +64,7 @@ def update_metadata_on_file( filename, **metadata):
 
 
 def update_tag_ogg( filename, **metadata):
-    data = '\n'.join( [ '%s=%s' % ( i.upper(), metadata[i] ) for i in metadata ] + [''])
+    data = '\n'.join( [ '%s=%s' % ( i.upper(), metadata[i] ) for i in metadata if metadata[i] != ''] + [''])
 
     p = popen2.Popen3('vorbiscomment -w "%s"' % filename)
 
@@ -102,7 +102,7 @@ def update_tag_mp3( filename, **metadata):
             tag.setTitle( metadata[key])
         elif key.lower() == 'album':
             tag.setAlbum( metadata[key])
-        elif key.lower() == 'genre':
+        elif key.lower() == 'genre' and metadata[key] != '':
             tag.setGenre(metadata[key])
 
     return tag.update( eyeD3.tag.ID3_V2) == 1 and tag.update( eyeD3.tag.ID3_V1) == 1
_______________________________________________
gpodder-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/gpodder-devel

Reply via email to