Update linkwarden stuff
This commit is contained in:
parent
d8439473fb
commit
bce1d7aaf8
2 changed files with 36 additions and 16 deletions
.config
|
@ -6,7 +6,7 @@ export HASTE_SERVER="https://haste.snrd.eu"
|
||||||
|
|
||||||
export IMMICH_INSTANCE_URL="https://gallery.serguzim.me"
|
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"
|
export OPENFAAS_URL="https://faas.serguzim.me"
|
||||||
|
|
||||||
|
|
|
@ -22,30 +22,41 @@ def get_links():
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
new_links = get_links_part(cursor)
|
new_links = get_links_part(cursor)
|
||||||
|
|
||||||
links += new_links
|
links += new_links
|
||||||
if len(new_links):
|
if len(new_links):
|
||||||
cursor = new_links[-1]["id"]
|
cursor = new_links[-1]["id"]
|
||||||
else:
|
else:
|
||||||
return links
|
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):
|
def format_links(links):
|
||||||
formatted_links = []
|
formatted_links = []
|
||||||
for link in links:
|
for link in links:
|
||||||
url = link.get("url")
|
if f_link := format_link(link):
|
||||||
if not url:
|
formatted_links.append(f_link)
|
||||||
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}")
|
|
||||||
return formatted_links
|
return formatted_links
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
|
@ -57,3 +68,12 @@ def init():
|
||||||
with open(os.path.expanduser("~/.config/qutebrowser/bookmarks/urls"), "w+") as f:
|
with open(os.path.expanduser("~/.config/qutebrowser/bookmarks/urls"), "w+") as f:
|
||||||
f.write("\n".join(links))
|
f.write("\n".join(links))
|
||||||
f.close()
|
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())))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue