Metadata-Version: 2.1
Name: gdzru
Version: 1.0.0
Summary: Python library for using gdz.ru API
Project-URL: Usage, https://github.com/Den4ikSuperOstryyPer4ik/GDZ-py#usage
Project-URL: Issues, https://github.com/Den4ikSuperOstryyPer4ik/GDZ-py/issues
Project-URL: Source, https://github.com/Den4ikSuperOstryyPer4ik/GDZ-py
Project-URL: Author, https://github.com/Den4ikSuperOstryyPer4ik
Author-email: Den4ikSuperOstryyPer4ik <oleynik.denis.2009@gmail.com>
License-Expression: MIT
License-File: LICENSE.txt
Keywords: api,gdz,gdz ru api,gdz.ru,gdz.ru api,gdzru,ru,гдз,гдз api,гдз ру
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.9
Requires-Dist: aiohttp
Requires-Dist: pydantic
Description-Content-Type: text/markdown

<p align="center"><a href="https://gdz.ru/"><img src="https://i.ibb.co/VCJF9dc/image-2.png" align="center"/></a> <a href="https://www.python.org/"><img src="https://i.ibb.co/DKCcTDj/image.png" align="center"/></p></a>

# gdz-ru-py
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Python Version](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11-blue)](https://www.python.org/downloads/release/python-391/)
[![PyPI - Version](https://img.shields.io/pypi/v/gdzru.svg)](https://pypi.org/project/gdzru)

Python library for using gdz.ru API

-----

**Table of Contents**

- [Installation](#installation)
- [Using](#using)
- [License](#license)


## Installation
### Stable version
```bash
$ pip install gdzru --upgrade
```

### Latest version
```bash
$ pip install https://github.com/OctoDiary/OctoDiary-py/archive/main.zip --upgrade
```

## Using
```python
from gdzru import AsyncAPI, SyncAPI

async def amain():
    """
    Asynchronous using GDZ.ru API
    """
    api = AsyncAPI()

    # Get info for classes, subjects, books, etc.
    info = await api.get_books_list()

    # Get info for one book
    book_info = await api.get_book(info.books[0].url)

    # Print book authors, title, etc.
    print("Title:", book_info.book.title)
    print("Authors:", ", ".join(book_info.book.authors))
    print("Year:", book_info.book.year)
    print("Publisher:", book_info.book.publisher)

    # Get get first task of first book structure
    task_info = await api.get_task(book.structure[0].tasks[0].url)
    print("Task title:", task_info.task.title)


    # Get images of task
    images: list[bytes] = [
        await api.get_image(image.url)
        for image in task_info.task.editions[0].images
    ]

def main():
    """
    Synchronous using GDZ.ru API
    """
    api = SyncAPI()

    # Get info for classes, subjects, books, etc.
    info = api.get_books_list()

    # Get info for one book
    book_info = api.get_book(info.books[0].url)

    # Print book authors, title, etc.
    print("Title:", book_info.book.title)
    print("Authors:", ", ".join(book_info.book.authors))
    print("Year:", book_info.book.year)
    print("Publisher:", book_info.book.publisher)

    # Get get first task of first book structure
    task_info = api.get_task(book.structure[0].tasks[0].url)

    # Print task title
    print("Task title:", task_info.task.title)

    # Get images of task
    images: list[bytes] = [
        api.get_image(image.url)
        for image in task_info.task.editions[0].images
    ]
```


## License

`gdzru` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.