unified all "folder/directory" into "directory" to end this mess

This commit is contained in:
k4yt3x
2019-04-29 00:06:54 -04:00
parent 0af68bb39c
commit c7353c4bf2
8 changed files with 93 additions and 94 deletions

View File

@@ -5,7 +5,7 @@ Name: Video2X Image Cleaner
Author: BrianPetkovsek
Author: K4YT3X
Date Created: March 24, 2019
Last Modified: April 21, 2019
Last Modified: April 28, 2019
Description: This class is to remove the extracted frames
that have already been upscaled.
@@ -27,11 +27,11 @@ class ImageCleaner(threading.Thread):
threading.Thread
"""
def __init__(self, input_folder, output_folder, num_threads):
def __init__(self, input_directory, output_directory, threads):
threading.Thread.__init__(self)
self.input_folder = input_folder
self.output_folder = output_folder
self.num_threads = num_threads
self.input_directory = input_directory
self.output_directory = output_directory
self.threads = threads
self.running = False
def run(self):
@@ -53,23 +53,23 @@ class ImageCleaner(threading.Thread):
""" remove frames that have already been upscaled
This method compares the files in the extracted frames
folder with the upscaled frames folder, and removes
directory with the upscaled frames directory, and removes
the frames that has already been upscaled.
"""
# list all images in the extracted frames
output_frames = [f for f in os.listdir(self.output_folder) if os.path.isfile(os.path.join(self.output_folder, f))]
output_frames = [f for f in os.listdir(self.output_directory) if os.path.isfile(os.path.join(self.output_directory, f))]
# compare and remove frames downscaled images that finished being upscaled
# within each thread's extracted frames folder
for i in range(self.num_threads):
dir_path = os.path.join(self.input_folder, str(i))
# within each thread's extracted frames directory
for i in range(self.threads):
dir_path = os.path.join(self.input_directory, str(i))
# for each file within all the folders
# for each file within all the directories
for f in os.listdir(dir_path):
file_path = os.path.join(dir_path, f)
# if file also exists in the output folder, then the file
# if file also exists in the output directory, then the file
# has already been processed, thus not needed anymore
if os.path.isfile(file_path) and f in output_frames:
os.remove(file_path)