22from os import scandir
33
44image_extensions = [".jpg" , ".jpeg" , ".png" , ".tif" , ".tiff" ]
5+ video_extensions = [".mp4" , ".mov" , ".mpg" , ".wmv" , ".mkv" , ".avi" , ".avchd" , ".flv" , ".f4v" , ".swf" , "webm" ]
56
67def write_bytes_safe (p , bytes_data ):
78 """
@@ -21,7 +22,7 @@ def scantree(path):
2122 else :
2223 yield entry
2324
24- def get_image_paths (dir_path , image_extensions = image_extensions , subdirs = False , return_Path_class = False ):
25+ def get_extension_paths (dir_path , extensions , subdirs = False , return_Path_class = False ):
2526 dir_path = Path (dir_path )
2627
2728 result = []
@@ -33,10 +34,16 @@ def get_image_paths(dir_path, image_extensions=image_extensions, subdirs=False,
3334 gen = scandir (str (dir_path ))
3435
3536 for x in gen :
36- if any (x .name .lower ().endswith (ext ) for ext in image_extensions ): # listcomp is not needed, any() can handle gencomp
37- result .append ( Path (x ) if return_Path_class else x .path ) # avoid unnecessary negative condition
37+ if any (x .name .lower ().endswith (ext ) for ext in extensions ): # listcomp is not needed, any() can handle gencomp
38+ result .append ( Path (x ) if return_Path_class else x .path ) # avoid unnecessary negative condition
3839 return result # scandir should already be sorted
3940
41+ def get_image_paths (dir_path , image_extensions = image_extensions , subdirs = False , return_Path_class = False ):
42+ return get_extension_paths (dir_path , image_extensions , subdirs , return_Path_class )
43+
44+ def get_video_paths (dir_path , video_extensions = video_extensions , subdirs = False , return_Path_class = False ):
45+ return get_extension_paths (dir_path , video_extensions , subdirs , return_Path_class )
46+
4047def get_image_unique_filestem_paths (dir_path , verbose_print_func = None ):
4148 result = get_image_paths (dir_path )
4249 result_dup = set ()
@@ -59,7 +66,7 @@ def get_paths(dir_path):
5966 return [ Path (x ) for x in sorted ([ x .path for x in list (scandir (str (dir_path ))) ]) ]
6067 else :
6168 return []
62-
69+
6370def get_file_paths (dir_path ):
6471 dir_path = Path (dir_path )
6572
0 commit comments