diff --git a/.config/env.d/30-services b/.config/env.d/30-services index 1c270ce..ef2345d 100755 --- a/.config/env.d/30-services +++ b/.config/env.d/30-services @@ -6,7 +6,7 @@ export HASTE_SERVER="https://haste.snrd.eu" export IMMICH_INSTANCE_URL="https://gallery.serguzim.me" -export LINKWARDEN_URL="https://bookmarks.serguzim.me" +export LINKWARDEN_URL="https://bookmarks.kuechler.xyz" export OPENFAAS_URL="https://faas.serguzim.me" diff --git a/.config/qutebrowser/linkwarden.py b/.config/qutebrowser/linkwarden.py index d0b5c5b..a454729 100644 --- a/.config/qutebrowser/linkwarden.py +++ b/.config/qutebrowser/linkwarden.py @@ -22,30 +22,41 @@ def get_links(): while True: new_links = get_links_part(cursor) + links += new_links if len(new_links): cursor = new_links[-1]["id"] else: return links +def format_link(link): + url = link.get("url") + if not url: + return None + + for tag in link.get("tags", []): + if tag.get("name") == "Archived": + return None + if tag.get("name") == "Inactive": + return None + + title = link.get("name") + if not title: + title = link.get("description") + if not title: + title = "<untitled>" + + collection = link.get("collection", {}).get("name") + if not collection: + collection = "<uncategorized>" + + return f"{url} {collection}/{title}" + def format_links(links): formatted_links = [] for link in links: - url = link.get("url") - if not url: - continue - - title = link.get("name") - if not title: - title = link.get("description") - if not title: - title = "<untitled>" - - collection = link.get("collection", {}).get("name") - if not collection: - collection = "<uncategorized>" - - formatted_links.append(f"{url} {collection}/{title}") + if f_link := format_link(link): + formatted_links.append(f_link) return formatted_links def init(): @@ -57,3 +68,12 @@ def init(): with open(os.path.expanduser("~/.config/qutebrowser/bookmarks/urls"), "w+") as f: f.write("\n".join(links)) f.close() + + +if __name__ == "__main__": + if linkwarden_url is None or linkwarden_token is None: + print("LINKWARDEN_URL and LINKWARDEN_TOKEN environment variables are required.") + exit(1) + + print("\n".join(format_links(get_links()))) +