Value for header {session_id: {'error_code': 1000047, 'description': 'Недоступно для веб-портала', 'details': []}} must be of type str or bytes, not
TypeError: expected string or bytes-like object
Это сама ошибка
А вот сам код:
import requests
from time import sleep
import re
import logging
import io
from aiogram import Bot, Dispatcher, executor, types
from datetime import datetime
from random import choice
import sqlite3
# Объект бота
bot = Bot(token="токен")
# Диспетчер для бота
dp = Dispatcher(bot)
# Включаем логирование, чтобы не пропустить важные сообщения
logging.basicConfig(level=logging.INFO)
def try_or(fn, df):
try:
return fn
except Exception as err:
print(err)
return df
def getUID():
uid = "".join(choice("123450123456789abcdefgh") for _ in range(16))
f = requests.post(
"https://yug-krdr-itv04.svc.iptv.rt.ru/api/v2/itv/devices",
json={
"model": "".join(choice("123450123456789abcdefgh") for _ in range(10)),
"platform": "Windows",
"real_uid": uid,
"sn": uid,
"terminal_name": "".join(choice("123450123456789abcdefgh") for _ in range(16)),
"type": "NCWEB",
"vendor": "Bebra",
},
headers={
"x-rt-uid": "",
"x-rt-san": "",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
},
)
return f.json()["uid"]
def regAccount():
email = "".join(choice("834158135jgjfjgjdg") for _ in range(10)) + "@gmail.com"
ud = getUID()
sess_id = requests.post(
"https://yug-krdr-itv04.svc.iptv.rt.ru/api/v2/itv/sessions",
headers={
"x-rt-uid": ud,
"x-rt-san": "",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
},
json={"device_uid": ud},
).json()["session_id"]
san = requests.post(
"https://yug-krdr-itv04.svc.iptv.rt.ru/api/v2/user/accounts",
headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)", "session_id": sess_id},
json={"login": email, "login_type": "email", "password": "1234567"},
).json()
session_id = requests.post(
"https://yug-krdr-itv04.svc.iptv.rt.ru/api/v2/user/sessions",
headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)", "session_id": sess_id},
json={"login": email, "login_type": "email", "password": "1234567"},
).json()
return {"san": san, "session_id": session_id, "uid": ud}
def requestBuilderWink(url, data=None, params=None, json=None, method=None):
register = regAccount()
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
"session_id": register["session_id"],
"x-rt-uid": register["uid"],
"x-rt-san": register["san"],
}
while True:
try:
if method == 'post':
response = requests.post(url=url, headers=headers, json=json)
else:
response = requests.get(url=url, headers=headers)
if data in response.text:
return response.json()
break
except Exception as err:
print(err)
sleep(5)
def getBind(card, mm, yy, cvc):
data = requestBuilderWink(
"https://yug-krdr-itv04.svc.iptv.rt.ru/api/v2/portal/buy",
data="order_id",
method="post",
json={
"purchase_option_id": "0",
"is_should_link_card": "true",
"service_id": "98776236",
"content_id": "133463641",
"payment_method_id": "1"}
)
return requests.post(
"https://isespp.pay.rt.ru/p/1/driver/sdbc/",
headers={
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
"Accept": "application/json, text/plain, */*",
"Referer": "https://wink.rt.ru/services/98776236",
"Origin": "https://wink.rt.ru",
},
json={
"authPay": {
"orderId": data["order_id"],
"payAmount": 19900,
"payCurrId": "RUB",
"reqTime": "2021-12-14T19:00:47.834+03:00",
},
"cardCvc": str(cvc),
"cardExpMonth": int(f"{mm}"),
"cardExpYear": int(f"20{yy}"),
"cardHolder": "CARD HOLDER",
"cardNumber": str(card),
"confirm": 0,
"delay": 1,
"reqId": data["req_id"],
"reqType": "createPayment",
},
).json()
Помогите решить пожалуйста...