wallabag-tools/helpers.py
2023-12-21 15:22:35 +01:00

25 lines
668 B
Python

import configparser
from wallabag_api.wallabag import Wallabag
import aiohttp
from typing import Dict
def load_configuration(path):
config = configparser.ConfigParser()
config.read(path)
return config["Wallabag Configuration"]
async def connect_to_wallabag(
configuration: Dict[str, str], session: aiohttp.ClientSession
) -> Wallabag:
configuration["access_token"] = await Wallabag.get_token(**configuration)
return Wallabag(
host=configuration["host"],
token=configuration["access_token"],
client_id=configuration["client_id"],
client_secret=configuration["client_secret"],
aio_sess=session,
)