Skip to content

Commit

Permalink
utils: Ignore non-Linux screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
bbhtt committed Nov 5, 2024
1 parent 23c9b58 commit 58203b2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
11 changes: 11 additions & 0 deletions backend/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def appstream2dict(appstream_url=None) -> dict[str, dict]:
for i, screenshot in enumerate(screenshots):
attrs = {}

attrs["is_linux"] = True
if screenshot.attrib.get("environment") in ("macos", "windows"):
attrs["is_linux"] = False

if component.attrib.get("type") == "desktop-application":
for caption in screenshot.findall("caption"):
if caption is not None:
Expand Down Expand Up @@ -178,6 +182,13 @@ def appstream2dict(appstream_url=None) -> dict[str, dict]:
app["screenshots"].append(attrs.copy())
component.remove(screenshots)

if app["screenshots"] and not all(
not sc["is_linux"] for sc in app["screenshots"]
):
for sc in app["screenshots"][:]:
if not sc["is_linux"]:
app["screenshots"].remove(sc)

releases = component.find("releases")
if releases is not None:
app["releases"] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "<p>Good at finding your way out of hard situations? Let's see! Try to make your way through an increasingly difficult path.</p>",
"screenshots": [
{
"is_linux": true,
"sizes": [
{
"width": "800",
Expand Down Expand Up @@ -38,6 +39,7 @@
},
{
"default": true,
"is_linux": true,
"sizes": [
{
"width": "800",
Expand Down Expand Up @@ -72,6 +74,7 @@
]
},
{
"is_linux": true,
"sizes": [
{
"width": "800",
Expand Down Expand Up @@ -393,4 +396,4 @@
"sdk": "org.gnome.Sdk/x86_64/3.36"
},
"is_free_license": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "<p>Good at finding your way out of hard situations? Let's see! Try to make your way through an increasingly difficult path.</p>",
"screenshots": [
{
"is_linux": true,
"sizes": [
{
"width": "800",
Expand Down Expand Up @@ -38,6 +39,7 @@
},
{
"default": true,
"is_linux": true,
"sizes": [
{
"width": "800",
Expand Down Expand Up @@ -72,6 +74,7 @@
]
},
{
"is_linux": true,
"sizes": [
{
"width": "800",
Expand Down Expand Up @@ -393,4 +396,4 @@
"sdk": "org.gnome.Sdk/x86_64/3.36"
},
"is_free_license": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "<p>Gut deinen Weg aus einer schwierigen Situation zu finden?</p>",
"screenshots": [
{
"is_linux": true,
"sizes": [
{
"width": "800",
Expand Down Expand Up @@ -37,6 +38,7 @@
]
},
{
"is_linux": true,
"default": true,
"sizes": [
{
Expand Down Expand Up @@ -72,6 +74,7 @@
]
},
{
"is_linux": true,
"sizes": [
{
"width": "800",
Expand Down Expand Up @@ -393,4 +396,4 @@
"sdk": "org.gnome.Sdk/x86_64/3.36"
},
"is_free_license": true
}
}

0 comments on commit 58203b2

Please sign in to comment.