Revision: 1963
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1963&view=rev
Author:   jcsjcs
Date:     2008-04-19 02:13:33 -0700 (Sat, 19 Apr 2008)

Log Message:
-----------
        * bindings/python/examples/Makefile.am
          Added fix_empty_artist_field.py provided by Thomas Perl.

Modified Paths:
--------------
    libgpod/trunk/ChangeLog
    libgpod/trunk/bindings/python/examples/Makefile.am

Added Paths:
-----------
    libgpod/trunk/bindings/python/examples/fix_empty_artist_field.py

Modified: libgpod/trunk/ChangeLog
===================================================================
--- libgpod/trunk/ChangeLog     2008-04-19 04:33:50 UTC (rev 1962)
+++ libgpod/trunk/ChangeLog     2008-04-19 09:13:33 UTC (rev 1963)
@@ -1,3 +1,8 @@
+2008-01-26  Jorg Schuler <jcsjcs at users.sourceforge.net>
+
+        * bindings/python/examples/Makefile.am
+         Added fix_empty_artist_field.py provided by Thomas Perl.
+
 2008-03-29  Todd Zullinger  <tmzullinger at users.sourceforge.net>
 
        * bindings/python/Makefile.am

Modified: libgpod/trunk/bindings/python/examples/Makefile.am
===================================================================
--- libgpod/trunk/bindings/python/examples/Makefile.am  2008-04-19 04:33:50 UTC 
(rev 1962)
+++ libgpod/trunk/bindings/python/examples/Makefile.am  2008-04-19 09:13:33 UTC 
(rev 1963)
@@ -2,6 +2,7 @@
         add_song.py                     \
         coverart_fetch.py               \
         create_mp3_tags_from_itdb.py    \
+       fix_empty_artist_field.py       \
         play_with_ipod_api.py           \
         play_with_smart_playlists.py    \
         save_photos.py                  \

Added: libgpod/trunk/bindings/python/examples/fix_empty_artist_field.py
===================================================================
--- libgpod/trunk/bindings/python/examples/fix_empty_artist_field.py            
                (rev 0)
+++ libgpod/trunk/bindings/python/examples/fix_empty_artist_field.py    
2008-04-19 09:13:33 UTC (rev 1963)
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+"""
+Fix iTunesDB tracks that have filename-like titles, but no artist
+-----------------------------------------------------------------
+
+Edit tracks that have no artist, but a title that looks like a 
+MP3 filename, by trying to split the title into Artist and Title 
+fields and then updating the fields in the iTunesDB.
+
+Author: Thomas Perl <thpinfo.com>, 2008-03-28
+"""
+
+import gpod
+import os.path
+import sys
+
+if len(sys.argv) == 1:
+    print 'Usage: python %s /path/to/ipod' % os.path.basename(sys.argv[0])
+    print __doc__
+    sys.exit(-1)
+else:
+    mount_point = sys.argv[-1]
+
+try:
+    db = gpod.Database(mount_point)
+except gpod.ipod.DatabaseException, dbe:
+    print 'Error opening your iPod database: %s' % dbe
+    sys.exit(-2)
+
+(updated, count) = (0, len(db))
+
+print 'Database opened: %d tracks to consider' % count
+for track in db:
+    # If the track has a ".mp3" title and no artist, try to fix it
+    if track['title'].lower().endswith('.mp3') and track['artist'] is None:
+        # Assume "Artist - Title.mp3" file names
+        items = os.path.splitext(track['title'])[0].split(' - ')
+        if len(items) == 2:
+            (artist, title) = items
+            print 'Correcting: %s' % track['title']
+            track['artist'] = artist
+            track['title'] = artist
+            updated += 1
+        else:
+            # Doesn't look like "Artist - Title.mp3", leave untouched
+            print 'Leaving untouched: %s' % repr(items)
+
+print 'Saving iPod database...'
+db.close()
+
+print 'Finished. %d tracks updated, %d tracks untouched' % (updated, 
count-updated)
+


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to