playing with tril api
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
from trilium_py.client import ETAPI
|
||||
import os
|
||||
|
||||
|
||||
class TrilumNotes:
|
||||
def __init__(self):
|
||||
self.protocol = os.environ.get('TRILUM_PROTOCOL')
|
||||
self.host = os.environ.get('TRILIUM_HOST')
|
||||
self.port = os.environ.get('TRILIUM_PORT')
|
||||
self.tril_pass = os.environ.get('TRILIUM_PASS')
|
||||
self.token = os.environ.get('TRILIUM_TOKEN')
|
||||
if not all([self.protocol, self.host, self.port, self.tril_pass]):
|
||||
print("One or more required environment variables not found. Have you set a .env?")
|
||||
|
||||
self.server_url = f'{self.protocol}://{self.host}:{self.port}'
|
||||
|
||||
if not self.token:
|
||||
print("Please run get_token and set your token")
|
||||
else:
|
||||
self.ea = ETAPI(self.server_url, self.token)
|
||||
|
||||
def get_token(self):
|
||||
ea = ETAPI(self.server_url)
|
||||
token = ea.login(self.tril_pass)
|
||||
print(token)
|
||||
print("I would recomend you update the env file with this tootsweet!")
|
||||
|
||||
def get_new_notes(self):
|
||||
notes = self.ea.search_note(
|
||||
search="#ai_blog #blog_written=false",
|
||||
ancestorNoteId="kYZXOUVabB7s",
|
||||
fastSearch=False,
|
||||
limit=10
|
||||
)
|
||||
self.new_notes = notes
|
||||
return notes
|
||||
Reference in New Issue
Block a user