# Buggy code
def snatch_episode(result):
    """
    Internal logic necessary to actually "snatch" a result that has been found.

    :param result: SearchResult instance to be snatched.
    :return: boolean, True on success
    """
    if result is None:
        return False

    result.priority = 0  # -1 = low, 0 = normal, 1 = high
    is_proper = False
    if app.ALLOW_HIGH_PRIORITY:
        # if it aired recently make it high priority
        for cur_ep in result.episodes:
            if datetime.date.today() - cur_ep.airdate <= datetime.timedelta(days=7):
                result.priority = 1
    if result.proper_tags:
        logger.log(
            "Found proper tags for {0}. Snatching as PROPER".format(result.name),
            logger.DEBUG,
        )
        is_proper = True
        end_status = SNATCHED_PROPER
    else:
        end_status = SNATCHED

    if result.url.startswith("magnet") or result.url.endswith("torrent"):
        result.resultType = "torrent"

    # NZBs can be sent straight to SAB or saved to disk
    if result.resultType in ("nzb", "nzbdata"):
        if app.NZB_METHOD == "blackhole":
            result_downloaded = _download_result(result)
        elif app.NZB_METHOD == "sabnzbd":
            result_downloaded = sab.sendNZB(result)
        elif app.NZB_METHOD == "nzbget":
            result_downloaded = nzbget.sendNZB(result, is_proper)
        else:
            logger.log(
                "Unknown NZB action specified in config: " + app.NZB_METHOD,
                logger.ERROR,
            )
            result_downloaded = False

    # Torrents can be sent to clients or saved to disk
    elif result.resultType == "torrent":
        # torrents are saved to disk when blackhole mode
        if app.TORRENT_METHOD == "blackhole":
            result_downloaded = _download_result(result)
        else:
            if not result.content and not result.url.startswith("magnet"):
                if result.provider.login():
                    result.content = result.provider.get_url(
                        result.url, returns="content"
                    )

            if result.content or result.url.startswith("magnet"):
                client = torrent.get_client_class(app.TORRENT_METHOD)()
                result_downloaded = client.send_torrent(result)
            else:
                logger.log("Torrent file content is empty", logger.WARNING)
                result_downloaded = False
    else:
        logger.log(
            "Unknown result type, unable to download it (%r)" % result.resultType,
            logger.ERROR,
        )
        result_downloaded = False

    if not result_downloaded:
        return False

    if app.USE_FAILED_DOWNLOADS:
        failed_history.log_snatch(result)

    ui.notifications.message("Episode snatched", result.name)

    history.log_snatch(result)

    # don't notify when we re-download an episode
    sql_l = []
    trakt_data = []
    for curEpObj in result.episodes:
        with curEpObj.lock:
            if is_first_best_match(result):
                curEpObj.status = Quality.composite_status(
                    SNATCHED_BEST, result.quality
                )
            else:
                curEpObj.status = Quality.composite_status(end_status, result.quality)
            # Reset all others fields to the "snatched" status
            # New snatch by default doesn't have nfo/tbn
            curEpObj.hasnfo = False
            curEpObj.hastbn = False

            # We can't reset location because we need to know what we are replacing
            # curEpObj.location = ''

            # Size and release name are fetched in PP (only for downloaded status, not snatched)
            curEpObj.file_size = 0
            curEpObj.release_name = ""

            # Need to reset subtitle settings because it's a different file
            curEpObj.subtitles = list()
            curEpObj.subtitles_searchcount = 0
            curEpObj.subtitles_lastsearch = "0001-01-01 00:00:00"

            # Need to store the correct is_proper. Not use the old one
            curEpObj.is_proper = True if result.proper_tags else False
            curEpObj.version = 0

            # Release group is parsed in PP
            curEpObj.release_group = ""

            curEpObj.manually_searched = result.manually_searched

            sql_l.append(curEpObj.get_sql())

        if curEpObj.status not in Quality.DOWNLOADED:
            # TODO: Remove this broad catch when all notifiers handle exceptions
            try:
                notify_message = curEpObj.formatted_filename("%SN - %Sx%0E - %EN - %QN")
                if all(
                    [
                        app.SEEDERS_LEECHERS_IN_NOTIFY,
                        result.seeders not in (-1, None),
                        result.leechers not in (-1, None),
                    ]
                ):
                    notifiers.notify_snatch(
                        "{0} with {1} seeders and {2} leechers from {3}".format(
                            notify_message,
                            result.seeders,
                            result.leechers,
                            result.provider.name,
                        ),
                        is_proper,
                    )
                else:
                    notifiers.notify_snatch(
                        "{0} from {1}".format(notify_message, result.provider.name),
                        is_proper,
                    )
            except Exception as e:
                # Without this, when notification fail, it crashes the snatch thread and Medusa will
                # keep snatching until notification is sent
                logger.log(
                    "Failed to send snatch notification. Error: {0}".format(e),
                    logger.DEBUG,
                )

            if app.USE_TRAKT and app.TRAKT_SYNC_WATCHLIST:
                trakt_data.append((curEpObj.season, curEpObj.episode))
                logger.log(
                    "Adding {0} {1} to Trakt watchlist".format(
                        result.show.name, episode_num(curEpObj.season, curEpObj.episode)
                    ),
                    logger.INFO,
                )

    if trakt_data:
        data_episode = notifiers.trakt_notifier.trakt_episode_data_generate(trakt_data)
        if data_episode:
            notifiers.trakt_notifier.update_watchlist(
                result.show, data_episode=data_episode, update="add"
            )

    if sql_l:
        main_db_con = db.DBConnection()
        main_db_con.mass_action(sql_l)

    return True


# Traceback (gaierror)
2017-01-16 09:18:56 DEBUG    FINDSUBTITLES :: [49af1f0] [opensubtitles:pt   ] score = 355/352 for A.Series.of.Unfortunate.Events.s01e01.WebRip.x264-FS.srt
2017-01-16 09:18:56 DEBUG    FINDSUBTITLES :: [49af1f0] [opensubtitles:pt   ] score = 331/352 for A Series of Unfortunate Events s01e01.srt
2017-01-16 09:18:57 INFO     FINDSUBTITLES :: [49af1f0] Found subtitle for A.Series.of.Unfortunate.Events.S01E01.1080p.WEBRip.DD5.1.x264.mkv in opensubtitles provider with language por
2017-01-16 09:18:57 DEBUG    FINDSUBTITLES :: [49af1f0] Setting permissions for /media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E01.1080p.WEBRip.DD5.1.x264.pt.srt to 438 as parent directory has 511
2017-01-16 09:18:57 DEBUG    FINDSUBTITLES :: [49af1f0] history.logSubtitle opensubtitles, por
2017-01-16 09:18:57 DEBUG    FINDSUBTITLES :: [49af1f0] Cached video information under key medusa.subtitles:video|/media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E01.1080p.WEBRip.DD5.1.x264.mkv was invalidated
2017-01-16 09:18:57 DEBUG    FINDSUBTITLES :: [49af1f0] Scanning video /media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E01.1080p.WEBRip.DD5.1.x264.mkv...
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] Starting release refiner [extension=release, release_name=None, release_file=None]
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] No release name for /media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E01.1080p.WEBRip.DD5.1.x264.mkv
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] Refining using TVShow information.
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] Attribute series_tvdb_id changed from None to 306304
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] Attribute series_imdb_id changed from None to tt4834206
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] Attribute year changed from None to 2017
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] Refining using TVEpisode information.
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] Attribute title changed from None to The Bad Beginning: Part One
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] Attribute tvdb_id changed from None to 5778150
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] Attribute release_group changed from None to FS
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] Video information cached under key medusa.subtitles:video|/media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E01.1080p.WEBRip.DD5.1.x264.mkv
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] 306304: Subtitle changes detected for this show A Series of Unfortunate Events S01E01. Current subtitles: [u'eng', u'pob', u'por', u'und']
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] 306304: Saving subtitles changes to database
2017-01-16 09:18:58 DEBUG    FINDSUBTITLES :: [49af1f0] 306304: Saving last subtitles search to database
2017-01-16 09:18:59 INFO     FINDSUBTITLES :: [49af1f0] 306304: Downloaded Portuguese subtitles for A Series of Unfortunate Events S01E01
2017-01-16 09:18:59 DEBUG    FINDSUBTITLES :: [49af1f0] Parsed '/media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E01.1080p.WEBRip.DD5.1.x264' into title: A Series of Unfortunate Events, season: 1, episode: [1], screen_size: 1080p, format: WEBRip, audio_codec: AC3, audio_channels: 5.1, video_codec: h264, video_encoder: x264, type: episode, parsing_time: 0.458311080933, total_time: 0.458526849747, absolute_episode: [], quality: 1080p WEB-DL
2017-01-16 09:18:59 DEBUG    FINDSUBTITLES :: [49af1f0] Using cached parse result for 'A.Series.of.Unfortunate.Events.S01E01.1080p.WEBRip.DD5.1.x264'
2017-01-16 09:18:59 DEBUG    FINDSUBTITLES :: [49af1f0] Found codec for A Series of Unfortunate Events The Bad Beginning: Part One
2017-01-16 09:18:59 DEBUG    FINDSUBTITLES :: [49af1f0] 306304: Formatting pattern: %SN - S%0SE%0E - %EN -> A Series of Unfortunate Events - S01E01 - The Bad Beginning Part One
2017-01-16 09:18:59 DEBUG    FINDSUBTITLES :: [49af1f0] Notification for PLEX not enabled, skipping this notification
2017-01-16 09:18:59 DEBUG    FINDSUBTITLES :: [49af1f0] Notification for NMJ scan update not enabled, skipping this notification
2017-01-16 09:18:59 DEBUG    FINDSUBTITLES :: [49af1f0] NMA: Sending notice with details: event="Subtitle Download Finished", message="A Series of Unfortunate Events - S01E01 - The Bad Beginning Part One: Portuguese", priority=0, batch=False
2017-01-16 09:19:00 INFO     FINDSUBTITLES :: [49af1f0] NMA: Notification sent to NotifyMyAndroid
2017-01-16 09:19:00 DEBUG    FINDSUBTITLES :: [49af1f0] Checking subtitle candidates for A Series of Unfortunate Events S01E03 (A.Series.of.Unfortunate.Events.S01E03.1080p.NF.WEBRip.DD5.1.x264-ViSUM.mkv)
2017-01-16 09:19:00 DEBUG    FINDSUBTITLES :: [49af1f0] Found cached video information under key medusa.subtitles:video|/media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E03.1080p.NF.WEBRip.DD5.1.x264-ViSUM.mkv
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [opensubtitles:en   ] score = 359/352 for A.Series.of.Unfortunate.Events.S01E03.1080p.NF.WEBRip.DD5.1.x264-ViSUM.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [opensubtitles:pt-BR] score = 340/352 for A.Series.of.Unfortunate.Events.s01e03.WebRip.x264-FS.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [opensubtitles:pt   ] score = 340/352 for A.Series.of.Unfortunate.Events.s01e03.WebRip.x264-FS.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [opensubtitles:en   ] score = 340/352 for A.Series.of.Unfortunate.Events.s01e03.WebRip.x264-FS-eng.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [   legendastv:pt-BR] score = 339/352 for A.Series.of.Unfortunate.Events.S01E03.WebRip.x264-FS.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [   legendastv:pt-BR] score = 339/352 for A.Series.of.Unfortunate.Events.s01e03.WebRip.x264-FS.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [     addic7ed:en   ] score = 331/352 for FS
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [opensubtitles:pt   ] score = 331/352 for A Series of Unfortunate Events s01e03.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [     addic7ed:en   ] score = 330/352 for FS
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [   legendastv:pt-BR] score = 309/352 for A.Series.of.Unfortunate.Events.S01E07.WebRip.x264-FS.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [   legendastv:pt-BR] score = 309/352 for A.Series.of.Unfortunate.Events.S01E04.WebRip.x264-FS.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [   legendastv:pt-BR] score = 309/352 for A.Series.of.Unfortunate.Events.S01E02.WebRip.x264-FS.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [   legendastv:pt-BR] score = 309/352 for A.Series.of.Unfortunate.Events.S01E06.WebRip.x264-FS.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [   legendastv:pt-BR] score = 309/352 for A.Series.of.Unfortunate.Events.S01E08.WebRip.x264-FS.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [   legendastv:pt-BR] score = 309/352 for A.Series.of.Unfortunate.Events.S01E05.WebRip.x264-FS.srt
2017-01-16 09:19:09 DEBUG    FINDSUBTITLES :: [49af1f0] [   legendastv:pt-BR] score = 309/352 for A.Series.of.Unfortunate.Events.S01E01.WebRip.x264-FS.srt
2017-01-16 09:19:13 INFO     FINDSUBTITLES :: [49af1f0] Found subtitle for A.Series.of.Unfortunate.Events.S01E03.1080p.NF.WEBRip.DD5.1.x264-ViSUM.mkv in opensubtitles provider with language eng
2017-01-16 09:19:13 DEBUG    FINDSUBTITLES :: [49af1f0] Setting permissions for /media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E03.1080p.NF.WEBRip.DD5.1.x264-ViSUM.en.srt to 438 as parent directory has 511
2017-01-16 09:19:13 DEBUG    FINDSUBTITLES :: [49af1f0] history.logSubtitle opensubtitles, eng
2017-01-16 09:19:13 DEBUG    FINDSUBTITLES :: [49af1f0] Cached video information under key medusa.subtitles:video|/media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E03.1080p.NF.WEBRip.DD5.1.x264-ViSUM.mkv was invalidated
2017-01-16 09:19:13 DEBUG    FINDSUBTITLES :: [49af1f0] Scanning video /media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E03.1080p.NF.WEBRip.DD5.1.x264-ViSUM.mkv...
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] Starting release refiner [extension=release, release_name=None, release_file=None]
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] No release name for /media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E03.1080p.NF.WEBRip.DD5.1.x264-ViSUM.mkv
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] Refining using TVShow information.
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] Attribute series_tvdb_id changed from None to 306304
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] Attribute series_imdb_id changed from None to tt4834206
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] Attribute year changed from None to 2017
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] Refining using TVEpisode information.
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] Attribute title changed from None to The Reptile Room: Part One
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] Attribute tvdb_id changed from None to 5922016
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] Video information cached under key medusa.subtitles:video|/media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E03.1080p.NF.WEBRip.DD5.1.x264-ViSUM.mkv
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] 306304: Subtitle changes detected for this show A Series of Unfortunate Events S01E03. Current subtitles: [u'eng', u'fre', u'pol', u'und']
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] 306304: Saving subtitles changes to database
2017-01-16 09:19:15 DEBUG    FINDSUBTITLES :: [49af1f0] 306304: Saving last subtitles search to database
2017-01-16 09:19:15 INFO     FINDSUBTITLES :: [49af1f0] 306304: Downloaded English subtitles for A Series of Unfortunate Events S01E03
2017-01-16 09:19:16 DEBUG    FINDSUBTITLES :: [49af1f0] Parsed '/media/extssd/Shows/A Series of Unfortunate Events/Season 01/A.Series.of.Unfortunate.Events.S01E03.1080p.NF.WEBRip.DD5.1.x264-ViSUM' into title: A Series of Unfortunate Events, season: 1, episode: [3], screen_size: 1080p, streaming_service: Netflix, format: WEBRip, audio_codec: AC3, audio_channels: 5.1, video_codec: h264, video_encoder: x264, release_group: ViSUM, type: episode, parsing_time: 0.47635102272, total_time: 0.476587057114, absolute_episode: [], quality: 1080p WEB-DL
2017-01-16 09:19:16 DEBUG    FINDSUBTITLES :: [49af1f0] Using cached parse result for 'A.Series.of.Unfortunate.Events.S01E03.1080p.NF.WEBRip.DD5.1.x264-ViSUM'
2017-01-16 09:19:16 DEBUG    FINDSUBTITLES :: [49af1f0] Found codec for A Series of Unfortunate Events The Reptile Room: Part One
2017-01-16 09:19:16 DEBUG    FINDSUBTITLES :: [49af1f0] 306304: Formatting pattern: %SN - S%0SE%0E - %EN -> A Series of Unfortunate Events - S01E03 - The Reptile Room Part One
2017-01-16 09:19:16 DEBUG    FINDSUBTITLES :: [49af1f0] Notification for PLEX not enabled, skipping this notification
2017-01-16 09:19:16 DEBUG    FINDSUBTITLES :: [49af1f0] Notification for NMJ scan update not enabled, skipping this notification
2017-01-16 09:19:16 DEBUG    FINDSUBTITLES :: [49af1f0] NMA: Sending notice with details: event="Subtitle Download Finished", message="A Series of Unfortunate Events - S01E03 - The Reptile Room Part One: English", priority=0, batch=False
2017-01-16 09:19:26 ERROR    FINDSUBTITLES :: [49af1f0] Unable to find subtitles for A Series of Unfortunate Events S01E03. Error: error -2 : Name or service not known
Traceback (most recent call last):
  File "/home/pi/Medusa/medusa/subtitles.py", line 1031, in run
    episode_object.download_subtitles()
  File "/home/pi/Medusa/medusa/tv.py", line 2141, in download_subtitles
    notifiers.notify_subtitle_download(self.pretty_name(), subtitle_list)
  File "/home/pi/Medusa/medusa/notifiers/__init__.py", line 82, in notify_subtitle_download
    n.notify_subtitle_download(ep_name, lang)
  File "/home/pi/Medusa/medusa/notifiers/nma.py", line 25, in notify_subtitle_download
    message=ep_name + ": " + lang)
  File "/home/pi/Medusa/medusa/notifiers/nma.py", line 62, in _sendNMA
    response = p.push(application=title, event=event, description=message, priority=nma_priority, batch_mode=batch)
  File "/home/pi/Medusa/lib/pynma/pynma.py", line 106, in push
    res = self.callapi('POST', ADD_PATH, datas)
  File "/home/pi/Medusa/lib/pynma/pynma.py", line 119, in callapi
    http_handler.request(method, path, urlencode(args), headers)
  File "/usr/lib/python2.7/httplib.py", line 1039, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1073, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 1035, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 879, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 841, in send
    self.connect()
  File "/usr/lib/python2.7/httplib.py", line 1242, in connect
    HTTPConnection.connect(self)
  File "/usr/lib/python2.7/httplib.py", line 822, in connect
    self.timeout, self.source_address)
  File "/usr/lib/python2.7/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
