예제 #1
0
    def process(self, src, dst, temp_dir):
        if not isinstance(src, (tuple, list)):
            src = [src]
        info = self._get_remote_info(src)
        if not info:
            return

        self.total = sum([d['size'] for d in info])
        temp_files = []
        dst_files = []
        with mkdtemp(temp_dir, prefix='transfer_') as temp_dst:
            for data in info:
                self.name = data['filename']
                temp_file = os.path.join(temp_dst, data['filename'])
                if not self._download_file(data['url'], temp_file):
                    return

                temp_files.append(temp_file)
                self.transferred = self.transferred_current

            for temp_file in temp_files:
                dst_file = move_file(temp_file, dst)
                if not dst_file:
                    return
                dst_files.append(dst_file)
                logger.info('moved finished transfer "%s" to %s', data['filename'], dst)

        return dst_files
예제 #2
0
    def download(self, url, dst, temp_dir):
        files_dst = []
        with mkdtemp(temp_dir) as temp_dst:
            file = self._download(url, temp_dst)
            if not file:
                return
            dir = unpack_download(file)
            for file_ in files(dir, types='subtitles'):
                file_dst = move_file(clean_file(file_.file), dst)
                if file_dst:
                    files_dst.append(file_dst)

        return files_dst
예제 #3
0
    def download(self, url, dst, temp_dir):
        files_dst = []
        with mkdtemp(temp_dir) as temp_dst:
            res = download_file(url, temp_dst, temp_dst)
            if not res:
                return
            if not self._check_file(res[0]):
                return
            dir = unpack_download(res[0])
            for file_ in files(dir, types='subtitles'):
                file_dst = move_file(clean_file(file_.file), dst)
                if file_dst:
                    files_dst.append(file_dst)

        return files_dst