GiorgosXou/untappdscr

Solve bad request issues

Closed this issue · 1 comments

def __get_data_from(self, url_path): # TODO: coockies= login-cockies only for special request

With the below code (i think that) I will solve a great amount of bad request issues, like suddent internet loss and etc. 10 retries each multiplied by the 2 minute retry_delay ranging between 2-110 minutes of total delay

TODO:

  • remove Try
  • add retries=10 retry_delay=120 default values in constructor
    def __get_data_from(self, url_path, retries=0, mult_delay=1): # TODO: coockies= login-cockies only for special request
        self.request_counter += 1
        if self.delay_range : sleep(randint(*self.delay_range)) # * tuple
        if self.debug_mode  : print(f'- GET REQUEST #{self.request_counter}: {url_path}')  
        response = requests.get(self.URL + url_path, headers=self.headers,  verify=True, cookies=self.cookies) 
        if not response.text and retries != self.retries:
            sleep(self.retry_delay * mult_delay)
            self.__get_data_from(url_path, retries + 1, mult_delay + 1)
        return response.text 

^ (big monkey brain momment) I might make it a bit more sophisticated

So far this method works fine, when i find time i'll patch it