diff --git a/src/main.py b/src/main.py index b80abc6..a479574 100644 --- a/src/main.py +++ b/src/main.py @@ -69,9 +69,6 @@ class LemonadeWindow(Gtk.ApplicationWindow): def refresh(self, *args): self.communities = requests.get("https://lemmy.ml/api/v3/community/list?sort=Hot").json() for community in self.communities["communities"]: - if community["community"]["nfsw"] == True or community["community"]["hidden"] == True: - continue - box = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL, margin_top = 20, @@ -86,19 +83,20 @@ class LemonadeWindow(Gtk.ApplicationWindow): if "icon" in community["community"]: try: - urllib.request.urlretrieve(community["community"]["icon"], "tmp.png") + name = community["community"]["name"] + urllib.request.urlretrieve(community["community"]["icon"], f"{name}.png") + avatar.set_custom_image(Gdk.Texture.new_from_file(Gio.File.new_for_path(f"./{name}.png"))) except urllib.error.HTTPError as e: - print(e) - - avatar.set_custom_image(Gdk.Texture.new_from_file(Gio.File.new_for_path("./tmp.png"))) + print(f"Error while downloading icon: {e}") + pass else: pass if not "description" in community["community"]: - label.set_markup(f"""{community["community"]["title"]} c/{community["community"]["name"]}""") + label.set_markup(f"""{community["community"]["title"]} !{community["community"]["name"]}@{community["community"]["actor_id"].split("/")[2]}""") else: split = community["community"]["description"].split("\n")[0] - label.set_markup(f"""{community["community"]["title"]} c/{community["community"]["name"]} + label.set_markup(f"""{community["community"]["title"]} !{community["community"]["name"]}@{community["community"]["actor_id"].split("/")[2]} {split}""") label.props.margin_start = 5