From 0bbde7d3c0e817321b7603f4e5acc1ae80ca9f58 Mon Sep 17 00:00:00 2001 From: iPromKnight <156901906+iPromKnight@users.noreply.github.com> Date: Tue, 5 Nov 2024 09:11:32 +0000 Subject: [PATCH] fix: MediaFusion scraper. (#850) - Allow scrapers to override main response type in shared base --- src/program/services/scrapers/mediafusion.py | 4 ++-- src/program/services/scrapers/shared.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/program/services/scrapers/mediafusion.py b/src/program/services/scrapers/mediafusion.py index fff743e9..5a184210 100644 --- a/src/program/services/scrapers/mediafusion.py +++ b/src/program/services/scrapers/mediafusion.py @@ -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: @@ -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}") diff --git a/src/program/services/scrapers/shared.py b/src/program/services/scrapers/shared.py index ef79f5d1..a9e9dafb 100644 --- a/src/program/services/scrapers/shared.py +++ b/src/program/services/scrapers/shared.py @@ -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]: