# [HDRezka](https://rezka.ag/) site API.
# Install
`pip install HDRezka`
# Example
```python
import asyncio
from hdrezka import Search
async def main():
player = await (await Search('Breaking Bad').get_page(1))[0].player
print(player.post.info, end='\n\n')
translator_id = None # default
for name, id_ in player.post.translators.name_id.items():
if 'субтитры' in name.casefold(): translator_id = id_; break
stream = await player.get_stream(1, 1, translator_id) # raise AJAXFail if invalid episode or translator
video = stream.video
print(await video.last_url) # best quality (.m3u8)
print((await video[video.min].last_url).mp4, end='\n\n') # worst quality (.mp4)
subtitles = stream.subtitles
print(subtitles.default.url) # subtitles.ru.url or subtitles['Русский'].url
if __name__ == '__main__': asyncio.run(main())
```
# [Documentation](https://nikdissv-forever.github.io/HDRezka/)
---
# CHANGELOG
## 3.2.2
- ### post.urls
- Added supports of added support for quality in the format `2K`, `4K`, ...
## 3.2.1
- ### post.kind.video
- if **await** `VideoURL` instance, it's follow url redirects and return correct download url.
_See [issue 5](https://github.com/NIKDISSV-Forever/HDRezka/issues/5)_.
- Now `VideoURL.mp4` is `property`.
- ### api.http
- passed `get_response(..., **kwargs)` have more weight than `DEFAULT_REQUEST_KWARGS`.
## 3.2.0
- **Documentation and doc-strings improved.**
- Type-checking improved (_None-safety_ checks)
- #### New submodule `api.types`.
- ### api
- #### http
- Added `RequestKwargs(TypedDict)` type-hint.
- **`DEFAULT_CLINET_KWARGS` replaced with just `DEFAULT_CLIENT`.**
- #### types
- Added `APIResponse(TypedDict)` type-hint.
- ### post.fields
- Added default empty strings.
- ### post.info.PostInfo
- if `age_rating` rating not found, `AgeRating.age` sets **-1**.
- ### post.urls.king.video.VideoURLs
- `__getitem__(self, item: str | SupportsInt | Iterable | slice)` updated (see documentations).
- ### stream.player
- **fixed [issue 1](https://github.com/NIKDISSV-Forever/HDRezka/issues/1)**.
- fixed [issue 4](https://github.com/NIKDISSV-Forever/HDRezka/issues/4).
- `PlayerType` everyplace replaced with `PlayerMovie | PlayerSeries`.
## 3.1.2
- ### post.urls
- Fixed [issue 2](https://github.com/NIKDISSV-Forever/HDRezka/issues/2). _rezka.ag stopped redirecting from links of
this type:"https://rezka.ag/1-1.html". now returns a 500
error._
## 3.1.1
- Documentation improved.
## 3.1.0
- ### requirements.txt
- `bs4` replaced with `beautifulsoup4`.
- `lxml` now installs on versions < 3.13 (instead of < 3.12).
- ### api.http
- Added `DEFAULT_REQUEST_KWARGS`.
## 3.0.3
- ### stream.player
- #### Player Caching
- fixed `RuntimeError: dictionary changed size during iteration`.
- removed `sys.getsizeof` (for compatibility with PyPy), used `len` instead.
## 3.0.2
- ### post.urls.kind.VideoURLs
- `__init__(self, data: str | dict)` now raises `TypeError`
if `data` isn't of type `str | dict` (see [this issue](https://github.com/NIKDISSV-Forever/HDRezka/issues/1)).
## 3.0.1
- Now `__await__` method (need `await ...` expression) instead `ainit` method.
## 3.0.0
- **Now a fully asynchronous package.**
- ### post.page.Page
- Implements `__aiter__` and `__anext__` methods that list all the pages found.
- Instead of `get_pages`, now only the `get_page` method.
## 2.0.1
- Fixed bug with PIP.
## 2.0.0
Backward incompatible changes have been made.
- #### New submodules `urls.short`, `urls.kind`, `urls.kind.quality`, `urls.kind.subtitles`, `urls.kind.video`.
- Optimizations.
- `Ajax` renamed to `AJAX` (PEP-8).
- the `get_stream` method now contains the `video` attribute and the `subtitle` attribute.
- ### urls
- New function `urls_from_ajax_response -> URLs`.
- ### urls.short
- `short_url`, `long_url`.
- ### urls.kind
- class `Quality` now in `urls.king.quality` (also in \_\_init__).
- ### urls.kind.video
- classes `VideoURL`, `VideoURLs`.
- ### urls.kind.subtitle
- classes `SubtitleURL`, `SubtitleURLs`.
## 1.1.3
- internal bugfixes.
## 1.1.2
- added pdoc documentation.
- now Python **3.10** has become the minimum compatible version.
- removed all `from __future__ import annotations` statements.
- used `match...case` statements.
- optimization.
- new submodule `api.http`.
- `get_response` moved to `api.http` submodule.
## 1.1.1
- fixed bug with importing `stream.Post`.
- fixed `post.urls.url_short` function.
## 1.1.0
- `post.urls.short_url` now even shorter.
- ### 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`.
## 1.0.0
**Backward incompatible changes have been made.**
- bs4 now selects lxml (if it available) once at startup.
- new submodule `post`, `post.info`, `post.info.fields`.
- class `post.Post` created.
- class `post.info.PostInfo` created.
- ##### `urls` submodule now is `post.urls`.
- ### stream
- type-hinting fixes.
- `Player` now caching.
- ### post.urls
- `short_url` and `long_url` functions added (caching).
- `short_url`, `long_url`, `Quality`, `URL` now in `__all__`.
- ### post.info.fields
- classes `Rating`, `Place`, `Release`, `AgeRating`, `Duration`, `Poster` created.
## 0.0.2
- initial version.
Raw data
{
"_id": null,
"home_page": "https://github.com/NIKDISSV-Forever/HDRezka",
"name": "HDRezka",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "HDRezka,rezka.ag,watch online,api,stream",
"author": "Nikita (NIKDISSV)",
"author_email": "nikdissv@proton.me",
"download_url": "https://files.pythonhosted.org/packages/1b/7b/ee8040123ff619ca1e1349299acc7356341a768d05efe7e3a9e3e8f812f0/HDRezka-3.2.2.tar.gz",
"platform": null,
"description": "# [HDRezka](https://rezka.ag/) site API.\r\n\r\n# Install\r\n\r\n`pip install HDRezka`\r\n\r\n# Example\r\n\r\n```python\r\nimport asyncio\r\nfrom hdrezka import Search\r\n\r\n\r\nasync def main():\r\n player = await (await Search('Breaking Bad').get_page(1))[0].player\r\n print(player.post.info, end='\\n\\n')\r\n\r\n translator_id = None # default\r\n for name, id_ in player.post.translators.name_id.items():\r\n if '\u0441\u0443\u0431\u0442\u0438\u0442\u0440\u044b' in name.casefold(): translator_id = id_; break\r\n\r\n stream = await player.get_stream(1, 1, translator_id) # raise AJAXFail if invalid episode or translator\r\n video = stream.video\r\n print(await video.last_url) # best quality (.m3u8)\r\n print((await video[video.min].last_url).mp4, end='\\n\\n') # worst quality (.mp4)\r\n\r\n subtitles = stream.subtitles\r\n print(subtitles.default.url) # subtitles.ru.url or subtitles['\u0420\u0443\u0441\u0441\u043a\u0438\u0439'].url\r\n\r\n\r\nif __name__ == '__main__': asyncio.run(main())\r\n```\r\n\r\n# [Documentation](https://nikdissv-forever.github.io/HDRezka/)\r\n\r\n---\r\n\r\n# CHANGELOG\r\n\r\n## 3.2.2\r\n\r\n- ### post.urls\r\n - Added supports of added support for quality in the format `2K`, `4K`, ...\r\n \r\n## 3.2.1\r\n\r\n- ### post.kind.video\r\n - if **await** `VideoURL` instance, it's follow url redirects and return correct download url.\r\n _See [issue 5](https://github.com/NIKDISSV-Forever/HDRezka/issues/5)_.\r\n - Now `VideoURL.mp4` is `property`.\r\n- ### api.http\r\n - passed `get_response(..., **kwargs)` have more weight than `DEFAULT_REQUEST_KWARGS`.\r\n\r\n## 3.2.0\r\n\r\n- **Documentation and doc-strings improved.**\r\n- Type-checking improved (_None-safety_ checks)\r\n- #### New submodule `api.types`.\r\n\r\n- ### api\r\n - #### http\r\n - Added `RequestKwargs(TypedDict)` type-hint.\r\n - **`DEFAULT_CLINET_KWARGS` replaced with just `DEFAULT_CLIENT`.**\r\n - #### types\r\n - Added `APIResponse(TypedDict)` type-hint.\r\n- ### post.fields\r\n - Added default empty strings.\r\n- ### post.info.PostInfo\r\n - if `age_rating` rating not found, `AgeRating.age` sets **-1**.\r\n- ### post.urls.king.video.VideoURLs\r\n - `__getitem__(self, item: str | SupportsInt | Iterable | slice)` updated (see documentations).\r\n- ### stream.player\r\n - **fixed [issue 1](https://github.com/NIKDISSV-Forever/HDRezka/issues/1)**.\r\n - fixed [issue 4](https://github.com/NIKDISSV-Forever/HDRezka/issues/4).\r\n - `PlayerType` everyplace replaced with `PlayerMovie | PlayerSeries`.\r\n\r\n## 3.1.2\r\n\r\n- ### post.urls\r\n - Fixed [issue 2](https://github.com/NIKDISSV-Forever/HDRezka/issues/2). _rezka.ag stopped redirecting from links of\r\n this type:\"https://rezka.ag/1-1.html\". now returns a 500\r\n error._\r\n\r\n## 3.1.1\r\n\r\n- Documentation improved.\r\n\r\n## 3.1.0\r\n\r\n- ### requirements.txt\r\n - `bs4` replaced with `beautifulsoup4`.\r\n - `lxml` now installs on versions < 3.13 (instead of < 3.12).\r\n- ### api.http\r\n - Added `DEFAULT_REQUEST_KWARGS`.\r\n\r\n## 3.0.3\r\n\r\n- ### stream.player\r\n - #### Player Caching\r\n - fixed `RuntimeError: dictionary changed size during iteration`.\r\n - removed `sys.getsizeof` (for compatibility with PyPy), used `len` instead.\r\n\r\n## 3.0.2\r\n\r\n- ### post.urls.kind.VideoURLs\r\n - `__init__(self, data: str | dict)` now raises `TypeError`\r\n if `data` isn't of type `str | dict` (see [this issue](https://github.com/NIKDISSV-Forever/HDRezka/issues/1)).\r\n\r\n## 3.0.1\r\n\r\n- Now `__await__` method (need `await ...` expression) instead `ainit` method.\r\n\r\n## 3.0.0\r\n\r\n- **Now a fully asynchronous package.**\r\n\r\n- ### post.page.Page\r\n - Implements `__aiter__` and `__anext__` methods that list all the pages found.\r\n - Instead of `get_pages`, now only the `get_page` method.\r\n\r\n## 2.0.1\r\n\r\n- Fixed bug with PIP.\r\n\r\n## 2.0.0\r\n\r\nBackward incompatible changes have been made.\r\n\r\n- #### New submodules `urls.short`, `urls.kind`, `urls.kind.quality`, `urls.kind.subtitles`, `urls.kind.video`.\r\n- Optimizations.\r\n- `Ajax` renamed to `AJAX` (PEP-8).\r\n- the `get_stream` method now contains the `video` attribute and the `subtitle` attribute.\r\n\r\n- ### urls\r\n - New function `urls_from_ajax_response -> URLs`.\r\n- ### urls.short\r\n - `short_url`, `long_url`.\r\n- ### urls.kind\r\n - class `Quality` now in `urls.king.quality` (also in \\_\\_init__).\r\n- ### urls.kind.video\r\n - classes `VideoURL`, `VideoURLs`.\r\n- ### urls.kind.subtitle\r\n - classes `SubtitleURL`, `SubtitleURLs`.\r\n\r\n## 1.1.3\r\n\r\n- internal bugfixes.\r\n\r\n## 1.1.2\r\n\r\n- added pdoc documentation.\r\n- now Python **3.10** has become the minimum compatible version.\r\n- removed all `from __future__ import annotations` statements.\r\n- used `match...case` statements.\r\n- optimization.\r\n\r\n- new submodule `api.http`.\r\n- `get_response` moved to `api.http` submodule.\r\n\r\n## 1.1.1\r\n\r\n- fixed bug with importing `stream.Post`.\r\n- fixed `post.urls.url_short` function.\r\n\r\n## 1.1.0\r\n\r\n- `post.urls.short_url` now even shorter.\r\n\r\n- ### errors\r\n - `EmptySearchPage` replaced with `EmptyPage`.\r\n\r\n- #### New submodule `post.page`\r\n\r\n- ### post.page\r\n - new `Page` class that will parse any page rezka.ag on `InlineItem` (new data class).\r\n\r\n- ### api.search\r\n - `Search` now inherited from `Page`.\r\n\r\n## 1.0.0\r\n\r\n**Backward incompatible changes have been made.**\r\n\r\n- bs4 now selects lxml (if it available) once at startup.\r\n- new submodule `post`, `post.info`, `post.info.fields`.\r\n- class `post.Post` created.\r\n- class `post.info.PostInfo` created.\r\n\r\n- ##### `urls` submodule now is `post.urls`.\r\n\r\n- ### stream\r\n - type-hinting fixes.\r\n - `Player` now caching.\r\n\r\n- ### post.urls\r\n - `short_url` and `long_url` functions added (caching).\r\n - `short_url`, `long_url`, `Quality`, `URL` now in `__all__`.\r\n\r\n- ### post.info.fields\r\n - classes `Rating`, `Place`, `Release`, `AgeRating`, `Duration`, `Poster` created.\r\n\r\n## 0.0.2\r\n\r\n- initial version.\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "HDRezka (rezka.ag) Python API",
"version": "3.2.2",
"project_urls": {
"Documentation": "https://nikdissv-forever.github.io/HDRezka/hdrezka",
"GitHub": "https://github.com/NIKDISSV-Forever/HDRezka",
"Homepage": "https://github.com/NIKDISSV-Forever/HDRezka"
},
"split_keywords": [
"hdrezka",
"rezka.ag",
"watch online",
"api",
"stream"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b9c0abef7af1f61170beef385abb1a5f814418687d64f84093b4360615b90920",
"md5": "cefabb747427ed9a3202d65aaed30631",
"sha256": "7fd7aa8dd6491451f37552235887be3f49367ef46e735ea27b0fc9b65022e70c"
},
"downloads": -1,
"filename": "HDRezka-3.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cefabb747427ed9a3202d65aaed30631",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 20780,
"upload_time": "2024-02-10T05:41:42",
"upload_time_iso_8601": "2024-02-10T05:41:42.892655Z",
"url": "https://files.pythonhosted.org/packages/b9/c0/abef7af1f61170beef385abb1a5f814418687d64f84093b4360615b90920/HDRezka-3.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1b7bee8040123ff619ca1e1349299acc7356341a768d05efe7e3a9e3e8f812f0",
"md5": "c8d5d271ced18b1affaff66853a195e5",
"sha256": "03c56b54857499cc564831134531e448ca82e56c6ea2babeb42888b13a409bd9"
},
"downloads": -1,
"filename": "HDRezka-3.2.2.tar.gz",
"has_sig": false,
"md5_digest": "c8d5d271ced18b1affaff66853a195e5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 14965,
"upload_time": "2024-02-10T05:41:44",
"upload_time_iso_8601": "2024-02-10T05:41:44.908778Z",
"url": "https://files.pythonhosted.org/packages/1b/7b/ee8040123ff619ca1e1349299acc7356341a768d05efe7e3a9e3e8f812f0/HDRezka-3.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-10 05:41:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "NIKDISSV-Forever",
"github_project": "HDRezka",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "beautifulsoup4",
"specs": []
},
{
"name": "lxml",
"specs": []
},
{
"name": "httpx",
"specs": []
}
],
"lcname": "hdrezka"
}