Add HTTP heders to send on request

This commit is contained in:
samedamci 2021-09-16 18:55:43 +02:00
parent 8ac44229df
commit 01d3d8379b
No known key found for this signature in database
GPG Key ID: FCB4A9A20D00E894
2 changed files with 22 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import m3u8
from urllib3.exceptions import HTTPError from urllib3.exceptions import HTTPError
from typing import List from typing import List
from .auth import login from .auth import login
from .consts import API from .consts import API, PLATFORM_ID, security_values
from .helpers import now_timestamp from .helpers import now_timestamp
from .types import Program from .types import Program
from .exceptions import RecordingException from .exceptions import RecordingException
@ -21,7 +21,16 @@ class MatteBOX:
} }
def __get(self, endpoint: str, params: dict) -> dict: 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: if res.status_code >= 400:
raise requests.exceptions.BaseHTTPError(res.text) raise requests.exceptions.BaseHTTPError(res.text)
return json.loads(res.text) return json.loads(res.text)

View File

@ -7,3 +7,14 @@ PLATFORM_ID = "8a5eaad0e39a83621c25f20b0a10d721"
# Probably your ISP but tested only with this single client. # Probably your ISP but tested only with this single client.
CLIENT_ID = "feromedia-mobile" CLIENT_ID = "feromedia-mobile"
CLIENT_SECRET = "4SbnLL2BdBmbQ94qdPa2N0kF7Xv4fJzo" 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"