ITunesDB/OTG Playlist File

From iPodLinux

Jump to: navigation, search

On The Go Playlist files

mhpo format
offset field size value
0 header identifier 4 mhpo
4 file size 4 the header length, always 20 on my 4gen iPod
8 unk1 4 unknown, appears to always be 0 (on my 4gen iPod it seems to be always 4)
12 tracks 4 number of tracks in this OTG playlist
16 unk2 4 unknown, appears to always be 0 (on my 4gen iPod it is a fixed number, and the OTG file will not work if this number is 0)
20 track index number 4 * tracks This is a list of the tracks in the playlist, one after another. The number is a zero based index into the Track List (MHLT) in the iTunesDB file. So the first track in the MHLT would be 0, the second would be 1, and so forth.

Because the OTG Playlist uses track indexes, it is only valid until the next time the iTunesDB changes. This means that you should read any OTGPlaylist files on a sync and create proper Playlists for them in the iTunesDB file or do something else with them. After you change the iTunesDB file, they won't be valid anymore.

iTunes handles this by deleting the files once they are read, during an autosync. Apple's iPod firmware also deletes these files if the iTunesDB changes and it detects it, after you undock the iPod. iTunes will read them and create real playlists from them before it syncs anything. Note that in any sync operation, this *must* occur before the iTunesDB changes, otherwise you'll lose the playlist.