Flatpak source cleanups

This commit is contained in:
kramo
2023-06-30 21:13:06 +02:00
parent fccf302c4b
commit 07960182c7
4 changed files with 29 additions and 3 deletions

View File

@@ -46,7 +46,7 @@ class FlatpakSourceIterator(SourceIterator):
with entry.open("r", encoding="utf-8") as open_file:
string = open_file.read()
desktop_values = {"Name": None, "Icon": None}
desktop_values = {"Name": None, "Icon": None, "Categories": None}
for key in desktop_values:
if regex := re.findall(f"{key}=(.*)\n", string):
desktop_values[key] = regex[0]
@@ -54,6 +54,12 @@ class FlatpakSourceIterator(SourceIterator):
if not desktop_values["Name"]:
continue
if not desktop_values["Categories"]:
continue
if not "Game" in desktop_values["Categories"].split(";"):
continue
values = {
"source": self.source.id,
"added": added_time,
@@ -67,8 +73,10 @@ class FlatpakSourceIterator(SourceIterator):
additional_data = {}
if icon_name := desktop_values["Icon"]:
if icon_path := IconTheme.getIconPath(icon_name):
if icon_path := IconTheme.getIconPath(icon_name, 512):
additional_data = {"local_image_path": Path(icon_path)}
else:
print(":(")
# Produce game
yield (game, additional_data)