# Buggy code
def load_imdb_info(self):
    """Load all required show information from IMDb with ImdbPie."""
    imdb_api = imdbpie.Imdb()

    if not self.imdb_id:
        self.imdb_id = helpers.title_to_imdb(self.name, self.start_year, imdb_api)

        if not self.imdb_id:
            log.info(
                "{id}: Not loading show info from IMDb, because we don't know its ID.",
                {"id": self.indexerid},
            )
            return

    # Make sure we only use the first ID
    self.imdb_id = self.imdb_id.split(",")[0]

    log.debug(
        "{id}: Loading show info from IMDb with ID: {imdb_id}",
        {"id": self.indexerid, "imdb_id": self.imdb_id},
    )

    imdb_obj = imdb_api.get_title_by_id(self.imdb_id)

    # If the show has no year, IMDb returned something we don't want
    if not imdb_obj.year:
        log.debug(
            "{id}: IMDb returned invalid info for {imdb_id}, skipping update.",
            {"id": self.indexerid, "imdb_id": self.imdb_id},
        )
        return

    # Set retrieved IMDb ID as imdb_id for externals
    self.externals["imdb_id"] = self.imdb_id

    self.imdb_info = {
        "imdb_id": imdb_obj.imdb_id,
        "title": imdb_obj.title,
        "year": imdb_obj.year,
        "akas": "",
        "genres": "|".join(imdb_obj.genres or ""),
        "countries": "",
        "country_codes": "",
        "rating": str(imdb_obj.rating) if imdb_obj.rating else "",
        "votes": imdb_obj.votes or "",
        "runtimes": int(imdb_obj.runtime / 60)
        if imdb_obj.runtime
        else "",  # Time is returned in seconds
        "certificates": imdb_obj.certification or "",
        "plot": imdb_obj.plots[0] if imdb_obj.plots else imdb_obj.plot_outline or "",
        "last_update": datetime.date.today().toordinal(),
    }

    tmdb_id = self.externals.get("tmdb_id")
    if tmdb_id:
        # Country codes and countries obtained from TMDB's API. Not IMDb info.
        country_codes = Tmdb().get_show_country_codes(tmdb_id)
        if country_codes:
            countries = (
                from_country_code_to_name(country) for country in country_codes
            )
            self.imdb_info["countries"] = "|".join(filter(None, countries))
            self.imdb_info["country_codes"] = "|".join(country_codes).lower()

    log.debug(
        "{id}: Obtained info from IMDb: {imdb_info}",
        {"id": self.indexerid, "imdb_info": self.imdb_info},
    )


# 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 load_imdb_info(self):
    """Load all required show information from IMDb with ImdbPie."""
    imdb_api = imdbpie.Imdb()

    if not self.imdb_id:
        self.imdb_id = helpers.title_to_imdb(self.name, self.start_year, imdb_api)

        if not self.imdb_id:
            log.info(
                "{id}: Not loading show info from IMDb, because we don't know its ID.",
                {"id": self.indexerid},
            )
            return

    # Make sure we only use the first ID
    self.imdb_id = self.imdb_id.split(",")[0]

    log.debug(
        "{id}: Loading show info from IMDb with ID: {imdb_id}",
        {"id": self.indexerid, "imdb_id": self.imdb_id},
    )

    imdb_obj = imdb_api.get_title_by_id(self.imdb_id)

    # If the show has no year, IMDb returned something we don't want
    if not imdb_obj or not imdb_obj.year:
        log.debug(
            "{id}: IMDb returned none or invalid info for {imdb_id}, skipping update.",
            {"id": self.indexerid, "imdb_id": self.imdb_id},
        )
        return

    # Set retrieved IMDb ID as imdb_id for externals
    self.externals["imdb_id"] = self.imdb_id

    self.imdb_info = {
        "imdb_id": imdb_obj.imdb_id,
        "title": imdb_obj.title,
        "year": imdb_obj.year,
        "akas": "",
        "genres": "|".join(imdb_obj.genres or ""),
        "countries": "",
        "country_codes": "",
        "rating": str(imdb_obj.rating) if imdb_obj.rating else "",
        "votes": imdb_obj.votes or "",
        "runtimes": int(imdb_obj.runtime / 60)
        if imdb_obj.runtime
        else "",  # Time is returned in seconds
        "certificates": imdb_obj.certification or "",
        "plot": imdb_obj.plots[0] if imdb_obj.plots else imdb_obj.plot_outline or "",
        "last_update": datetime.date.today().toordinal(),
    }

    tmdb_id = self.externals.get("tmdb_id")
    if tmdb_id:
        # Country codes and countries obtained from TMDB's API. Not IMDb info.
        country_codes = Tmdb().get_show_country_codes(tmdb_id)
        if country_codes:
            countries = (
                from_country_code_to_name(country) for country in country_codes
            )
            self.imdb_info["countries"] = "|".join(filter(None, countries))
            self.imdb_info["country_codes"] = "|".join(country_codes).lower()

    log.debug(
        "{id}: Obtained info from IMDb: {imdb_info}",
        {"id": self.indexerid, "imdb_info": self.imdb_info},
    )