D
D
Desmoke2021-03-24 22:39:24
Python
Desmoke, 2021-03-24 22:39:24

Problem with checker, how to fix?

Hello again great coders!

I ask for your help, I have a Discord Nitro checker with connected proxies.
Requests go normally, the answer is received, but if json.load(r.text)["message"] == "the text about waiting copied exactly exactly" for some reason does not work.

Help!

Here is the code:

import random,string,requests,json
from time import sleep
from threading import Thread
from prettytable import PrettyTable
import os
cods,proxy = int(input('| Кол-во кодов на прокси > ')),input('| Файл с прокси > ')
valid = []
def thr(myid,proxy,ds,dp,vald,cods):
    ds(myid,4,proxy)
    for i in range(cods):
        c = ''.join(random.choices(string.ascii_letters + string.digits, k=16))
        url = f"https://discordapp.com/api/v6/entitlements/gift-codes/{c}?with_application=false&with_subscription_plan=true"
        #ds(myid,4,f'жду ответ {c}')
        r = requests.get(url)
        #ds(myid,4,f'разбор ответа {c}')
        re = json.loads(r.text)
        if "message" in re:
            ds(myid,3,'-')
            if re["message"]=="Unknown Gift Code":
                #ds(myid,4,f'невалид {c}')
                dp(myid,2)
            else:
                valid.append(c)
                dp(myid,1)
                #ds(myid,4,f'ВАЛИД {c}')
            data[myid][0] +=1
        elif re['message']=='You are being rate limited.':
            ds(myid,3,re["retry_after"][0:-3])
            ds(myid,4,'жду 5 сек для обновл. кд')
            sleep(4.9)
        ds(myid,4,re)
        sleep(0.1)
def ds(idd,key,val):
    global data
    data[idd][key]=val
def dp(idd,key):
    global data
    data[idd][key]+=1
def vald(text):
    global valid
    valid.append(text)
def main():
    global data,valid,cods
    try:
        f = open(proxy,'r')
    except:
        return 'proxy file invalid'
    pr = f.read().split('\n')
    print(f'| {len(pr)} прокси загружено успешно!')
    data=*len(pr)
    print('| =========')
    for i in range(len(pr)):
        Thread(target=thr,args=(i,pr[i],ds,dp,vald,cods)).start()
    while True:
        table = PrettyTable(["№", "проверено","валид","невалид","кд","статус"])
        for i in range(len(pr)):
            table.add_row([i]+data[i])
        l = os.get_terminal_size().lines
        k = len(str(table).split('\n'))
        print(table)
        print('\n'*(l-k-2))
        sleep(0.1)
print(main())

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeniy _, 2021-03-24
@GeneD88

1. Check that json.loads(r.text)["message"] is also a str
2. You can use the built-in method: re = r.json()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question