diff --git a/mattebox/app.py b/mattebox/app.py index c9ae664..d15dae6 100644 --- a/mattebox/app.py +++ b/mattebox/app.py @@ -4,7 +4,7 @@ import m3u8 from urllib3.exceptions import HTTPError from typing import List from .auth import login -from .consts import API +from .consts import API, PLATFORM_ID, security_values from .helpers import now_timestamp from .types import Program from .exceptions import RecordingException @@ -21,7 +21,16 @@ class MatteBOX: } def __get(self, endpoint: str, params: dict) -> dict: - res = requests.get(API + endpoint, params=params, cookies=self.cookies) + res = requests.get( + API + endpoint, params=params, cookies=self.cookies, headers={ + "X-NanguTv-Platform-Id": PLATFORM_ID, + "X-NanguTv-Device-size": "normal", + "X-NanguTv-Device-Name": security_values.device_name, + "X-NanguTv-App-Version": security_values.app_version, + "X-NanguTv-Device-density": security_values.device_density, + "User-Agent": security_values.user_agent, + } + ) if res.status_code >= 400: raise requests.exceptions.BaseHTTPError(res.text) return json.loads(res.text) diff --git a/mattebox/consts.py b/mattebox/consts.py index 1de35a2..05157eb 100644 --- a/mattebox/consts.py +++ b/mattebox/consts.py @@ -7,3 +7,14 @@ PLATFORM_ID = "8a5eaad0e39a83621c25f20b0a10d721" # Probably your ISP but tested only with this single client. CLIENT_ID = "feromedia-mobile" CLIENT_SECRET = "4SbnLL2BdBmbQ94qdPa2N0kF7Xv4fJzo" + + +class security_values: + """Values to send in HTTP headers to avoid consequences of usings this kind + unofficial library. + """ + + user_agent = "Mozilla/5.0 (Android 9; Mobile; rv:68.0) Gecko/68.0 Firefox/68.0" + app_version = "Android#3.5.32.9-release" + device_density = "568" + device_name = "SAMSUNG SM-G960U"