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 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
	
	Block a user