Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to display abook length #1

Open
asdil12 opened this issue Jul 28, 2017 · 0 comments
Open

Add option to display abook length #1

asdil12 opened this issue Jul 28, 2017 · 0 comments

Comments

@asdil12
Copy link
Member

asdil12 commented Jul 28, 2017

Maybe cache the info within the abook folder?

Sample code for mp3:

#!/usr/bin/python                                                                                                                                              

import glob
from mutagen.mp3 import MP3 
files = glob.glob ('*.mp3')
myTotal = 0 
 
def fix_time( seconds ):
  hours = int(seconds) / 3600
  seconds = seconds % 3600
  minutes = int(seconds) / 60
  seconds = seconds % 60
  seconds = int(seconds)
  return "%d:%02d:%02d" % (hours, minutes, seconds)
 
for eachfile in files:
    audio = MP3(eachfile)
    eachTime = fix_time( audio.info.length )
    print("File: %s - Length: %s" % (eachfile, eachTime))
    myTotal = myTotal + audio.info.length
 
newTotal = fix_time( myTotal )   
print("Total time: %s" % (newTotal))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant