def test_is_sync_file(self):
        """
        Test is sync file
        """
        sickbeard.SYNC_FILES = '!sync,lftp-pget-status,part'

        test_cases = {
            None: False,
            42: False,
            '': False,
            'filename': False,
            '.syncthingfilename': True,
            '.syncthing.filename': True,
            '.syncthing-filename': True,
            '.!sync': True,
            'file.!sync': True,
            'file.!sync.ext': False,
            '.lftp-pget-status': True,
            'file.lftp-pget-status': True,
            'file.lftp-pget-status.ext': False,
            '.part': True,
            'file.part': True,
            'file.part.ext': False,
        }

        unicode_test_cases = {
            u'': False,
            u'filename': False,
            u'.syncthingfilename': True,
            u'.syncthing.filename': True,
            u'.syncthing-filename': True,
            u'.!sync': True,
            u'file.!sync': True,
            u'file.!sync.ext': False,
            u'.lftp-pget-status': True,
            u'file.lftp-pget-status': True,
            u'file.lftp-pget-status.ext': False,
            u'.part': True,
            u'file.part': True,
            u'file.part.ext': False,
        }

        for tests in test_cases, unicode_test_cases:
            for (filename, result) in tests.iteritems():
                self.assertEqual(is_sync_file(filename), result)
Example #2
0
    def test_is_sync_file(self):
        """
        Test is sync file
        """
        sickbeard.SYNC_FILES = '!sync,lftp-pget-status'

        test_cases = {
            None: False,
            42: False,
            '': False,
            'filename': False,
            '.syncthingfilename': True,
            '.syncthing.filename': True,
            '.syncthing-filename': True,
            '.!sync': True,
            'file.!sync': True,
            'file.!sync.ext': False,
            '.lftp-pget-status': True,
            'file.lftp-pget-status': True,
            'file.lftp-pget-status.ext': False,
            '.part': False,
            'file.part': False,
            'file.part.ext': False,
        }

        unicode_test_cases = {
            '': False,
            'filename': False,
            '.syncthingfilename': True,
            '.syncthing.filename': True,
            '.syncthing-filename': True,
            '.!sync': True,
            'file.!sync': True,
            'file.!sync.ext': False,
            '.lftp-pget-status': True,
            'file.lftp-pget-status': True,
            'file.lftp-pget-status.ext': False,
            '.part': False,
            'file.part': False,
            'file.part.ext': False,
        }

        for tests in test_cases, unicode_test_cases:
            for (filename, result) in six.iteritems(tests):
                self.assertEqual(is_sync_file(filename), result)
