mtime in the database file [Solved]

Discuss client development (or even MPD development if you feel so inclined), ask questions about the client libs, MPD feature requests from client developers, etc...
Post Reply
ryeguy146
Posts: 1
Joined: April 28th, 2013, 10:14 am

mtime in the database file [Solved]

Post by ryeguy146 » April 28th, 2013, 10:22 am

I've got an extremely large music collection, and mpd seems to struggle with it. When creating a db file, it crashes after reaching a certain point. I've determined that it isn't a file that's causing problems as I've moved the files where it has quit before out of the directory, and it still crashes after a certain number of files have been read into the db. I should note that this is likely a Windows (as in Windows 7) error. I've never seen this issue on linux, and if I could, I'd be using linux here, but that's not possible. MPD works perfectly if I set the music root to a directory that holds a smaller number of files.

So I'm looking to create a quick python script to craft a db file (thanks for making it plaintext!), but I'm stumbling over one aspect: mtime. I believe that this is the modify date, but I can't puzzle out how to convert it from the ISO format I see using an `ls` command to what I see in the db file. Some examples:

Code: Select all

mtime: 1267504195  ISO: 2010-03-01 19:29:55
mtime: 1267504196  ISO: 2010-03-01 19:29:56
mtime: 1267504197  ISO: 2010-03-01 19:29:57
mtime: 1267504198  ISO: 2010-03-01 19:29:58
mtime: 1278004187  ISO: 2010-07-01 10:09:47
mtime: 1267572094  ISO: 2010-03-02 14:21:34
mtime: 1267572093  ISO: 2010-03-02 14:21:33
mtime: 1281124198  ISO: 2010-08-06 12:49:58
mtime as reported by the db file constructed by mpd
ISO as reported by `ls -l --time-style=full-iso`

I looked through the help file, and even some of the source code (song.h), but I can't find it. Can anyone help me? I just need to be able to convert the ISO time to whatever you're using in the db file.

EDIT: Nevermind, it's just seconds since Epoch.

Code: Select all

from datetime import datetime
import time


EPOCH = datetime(1970, 1, 1)

def seconds_since_epoch(datetime_obj):
    since_epoch = datetime_obj - EPOCH
    return since_epoch.total_seconds()

Post Reply