Skip to content

Commit

Permalink
getFiles and durations
Browse files Browse the repository at this point in the history
  • Loading branch information
peynaj committed Feb 24, 2019
1 parent cd35834 commit b2d7239
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion mconv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import argparse
from mutagen.mp3 import MP3

conv = [
" ",
Expand Down Expand Up @@ -66,7 +67,6 @@ def video_to_audio_and_change_rate(dir_path, speed_rate=2):
print('# {} -> finished!'.format(new_fpath))



def video_to_audio(dir_path):
prefix = '{}_r_'.format('ToAudio')
if os.path.exists(dir_path):
Expand Down Expand Up @@ -94,4 +94,18 @@ def video_to_audio(dir_path):
os.system(comm)
print('# {} -> finished!'.format(new_fpath))

def get_files(bp):
files = []
for d in os.listdir(bp):
if os.path.isfile(os.path.join(bp,d)):
files.append(os.path.join(bp,d))
elif os.path.isdir(os.path.join(bp,d)):
_files = get_files(os.path.join(bp,d))
files.extend(_files)
return files

def get_audio_details(p):
l = get_files(p)
d = {i: MP3(i).info.length/60 for i in l}
return d

0 comments on commit b2d7239

Please sign in to comment.