Skip to content

Commit

Permalink
fix: MediaFusion scraper. (#850)
Browse files Browse the repository at this point in the history
- Allow scrapers to override main response type in shared base
  • Loading branch information
iPromKnight authored Nov 5, 2024
1 parent 00ffee9 commit 0bbde7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/program/services/scrapers/mediafusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from program.services.scrapers.shared import _get_stremio_identifier, ScraperRequestHandler
from program.settings.manager import settings_manager
from program.settings.models import AppModel
from program.utils.request import create_service_session, get_rate_limit_params, RateLimitExceeded, HttpMethod
from program.utils.request import create_service_session, get_rate_limit_params, RateLimitExceeded, HttpMethod, ResponseType


class Mediafusion:
Expand Down Expand Up @@ -79,7 +79,7 @@ def validate(self) -> bool:
headers = {"Content-Type": "application/json"}

try:
response = self.request_handler.execute(HttpMethod.POST, url, json=payload, additional_headers=headers)
response = self.request_handler.execute(HttpMethod.POST, url, overriden_response_type=ResponseType.DICT, json=payload, additional_headers=headers)
self.encrypted_string = json.loads(response.data)["encrypted_str"]
except Exception as e:
logger.error(f"Failed to encrypt user data: {e}")
Expand Down
4 changes: 2 additions & 2 deletions src/program/services/scrapers/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class ScraperRequestHandler(BaseRequestHandler):
def __init__(self, session: Session, response_type=ResponseType.SIMPLE_NAMESPACE, custom_exception: Optional[Type[Exception]] = None, request_logging: bool = False):
super().__init__(session, response_type=response_type, custom_exception=custom_exception, request_logging=request_logging)

def execute(self, method: HttpMethod, endpoint: str, **kwargs) -> ResponseObject:
return super()._request(method, endpoint, **kwargs)
def execute(self, method: HttpMethod, endpoint: str, overriden_response_type: ResponseType = None, **kwargs) -> ResponseObject:
return super()._request(method, endpoint, overriden_response_type=overriden_response_type, **kwargs)


def _get_stremio_identifier(item: MediaItem) -> tuple[str | None, str, str]:
Expand Down

0 comments on commit 0bbde7d

Please sign in to comment.