FFMpeg-Compressor: Compress subfolders & Add progressbar
This commit is contained in:
parent
250c4f789a
commit
1caebeb158
6 changed files with 63 additions and 45 deletions
|
@ -1,21 +1,38 @@
|
|||
import os
|
||||
from progress.bar import IncrementalBar
|
||||
|
||||
|
||||
# Fill whole string with spaces for cleaning progress bar
|
||||
def clean_str(string):
|
||||
return string + " " * (os.get_terminal_size().columns - len(string))
|
||||
|
||||
|
||||
def bar_init(folder):
|
||||
file_count = 0
|
||||
for folder, folders, file in os.walk(folder):
|
||||
file_count += len(file)
|
||||
global bar
|
||||
bar = IncrementalBar('Compressing', max=file_count, suffix='[%(index)d/%(max)d] (%(percent).1f%%) - ETA: %(eta)ds')
|
||||
|
||||
|
||||
def info(string):
|
||||
print(f"[INFO] \033[0;32m{string}\033[0m")
|
||||
print(clean_str(f"\r\033[0;32m[INFO] \033[0m {string}" + " "))
|
||||
|
||||
|
||||
def files(progress, source, dest, dest_ext, comment):
|
||||
def files(source, dest, dest_ext, comment):
|
||||
|
||||
source_ext = os.path.splitext(source)[1]
|
||||
source_name= os.path.splitext(source)[0]
|
||||
source_name = os.path.splitext(source)[0]
|
||||
|
||||
if progress < 10:
|
||||
progress = f" {progress}"
|
||||
elif progress < 100:
|
||||
progress = f" {progress}"
|
||||
print(clean_str(f"\r[COMP] \033[0;32m{source_name}\033[0m{source_ext}\033[0;32m -> {dest}\033[0m.{dest_ext}\033[0;32m ({comment})\033[0m"))
|
||||
bar.next()
|
||||
|
||||
print(f"[{progress}%] \033[0;32m{source_name}\033[0m{source_ext}\033[0;32m -> {dest}\033[0m.{dest_ext}\033[0;32m ({comment})\033[0m")
|
||||
|
||||
def unknown_file(file):
|
||||
|
||||
print(clean_str(f"\r[COMP] \033[0;33m{file}\033[0m"))
|
||||
bar.next()
|
||||
|
||||
|
||||
def warning(string):
|
||||
print(f"\033[0;33m[WARNING] {string}\033[0m")
|
||||
print(clean_str(f"\r\033[0;33m[WARNING] {string}\033[0m"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue