From 8a6502bf45aa979cd09dabce985d78c4c376ab09 Mon Sep 17 00:00:00 2001 From: ChaotiCryptidz Date: Thu, 10 Feb 2022 11:32:45 +0000 Subject: [PATCH] git push --- musicutil/commands/copy_command.py | 3 +- musicutil/commands/genhtml_command.py | 70 +++++++++++++++------------ musicutil/commands/stats_command.py | 10 ++-- 3 files changed, 46 insertions(+), 37 deletions(-) diff --git a/musicutil/commands/copy_command.py b/musicutil/commands/copy_command.py index 693e159..17b823f 100644 --- a/musicutil/commands/copy_command.py +++ b/musicutil/commands/copy_command.py @@ -2,7 +2,7 @@ from musicutil.utils.do_replaygain import do_replaygain from ..types import File from ..utils.scan_for_music import scan_for_music from ..utils.load_tag_information import load_tag_information -from ..transcode_presets import print_transcode_presets, transcode_presets_list +from ..transcode_presets import print_transcode_presets from ..utils.transcoder import TranscodeConfig, transcode, get_transcode_config from os import makedirs as make_directories @@ -10,7 +10,6 @@ from os.path import exists as path_exists from shutil import copy as copy_file from copy import deepcopy as deep_copy - class CopyCommandState: files: list[File] = [] transcoded_files: list[File] = [] diff --git a/musicutil/commands/genhtml_command.py b/musicutil/commands/genhtml_command.py index 17b7c8a..f90a63c 100644 --- a/musicutil/commands/genhtml_command.py +++ b/musicutil/commands/genhtml_command.py @@ -1,3 +1,4 @@ +from musicutil.types import File from musicutil.utils.load_tag_information import load_tag_information from musicutil.utils.scan_for_music import scan_for_music @@ -36,6 +37,43 @@ def get_genhtml_args(args) -> GenHTMLArgs: command_args.description = args.description return command_args +def make_table_for_files(files: list[File]) -> str: + html_content = "" + html_content += """ + + + + + + + + + + + """ + isOdd = True + for file in files: + tdClass = "pure-table-odd" if isOdd else "pure-table-even" + data_path = escape_html(file.path_from_src) + data_title = escape_html(file.tags.title) + data_artist = escape_html(file.tags.artist) + data_extension = escape_html(file.extension) + html_content += f""" + + + + + + + """ + isOdd = not isOdd + html_content += """ + +
PathTitleArtistFormat
{data_path}{data_title}{data_artist}{data_extension}
+ """ + + + class GenHTMLCommand(): def __init__(self, args: GenHTMLArgs): self.args = args @@ -66,42 +104,14 @@ class GenHTMLCommand(): """ - html_content += """ - - - - - - - - - - - """ - isOdd = True - for file in files: - tdClass = "pure-table-odd" if isOdd else "pure-table-even" - data_path = escape_html(file.path_from_src) - data_title = escape_html(file.tags.title) - data_artist = escape_html(file.tags.artist) - data_extension = escape_html(file.extension) + html_content += make_table_for_files(files) - html_content += f""" - - - - - - - """ - isOdd = not isOdd html_content += """ - -
PathTitleArtistFormat
{data_path}{data_title}{data_artist}{data_extension}
""" + print("Writing HTML...") with open(self.args.dest, "w+") as html_file: html_file.write(html_content) diff --git a/musicutil/commands/stats_command.py b/musicutil/commands/stats_command.py index 3d1285e..6faade5 100644 --- a/musicutil/commands/stats_command.py +++ b/musicutil/commands/stats_command.py @@ -44,11 +44,11 @@ class StatsCommand(): lossless_percent = (lossless_files_count/total_files_count) print("Stats:") - print(f"Total Files: {total_files_count}") - print(f"Lossy#: {lossy_files_count}/{total_files_count}") - print(f"Lossless#: {lossless_files_count}/{total_files_count}") - print(f"Lossy%: {lossy_percent:.2%}") - print(f"Lossless%: {lossless_percent:.2%}") + print(f" Total Files: {total_files_count}") + print(f" Lossy#: {lossy_files_count}/{total_files_count}") + print(f" Lossless#: {lossless_files_count}/{total_files_count}") + print(f" Lossy%: {lossy_percent:.2%}") + print(f" Lossless%: {lossless_percent:.2%}")