Example #3
0
def processDir(
    dirName,
    nzbName=None,
    process_method=None,
    force=False,
    is_priority=None,
    delete_on=False,
    failed=False,
    proc_type="auto",
):
    """
    Scans through the files in dirName and processes whatever media files it finds

    :param dirName: The folder name to look in
    :param nzbName: The NZB name which resulted in this folder being downloaded
    :param force: True to postprocess already postprocessed files
    :param failed: Boolean for whether or not the download failed
    :param proc_type: Type of postprocessing auto or manual
    """

    result = ProcessResult()

    # if they passed us a real dir then assume it's the one we want
    if ek(os.path.isdir, dirName):
        dirName = ek(os.path.realpath, dirName)
        result.output += logHelper(u"Processing folder %s" % dirName, logger.DEBUG)

    # if the client and SickRage are not on the same machine translate the directory into a network directory
    elif all(
        [
            sickbeard.TV_DOWNLOAD_DIR,
            ek(os.path.isdir, sickbeard.TV_DOWNLOAD_DIR),
            ek(os.path.normpath, dirName) == ek(os.path.normpath, sickbeard.TV_DOWNLOAD_DIR),
        ]
    ):
        dirName = ek(os.path.join, sickbeard.TV_DOWNLOAD_DIR, ek(os.path.abspath, dirName).split(os.path.sep)[-1])
        result.output += logHelper(u"Trying to use folder: %s " % dirName, logger.DEBUG)

    # if we didn't find a real dir then quit
    if not ek(os.path.isdir, dirName):
        result.output += logHelper(
            u"Unable to figure out what folder to process. "
            u"If your downloader and SickRage aren't on the same PC "
            u"make sure you fill out your TV download dir in the config.",
            logger.DEBUG,
        )
        return result.output

    path, dirs, files = get_path_dir_files(dirName, nzbName, proc_type)

    files = [x for x in files if not is_torrent_or_nzb_file(x)]
    SyncFiles = [x for x in files if is_sync_file(x)]
    nzbNameOriginal = nzbName

    # Don't post process if files are still being synced and option is activated
    postpone = SyncFiles and sickbeard.POSTPONE_IF_SYNC_FILES

    if not postpone:
        result.output += logHelper(u"PostProcessing Path: %s" % path, logger.INFO)
        result.output += logHelper(u"PostProcessing Dirs: %s" % str(dirs), logger.DEBUG)

        rarFiles = [x for x in files if helpers.isRarFile(x)]
        rarContent = unRAR(path, rarFiles, force, result)
        files += rarContent
        videoFiles = [x for x in files if helpers.isMediaFile(x)]
        videoInRar = [x for x in rarContent if helpers.isMediaFile(x)]

        result.output += logHelper(u"PostProcessing Files: %s" % files, logger.DEBUG)
        result.output += logHelper(u"PostProcessing VideoFiles: %s" % videoFiles, logger.DEBUG)
        result.output += logHelper(u"PostProcessing RarContent: %s" % rarContent, logger.DEBUG)
        result.output += logHelper(u"PostProcessing VideoInRar: %s" % videoInRar, logger.DEBUG)

        # If nzbName is set and there's more than one videofile in the folder, files will be lost (overwritten).
        nzbName = None if len(videoFiles) >= 2 else nzbName

        process_method = process_method if process_method else sickbeard.PROCESS_METHOD
        result.result = True

        # Don't Link media when the media is extracted from a rar in the same path
        if process_method in (u"hardlink", u"symlink") and videoInRar:
            process_media(path, videoInRar, nzbName, u"move", force, is_priority, result)
            delete_files(path, rarContent, result)
            for video in set(videoFiles) - set(videoInRar):
                process_media(path, [video], nzbName, process_method, force, is_priority, result)
        elif sickbeard.DELRARCONTENTS and videoInRar:
            process_media(path, videoInRar, nzbName, process_method, force, is_priority, result)
            delete_files(path, rarContent, result, True)
            for video in set(videoFiles) - set(videoInRar):
                process_media(path, [video], nzbName, process_method, force, is_priority, result)
        else:
            for video in videoFiles:
                process_media(path, [video], nzbName, process_method, force, is_priority, result)

    else:
        result.output += logHelper(u"Found temporary sync files: %s in path: %s" % (SyncFiles, path))
        result.output += logHelper(u"Skipping post processing for folder: %s" % path)
        result.missedfiles.append(u"%s : Syncfiles found" % path)

    # Process Video File in all TV Subdir
    for curDir in [x for x in dirs if validateDir(path, x, nzbNameOriginal, failed, result)]:
        result.result = True

        for processPath, _, fileList in ek(os.walk, ek(os.path.join, path, curDir), topdown=False):

            if not validateDir(path, processPath, nzbNameOriginal, failed, result):
                continue

            SyncFiles = [x for x in fileList if is_sync_file(x)]

            # Don't post process if files are still being synced and option is activated
            postpone = SyncFiles and sickbeard.POSTPONE_IF_SYNC_FILES

            if not postpone:
                rarFiles = [x for x in fileList if helpers.isRarFile(x)]
                rarContent = unRAR(processPath, rarFiles, force, result)
                fileList = set(fileList + rarContent)
                videoFiles = [x for x in fileList if helpers.isMediaFile(x)]
                videoInRar = [x for x in rarContent if helpers.isMediaFile(x)]
                notwantedFiles = [x for x in fileList if x not in videoFiles]
                if notwantedFiles:
                    result.output += logHelper(u"Found unwanted files: %s" % notwantedFiles, logger.DEBUG)

                # Don't Link media when the media is extracted from a rar in the same path
                if process_method in (u"hardlink", u"symlink") and videoInRar:
                    process_media(processPath, videoInRar, nzbName, u"move", force, is_priority, result)
                    process_media(
                        processPath,
                        set(videoFiles) - set(videoInRar),
                        nzbName,
                        process_method,
                        force,
                        is_priority,
                        result,
                    )
                    delete_files(processPath, rarContent, result)
                elif sickbeard.DELRARCONTENTS and videoInRar:
                    process_media(processPath, videoInRar, nzbName, process_method, force, is_priority, result)
                    process_media(
                        processPath,
                        set(videoFiles) - set(videoInRar),
                        nzbName,
                        process_method,
                        force,
                        is_priority,
                        result,
                    )
                    delete_files(processPath, rarContent, result, True)
                else:
                    process_media(processPath, videoFiles, nzbName, process_method, force, is_priority, result)

                # Delete all file not needed and avoid deleting files if Manual PostProcessing
                if not (process_method == u"move" and result.result) or (proc_type == u"manual" and not delete_on):
                    continue

                delete_folder(ek(os.path.join, processPath, u"@eaDir"))
                delete_files(processPath, notwantedFiles, result)

                if all(
                    [
                        not sickbeard.NO_DELETE or proc_type == u"manual",
                        process_method == u"move",
                        ek(os.path.normpath, processPath) != ek(os.path.normpath, sickbeard.TV_DOWNLOAD_DIR),
                    ]
                ):

                    if delete_folder(processPath, check_empty=True):
                        result.output += logHelper(u"Deleted folder: %s" % processPath, logger.DEBUG)

            else:
                result.output += logHelper(u"Found temporary sync files: %s in path: %s" % (SyncFiles, processPath))
                result.output += logHelper(u"Skipping post processing for folder: %s" % processPath)
                result.missedfiles.append(u"%s : Syncfiles found" % path)

    if result.aggresult:
        result.output += logHelper(u"Successfully processed")
        if result.missedfiles:
            result.output += logHelper(u"I did encounter some unprocessable items: ")
            for missedfile in result.missedfiles:
                result.output += logHelper(u"[%s]" % missedfile)
    else:
        result.output += logHelper(
            u"Problem(s) during processing, failed the following files/folders:  ", logger.WARNING
        )
        for missedfile in result.missedfiles:
            result.output += logHelper(u"[%s]" % missedfile, logger.WARNING)

    return result.output
Example #4
0
def processDir(dirName,
               nzbName=None,
               process_method=None,
               force=False,
               is_priority=None,
               delete_on=False,
               failed=False,
               proc_type="auto"):
    """
    Scans through the files in dirName and processes whatever media files it finds

    :param dirName: The folder name to look in
    :param nzbName: The NZB name which resulted in this folder being downloaded
    :param force: True to postprocess already postprocessed files
    :param failed: Boolean for whether or not the download failed
    :param proc_type: Type of postprocessing auto or manual
    """

    result = ProcessResult()

    # if they passed us a real dir then assume it's the one we want
    if ek(os.path.isdir, dirName):
        dirName = ek(os.path.realpath, dirName)
        result.output += logHelper(u"Processing folder %s" % dirName,
                                   logger.DEBUG)

    # if the client and SickRage are not on the same machine translate the directory into a network directory
    elif all([
            sickbeard.TV_DOWNLOAD_DIR,
            ek(os.path.isdir, sickbeard.TV_DOWNLOAD_DIR),
            ek(os.path.normpath, dirName) == ek(os.path.normpath,
                                                sickbeard.TV_DOWNLOAD_DIR)
    ]):
        dirName = ek(os.path.join, sickbeard.TV_DOWNLOAD_DIR,
                     ek(os.path.abspath, dirName).split(os.path.sep)[-1])
        result.output += logHelper(u"Trying to use folder: %s " % dirName,
                                   logger.DEBUG)

    # if we didn't find a real dir then quit
    if not ek(os.path.isdir, dirName):
        result.output += logHelper(
            u"Unable to figure out what folder to process. "
            u"If your downloader and SickRage aren't on the same PC "
            u"make sure you fill out your TV download dir in the config.",
            logger.DEBUG)
        return result.output

    path, dirs, files = get_path_dir_files(dirName, nzbName, proc_type)

    files = [x for x in files if not is_torrent_or_nzb_file(x)]
    SyncFiles = [x for x in files if is_sync_file(x)]
    nzbNameOriginal = nzbName

    # Don't post process if files are still being synced and option is activated
    postpone = SyncFiles and sickbeard.POSTPONE_IF_SYNC_FILES

    # Warn user if 'postpone if no subs' is enabled. Will debug possible user issues with PP
    if sickbeard.POSTPONE_IF_NO_SUBS:
        result.output += logHelper(
            u"Feature 'postpone postprocessing if no subtitle available' is enabled",
            logger.INFO)

    if not postpone:
        result.output += logHelper(u"PostProcessing Path: %s" % path,
                                   logger.INFO)
        result.output += logHelper(u"PostProcessing Dirs: %s" % str(dirs),
                                   logger.DEBUG)

        videoFiles = [x for x in files if helpers.isMediaFile(x)]
        rarFiles = [x for x in files if helpers.isRarFile(x)]
        rarContent = ""
        if rarFiles and not (sickbeard.POSTPONE_IF_NO_SUBS and videoFiles):
            # Unpack only if video file was not already extracted by 'postpone if no subs' feature
            rarContent = unRAR(path, rarFiles, force, result)
            files += rarContent
        videoInRar = [x for x in rarContent
                      if helpers.isMediaFile(x)] if rarContent else ''

        result.output += logHelper(u"PostProcessing Files: %s" % files,
                                   logger.DEBUG)
        result.output += logHelper(
            u"PostProcessing VideoFiles: %s" % videoFiles, logger.DEBUG)
        result.output += logHelper(
            u"PostProcessing RarContent: %s" % rarContent, logger.DEBUG)
        result.output += logHelper(
            u"PostProcessing VideoInRar: %s" % videoInRar, logger.DEBUG)

        # If nzbName is set and there's more than one videofile in the folder, files will be lost (overwritten).
        nzbName = None if len(videoFiles) >= 2 else nzbName

        process_method = process_method if process_method else sickbeard.PROCESS_METHOD
        result.result = True

        # Don't Link media when the media is extracted from a rar in the same path
        if process_method in (u'hardlink', u'symlink') and videoInRar:
            process_media(path, videoInRar, nzbName, u'move', force,
                          is_priority, result)
            delete_files(path, rarContent, result)
            for video in set(videoFiles) - set(videoInRar):
                process_media(path, [video], nzbName, process_method, force,
                              is_priority, result)
        elif sickbeard.DELRARCONTENTS and videoInRar:
            process_media(path, videoInRar, nzbName, process_method, force,
                          is_priority, result)
            delete_files(path, rarContent, result, True)
            for video in set(videoFiles) - set(videoInRar):
                process_media(path, [video], nzbName, process_method, force,
                              is_priority, result)
        else:
            for video in videoFiles:
                process_media(path, [video], nzbName, process_method, force,
                              is_priority, result)

    else:
        result.output += logHelper(
            u"Found temporary sync files: %s in path: %s" % (SyncFiles, path))
        result.output += logHelper(u"Skipping post processing for folder: %s" %
                                   path)
        result.missedfiles.append(u"%s : Syncfiles found" % path)

    # Process Video File in all TV Subdir
    for curDir in [
            x for x in dirs
            if validateDir(path, x, nzbNameOriginal, failed, result)
    ]:
        result.result = True

        for processPath, _, fileList in ek(os.walk,
                                           ek(os.path.join, path, curDir),
                                           topdown=False):

            if not validateDir(path, processPath, nzbNameOriginal, failed,
                               result):
                continue

            SyncFiles = [x for x in fileList if is_sync_file(x)]

            # Don't post process if files are still being synced and option is activated
            postpone = SyncFiles and sickbeard.POSTPONE_IF_SYNC_FILES

            if not postpone:
                videoFiles = [x for x in fileList if helpers.isMediaFile(x)]
                rarFiles = [x for x in fileList if helpers.isRarFile(x)]
                rarContent = ""
                if rarFiles and not (sickbeard.POSTPONE_IF_NO_SUBS
                                     and videoFiles):
                    # Unpack only if video file was not already extracted by 'postpone if no subs' feature
                    rarContent = unRAR(processPath, rarFiles, force, result)
                    fileList = set(fileList + rarContent)

                videoInRar = [x for x in rarContent
                              if helpers.isMediaFile(x)] if rarContent else ''
                notwantedFiles = [x for x in fileList if x not in videoFiles]
                if notwantedFiles:
                    result.output += logHelper(
                        u"Found unwanted files: %s" % notwantedFiles,
                        logger.DEBUG)

                # Don't Link media when the media is extracted from a rar in the same path
                if process_method in (u'hardlink', u'symlink') and videoInRar:
                    process_media(processPath, videoInRar, nzbName, u'move',
                                  force, is_priority, result)
                    process_media(processPath,
                                  set(videoFiles) - set(videoInRar), nzbName,
                                  process_method, force, is_priority, result)
                    delete_files(processPath, rarContent, result)
                elif sickbeard.DELRARCONTENTS and videoInRar:
                    process_media(processPath, videoInRar, nzbName,
                                  process_method, force, is_priority, result)
                    process_media(processPath,
                                  set(videoFiles) - set(videoInRar), nzbName,
                                  process_method, force, is_priority, result)
                    delete_files(processPath, rarContent, result, True)
                else:
                    process_media(processPath, videoFiles, nzbName,
                                  process_method, force, is_priority, result)

                    # Delete all file not needed and avoid deleting files if Manual PostProcessing
                    if not (process_method == u"move" and result.result) or (
                            proc_type == u"manual" and not delete_on):
                        continue

                    delete_folder(ek(os.path.join, processPath, u'@eaDir'))
                    delete_files(processPath, notwantedFiles, result)

                    if all([
                            not sickbeard.NO_DELETE or proc_type == u"manual",
                            process_method == u"move",
                            ek(os.path.normpath, processPath) != ek(
                                os.path.normpath, sickbeard.TV_DOWNLOAD_DIR)
                    ]):

                        if delete_folder(processPath, check_empty=True):
                            result.output += logHelper(
                                u"Deleted folder: %s" % processPath,
                                logger.DEBUG)

            else:
                result.output += logHelper(
                    u"Found temporary sync files: %s in path: %s" %
                    (SyncFiles, processPath))
                result.output += logHelper(
                    u"Skipping post processing for folder: %s" % processPath)
                result.missedfiles.append(u"%s : Syncfiles found" % path)

    if result.aggresult:
        result.output += logHelper(u"Successfully processed")
        if result.missedfiles:
            result.output += logHelper(
                u"I did encounter some unprocessable items: ")
            for missedfile in result.missedfiles:
                result.output += logHelper(u"[%s]" % missedfile)
    else:
        result.output += logHelper(
            u"Problem(s) during processing, failed the following files/folders:  ",
            logger.WARNING)
        for missedfile in result.missedfiles:
            result.output += logHelper(u"[%s]" % missedfile, logger.WARNING)

    return result.output
