# Buggy code
def getTrendingShowImage(indexerId):
    image_url = sickchill.indexer.series_poster_by_id(indexerId)
    if image_url:
        image_path = trakt_trending.get_image_path(
            trakt_trending.get_image_name(indexerId)
        )
        trakt_trending.cache_image(image_url, image_path)
        return indexerId


# Traceback (AttributeError)
2020-01-12 09:11:36 ERROR    SHOWQUEUE-ADD :: [b6fe632] Unable to look up the show in None on theTVDB using ID 360733, not using the NFO. Delete .nfo and try adding manually again.: 'Series' object has no attribute 'title'
2020-01-12 09:11:36 INFO     SHOWQUEUE-ADD :: Starting to add show by Indexer Id: 360733
2020-01-12 09:11:35 DEBUG    SEARCHQUEUE-BACKLOG-258541 :: [NZB.Cat] :: Search string: Chicago Fire S05E11
2020-01-12 09:11:35 DEBUG    SEARCHQUEUE-BACKLOG-258541 :: [NZB.Cat] :: Search Mode: Episode
2020-01-12 09:11:34 INFO     SEARCHQUEUE-BACKLOG-258541 :: [NZB.Cat] :: Request failed: 429 Client Error: Too Many Requests for url: https://nzb.cat/api?apikey=**********&tvdbid=258541&season=5&maxage=999&cat=5030%2C5040&limit=100&t=tvsearch&offset=0&ep=10 (<type 'str'>)

AttributeError: 'ShowIndexer' object has no attribute 'series_poster_by_id'
    image_url = sickchill.indexer.series_poster_by_id(indexerId)
  File "C:\SickRage\SickRage\sickchill\views\manage\add_shows.py", line 345, in getTrendingShowImage
    result = function(**kwargs)
  File "C:\SickRage\SickRage\sickchill\views\index.py", line 182, in async_call
    result = self.fn(*self.args, **self.kwargs)
  File "C:\SickRage\SickRage\lib\concurrent\futures\thread.py", line 63, in run
    return self.__get_result()
  File "C:\SickRage\SickRage\lib\concurrent\futures\_base.py", line 455, in result
    value = future.result()
  File "C:\SickRage\SickRage\lib\tornado\gen.py", line 1055, in run
    results = yield self.async_call(method)
  File "C:\SickRage\SickRage\sickchill\views\index.py", line 160, in get
2020-01-12 09:11:34 DEBUG    TORNADO :: Failed doing webui request "getTrendingShowImage": Traceback (most recent call last):

AttributeError: 'ShowIndexer' object has no attribute 'series_poster_by_id'
    image_url = sickchill.indexer.series_poster_by_id(indexerId)
  File "C:\SickRage\SickRage\sickchill\views\manage\add_shows.py", line 345, in getTrendingShowImage
    result = function(**kwargs)
  File "C:\SickRage\SickRage\sickchill\views\index.py", line 182, in async_call
    result = self.fn(*self.args, **self.kwargs)
  File "C:\SickRage\SickRage\lib\concurrent\futures\thread.py", line 63, in run
    return self.__get_result()
  File "C:\SickRage\SickRage\lib\concurrent\futures\_base.py", line 455, in result
    value = future.result()
  File "C:\SickRage\SickRage\lib\tornado\gen.py", line 1055, in run
    results = yield self.async_call(method)
  File "C:\SickRage\SickRage\sickchill\views\index.py", line 160, in get
2020-01-12 09:11:33 DEBUG    TORNADO :: Failed doing webui request "getTrendingShowImage": Traceback (most recent call last):

AttributeError: 'ShowIndexer' object has no attribute 'series_poster_by_id'
    image_url = sickchill.indexer.series_poster_by_id(indexerId)
  File "C:\SickRage\SickRage\sickchill\views\manage\add_shows.py", line 345, in getTrendingShowImage
    result = function(**kwargs)
  File "C:\SickRage\SickRage\sickchill\views\index.py", line 182, in async_call
    result = self.fn(*self.args, **self.kwargs)
  File "C:\SickRage\SickRage\lib\concurrent\futures\thread.py", line 63, in run
    return self.__get_result()
  File "C:\SickRage\SickRage\lib\concurrent\futures\_base.py", line 455, in result
    value = future.result()
  File "C:\SickRage\SickRage\lib\tornado\gen.py", line 1055, in run
    results = yield self.async_call(method)
  File "C:\SickRage\SickRage\sickchill\views\index.py", line 160, in get
2020-01-12 09:11:33 DEBUG    TORNADO :: Failed doing webui request "getTrendingShowImage": Traceback (most recent call last):


# Fixed code
def getTrendingShowImage(indexerId):
    image_url = sickchill.indexer.series_poster_url_by_id(indexerId)
    if image_url:
        image_path = trakt_trending.get_image_path(
            trakt_trending.get_image_name(indexerId)
        )
        trakt_trending.cache_image(image_url, image_path)
        return indexerId