Booom...........

LabNotes and Random Thoughts...............

Thursday, August 13, 2015

mp3 time

so many audio books...
how to check the length of each mp3
I want it as h:m:s format

So this is what i did

import mutagen
from glob import glob

import time

def mp3LengthList(files):
    '''list->list
    '''
    s=[]
    for i in files:
        m = mutagen.File(i)
        s.append(m.filename + " : " + secondsToPrint( float(m.info.length) ) )
    return s

def secondsToPrint(seconds):

    return time.strftime("%H:%M:%S", time.gmtime(seconds))
f = glob("../Richard Dawkins/The Selfish Gene - 1976/*.mp3")

../Richard Dawkins/The Selfish Gene - 1976/The Selfish Gene - 01.mp3 : 02:00:00
../Richard Dawkins/The Selfish Gene - 1976/The Selfish Gene - 02.mp3 : 02:00:00
../Richard Dawkins/The Selfish Gene - 1976/The Selfish Gene - 03.mp3 : 02:00:00
../Richard Dawkins/The Selfish Gene - 1976/The Selfish Gene - 04.mp3 : 01:45:30
../Richard Dawkins/The Selfish Gene - 1976/The Selfish Gene - 05.mp3 : 02:00:00
../Richard Dawkins/The Selfish Gene - 1976/The Selfish Gene - 06.mp3 : 02:00:00
../Richard Dawkins/The Selfish Gene - 1976/The Selfish Gene - 07.mp3 : 02:00:00
../Richard Dawkins/The Selfish Gene - 1976/The Selfish Gene - 08.mp3 : 02:00:00
../Richard Dawkins/The Selfish Gene - 1976/The Selfish Gene - 09.mp3 : 00:25:00

No comments: