Skip to content

Commit

Permalink
pysnippetGH-49: Update progress descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtyomVancyan committed Mar 17, 2023
1 parent bccfa67 commit d0d7f6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/thumbnails/thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, video, base, skip, output):
self.metadata_path = self._get_metadata_path()
self._perform_skip()

with Progress("Extracting frames", "Frames have been extracted"):
with Progress("Extracting the frames by the given interval"):
self.extract_frames()

def _get_metadata_path(self):
Expand Down Expand Up @@ -103,14 +103,15 @@ def prepare_frames(self):
master = Image.new(mode="RGBA", size=next(thumbnails))
master_path = os.path.join(self.thumbnail_dir, extract_name(self.filepath) + ".png")

with Progress("Processing frames", "Frames have been merged into one") as progress:
with Progress("Preprocessing the frames before merging") as progress:
for frame, *_, x, y in thumbnails:
progress.update("Processing '%s'" % frame)
offset = extract_name(frame).replace("-", ":").split(".")[0]
progress.update("Processing [bold]%s[/bold] frame" % offset)
with Image.open(frame) as image:
image = image.resize((self.width, self.height), Image.ANTIALIAS)
master.paste(image, (x, y))

progress.update("Saving the result '%s'" % master_path)
with Progress("Saving the result at '%s'" % master_path):
master.save(master_path)

def generate(self):
Expand All @@ -123,7 +124,7 @@ def format_time(secs):
route = os.path.join(prefix, extract_name(self.filepath) + ".png")
route = pathlib.Path(route).as_posix()

with Progress("Generating thumbnail metadata", "Thumbnail metadata has been generated") as progress:
with Progress("Saving thumbnail metadata at '%s'" % self.metadata_path) as progress:
for _, start, end, x, y in self.thumbnails():
progress.update("Generating metadata for '%s'" % route)
thumbnail_data = "%s --> %s\n%s#xywh=%d,%d,%d,%d\n\n" % (
Expand Down
2 changes: 1 addition & 1 deletion src/thumbnails/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, filepath, compress, interval):
self.__frames_count = None
self.__columns = None

with Progress("Parsing the video metadata ...", "Metadata has been parsed"):
Remove useless `done_description` with Progress("Parsing metadata from the video"):
_FFMpeg.__init__(self, filepath)
_Frame.__init__(self, self.size)

Expand Down

0 comments on commit d0d7f6b

Please sign in to comment.