# Buggy code
def _set_attrs_to_values(self, response={}):
    """
    Set attributes to dictionary values.

    - e.g.
    >>> import tmdbsimple as tmdb
    >>> movie = tmdb.Movies(103332)
    >>> response = movie.info()
    >>> movie.title  # instead of response['title']
    """
    if isinstance(response, dict):
        for key in response.keys():
            setattr(self, key, response[key])


# Traceback (ZeroDivisionError)
2018-04-14 23:42:05 DEBUG    ThreadPoolExecutor-0_1 :: [b4c38d5] 78783: Saving to database: Hunting Nazi Treasure
2018-04-14 23:42:20 DEBUG    ThreadPoolExecutor-0_1 :: [b4c38d5] 78783: Queueing show refresh for Hunting Nazi Treasure
2018-04-14 23:42:20 DEBUG    ThreadPoolExecutor-0_1 :: [b4c38d5] Finished editing show: Hunting Nazi Treasure
2018-04-14 23:42:22 INFO     SHOWQUEUE-REFRESH :: [b4c38d5] 78783: Performing refresh on Hunting Nazi Treasure
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] 78783: Loading all episodes from the show directory: /media/ssd/Shows/Hunting Nazi Treasure
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] 78783: Found files: [u'/media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.mkv', u'/media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E02.The.Mystery.of.Rommels.Gold.HDTV.x264-CAFFEiNE.mkv', u'/media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E03.Hitlers.Obsession.HDTV.x264-CAFFEiNE.mkv', u'/media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E04.Nazi.Gold.HDTV.x264-CAFFEiNE.mkv', u'/media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E06.Blood.Treasure.HDTV.x264-CAFFEiNE.mkv', u'/media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E07.City.of.Loot.HDTV.x264-CAFFEiNE.mkv', u'/media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E08.Stealing.Italy.HDTV.x264-CAFFEiNE.mkv']
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] 78783: Creating episode from: /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.mkv
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] 78783: Creating episode object from /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.mkv
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Scene numbering enabled series Hunting Nazi Treasure using indexer numbering: S01E01
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Converted parsed result /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.mkv into title: Hunting Nazi Treasure, season: 1, episode: [1], episode_title: Pilot, episode_details: Pilot, format: HDTV, video_codec: h264, video_encoder: x264, release_group: CAFFEiNE, container: mkv, mimetype: video/x-matroska, type: episode, parsing_time: 0.366448879242, total_time: None, absolute_episode: [], quality: SDTV
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Matched release /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.mkv to a series in your database: Hunting Nazi Treasure
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Parsed /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.mkv into title: Hunting Nazi Treasure, season: 1, episode: [1], episode_title: Pilot, episode_details: Pilot, format: HDTV, video_codec: h264, video_encoder: x264, release_group: CAFFEiNE, container: mkv, mimetype: video/x-matroska, type: episode, parsing_time: 0.366448879242, total_time: 0.390615940094, absolute_episode: [], quality: SDTV
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] 78783: /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.mkv parsed to Hunting Nazi Treasure S01E01
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] 78783: Setter sets location to /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.mkv
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Checking if /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.nfo exists: True
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Checking if /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE-thumb.jpg exists: False
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] 78783: Setter sets location to /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.mkv
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Checking if /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.nfo exists: True
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Checking if /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE-thumb.jpg exists: False
2018-04-14 23:42:22 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] 78783: Not changing current status 'Downloaded (SDTV)' based on file: /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.mkv. Reason: New file is the same as current file
2018-04-14 23:42:23 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Transaction with 1 queries executed
2018-04-14 23:42:23 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Checking if /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE.nfo exists: True
2018-04-14 23:42:23 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Checking if /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE-thumb.jpg exists: False
2018-04-14 23:42:23 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Matched release /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE to a series in your database: Hunting Nazi Treasure
2018-04-14 23:42:23 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Parsed /media/ssd/Shows/Hunting Nazi Treasure/Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE into title: Hunting Nazi Treasure, season: 1, episode: [1], episode_title: Pilot, episode_details: Pilot, format: HDTV, video_codec: h264, video_encoder: x264, release_group: CAFFEiNE, type: episode, parsing_time: 0.411699056625, total_time: 0.412950992584, absolute_episode: [], quality: SDTV
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Matched release Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE to a series in your database: Hunting Nazi Treasure
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Parsed Hunting.Nazi.Treasure.S01E01.Pilot.HDTV.x264-CAFFEiNE into title: Hunting Nazi Treasure, season: 1, episode: [1], episode_title: Pilot, episode_details: Pilot, format: HDTV, video_codec: h264, video_encoder: x264, release_group: CAFFEiNE, type: episode, parsing_time: 0.245923995972, total_time: 0.247278928757, absolute_episode: [], quality: SDTV
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Found codec for Hunting Nazi Treasure Pilot
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] 78783: Formatting pattern: %SN - S%0SE01 - %EN -> Hunting Nazi Treasure - S01E01 - Pilot
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Metadata provider KODI 12+ creating episode thumbnail for Hunting Nazi Treasure - S01E01 - Pilot
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] 78783: Using language from show settings: en
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] GET URL: https://api.themoviedb.org/3/configuration?api_key=**********
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] User-Agent: Medusa/0.1.23 (Linux; 4.9.35-v7+; 5b3a1fbc-4032-11e8-8594-b827eb6b4d4c)
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] 78783: Using language from show settings: en
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] GET URL: https://api.themoviedb.org/3/configuration?api_key=**********
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] User-Agent: Medusa/0.1.23 (Linux; 4.9.35-v7+; 5b3a1fbc-4032-11e8-8594-b827eb6b4d4c)
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Configured language en override show language of en
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Getting all series data for 78783
2018-04-14 23:42:24 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Getting all show data for 78783
2018-04-14 23:42:25 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] GET URL: https://api.themoviedb.org/3/tv/78783?api_key=**********&language=en%2Cnull [Status: 200]
2018-04-14 23:42:25 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] User-Agent: Medusa/0.1.23 (Linux; 4.9.35-v7+; 5b3a1fbc-4032-11e8-8594-b827eb6b4d4c)
2018-04-14 23:42:26 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] GET URL: https://api.themoviedb.org/3/tv/78783/external_ids?api_key=**********
2018-04-14 23:42:26 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] User-Agent: Medusa/0.1.23 (Linux; 4.9.35-v7+; 5b3a1fbc-4032-11e8-8594-b827eb6b4d4c)
2018-04-14 23:42:26 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Getting all episodes of 78783
2018-04-14 23:42:26 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] GET URL: https://api.themoviedb.org/3/tv/78783/season/1?api_key=**********&language=en [Status: 200]
2018-04-14 23:42:26 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] User-Agent: Medusa/0.1.23 (Linux; 4.9.35-v7+; 5b3a1fbc-4032-11e8-8594-b827eb6b4d4c)
2018-04-14 23:42:26 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Getting show banners for 78783
2018-04-14 23:42:27 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] GET URL: https://api.themoviedb.org/3/tv/78783/images?api_key=**********&params=include_image_language [Status: 200]
2018-04-14 23:42:27 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] User-Agent: Medusa/0.1.23 (Linux; 4.9.35-v7+; 5b3a1fbc-4032-11e8-8594-b827eb6b4d4c)
2018-04-14 23:42:27 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Adding base url for image: /kOiXiSQNHiDNMRqvcNmSXnLao6F.jpg
2018-04-14 23:42:27 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Adding base url for image: /kOiXiSQNHiDNMRqvcNmSXnLao6F.jpg
2018-04-14 23:42:27 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Adding base url for image: /kOiXiSQNHiDNMRqvcNmSXnLao6F.jpg
2018-04-14 23:42:27 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Adding base url for image: /kOiXiSQNHiDNMRqvcNmSXnLao6F.jpg
2018-04-14 23:42:27 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Adding base url for image: /kOiXiSQNHiDNMRqvcNmSXnLao6F.jpg
2018-04-14 23:42:27 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Adding base url for image: /kOiXiSQNHiDNMRqvcNmSXnLao6F.jpg
2018-04-14 23:42:27 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Adding base url for image: /kOiXiSQNHiDNMRqvcNmSXnLao6F.jpg
2018-04-14 23:42:27 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] No banners found for 78783
2018-04-14 23:42:27 DEBUG    SHOWQUEUE-REFRESH :: [b4c38d5] Found 0 total fanarts for series 78783
2018-04-14 23:42:27 ERROR    SHOWQUEUE-REFRESH :: [b4c38d5] 78783: Error while refreshing show Hunting Nazi Treasure. Error: division by zero
Traceback (most recent call last):
  File "/home/pi/Medusa/medusa/show_queue.py", line 637, in run
    self.show.refresh_dir()
  File "/home/pi/Medusa/medusa/tv/series.py", line 1754, in refresh_dir
    self.load_episodes_from_dir()
  File "/home/pi/Medusa/medusa/tv/series.py", line 932, in load_episodes_from_dir
    cur_episode = self.make_ep_from_file(os.path.join(self.location, media_file))
  File "/home/pi/Medusa/medusa/tv/series.py", line 1398, in make_ep_from_file
    **********_ep.create_meta_files()
  File "/home/pi/Medusa/medusa/tv/episode.py", line 1111, in create_meta_files
    self.__create_thumbnail(metadata_provider)
  File "/home/pi/Medusa/medusa/tv/episode.py", line 1134, in __create_thumbnail
    result = metadata_provider.create_episode_thumb(self) or result
  File "/home/pi/Medusa/medusa/metadata/generic.py", line 331, in create_episode_thumb
    return self.save_thumbnail(ep_obj)
  File "/home/pi/Medusa/medusa/metadata/generic.py", line 497, in save_thumbnail
    thumb_data = self._retrieve_show_image(u'thumbnail', ep_obj.series, ep_obj)
  File "/home/pi/Medusa/medusa/metadata/generic.py", line 734, in _retrieve_show_image
    indexer_show_obj = self._get_show_data(show_obj)
  File "/home/pi/Medusa/medusa/metadata/generic.py", line 857, in _get_show_data
    my_show = self.indexer_api[int(series_id)]
  File "/home/pi/Medusa/medusa/indexers/indexer_base.py", line 402, in __getitem__
    self._get_show_data(key, self.config['language'])
  File "/home/pi/Medusa/medusa/indexers/tmdb/tmdb.py", line 469, in _get_show_data
    self._parse_images(sid)
  File "/home/pi/Medusa/medusa/indexers/tmdb/tmdb.py", line 370, in _parse_images
    self._save_images(sid, _images)
  File "/home/pi/Medusa/medusa/indexers/indexer_base.py", line 395, in _save_images
    self._save_images_by_type(img_type, series_id, images_by_type)
  File "/home/pi/Medusa/medusa/indexers/indexer_base.py", line 296, in _save_images_by_type
    rating_mean, rating_dev, ratings = pop_stats(merged_images, 'rating')
  File "/home/pi/Medusa/medusa/indexers/indexer_base.py", line 229, in pop_stats
    mean = total / num_values
ZeroDivisionError: division by zero

# Fixed code
def _set_attrs_to_values(self, response={}):
    """
    Set attributes to dictionary values.

    - e.g.
    >>> import tmdbsimple as tmdb
    >>> movie = tmdb.Movies(103332)
    >>> response = movie.info()
    >>> movie.title  # instead of response['title']
    """
    if isinstance(response, dict):
        for key in response.keys():
            if not hasattr(self, key) or not callable(getattr(self, key)):
                setattr(self, key, response[key])