Extracted read_wave_duration out of code
This commit is contained in:
parent
7586aa37f3
commit
12e27e659a
|
@ -3,8 +3,6 @@ import mutagen
|
|||
import math
|
||||
import os
|
||||
import copy
|
||||
import wave
|
||||
import contextlib
|
||||
from collections import namedtuple
|
||||
from mutagen.easymp4 import EasyMP4KeyError
|
||||
|
||||
|
@ -214,11 +212,7 @@ class Metadata(Loggable):
|
|||
|
||||
# Hickity Hackity for .wav files. Properly do this later
|
||||
if mmp.extension(fpath) == 'wav':
|
||||
with contextlib.closing(wave.open(fpath,'r')) as f:
|
||||
frames = f.getnframes()
|
||||
rate = f.getframerate()
|
||||
duration = frames/float(rate)
|
||||
full_mutagen.set_length(duration)
|
||||
full_mutagen.set_length(mmp.read_wave_duration(fpath))
|
||||
|
||||
# Finally, we "normalize" all the metadata here:
|
||||
self.__metadata = mmp.normalized_metadata(self.__metadata, fpath)
|
||||
|
|
|
@ -3,6 +3,8 @@ import copy
|
|||
import subprocess
|
||||
import os
|
||||
import math
|
||||
import wave
|
||||
import contextlib
|
||||
import shutil
|
||||
import re
|
||||
import sys
|
||||
|
@ -97,6 +99,13 @@ def is_airtime_recorded(md):
|
|||
if not 'MDATA_KEY_CREATOR' in md: return False
|
||||
return md['MDATA_KEY_CREATOR'] == u'Airtime Show Recorder'
|
||||
|
||||
def read_wave_duration(path):
|
||||
with contextlib.closing(wave.open(path,'r')) as f:
|
||||
frames = f.getnframes()
|
||||
rate = f.getframerate()
|
||||
duration = frames/float(rate)
|
||||
return duration
|
||||
|
||||
def clean_empty_dirs(path):
|
||||
"""
|
||||
walks path and deletes every empty directory it finds
|
||||
|
|
Loading…
Reference in New Issue