Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Python and libgpod (gtkpod) to load music to an iPod from Linux

Tags:

python

linux

ipod

The following code, which I think is a minimal program to load music

db = Database('/media/[email protected] ipod')
itdb_device_set_sysinfo(db._itdb.device, "ModelNumStr", "C297")
db.import_file('/home/andrew/some-track.mp3')
db.copy_delayed_files()
db.close()

prints the following to stderr:

** (utrunner.py:11333): WARNING **: Itdb_Track ID '0' not found.
** (utrunner.py:11333): CRITICAL **: itdb_get_mountpoint: assertion `itdb' failed
** (utrunner.py:11333): CRITICAL **: prepare_itdb_for_write: assertion `link' failed
** (utrunner.py:11333): CRITICAL **: mk_mhla: assertion `fexp->albums' failed
** (utrunner.py:11333): CRITICAL **: mk_mhli: assertion `fexp->artists' failed
** (utrunner.py:11333): CRITICAL **: itdb_splr_validate: assertion `at != ITDB_SPLAT_UNKNOWN' failed

and does not load any music.

When I run gtkpod (which uses libgpod - they are both from the same project), it does work (and prints only the initial warning and the ITDB_SPLAT_UNKNOWN message). The paths are all correct and I can open directories, write to files, etc. The database object appears to be correct (shows 2 playlists, for example) and the SysInfoExtended file is present.

What am I doing wrong? Has anyone got this (the libgpod Python wrapper) to work?

One possible clue is that gtkpod prompts me for the iPod type (Classic 160GB). I do not set that information above. How can I set that? update - I did try the call shown above and mentioned in an answer below, but it seemed to have no effect (I didn't include it originally because I thought it must have been wrong, but perhaps it is needed and the problem is elsewhere). Also, gtkpod calls it "xB150"?!

I have asked the libgpod/gtkpod mailing list, but received no response. This is with both the latest stable release and the git trunk (compiled with CFLAGS=-w).

update I deleted all music, then ran the code above with both C297 and xB150. in neither case did the file Extras.itdb (which looks like an sqlite db) change size and the disconnected iPod has no songs. related files are at the following links:

  • SysInfo (empty file)
  • SysInfoExtended
  • Extras.itdb (sqlite db?)

General notes on this issue, which will be updated in future, here.

like image 434
andrew cooke Avatar asked Aug 02 '12 12:08

andrew cooke


1 Answers

One possible clue is that gtkpod prompts me for the iPod type (Classic 160GB). I do not set that information above. How can I set that?

itdb_device_set_sysinfo (db._itdb.device, "ModelNumStr", "FOOBAR");

Replace FOOBAR with your model according to the model list.

Edit:

My suggestion is to compile gtkpod with debug symbols and trace its run with gdb. A breakpoint in libgtkpod/file.c:add_track_by_filename() seems a nice starting point.

Compare its usage of libgpod with yours and see if there are any additional calls. Obviously, the Python bindings abstract things more but it shouldn't be a problem to figure out what they end up calling.

(eg. import_file calls itdb_cp_track_to_ipod and itdb_playlist_add_track)

Sorry, that's all the help I can give without access to the device.

like image 184
InternetSeriousBusiness Avatar answered Nov 15 '22 18:11

InternetSeriousBusiness