add regex to test if audio file names are correctly formated
This commit is contained in:
parent
13ae7e5b57
commit
1fe049e065
|
@ -8,13 +8,13 @@ class Config:
|
|||
password = None
|
||||
url = None
|
||||
path = None
|
||||
|
||||
|
||||
def parse_args(self):
|
||||
parser = argparse.ArgumentParser(description='Process some integers.')
|
||||
parser.add_argument('--path', type=str, help='Path to config yaml file', dest='path')
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
def load_config(self, path=None):
|
||||
if path is None:
|
||||
path = '.config.yaml'
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
import time
|
||||
import os
|
||||
import re
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
|
@ -33,11 +34,15 @@ class Picker:
|
|||
if file_marker < marker:
|
||||
return file
|
||||
|
||||
def match_name(self, input):
|
||||
pattern = r"^\d{4}_\d{2}_\d{2}_\d{2}_\d{2}_\d{2}\.m4a$"
|
||||
return bool(re.match(pattern, input))
|
||||
|
||||
def list_files(self):
|
||||
files = []
|
||||
for filename in os.listdir(self.directory):
|
||||
filepath = os.path.join(self.directory, filename)
|
||||
if os.path.isfile(filepath) and filename.endswith(".m4a"):
|
||||
if os.path.isfile(filepath) and self.match_name(filename):
|
||||
files.append(filepath)
|
||||
return files
|
||||
|
||||
|
|
Loading…
Reference in New Issue