How to use the pyexpander.subtitles.find_file_subtitles function in pyexpander

To help you get started, we’ve selected a few pyexpander examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github omerbenamram / py-expander / pyexpander / postprocess.py View on Github external
category_path = get_categorized_path(os.path.join(torrent_name, filename))
    if category_path is not None:
        destination_dir = os.path.join(category_path, torrent_name)
        # Creates target directory (of category path).
        _create_destination_path(destination_dir)
        destination_path = os.path.join(destination_dir, filename)
        try:
            # Move\Copy all relevant files to their location (keep original files for uploading).
            handler(file_path, destination_path)
            logger.info('{} {} to {}'.format(handler.__name__, file_path, destination_path))
            if os.name != 'nt':
                subprocess.check_output(['chmod', config.EXTRACTION_FILES_MASK, '-R', destination_dir])
            # Get subtitles.
            subtitles_paths = None
            if config.SHOULD_FIND_SUBTITLES:
                subtitles_paths = find_file_subtitles(destination_path)
            # Upload files to Amazon.
            if config.SHOULD_UPLOAD:
                upload_file(destination_path)
                if subtitles_paths:
                    for subtitles_path in subtitles_paths:
                        upload_file(subtitles_path)
        except OSError as ex:
            logger.exception('Failed to {} {}: {}'.format(handler.__name__, file_path, ex))