Skip to main content

HDRezka (rezka.ag) Python API

Project description

HDRezka

HDRezka (rezka.ag) Python API

from hdrezka import *

player = Search('Avatar')[1, 0].player
print(player.post.info)
print(player.get_stream().best_url)

hdrezka library

Errors

hdrezka.errors
class HDRezkaError(Exception):
    """Any HDRezka exception"""


class UnknownContentType(HDRezkaError, TypeError):
    """Invalid content type"""


class AjaxFail(HDRezkaError):
    """No success response"""


class EmptyPage(HDRezkaError):
    """Asked page is empty (see Page class)"""

Translators info

hdrezka.translators
class Translators:
    __slots__ = ('names', 'ids', 'name_id', 'id_name')
    names: tuple[str]
    ids: tuple[int]
    name_id: dict[str, int]
    id_name: dict[int, str]

    def __init__(self, name_id: dict[str, int]):
        ...

Stream classes

hdrezka.stream.player
PlayerType = PlayerBase | PlayerMovie | PlayerSeries


class PlayerBase:
    def __init__(self, url_or_cast: Self | str):
        ...


class PlayerMovie(PlayerBase):
    def get_stream(self, translator_id: SupportsInt = None) -> URLs:
        ...


class PlayerSeries(PlayerBase):
    def get_episodes(self, translator_id: SupportsInt = None) -> defaultdict[int, tuple[int]]:
        ...

    def get_stream(self, season: int, episode: int, translator_id: SupportsInt = None) -> URLs:
        ...


def player(url_or_path: str) -> PlayerType:
    """
    Returns either Player Series if series, or PlayerMovie if movie, otherwise raises UnknownContentType
    """
    ...


Player = player

Post classes

hdrezka.post
class Post:
    """Stores information about the post"""
    __slots__ = ('url', 'translator_id', 'id', 'name', 'type', 'info', 'translators', 'other_parts_urls')

    def __init__(self, url: str):
        ...
hdrezka.post.page
PageNumber = Iterable[int] | slice | int


@dataclass(frozen=True)
class InlineItem:
    """Content Inline Item view"""
    url: str
    name: str
    info: str
    poster: str  # image url

    @property
    def player(self) -> PlayerType:
        return Player(self.url)


class Page:
    """Ajax class for HDRezka search"""
    page: str = property(..., ...)

    def __init__(self, url: str = 'https://rezka.ag/'):
        ...

    def __iter__(self) -> Iterator[InlineItem]:
        """
        Returns the generator of all found articles
        """
        ...

    def page_iter(self, page: PageNumber = 1) -> Iterator[InlineItem] | None:
        ...

    def get_pages(self, page: PageNumber = 1) -> tuple[InlineItem]:
        ...

    def __getitem__(self, item: PageNumber | Sequence[PageNumber | SupportsIndex | slice]
                    ) -> tuple[InlineItem] | InlineItem:
        ...
hdrezka.post.urls
def short_url(url: str) -> str:
    """
    Returns string rezka.ag post with format "{id}-{id}" (valid path)
    """
    ...


def long_url(url: str) -> str:
    """
    Returns full url of rezka.ag post
    """
    ...


class Quality(str):
    addon: str  # can contain 'ultra'

    def __int__(self):
        """
        returns pixels height
        """
        ...

    def __lt__(self, other):
        ...


class URL(str):
    mp4: str


class URLs:
    best_url: URL

    def __init__(self, data: str | dict):
        ...

    def __getitem__(self, item: (SupportsInt | str) | (slice | Iterable)):
        ...

Post Info classes

hdrezka.post.info
class PostInfo:
    FILL_FIELDS = ('rating', 'places', 'slogan', 'release', 'country', 'director', 'genre',
                   'quality', 'translator', 'age_rating', 'duration', 'from_', 'characters')
    __slots__ = FILL_FIELDS + ('fields', 'title', 'orig_title', 'poster', 'description')
    translator: str

    def __init__(self, soup: BeautifulSoup):
        ...
hdrezka.post.fields
@dataclass(frozen=True)
class Rating:
    service: str
    rating: int | float
    votes: int


@dataclass(frozen=True)
class Place:
    name: str
    place: int


@dataclass(frozen=True)
class Release:
    year: int
    day: str


@dataclass(frozen=True)
class AgeRating:
    age: int
    description: str


@dataclass(frozen=True)
class Duration:
    number: int
    units: str


class Poster(NamedTuple):
    full: str
    preview: str

API classes

hdrezka.api.ajax
class Ajax:
    """HDRezka Ajax class"""

    @classmethod
    def get_cdn_series(cls, data: dict[str]):
        ...

    @classmethod
    def get_episodes(cls, id: int | str, translator_id: int | str):
        ...

    @classmethod
    def get_stream(cls, id: int | str, translator_id: int | str, season: int | str, episode: int | str):
        ...

    @classmethod
    def get_movie(cls, id: int | str, translator_id: int | str):
        ...
hdrezka.api.search
class Search(Page):
    """Ajax class for HDRezka search"""
    query: str = property(..., ...)

    def __init__(self, query: str = ''):
        ...

    def __iter__(self) -> Iterator[InlineItem]:
        """
        Returns the generator of all found articles
        """
        ...

CHANGELOG

1.1.1

  • Fixed bug with importing Post stream
  • Fixed url_short function post.urls

1.1.0

  • errors

    • EmptySearchPage replaced with EmptyPage
  • New submodule post.page

  • post.page

    • new Page class that will parse any page rezka.ag on InlineItem (new data class)
  • api.search

    • Search now inherited from Page
  • post.urls

    • short_url now even shorter

1.0.0

Backward incompatible changes have been made

  • bs4 now selects lxml (if it available) once at startup

  • stream

    • Hint typing fixes
    • Player now caching
  • New submodule post, post.info, post.info.fields

  • urls submodule now is post.urls
  • post

    • class Post created
  • post.urls

    • short_url and long_url functions added (caching)
    • short_url, long_url, Quality, URL now in __all__
  • post.info

    • class PostInfo created
  • post.info.fields

    • classes Rating, Place, Release, AgeRating, Duration, Poster created

0.0.2

  • Initial version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

HDRezka-1.1.1.tar.gz (12.8 kB view hashes)

Uploaded Source

Built Distribution

HDRezka-1.1.1-py3-none-any.whl (15.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page