init commit

This commit is contained in:
firedotguy
2026-01-29 19:46:37 +03:00
parent f64fccf393
commit 6441ffabf1
6 changed files with 44 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
test.py
venv/
__pycache__/

1
itd/__init__.py Normal file
View File

@@ -0,0 +1 @@
from itd.client import Client as ITDClient

11
itd/client.py Normal file
View File

@@ -0,0 +1,11 @@
from itd.users import get_user
class Client:
def __init__(self, token: str):
self.token = token.replace('Bearer ', '')
def get_user(self, username: str) -> dict:
return get_user(self.token, username)
def get_me(self) -> dict:
return self.get_user('me')

24
itd/request.py Normal file
View File

@@ -0,0 +1,24 @@
from requests import Session
s = Session()
def fetch(token: str, method: str, url: str):
res = eval(f's.{method}')(f'https://итд.com/api/{url}', headers={
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Authorization": 'Bearer ' + token,
"Sec-GPC": "1",
"Upgrade-Insecure-Requests": "1",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Priority": "u=0, i",
"Pragma": "no-cache",
"Cache-Control": "no-cache",
"TE": "trailers"
})
res.raise_for_status()
return res.json()

5
itd/users.py Normal file
View File

@@ -0,0 +1,5 @@
from itd.request import fetch
def get_user(token: str, username: str):
return fetch(token, 'get', f'users/{username}')

0
requirements.txt Normal file
View File