Update linkwarden stuff

This commit is contained in:
Tobias Reisinger 2025-04-29 19:24:13 +02:00
parent d8439473fb
commit bce1d7aaf8
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
2 changed files with 36 additions and 16 deletions
.config
env.d
qutebrowser

View file

@ -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"

View file

@ -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())))