# Buggy code
def _add_to_anidb_mylist(self, file_path):
    """
    Add an episode to anidb mylist.

    :param file_path: file to add to mylist
    """
    if helpers.set_up_anidb_connection():
        if (
            not self.anidbEpisode
        ):  # seems like we could parse the name before, now lets build the anidb object
            self.anidbEpisode = self._build_anidb_episode(
                app.ADBA_CONNECTION, file_path
            )

        self.log("Adding the file to the anidb mylist", logger.DEBUG)
        try:
            self.anidbEpisode.add_to_mylist(
                status=1
            )  # status = 1 sets the status of the file to "internal HDD"
        except Exception as e:
            self.log("Exception message: {0!r}".format(e))


# Traceback (AttributeError)
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Starting new thread: POSTPROCESSOR
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Processing path: /downloads/complete/medusa
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] No processable items found in folder: /downloads/complete/medusa
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Processing folder: /downloads/complete/medusa/[HorribleSubs]_Sword_Art_Online_Alternative_-_Gun_Gale_Online_-_04_[720p]
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Post-processing files: [u'[HorribleSubs] Sword Art Online Alternative - Gun Gale Online - 04 [720p].mkv']
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Post-processing video files: [u'[HorribleSubs] Sword Art Online Alternative - Gun Gale Online - 04 [720p].mkv']
2018-04-28 22:15:58 INFO     POSTPROCESSOR :: [44439bc] Processing /downloads/complete/medusa/[HorribleSubs]_Sword_Art_Online_Alternative_-_Gun_Gale_Online_-_04_[720p]/[HorribleSubs] Sword Art Online Alternative - Gun Gale Online - 04 [720p].mkv
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Analyzing name: [HorribleSubs] Sword Art Online Alternative - Gun Gale Online - 04 [720p].mkv
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Using cached parse result for [HorribleSubs] Sword Art Online Alternative - Gun Gale Online - 04 [720p].mkv
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Show information parsed from file name
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Retrieving episode object for Sword Art Online Alternative: Gun Gale Online S01E04
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] The episode file has a quality in it, using that: 720p HDTV
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] This episode was found in history as SNATCHED.
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Quality of the episode we are processing: 720p HDTV
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Snatch in history: True
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Manually snatched: False
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Info hash: None
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] NZB: False
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Current quality: 720p HDTV
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] New quality: 720p HDTV
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Proper: False
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] This episode is a priority download: True
2018-04-28 22:15:58 INFO     POSTPROCESSOR :: [44439bc] New file: /downloads/complete/medusa/[HorribleSubs]_Sword_Art_Online_Alternative_-_Gun_Gale_Online_-_04_[720p]/[HorribleSubs] Sword Art Online Alternative - Gun Gale Online - 04 [720p].mkv
2018-04-28 22:15:58 INFO     POSTPROCESSOR :: [44439bc] New size: 322.47 MB
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] There is no existing file so there's no worries about replacing it
2018-04-28 22:15:58 INFO     POSTPROCESSOR :: [44439bc] This download is marked a priority download so I'm going to replace an existing file if I find one
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Trying to determine free space on destination drive
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Found release name [HorribleSubs] Sword Art Online Alternative - Gun Gale Online - 04 [720p]
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Using cached parse result for [HorribleSubs]_Sword_Art_Online_Alternative_-_Gun_Gale_Online_-_04_[720p]
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Folder name ([HorribleSubs]_Sword_Art_Online_Alternative_-_Gun_Gale_Online_-_04_[720p]) appears to be a valid release name. Using it.
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Matched release [HorribleSubs] Sword Art Online Alternative - Gun Gale Online - 04 [720p] to a series in your database: Sword Art Online Alternative: Gun Gale Online
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Parsed [HorribleSubs] Sword Art Online Alternative - Gun Gale Online - 04 [720p] into release_group: HorribleSubs, title: Sword Art Online Alternative, alias: Sword Art Online Alternative - Gun Gale Online, alternative_title: Gun Gale Online, episode: [], absolute_episode: [4], screen_size: 720p, type: episode, parsing_time: 0.10995388031, total_time: 0.110290050507, quality: 720p HDTV, season: None
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Found codec for Sword Art Online Alternative: Gun Gale Online Death Game
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] 335815: Formatting pattern: %SN - S%0SE04 - 004 - %EN -> Sword Art Online Alternative Gun Gale Online - S01E04 - 004 - Death Game
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Matched release [HorribleSubs] Sword Art Online Alternative - Gun Gale Online - 04 [720p] to a series in your database: Sword Art Online Alternative: Gun Gale Online
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Parsed [HorribleSubs] Sword Art Online Alternative - Gun Gale Online - 04 [720p] into release_group: HorribleSubs, title: Sword Art Online Alternative, alias: Sword Art Online Alternative - Gun Gale Online, alternative_title: Gun Gale Online, episode: [], absolute_episode: [4], screen_size: 720p, type: episode, parsing_time: 0.0994441509247, total_time: 0.0997660160065, quality: 720p HDTV, season: None
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Found codec for Sword Art Online Alternative: Gun Gale Online Death Game
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] 335815: Formatting pattern: Season %0S -> Season 01
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Destination folder for this episode: /tv/Anime/Sword Art Online Alternative Gun Gale Online/Season 01
2018-04-28 22:15:58 DEBUG    POSTPROCESSOR :: [44439bc] Checking if the path /tv/Anime/Sword Art Online Alternative Gun Gale Online/Season 01 already exists
2018-04-28 22:15:58 ERROR    POSTPROCESSOR :: [44439bc] Exception generated: 'module' object has no attribute 'set_up_anidb_connection'
Traceback (most recent call last):
  File "/app/medusa/medusa/scheduler.py", line 93, in run
    self.action.run(self.force)
  File "/app/medusa/medusa/auto_post_processor.py", line 58, in run
    process_tv.ProcessResult(app.TV_DOWNLOAD_DIR, app.PROCESS_METHOD).process(force=force)
  File "/app/medusa/medusa/process_tv.py", line 148, in process
    ignore_subs=ignore_subs)
  File "/app/medusa/medusa/process_tv.py", line 336, in process_files
    self.process_media(path, self.video_files, force, is_priority, ignore_subs)
  File "/app/medusa/medusa/process_tv.py", line 537, in process_media
    self.result = processor.process()
  File "/app/medusa/medusa/post_processor.py", line 1211, in process
    self._add_to_anidb_mylist(self.file_path)
  File "/app/medusa/medusa/post_processor.py", line 530, in _add_to_anidb_mylist
    if helpers.set_up_anidb_connection():
AttributeError: 'module' object has no attribute 'set_up_anidb_connection'

# Fixed code
def _add_to_anidb_mylist(self, file_path):
    """
    Add an episode to anidb mylist.

    :param file_path: file to add to mylist
    """
    if set_up_anidb_connection():
        if (
            not self.anidbEpisode
        ):  # seems like we could parse the name before, now lets build the anidb object
            self.anidbEpisode = self._build_anidb_episode(
                app.ADBA_CONNECTION, file_path
            )

        self.log("Adding the file to the anidb mylist", logger.DEBUG)
        try:
            self.anidbEpisode.add_to_mylist(
                status=1
            )  # status = 1 sets the status of the file to "internal HDD"
        except Exception as e:
            self.log("Exception message: {0!r}".format(e))