gaierror: [Errno -2] Name or service not known

# Fixed code
def snatch_episode(result):
    """
    Internal logic necessary to actually "snatch" a result that has been found.

    :param result: SearchResult instance to be snatched.
    :return: boolean, True on success
    """
    if result is None:
        return False

    result.priority = 0  # -1 = low, 0 = normal, 1 = high
    is_proper = False
    if app.ALLOW_HIGH_PRIORITY:
        # if it aired recently make it high priority
        for cur_ep in result.episodes:
            if datetime.date.today() - cur_ep.airdate <= datetime.timedelta(days=7):
                result.priority = 1
    if result.proper_tags:
        logger.log(
            "Found proper tags for {0}. Snatching as PROPER".format(result.name),
            logger.DEBUG,
        )
        is_proper = True
        end_status = SNATCHED_PROPER
    else:
        end_status = SNATCHED

    if result.url.startswith("magnet") or result.url.endswith("torrent"):
        result.resultType = "torrent"

    # NZBs can be sent straight to SAB or saved to disk
    if result.resultType in ("nzb", "nzbdata"):
        if app.NZB_METHOD == "blackhole":
            result_downloaded = _download_result(result)
        elif app.NZB_METHOD == "sabnzbd":
            result_downloaded = sab.sendNZB(result)
        elif app.NZB_METHOD == "nzbget":
            result_downloaded = nzbget.sendNZB(result, is_proper)
        else:
            logger.log(
                "Unknown NZB action specified in config: " + app.NZB_METHOD,
                logger.ERROR,
            )
            result_downloaded = False

    # Torrents can be sent to clients or saved to disk
    elif result.resultType == "torrent":
        # torrents are saved to disk when blackhole mode
        if app.TORRENT_METHOD == "blackhole":
            result_downloaded = _download_result(result)
        else:
            if not result.content and not result.url.startswith("magnet"):
                if result.provider.login():
                    result.content = result.provider.get_url(
                        result.url, returns="content"
                    )

            if result.content or result.url.startswith("magnet"):
                client = torrent.get_client_class(app.TORRENT_METHOD)()
                result_downloaded = client.send_torrent(result)
            else:
                logger.log("Torrent file content is empty", logger.WARNING)
                result_downloaded = False
    else:
        logger.log(
            "Unknown result type, unable to download it (%r)" % result.resultType,
            logger.ERROR,
        )
        result_downloaded = False

    if not result_downloaded:
        return False

    if app.USE_FAILED_DOWNLOADS:
        failed_history.log_snatch(result)

    ui.notifications.message("Episode snatched", result.name)

    history.log_snatch(result)

    # don't notify when we re-download an episode
    sql_l = []
    trakt_data = []
    for curEpObj in result.episodes:
        with curEpObj.lock:
            if is_first_best_match(result):
                curEpObj.status = Quality.composite_status(
                    SNATCHED_BEST, result.quality
                )
            else:
                curEpObj.status = Quality.composite_status(end_status, result.quality)
            # Reset all others fields to the "snatched" status
            # New snatch by default doesn't have nfo/tbn
            curEpObj.hasnfo = False
            curEpObj.hastbn = False

            # We can't reset location because we need to know what we are replacing
            # curEpObj.location = ''

            # Size and release name are fetched in PP (only for downloaded status, not snatched)
            curEpObj.file_size = 0
            curEpObj.release_name = ""

            # Need to reset subtitle settings because it's a different file
            curEpObj.subtitles = list()
            curEpObj.subtitles_searchcount = 0
            curEpObj.subtitles_lastsearch = "0001-01-01 00:00:00"

            # Need to store the correct is_proper. Not use the old one
            curEpObj.is_proper = True if result.proper_tags else False
            curEpObj.version = 0

            # Release group is parsed in PP
            curEpObj.release_group = ""

            curEpObj.manually_searched = result.manually_searched

            sql_l.append(curEpObj.get_sql())

        if curEpObj.status not in Quality.DOWNLOADED:
            notify_message = curEpObj.formatted_filename("%SN - %Sx%0E - %EN - %QN")
            if all(
                [
                    app.SEEDERS_LEECHERS_IN_NOTIFY,
                    result.seeders not in (-1, None),
                    result.leechers not in (-1, None),
                ]
            ):
                notifiers.notify_snatch(
                    "{0} with {1} seeders and {2} leechers from {3}".format(
                        notify_message,
                        result.seeders,
                        result.leechers,
                        result.provider.name,
                    ),
                    is_proper,
                )
            else:
                notifiers.notify_snatch(
                    "{0} from {1}".format(notify_message, result.provider.name),
                    is_proper,
                )

            if app.USE_TRAKT and app.TRAKT_SYNC_WATCHLIST:
                trakt_data.append((curEpObj.season, curEpObj.episode))
                logger.log(
                    "Adding {0} {1} to Trakt watchlist".format(
                        result.show.name, episode_num(curEpObj.season, curEpObj.episode)
                    ),
                    logger.INFO,
                )

    if trakt_data:
        data_episode = notifiers.trakt_notifier.trakt_episode_data_generate(trakt_data)
        if data_episode:
            notifiers.trakt_notifier.update_watchlist(
                result.show, data_episode=data_episode, update="add"
            )

    if sql_l:
        main_db_con = db.DBConnection()
        main_db_con.mass_action(sql_l)

    return True