Update of /cvsroot/gtkpod/libgpod/bindings/python
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv6099/python
Modified Files:
gtkpod.py
Log Message:
Support sha1_hash entries in the extended database as well as md5_hash. Thanks
to Todd for noticing.
Index: gtkpod.py
===================================================================
RCS file: /cvsroot/gtkpod/libgpod/bindings/python/gtkpod.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gtkpod.py 14 Jan 2007 20:29:38 -0000 1.3
+++ gtkpod.py 14 Jan 2007 21:23:43 -0000 1.4
@@ -47,20 +47,23 @@
file.write('\n')
write_pair("itunesdb_hash", sha1_hash(itunesdb_file))
- write_pair("version", "0.88.1")
+ write_pair("version", "0.99.9")
for track in db:
write_pair("id", track['id'])
if not track['userdata']:
track['userdata'] = {}
- track['userdata']['filename_ipod'] = track.ipod_filename()
+ track['userdata']['filename_ipod'] = track['ipod_path']
try:
- del track['userdata']['md5_hash']
- except IndexError:
- pass
- if track['userdata'].has_key('filename_locale') and not
track['userdata'].has_key('md5_hash'):
+ hash_name = 'sha1_hash'
+ del track['userdata'][hash_name]
+ except KeyError:
+ # recent gpod uses sha1_hash, older uses md5_hash
+ hash_name = 'md5_hash'
+ del track['userdata'][hash_name]
+ if track['userdata'].has_key('filename_locale') and not
track['userdata'].has_key(hash_name):
if os.path.exists(track['userdata']['filename_locale']):
- track['userdata']['md5_hash'] = sha1_hash(
+ track['userdata'][hash_name] = sha1_hash(
track['userdata']['filename_locale'])
[write_pair(i[0],i[1]) for i in track['userdata'].items()]
@@ -115,7 +118,13 @@
tracks_by_id[id]['userdata'] = ext_block
else:
for track in db:
+ # make a dict to allow us to find each track by the sha1_hash
tracks_by_sha[sha1_hash(track.ipod_filename())] = track
for ext_block in ext_data.values():
- tracks_by_sha[ext_block['md5_hash']]['userdata'] = ext_block
+ try:
+ track = tracks_by_sha[ext_block['sha1_hash']]
+ except KeyError:
+ # recent gpod uses sha1_hash, older uses md5_hash
+ track = tracks_by_sha[ext_block['md5_hash']]
+ track['userdata'] = ext_block
-------------------------------------------------------------------------
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
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2