add regex to test if audio file names are correctly formated
This commit is contained in:
parent
13ae7e5b57
commit
1fe049e065
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
@ -33,11 +34,15 @@ class Picker:
|
||||||
if file_marker < marker:
|
if file_marker < marker:
|
||||||
return file
|
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):
|
def list_files(self):
|
||||||
files = []
|
files = []
|
||||||
for filename in os.listdir(self.directory):
|
for filename in os.listdir(self.directory):
|
||||||
filepath = os.path.join(self.directory, filename)
|
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)
|
files.append(filepath)
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue