# Buggy code
def cookie_login(self, check_login_text, check_url=None):
    """
    Check the response for text that indicates a login prompt.

    In that case, the cookie authentication was not successful.
    :param check_login_text: A string that's visible when the authentication failed.
    :param check_url: The url to use to test the login with cookies. By default the providers home page is used.

    :return: False when authentication was not successful. True if successful.
    """
    check_url = check_url or self.url

    if self.check_required_cookies():
        # All required cookies have been found within the current session, we don't need to go through this again.
        return True

    if self.cookies:
        result = self.add_cookies_from_ui()
        if not result["result"]:
            ui.notifications.message(result["message"])
            log.warning(result["message"])
            return False
    else:
        log.warning(
            "Failed to login, you will need to add your cookies in the provider settings"
        )
        ui.notifications.error(
            "Failed to auth with {provider}".format(provider=self.name),
            "You will need to add your cookies in the provider settings",
        )
        return False

    response = self.session.get(check_url)
    if any(
        [
            not response,
            not (response.text and response.status_code == 200),
            check_login_text.lower() in response.text.lower(),
        ]
    ):
        log.warning(
            "Please configure the required cookies for this provider. Check your provider settings"
        )
        ui.notifications.error(
            "Wrong cookies for {provider}".format(provider=self.name),
            "Check your provider settings",
        )
        self.session.cookies.clear()
        return False
    else:
        return True


# Traceback (AttributeError)
2016-12-02 19:05:00 INFO     FINDPROPERS :: [Rarbg] :: [1d6c65b] Searching for any new PROPER releases from Rarbg
2016-12-02 19:05:01 DEBUG    FINDPROPERS :: [Rarbg] :: [1d6c65b] GET URL: http://torrentapi.org/pubapi_v2.php?get_token=get_token&amp;app_id=medusa&amp;format=json [Status: 200]
2016-12-02 19:05:01 DEBUG    FINDPROPERS :: [Rarbg] :: [1d6c65b] Search mode: Episode
2016-12-02 19:05:01 DEBUG    FINDPROPERS :: [Rarbg] :: [1d6c65b] Unknown exception while searching for propers in Rarbg, skipping: 'NoneType' object has no attribute 'indexer'
2016-12-02 19:05:01 DEBUG    FINDPROPERS :: [Rarbg] :: [1d6c65b] Traceback (most recent call last):
File "C:/Users/Fernando/Documents/Medusa\medusa\search\proper.py", line 137, in _get_proper_results
cur_propers = cur_provider.find_propers(recently_aired)
File "C:/Users/Fernando/Documents/Medusa\medusa\providers\generic_provider.py", line 148, in find_propers
for item in self.search(search_strings[0], ep_obj=episode_obj):
File "C:/Users/Fernando/Documents/Medusa\medusa\providers\torrent\json\rarbg.py", line 99, in search
search_params['search_tvdb'] = self._get_tvdb_id()
File "C:/Users/Fernando/Documents/Medusa\medusa\providers\generic_provider.py", line 486, in _get_tvdb_id
return self.show.indexerid if self.show.indexer == INDEXER_TVDBV2 else self.show.externals.get('tvdb_id')
AttributeError: 'NoneType' object has no attribute 'indexer'

# Fixed code
def cookie_login(self, check_login_text, check_url=None):
    """
    Check the response for text that indicates a login prompt.

    In that case, the cookie authentication was not successful.
    :param check_login_text: A string that's visible when the authentication failed.
    :param check_url: The url to use to test the login with cookies. By default the providers home page is used.

    :return: False when authentication was not successful. True if successful.
    """
    check_url = check_url or self.url

    if self.check_required_cookies():
        # All required cookies have been found within the current session, we don't need to go through this again.
        return True

    if self.cookies:
        result = self.add_cookies_from_ui()
        if not result["result"]:
            ui.notifications.message(result["message"])
            log.warning(result["message"])
            return False
    else:
        log.warning(
            "Failed to login, you will need to add your cookies in the provider settings"
        )
        ui.notifications.error(
            "Failed to auth with {provider}".format(provider=self.name),
            "You will need to add your cookies in the provider settings",
        )
        return False

    response = self.session.get(check_url)
    if not response or any(
        [
            not (response.text and response.status_code == 200),
            check_login_text.lower() in response.text.lower(),
        ]
    ):
        log.warning(
            "Please configure the required cookies for this provider. Check your provider settings"
        )
        ui.notifications.error(
            "Wrong cookies for {provider}".format(provider=self.name),
            "Check your provider settings",
        )
        self.session.cookies.clear()
        return False
    else:
        return True