# Buggy code
def login(self):
    if dict_from_cookiejar(self.session.cookies).get("uid") and dict_from_cookiejar(
        self.session.cookies
    ).get("pass"):
        return True

    if self.cookies:
        self.add_cookies_from_ui()

        login_params = {
            "username": self.username,
            "password": self.password,
            "submit.x": 0,
            "submit.y": 0,
        }

        response = self.get_url(
            self.urls["login"], post_data=login_params, returns="response"
        )
        if response.status_code != 200:
            logger.log("Unable to connect to provider", logger.WARNING)
            return False

        if re.search("You tried too often", response.text):
            logger.log("Too many login access attempts", logger.WARNING)
            return False

        if (
            dict_from_cookiejar(self.session.cookies).get("uid")
            and dict_from_cookiejar(self.session.cookies).get("uid") in response.text
        ):
            return True
        else:
            logger.log("Failed to login, check your cookies", logger.WARNING)
            self.session.cookies.clear()
            return False


# Traceback (AttributeError)
SEARCHQUEUE-BACKLOG-266091 :: [TorrentDay] :: Unknown exception while searching TorrentDay. Error: "'int' object has no attribute 'get'"
Traceback (most recent call last):
File "/home/osmc/SickRage/sickbeard/search.py", line 547, in searchProviders
forced_search, downCurQuality, manual_search, manual_search_type)
File "/home/osmc/SickRage/sickrage/providers/GenericProvider.py", line 157, in find_search_results
items_list += self.search(search_string, ep_obj=episode)
File "/home/osmc/SickRage/sickbeard/providers/torrentday.py", line 108, in search
torrents = jdata.get('Fs', [dict()])[0].get('Cn', {}).get('torrents', [])
AttributeError: 'int' object has no attribute 'get'

# Fixed code
def login(self):
    if dict_from_cookiejar(self.session.cookies).get("uid") and dict_from_cookiejar(
        self.session.cookies
    ).get("pass"):
        return True

    if self.cookies:
        self.add_cookies_from_ui()
    else:
        logger.log(
            "Failed to login, you must add your cookies in the provider settings",
            logger.WARNING,
        )
        return False

        login_params = {
            "username": self.username,
            "password": self.password,
            "submit.x": 0,
            "submit.y": 0,
        }

        response = self.get_url(
            self.urls["login"], post_data=login_params, returns="response"
        )
        if response.status_code != 200:
            logger.log("Unable to connect to provider", logger.WARNING)
            return False

        if re.search("You tried too often", response.text):
            logger.log("Too many login access attempts", logger.WARNING)
            return False

        if (
            dict_from_cookiejar(self.session.cookies).get("uid")
            and dict_from_cookiejar(self.session.cookies).get("uid") in response.text
        ):
            return True
        else:
            logger.log("Failed to login, check your cookies", logger.WARNING)
            self.session.cookies.clear()
            return False