Skip to content

Commit

Permalink
7.2.1
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
SuperZombi committed Jan 6, 2025
1 parent 72bcded commit c11a196
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
33 changes: 17 additions & 16 deletions HdRezkaApi/HdRezkaApi.py → HdRezkaApi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@
from urllib.parse import urlparse
import time

try:
from utils.types import (HdRezkaTVSeries, HdRezkaMovie, HdRezkaRating)
from utils.stream import HdRezkaStream
except ImportError:
from .utils.types import (HdRezkaTVSeries, HdRezkaMovie, HdRezkaRating)
from .utils.stream import HdRezkaStream

class BeautifulSoupCustom(BeautifulSoup):
def __repr__(self): return "<HTMLDocument>"

class LoginRequiredError(Exception):
def __init__(self): super().__init__("Login is required to access this page.")
from .utils.stream import HdRezkaStream
from .utils.types import BeautifulSoupCustom
from .utils.types import (HdRezkaTVSeries, HdRezkaMovie, HdRezkaRating)
from .utils.errors import (LoginRequiredError, LoginFailed, FetchFailed)


class HdRezkaApi():
__version__ = "7.2.0"
__version__ = "7.2.1"
def __init__(self, url, proxy={}, headers={}, cookies={}):
self.url = url.split(".html")[0] + ".html"
uri = urlparse(self.url)
Expand All @@ -35,7 +27,9 @@ def __init__(self, url, proxy={}, headers={}, cookies={}):

def login(self, email:str, password:str):
response = requests.post(f"{self.origin}/ajax/login/",data={"login_name":email,"login_password":password},headers=self.HEADERS,proxies=self.proxy)
if response.json()['success']:self.cookies = {**self.cookies,**response.cookies.get_dict()}
data = response.json()
if data['success']: self.cookies = {**self.cookies,**response.cookies.get_dict()}
else: raise LoginFailed(data.get("message"))

@staticmethod
def make_cookies(user_id:str, password_hash:str):
Expand Down Expand Up @@ -197,7 +191,7 @@ def makeRequest(data):
for video in links:
stream.append(quality, video)
return stream
print("[WARN]: Failed to fetch!")
raise FetchFailed()

def getStreamSeries(self, season, episode, translation_id):
if not (season and episode):
Expand Down Expand Up @@ -244,7 +238,14 @@ def getStreamMovie(self, translation_id):


if self.type == HdRezkaTVSeries:
return getStreamSeries(self, int(season), int(episode), tr_id)
if season and episode:
return getStreamSeries(self, int(season), int(episode), tr_id)
elif season and (not episode):
raise TypeError("getStream() missing one required argument (episode)")
elif episode and (not season):
raise TypeError("getStream() missing one required argument (season)")
else:
raise TypeError("getStream() missing required arguments (season and episode)")
elif self.type == HdRezkaMovie:
return getStreamMovie(self, tr_id)
else:
Expand Down
8 changes: 8 additions & 0 deletions HdRezkaApi/utils/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class LoginRequiredError(Exception):
def __init__(self): super().__init__("Login is required to access this page.")

class LoginFailed(Exception):
def __init__(self, msg): super().__init__(msg)

class FetchFailed(Exception):
def __init__(self): super().__init__("Failed to fetch stream!")
5 changes: 5 additions & 0 deletions HdRezkaApi/utils/types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from bs4 import BeautifulSoup

class BeautifulSoupCustom(BeautifulSoup):
def __repr__(self): return "<HTMLDocument>"

class HdRezkaType():
def __init__(self, name):
self.name = name
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HdRezkaApi

<img src="https://shields.io/badge/version-v7.2-blue"> <a href="#donate"><img src="https://shields.io/badge/💲-Support_Project-2ea043"></a>
<img src="https://shields.io/badge/version-v7.2.1-blue"> <a href="#donate"><img src="https://shields.io/badge/💲-Support_Project-2ea043"></a>

### Install:
```
Expand Down

0 comments on commit c11a196

Please sign in to comment.