def request(url, control=False): try: thing = requests.get(url, headers=header) except: thing = requests.get(url, headers=header) if control: try: if thing.json()['error']['message'] == "no data": raise exceptions.TrackNotFound("Track not found :(") except KeyError: pass try: if thing.json()['error']['message'] == "Quota limit exceeded": raise exceptions.QuotaExceeded( "Too much requests limit yourself") except KeyError: pass try: if thing.json()['error']: raise exceptions.InvalidLink("Invalid link ;)") except KeyError: pass return thing
def request(url, control = False): try: thing = get(url, headers = header) except: thing = get(url, headers = header) if control: try: if thing.json()['error']['message'] == "no data": raise exceptions.NoDataApi("No data avalaible :(") except KeyError: pass try: if thing.json()['error']['message'] == "Quota limit exceeded": raise exceptions.QuotaExceeded("Too much requests limit yourself") except KeyError: pass return thing