'Executes any extra scripts defined in the config.
:param ep_obj: The object to use when calling the extra script'

def _run_extra_scripts(self, ep_obj):

    if (not sickbeard.EXTRA_SCRIPTS):
        return
    file_path = self.file_path
    if isinstance(file_path, six.text_type):
        try:
            file_path = file_path.encode(sickbeard.SYS_ENCODING)
        except UnicodeEncodeError:
            pass
    ep_location = ep_obj.location
    if isinstance(ep_location, six.text_type):
        try:
            ep_location = ep_location.encode(sickbeard.SYS_ENCODING)
        except UnicodeEncodeError:
            pass
    for curScriptName in sickbeard.EXTRA_SCRIPTS:
        if isinstance(curScriptName, six.text_type):
            try:
                curScriptName = curScriptName.encode(sickbeard.SYS_ENCODING)
            except UnicodeEncodeError:
                pass
        script_cmd = [piece for piece in re.split(u'(\\\'.*?\\\'|".*?"|    )', curScriptName) if piece.strip()]
        script_cmd[0] = ek(os.path.abspath, script_cmd[0])
        self._log(u'Absolute    path    to    script:    {0}'.format(script_cmd[0]), logger.DEBUG)
        script_cmd += [ep_location, file_path, str(ep_obj.show.indexerid), str(ep_obj.season), str(ep_obj.episode), str(ep_obj.airdate)]
        self._log(u'Executing    command:    {0}'.format(script_cmd))
        try:
            p = subprocess.Popen(script_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=sickbeard.PROG_DIR)
            (out, err_) = p.communicate()
            self._log(u'Script    result:    {0}'.format(out), logger.DEBUG)
        except Exception as e:
            self._log(u'Unable    to    run    extra_script:    {0}'.format(ex(e)))
