sane-tag-music: print results in real-time

This commit is contained in:
2024-07-11 23:59:31 +00:00
parent e2cca54e08
commit 6ccdbf50cd

View File

@@ -809,7 +809,7 @@ class Tagger:
return True
def walk_files(*roots: str) -> None:
def walk_paths(*roots: str) -> None:
for root in roots:
if os.path.isdir(root):
for dir_, subdirs, files_ in os.walk(root):
@@ -818,6 +818,15 @@ def walk_files(*roots: str) -> None:
else:
yield root
def walk_files(paths: list[str], media_type: MediaType):
for path_ in walk_paths(*paths):
file_ = MediaFile.new(path_)
if not file_:
logger.debug(f"skipping unsupported file: {path_}")
continue
if media_type is not None and not file_.is_type(media_type):
continue
yield file_
def main():
logging.basicConfig()
@@ -858,9 +867,6 @@ def main():
if args.verbose:
logging.getLogger().setLevel(logging.DEBUG)
media_type = args.type
file_paths = list(walk_files(*args.path))
manual_tags = Tags(
album=[args.album] if args.album else [],
albumartist=[args.album_artist] if args.album_artist else [],
@@ -876,15 +882,7 @@ def main():
manual_tags=manual_tags,
)
files = []
for path_ in file_paths:
file_ = MediaFile.new(path_)
if not file_:
logger.debug(f"skipping unsupported file: {path_}")
continue
if media_type is not None and not file_.is_type(media_type):
continue
files.append(file_)
files = walk_files(args.path, args.type)
if args.subcommand == "show":
for f in files: