This commit is contained in:
ChaotiCryptidz 2022-02-10 11:32:45 +00:00
parent 86f4865ac7
commit 8a6502bf45
3 changed files with 46 additions and 37 deletions

View file

@ -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] = []

View file

@ -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 += """
<table class="pure-table pure-table-horizontal">
<thead>
<tr>
<th>Path</th>
<th>Title</th>
<th>Artist</th>
<th>Format</th>
</tr>
</thead>
<tbody>
"""
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"""
<tr class="{tdClass}">
<td>{data_path}</td>
<td>{data_title}</td>
<td>{data_artist}</td>
<td>{data_extension}</td>
</tr>
"""
isOdd = not isOdd
html_content += """
</tbody>
</table>
"""
class GenHTMLCommand():
def __init__(self, args: GenHTMLArgs):
self.args = args
@ -66,42 +104,14 @@ class GenHTMLCommand():
</head>
<body>
"""
html_content += """
<table class="pure-table pure-table-horizontal">
<thead>
<tr>
<th>Path</th>
<th>Title</th>
<th>Artist</th>
<th>Format</th>
</tr>
</thead>
<tbody>
"""
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"""
<tr class="{tdClass}">
<td>{data_path}</td>
<td>{data_title}</td>
<td>{data_artist}</td>
<td>{data_extension}</td>
</tr>
"""
isOdd = not isOdd
html_content += """
</tbody>
</table>
</body>
</html>
"""
print("Writing HTML...")
with open(self.args.dest, "w+") as html_file:
html_file.write(html_content)

View file

@ -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%}")