Example #5
0
def processDir(dirName, nzbName=None, process_method=None, force=False, is_priority=None, delete_on=False, failed=False, proc_type="auto"):  # pylint: disable=too-many-arguments,too-many-branches,too-many-statements,too-many-locals
    """
    Scans through the files in dirName and processes whatever media files it finds

    :param dirName: The folder name to look in
    :param nzbName: The NZB name which resulted in this folder being downloaded
    :param force: True to postprocess already postprocessed files
    :param failed: Boolean for whether or not the download failed
    :param proc_type: Type of postprocessing auto or manual
    """

    result = ProcessResult()

    result.output += logHelper(u"Processing folder " + dirName, logger.DEBUG)

    result.output += logHelper(u"TV_DOWNLOAD_DIR: " + sickbeard.TV_DOWNLOAD_DIR, logger.DEBUG)
    postpone = False
    # if they passed us a real dir then assume it's the one we want
    if ek(os.path.isdir, dirName):
        dirName = ek(os.path.realpath, dirName)

    # if the client and SickRage are not on the same machine translate the Dir in a network dir
    elif sickbeard.TV_DOWNLOAD_DIR and ek(os.path.isdir, sickbeard.TV_DOWNLOAD_DIR) \
            and ek(os.path.normpath, dirName) != ek(os.path.normpath, sickbeard.TV_DOWNLOAD_DIR):
        dirName = ek(os.path.join, sickbeard.TV_DOWNLOAD_DIR, ek(os.path.abspath, dirName).split(os.path.sep)[-1])
        result.output += logHelper(u"Trying to use folder " + dirName, logger.DEBUG)

    # if we didn't find a real dir then quit
    if not ek(os.path.isdir, dirName):
        result.output += logHelper(
            u"Unable to figure out what folder to process. If your downloader and SickRage aren't on the same PC make sure you fill out your TV download dir in the config.",
            logger.DEBUG)
        return result.output

    path, dirs, files = get_path_dir_files(dirName, nzbName, proc_type)

    files = [x for x in files if not is_torrent_or_nzb_file(x)]
    SyncFiles = [x for x in files if is_sync_file(x)]

    # Don't post process if files are still being synced and option is activated
    if SyncFiles and sickbeard.POSTPONE_IF_SYNC_FILES:
        postpone = True

    nzbNameOriginal = nzbName

    if not postpone:
        result.output += logHelper(u"PostProcessing Path: " + path, logger.INFO)
        result.output += logHelper(u"PostProcessing Dirs: " + str(dirs), logger.DEBUG)

        rarFiles = [x for x in files if helpers.isRarFile(x)]
        rarContent = unRAR(path, rarFiles, force, result)
        files += rarContent
        videoFiles = [x for x in files if helpers.isMediaFile(x)]
        videoInRar = [x for x in rarContent if helpers.isMediaFile(x)]

        result.output += logHelper(u"PostProcessing Files: " + str(files), logger.DEBUG)
        result.output += logHelper(u"PostProcessing VideoFiles: " + str(videoFiles), logger.DEBUG)
        result.output += logHelper(u"PostProcessing RarContent: " + str(rarContent), logger.DEBUG)
        result.output += logHelper(u"PostProcessing VideoInRar: " + str(videoInRar), logger.DEBUG)

        # If nzbName is set and there's more than one videofile in the folder, files will be lost (overwritten).
        if len(videoFiles) >= 2:
            nzbName = None

        if not process_method:
            process_method = sickbeard.PROCESS_METHOD

        result.result = True

        # Don't Link media when the media is extracted from a rar in the same path
        if process_method in ('hardlink', 'symlink') and videoInRar:
            process_media(path, videoInRar, nzbName, 'move', force, is_priority, result)
            delete_files(path, rarContent, result)
            for video in set(videoFiles) - set(videoInRar):
                process_media(path, [video], nzbName, process_method, force, is_priority, result)
        elif sickbeard.DELRARCONTENTS and videoInRar:
            process_media(path, videoInRar, nzbName, process_method, force, is_priority, result)
            delete_files(path, rarContent, result, True)
            for video in set(videoFiles) - set(videoInRar):
                process_media(path, [video], nzbName, process_method, force, is_priority, result)
        else:
            for video in videoFiles:
                process_media(path, [video], nzbName, process_method, force, is_priority, result)

    else:
        result.output += logHelper(u"Found temporary sync files, skipping post processing for folder " + str(path))
        result.output += logHelper(u"Sync Files: " + str(SyncFiles) + " in path: " + path)
        result.missedfiles.append(path + " : Syncfiles found")

    # Process Video File in all TV Subdir
    for curDir in [x for x in dirs if validateDir(path, x, nzbNameOriginal, failed, result)]:

        result.result = True

        for processPath, _, fileList in ek(os.walk, ek(os.path.join, path, curDir), topdown=False):

            if not validateDir(path, processPath, nzbNameOriginal, failed, result):
                continue

            postpone = False

            SyncFiles = [x for x in fileList if is_sync_file(x)]

            # Don't post process if files are still being synced and option is activated
            if SyncFiles and sickbeard.POSTPONE_IF_SYNC_FILES:
                postpone = True

            if not postpone:
                rarFiles = [x for x in fileList if helpers.isRarFile(x)]
                rarContent = unRAR(processPath, rarFiles, force, result)
                fileList = set(fileList + rarContent)
                videoFiles = [x for x in fileList if helpers.isMediaFile(x)]
                videoInRar = [x for x in rarContent if helpers.isMediaFile(x)]
                notwantedFiles = [x for x in fileList if x not in videoFiles]
                if notwantedFiles:
                    result.output += logHelper(u"Found unwanted files: " + str(notwantedFiles), logger.DEBUG)

                # Don't Link media when the media is extracted from a rar in the same path
                if process_method in ('hardlink', 'symlink') and videoInRar:
                    process_media(processPath, videoInRar, nzbName, 'move', force, is_priority, result)
                    process_media(processPath, set(videoFiles) - set(videoInRar), nzbName, process_method, force,
                                  is_priority, result)
                    delete_files(processPath, rarContent, result)
                elif sickbeard.DELRARCONTENTS and videoInRar:
                    process_media(processPath, videoInRar, nzbName, process_method, force, is_priority, result)
                    process_media(processPath, set(videoFiles) - set(videoInRar), nzbName, process_method, force,
                                  is_priority, result)
                    delete_files(processPath, rarContent, result, True)
                else:
                    process_media(processPath, videoFiles, nzbName, process_method, force, is_priority, result)

                    # Delete all file not needed
                    if process_method != "move" or not result.result \
                            or (proc_type == "manual" and not delete_on):  # Avoid to delete files if is Manual PostProcessing
                        continue

                    delete_files(processPath, notwantedFiles, result)

                    if (not sickbeard.NO_DELETE or proc_type == "manual") and process_method == "move" and \
                        ek(os.path.normpath, processPath) != ek(os.path.normpath, sickbeard.TV_DOWNLOAD_DIR):
                        if delete_folder(processPath, check_empty=True):
                            result.output += logHelper(u"Deleted folder: " + processPath, logger.DEBUG)
            else:
                result.output += logHelper(u"Found temporary sync files, skipping post processing for folder: " + str(processPath))
                result.output += logHelper(u"Sync Files: " + str(SyncFiles) + " in path: " + processPath)
                result.missedfiles.append(processPath + " : Syncfiles found")

    if result.aggresult:
        result.output += logHelper(u"Processing completed")
        if result.missedfiles:
            result.output += logHelper(u"I did encounter some unprocessable items: ")
            for missedfile in result.missedfiles:
                result.output += logHelper(u"[" + missedfile + "]")
    else:
        result.output += logHelper(u"Problem(s) during processing, failed the following files/folders:  ", logger.WARNING)
        for missedfile in result.missedfiles:
            result.output += logHelper(u"[" + missedfile + "]", logger.WARNING)

    return result.output