# Buggy code
def __init__(
    self,
    name,
    url="",
    api_key="0",
    cat_ids=None,
    default=False,
    search_mode="eponly",
    search_fallback=False,
    enable_daily=True,
    enable_backlog=False,
    enable_manualsearch=False,
):
    """Initialize the class."""
    super(NewznabProvider, self).__init__(name)

    self.url = url
    self.api_key = api_key

    self.default = default

    self.search_mode = search_mode
    self.search_fallback = search_fallback
    self.enable_daily = enable_daily
    self.enable_manualsearch = enable_manualsearch
    self.enable_backlog = enable_backlog

    # 0 in the key spot indicates that no key is needed
    self.needs_auth = self.api_key != "0"
    self.public = not self.needs_auth

    self.cat_ids = cat_ids or ["5030", "5040"]

    self.torznab = False

    self.params = False
    self.cap_tv_search = None
    self.providers_without_caps = ["gingadaddy", "6box"]

    # For now apply the additional season search string for all newznab providers.
    # If we want to limited this per provider, I suggest using a dict, with provider: [list of season templates]
    # construction.
    self.season_templates = (
        "S{season:0>2}",  # example: 'Series.Name S03'
        "Season {season}",  # example: 'Series.Name Season 3'
    )

    self.cache = tv.Cache(self)


# 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 __init__(
    self,
    name,
    url="",
    api_key="0",
    cat_ids=None,
    default=False,
    search_mode="eponly",
    search_fallback=False,
    enable_daily=True,
    enable_backlog=False,
    enable_manualsearch=False,
):
    """Initialize the class."""
    super(NewznabProvider, self).__init__(name)

    self.url = url
    self.api_key = api_key

    self.default = default

    self.search_mode = search_mode
    self.search_fallback = search_fallback
    self.enable_daily = enable_daily
    self.enable_manualsearch = enable_manualsearch
    self.enable_backlog = enable_backlog

    # 0 in the key spot indicates that no key is needed
    self.needs_auth = self.api_key != "0"
    self.public = not self.needs_auth

    self.cat_ids = cat_ids or ["5030", "5040"]

    self.torznab = False

    self.params = False
    self.cap_tv_search = []
    self.providers_without_caps = ["gingadaddy", "6box"]

    # For now apply the additional season search string for all newznab providers.
    # If we want to limited this per provider, I suggest using a dict, with provider: [list of season templates]
    # construction.
    self.season_templates = (
        "S{season:0>2}",  # example: 'Series.Name S03'
        "Season {season}",  # example: 'Series.Name Season 3'
    )

    self.cache = tv.Cache(self)