librus_apix

Librus Synergia web scraper.

General usage

from librus_apix.client import new_client, Client, Token

# First thing we create a new client which can be done with new_client func
client: Client = new_client() # this creates a Client with default urls and empty Token

# Now we update the token with client.get_token(u, p)
_token: Token = client.get_token(username, password) # this sets and returns token attribute

# Now that we have our token updated we can work on saving it. This can be done by extracting the key.
# A key is a combination of 2 authorization cookies Librus uses. Format: '{DZIENNIKSID:SDZIENNIKSID}'
key = client.token.API_Key # can be also done with str(client.token)

# A token can be then created from such key or DZIENNIKSID/SDZIENNIKSID cookies
token = Token(API_Key=key)

# or with cookie values
token = Token(dzienniksid=d_id, sdzienniksid=sd_id)

# The token can then be just passed into new_client function
client = new_client(token=token)

# Now that we have our client ready we can pass it into any modules function like so:
from librus_apix.announcements import get_announcements, Announcement
announcements: list[Announcement] = get_announcements(client)
...

# If you think of hosting this on any kind of VPS, etc. You might want to setup yourself
# some kind of proxy, as librus tends to randomly block all known VPN, VPS ip addresses.
# This has nothing to do with with the library,
# they just happen to do it randomly for few hours at a time.

# Now you can pass proxy into your client
proxy={"http": "http://my-proxy.xyz"}
# with new_client()
client = new_client(proxy=proxy)
# with Client()
client = Client(proxy=proxy)
# or just pass it into your existing client
client.proxy = proxy

in further docs you will find AI slop. Be sure to report any inconsistencies in issues!

 1# type: ignore[attr-defined]
 2"""
 3# Librus Synergia web scraper.
 4
 5## General usage
 6```python
 7from librus_apix.client import new_client, Client, Token
 8
 9# First thing we create a new client which can be done with new_client func
10client: Client = new_client() # this creates a Client with default urls and empty Token
11
12# Now we update the token with client.get_token(u, p)
13_token: Token = client.get_token(username, password) # this sets and returns token attribute
14
15# Now that we have our token updated we can work on saving it. This can be done by extracting the key.
16# A key is a combination of 2 authorization cookies Librus uses. Format: '{DZIENNIKSID:SDZIENNIKSID}'
17key = client.token.API_Key # can be also done with str(client.token)
18
19# A token can be then created from such key or DZIENNIKSID/SDZIENNIKSID cookies
20token = Token(API_Key=key)
21
22# or with cookie values
23token = Token(dzienniksid=d_id, sdzienniksid=sd_id)
24
25# The token can then be just passed into new_client function
26client = new_client(token=token)
27
28# Now that we have our client ready we can pass it into any modules function like so:
29from librus_apix.announcements import get_announcements, Announcement
30announcements: list[Announcement] = get_announcements(client)
31...
32
33# If you think of hosting this on any kind of VPS, etc. You might want to setup yourself
34# some kind of proxy, as librus tends to randomly block all known VPN, VPS ip addresses.
35# This has nothing to do with with the library,
36# they just happen to do it randomly for few hours at a time.
37
38# Now you can pass proxy into your client
39proxy={"http": "http://my-proxy.xyz"}
40# with new_client()
41client = new_client(proxy=proxy)
42# with Client()
43client = Client(proxy=proxy)
44# or just pass it into your existing client
45client.proxy = proxy
46```
47
48### in further docs you will find AI slop. Be sure to report any inconsistencies in issues!
49"""
50
51from importlib import metadata as importlib_metadata
52
53
54def get_version() -> str:
55    try:
56        return importlib_metadata.version(__name__)
57    except importlib_metadata.PackageNotFoundError:  # pragma: no cover
58        return "unknown"
59
60
61version: str = get_version()
def get_version() -> str:
55def get_version() -> str:
56    try:
57        return importlib_metadata.version(__name__)
58    except importlib_metadata.PackageNotFoundError:  # pragma: no cover
59        return "unknown"
version: str = '1.0.0.dev0'