Skip to main content

HDRezka Python API

Project description

HdRezkaApi

Install:

pip install HdRezkaApi

Table of Contents:

  1. Usage
  2. Film Information
  3. getStream
  4. getSeasonStreams
  5. HdRezkaStream
  6. HdRezkaStreamSubtitles
  7. HdRezkaRating
  8. Proxy
  9. Cookies
  10. HdRezkaSearch
  11. HdRezkaSession

Usage

from HdRezkaApi import *

url = "https://hdrezka.ag/   __YOUR_URL__   .html"

rezka = HdRezkaApi(url)
print(rezka.name)
print(rezka.thumbnail)
print( rezka.rating.value )
print( rezka.rating.votes )
print( rezka.translators )
print( rezka.otherParts )
print( rezka.seriesInfo )

print(rezka.type)
print(rezka.type == HdRezkaTVSeries == HdRezkaTVSeries() == "tv_series")

print( rezka.getStream()('720p') ) # if movie
print( rezka.getStream('1', '1')('720p') )
print( dict(rezka.getSeasonStreams('1')) )

Film Information

Attribute Description
self.id Film ID
self.name Film name
self.description Film description
self.type HdRezkaTVSeries or HdRezkaMovie
self.thumbnail Film thumbnail URL
self.thumbnailHQ Film thumbnail in high quality
self.rating Film rating (HdRezkaRating)
self.otherParts Other parts of this film [{Film_name: url}]
self.translators Translators dict {Translator_name: translator_id}
self.seriesInfo Series info by translators
self.episodesInfo All seasons and episodes

seriesInfo

{
	Translator_name: {
		translator_id,
		seasons: {1, 2},
		episodes: {
			1: {1, 2, 3},
			2: {1, 2, 3}
		}
	}
}

episodesInfo

[
	{
		season: 1, season_text,
		episodes: [
			{
				episode: 1, episode_text,
				translations: [{translator_id, translator_name}]
			}
		]
	}
]

getStream

getStream(season, episode, translation=None, index=0)

getStream(
    translation='Дубляж' or translation='56' or index=0
)                                               ^ this is index in translators array

If type is movie then there is no need to specify season and episode.

stream = rezka.getStream() # if movie

getSeasonStreams

getSeasonStreams(season, translation=None, index=0, ignore=False, progress=None)

getSeasonStreams(
    translation='Дубляж' or translation='56' or index=0
)                                               ^ this is index in translators array

ignore - ignore errors

progress - callback function

def progress(current, all):
	percent = round(current * 100 / all)
	print(f"{percent}%: {current}/{all}", end="\r")

print( dict(rezka.getSeasonStreams(1, ignore=True, progress=progress)) )

Output example:

{'1': <HdRezkaStream(season:1, episode:1)>, '2': <HdRezkaStream(season:1, episode:2)>, ...}

If an error occurs, an attempt will be made to repeat the request again.
But if the error occurs again, then None will be added to the final dict.
To ignore errors and retry requests until a response is received, specify the ignore=True option.

for i, stream in rezka.getSeasonStreams('1'):
	print(stream)

HdRezkaStream

Attribute Description
self.videos Dict of videos where the key is resolution and value is list of URLs
self.name Film name
self.translator_id Translator ID
self.season Season number (None if film)
self.episode Episode number (None if film)
self.subtitles HdRezkaStreamSubtitles object
HdRezkaStream(resolution) Call object with argument to get the URL of the video

Usage examples:

stream = rezka.getStream(1, 5)

print( stream('720p') )
print( stream('720') )
print( stream(1080) )
print( stream('Ultra') )
print( stream('1080p Ultra') )
print( stream.videos )
{
	'360p': ['https://sambray.org/...mp4', 'https://stream.voidboost.cc/...mp4'],
	'480p': ['https://sambray.org/...mp4', 'https://stream.voidboost.cc/...mp4'],
	'720p': ['https://sambray.org/...mp4', 'https://stream.voidboost.cc/...mp4'],
}

HdRezkaStreamSubtitles

Attribute Description
self.subtitles Dict of subtitles where the key is the language code and value is the subtitle information
self.keys List of available subtitle language codes
self(id) Call object with argument to get URL of subtitles

Usage examples:

stream = rezka.getStream(1, 5)

print( stream.subtitles.subtitles )  # { 'en': {'title': 'English', 'link': 'https:/'}, ...  }
print( stream.subtitles.keys )       # ['en', 'ru']
print( stream.subtitles('en') )      # 'https:/'
print( stream.subtitles('English') ) # 'https:/'
print( stream.subtitles(0) )         # 'https:/'
#                       ^ index

