Skip to main content

aiorezka

Installation

Without cache

pip install aiorezka

With cache

It's recommended to use cache, because it will reduce load on Rezka API.

pip install aiorezka[request_cache]

Usage

from aiorezka.api import RezkaAPI
import asyncio

async def main():
    async with RezkaAPI() as api:
        details = await api.movie_detail.get(
            'https://rezka.ag/cartoons/comedy/2136-rik-i-morti-2013.html'
        )
        print(details)

asyncio.run(main())

You can find more examples in examples directory.

Download TV series

  1. Install aria2 and ffmpeg.
  2. Install yt-dlp:
pip install yt-dlp
  1. Install downloader extras for aiorezka:
pip install aiorezka[downloader]
  1. Run download process:
python -m aiorezka -u https://rezka.ag/cartoons/comedy/2136-rik-i-morti-2013-latest.html -a Сыендук -s 1
Aiorezka CLI

options:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -u URL, --url URL     URL of the movie or TV series to download. Can be full
                        URL or just urn (e.g. /films/series/12345.html)
  -p PATH, --path PATH  Path to save downloaded files (default: current
                        directory)
  -s SEASON, --season SEASON
                        Season number for TV series (default: 1)
  -a AUDIO_TRACK, --audio-track AUDIO_TRACK
                        Preferred audio track for TV series

Configuration

Hostname configuration

You can configure hostname for requests. By default it will use rezka.ag hostname. To change it, you can pass environment variable REZKA_HOSTNAME or change it in code:

import aiorezka

aiorezka.host = 'rezka.co'

Concurrency configuration

You can configure concurrency for API client, basically it will limit number of concurrent requests via asyncio.Semaphore. By default it will use 60 concurrent requests. To change it, you can pass environment variable REZKA_CONCURRENCY_LIMIT or change it in code:

import aiorezka

aiorezka.concurrency_limit = 100

Retry configuration

You can configure retry policy for requests. By default it will retry 3 times with 1 * (backoff ** retry_no) second delay. To change it, you can pass environment variables, such as REZKA_MAX_RETRY and REZKA_RETRY_DELAY or change it in code:

import aiorezka

aiorezka.max_retry = 5
aiorezka.retry_delay = 2

Cache configuration

You can configure cache for requests. By default, it will use aiorezka.cache.QueryCache + aiorezka.cache.DiskCacheThreadProvider with 1 day TTL. Cache will periodically save to disk, so you can use it between restarts.

use_cache

Enable or disable cache. By default, it's disabled.

import aiorezka

aiorezka.use_cache = False  # disable cache

or use environment variable REZKA_USE_CACHE

cache_directory

Directory where cache will be stored. By default, it's /tmp/aiorezka_cache.

import aiorezka

aiorezka.cache_directory = '/tmp/aiorezka_cache'

or use environment variable REZKA_CACHE_DIRECTORY

memcache_max_len

Max number of items in memory cache. When it's reached, it will be saved to disk.

By default, it's 1000.

import aiorezka

aiorezka.memcache_max_len = 1000

or use environment variable REZKA_MEMCACHE_MAX_LEN

cache_ttl

TTL for cache objects.

By default, it's 1 day.

import aiorezka

aiorezka.cache_ttl = 60 * 60 * 24  # 1 day

or use environment variable REZKA_CACHE_TTL

max_open_files

Max number of open files for cache. It's used for aiorezka.cache.DiskCacheThreadProvider. When app starts cache will be rebuilt on disk, so it will open a lot of files to check if they are expired.

By default, it's 5000.

import aiorezka

aiorezka.max_open_files = 5000

or use environment variable REZKA_MAX_OPEN_FILES

You can disable cache rebuild on start, then TTL will be ignored.

from aiorezka.api import RezkaAPI

async def main():
    async with RezkaAPI(cache_rebuild_on_start=False) as api:
        pass

Logging configuration

You can configure logging for aiorezka. By default, it will use logging.INFO level.

import aiorezka

aiorezka.log_level = "DEBUG"

or use environment variable REZKA_LOG_LEVEL

Debugging

Measure RPS

Measure requests per second, use it only for debug purposes.

import asyncio

from aiorezka.api import RezkaAPI
from aiorezka.cli import measure_rps


@measure_rps
async def main():
    async with RezkaAPI() as api:
        movies = await api.movie.iter_pages(range(1, 10), chain=True)
        detailed_movies = await api.movie_detail.many(movies)
        for movie in detailed_movies:
            attributes = '\n'.join([f'{attr["key"]}: {attr["value"]}' for attr in movie.attributes])
            print(f'{movie.title}\n{attributes}\n')

if __name__ == '__main__':
    asyncio.run(main())

Output will look like:

[main][333 requests in 37.82s] 8.81 rps

Metadata

Release files for aiorezka 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiorezka 1.3.1
File Size Uploaded
aiorezka-1.3.1.tar.gz 19.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiorezka 1.3.1
File Interpreter ABI Platform
aiorezka-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.8 kB

Release files / aiorezka-1.3.1.tar.gz

Download URL aiorezka-1.3.1.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a87c6936d6fc82de26f8da3d85a42194550a6eadf9ad6bf2513e64ca18964664
BLAKE2b-256 checksum
How to use checksums
1a50185c56e6cf03a57af2838661719d7491d6e981e39cc2da560c43f6824513
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.11.0 Linux/6.11.0-1018-azure

Release files / aiorezka-1.3.1-py3-none-any.whl

Download URL aiorezka-1.3.1-py3-none-any.whl
Size 23.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a76fe3ee2d9b5e91b6f436cc1830c003fff5528948165a2ca10a578c6f59ed79
BLAKE2b-256 checksum
How to use checksums
007fcf28ef422ab77a3f03060c3934c6cff06c6f707394ab536e8f125d8dab49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.4 CPython/3.11.0 Linux/6.11.0-1018-azure

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page