diff --git a/app/class_file_convert_read_out.py b/app/class_file_convert_read_out.py index dac98eb..a002c0d 100644 --- a/app/class_file_convert_read_out.py +++ b/app/class_file_convert_read_out.py @@ -112,38 +112,3 @@ class Process: "bitrate": self.bitrate, "speed": self.speed }}} - - @staticmethod - def size_convert(source: str, target, unit: str, size=0): - list_unit: list = [] - - if unit == "storage": - list_unit = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"] - elif unit == "data_rate": - list_unit = ["bps", "Kbps", "Mbps", "Gbps", "Tbps", "Pbps"] - elif unit == "binary_data_rate": - list_unit = ["b/s", "Kib/s", "Mib/s", "Gib/s", "Tib/s", "Pib/s"] - - factor = 1024 # Binäre Umrechnung - - if source not in list_unit: - raise ValueError("Ungültige Quell-Einheit!") - - source_index = list_unit.index(source) - - if target: - if target not in list_unit: - raise ValueError("Ungültige Ziel-Einheit!") - target_index = list_unit.index(target) - - if source_index < target_index: - return size / (factor ** (target_index - source_index)), target - else: - return size * (factor ** (source_index - target_index)), target - - # Automatische Umrechnung - while size >= 1000 and source_index < len(list_unit) - 1: - size /= factor - source_index += 1 - - return [round(size,1), list_unit[source_index]] diff --git a/app/class_media_file.py b/app/class_media_file.py index d245e16..18a16cb 100644 --- a/app/class_media_file.py +++ b/app/class_media_file.py @@ -11,7 +11,7 @@ class Media: self.source_file: str = path self.source_file_name: str = os.path.basename(self.source_file) self.source_duration: int = self.time_in_sec(streams_video[0]["tags"].get("DURATION" or "duration", "00:00:00")) - self.source_size: int = 0 + self.source_size: list = self.size_convert("B", None, "storage", int(streams_format[0].get("size"))) self.source_frame_rate: int = self.frame_rate(streams_video) self.source_frames_total: int = self.source_frame_rate * self.source_duration self.source_time: int = 0 @@ -172,4 +172,39 @@ class Media: h, m, s = map(float, parts) # In float umwandeln, falls Nachkommastellen im Sekundenwert sind return int(h * 3600 + m * 60 + s) # Alles in Sekunden umrechnen - raise ValueError(f"Ungültiges Zeitformat: {time_str}") \ No newline at end of file + raise ValueError(f"Ungültiges Zeitformat: {time_str}") + + @staticmethod + def size_convert(source: str, target, unit: str, size=0): + list_unit: list = [] + + if unit == "storage": + list_unit = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"] + elif unit == "data_rate": + list_unit = ["bps", "Kbps", "Mbps", "Gbps", "Tbps", "Pbps"] + elif unit == "binary_data_rate": + list_unit = ["b/s", "Kib/s", "Mib/s", "Gib/s", "Tib/s", "Pib/s"] + + factor = 1024 # Binäre Umrechnung + + if source not in list_unit: + raise ValueError("Ungültige Quell-Einheit!") + + source_index = list_unit.index(source) + + if target: + if target not in list_unit: + raise ValueError("Ungültige Ziel-Einheit!") + target_index = list_unit.index(target) + + if source_index < target_index: + return size / (factor ** (target_index - source_index)), target + else: + return size * (factor ** (source_index - target_index)), target + + # Automatische Umrechnung + while size >= 1000 and source_index < len(list_unit) - 1: + size /= factor + source_index += 1 + + return [round(size, 1), list_unit[source_index]] \ No newline at end of file diff --git a/app/main_server.py b/app/main_server.py index d21cc47..d7c74e7 100644 --- a/app/main_server.py +++ b/app/main_server.py @@ -99,7 +99,7 @@ class Server: app.router.add_get("/", self.handle_index) app.router.add_get("/api/ip", self.handle_ip) app.router.add_get("/api/stats", self.handle_stat) - app.router.add_static("/client", path="./client", name="client") + app.router.add_static("/client/", path="./client", name="client") runner = web.AppRunner(app) await runner.setup() site = web.TCPSite(runner, "0.0.0.0", 8080) diff --git a/client/index.html b/client/index.html index a5d1e40..54a519b 100755 --- a/client/index.html +++ b/client/index.html @@ -4,6 +4,7 @@ Websocket Client +