Stat Fehler Id angepasst

This commit is contained in:
Eduard Wisch 2025-04-24 10:56:14 +02:00
parent 4fc5249c0b
commit 3f2bf175c7
2 changed files with 9 additions and 5 deletions

View file

@ -7,7 +7,7 @@ class Media:
def __init__(self, path, streams_video, streams_audio, streams_subtitle, streams_format): def __init__(self, path, streams_video, streams_audio, streams_subtitle, streams_format):
# misc # misc
self.id = Media._id_counter self.id = int(f"{time.time()}{Media._id_counter}")
# source # source
self.source_file: str = path self.source_file: str = path
self.source_path: str = os.path.dirname(path) self.source_path: str = os.path.dirname(path)
@ -99,9 +99,8 @@ class Media:
} }
def to_dict_stat(self): def to_dict_stat(self):
return {time.time(): { return {self.id: {
# source # source
"id": self.id,
"source_file_name": self.source_file_name, "source_file_name": self.source_file_name,
"source_file": self.source_file, "source_file": self.source_file,
"source_duration": self.source_duration, "source_duration": self.source_duration,

View file

@ -1,3 +1,5 @@
import logging
import yaml import yaml
import os import os
@ -16,8 +18,11 @@ class Stat:
daten["videos"].update(obj.to_dict_stat()) daten["videos"].update(obj.to_dict_stat())
# Datei mit aktualisierten Daten speichern # Datei mit aktualisierten Daten speichern
try:
with open(self.path, "w", encoding="utf8") as file: with open(self.path, "w", encoding="utf8") as file:
yaml.dump(daten, file, default_flow_style=False, indent=4, allow_unicode=True) yaml.dump(daten, file, default_flow_style=False, indent=4, allow_unicode=True)
except Exception as e:
logging.error(f"Save Stat Failure: {e}")
def read_stat(self): def read_stat(self):
# Bestehende Daten laden # Bestehende Daten laden