HdRezkaRating

Attribute Description
self.value Rating value (float)
self.votes Number of votes (int)

Proxy

rezka = HdRezkaApi(url, proxy={'http': 'http://192.168.0.1:80'})

Cookies

rezka = HdRezkaApi(url, cookies={"dle_user_id": user_id, "dle_password": password_hash})

If you are not sure:

rezka = HdRezkaApi(url, cookies=HdRezkaApi.make_cookies(user_id, password_hash))

Manually login:

rezka = HdRezkaApi(url)
rezka.login("your_email@gmail.com", "your_password1234")

HdRezkaSearch

HdRezkaSearch(origin, proxy, headers, cookies)(query, find_all=False)

Fast search

results = HdRezkaSearch("https://hdrezka.ag/")("film name")
[
	{
		'title': 'Film name',
		'url': 'https://hdrezka.ag/__FILM_URL.html',
		'rating': 7.8
	}
]

Advanced search

results = HdRezkaSearch("https://hdrezka.ag/", cookies)("film name", find_all=True)
for page in results:
	for result in page:
		print(result)
{
	'title': 'Film name',
	'url': 'https://hdrezka.ag/__FILM_URL.html',
	'image': 'https://hdrezka.ag/image.jpg',
	'type': HdRezkaType()
}

HdRezkaType

HdRezkaTVSeries, HdRezkaMovie, HdRezkaCartoon, HdRezkaAnime.

All pages

print(results.all_pages)
[
	[ {'title', 'url', 'image', 'type'}, ...],
	[ {'title', 'url', 'image', 'type'}, ...],
	...
]

Flatten results

print(results.all)
[
	{'title', 'url', 'image', 'type'},
	{'title', 'url', 'image', 'type'},
	...
]

Specific page

print(results.get_page(2)) # page number
# or
print(results[1]) # index

Searching with session


HdRezkaSession

HdRezkaSession allows you to log in once and not send login requests every time.

You can also specify origin to make requests to a same site. Origin in full urls will be ignored.
In the next example, the request will be made to the url: "https://rezka_mirror.com/__YOUR_URL__.html"

with HdRezkaSession("https://rezka_mirror.com/") as session:
	session.login("email@gmail.com", "password")
	rezka = session.get("https://hdrezka.ag/__URL_PATH__.html")

Also when specifying origin you can specify only url path.

with HdRezkaSession("https://rezka_mirror.com/") as session:
	rezka = session.get("__URL_PATH__.html")

You can also not specify origin and then requests will be made to the URL you specified.
But then you won't be able to use login().

with HdRezkaSession() as session:
	rezka = session.get("https://hdrezka.ag/__URL_PATH__.html")
with HdRezkaSession(cookies=cookies, headers=headers, proxy=proxy) as session:
	# or inline seting up
	session.cookies = cookies
	session.headers = headers
	session.proxy = proxy

Searching with session

Fast search

with HdRezkaSession("https://rezka_mirror.com/") as session:
	results = session.search("film name")

Advanced search

with HdRezkaSession("https://rezka_mirror.com/") as session:
	session.login("email@gmail.com", "password")
	results = session.search("film name", find_all=True)
	for page in results:
		for result in page:
			print(result)

More info


💲Donate

Donatello
Donation Alerts

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

hdrezkaapi-8.2.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

HdRezkaApi-8.2.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file hdrezkaapi-8.2.0.tar.gz.

File metadata

  • Download URL: hdrezkaapi-8.2.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for hdrezkaapi-8.2.0.tar.gz
Algorithm Hash digest
SHA256 7b37debbc3f502d15f58bbca2267d7a19497fe9c43b8329e6f3198e9d4471e5d
MD5 f8a1e94413682d5a9db5234412379f2e
BLAKE2b-256 ce697ec28afd537fc67d7dc56aed0dd54f947e74e9f7373629db9b4e5424d053

See more details on using hashes here.

File details

Details for the file HdRezkaApi-8.2.0-py3-none-any.whl.

File metadata

  • Download URL: HdRezkaApi-8.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for HdRezkaApi-8.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1120d49c8612869cffefd82afa417199a4d7bc3a2a4ba5d5a9eaabca85b2881e
MD5 e4a959891bab65345c70629e783a1f95
BLAKE2b-256 3cedacd9d7d04dc49c4167d6af41fb32d2df19842302faa37fc109543981114b

See more details on using hashes here.

Supported by

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