BilibiliCacheVideoMergePython icon indicating copy to clipboard operation
BilibiliCacheVideoMergePython copied to clipboard

请教一下代码中的一个小问题

Open supersu097 opened this issue 1 year ago • 2 comments

   @staticmethod
    def decryptM4s(target_path: str, output_path: str, bufsize: int = 256 * 1024 * 1024) -> None:
        assert bufsize > 0
        with open(target_path, 'rb') as target_file:
            header = target_file.read(32)
            new_header = header.replace(b'000000000', b'')
            new_header = new_header.replace(b'$', b' ')
            new_header = new_header.replace(b'avc1', b'')
            with open(output_path, 'wb') as output_file:
                output_file.write(new_header)
                i = target_file.read(bufsize)
                while i:
                    output_file.write(i)
                    i = target_file.read(bufsize)

请问一下上述代码中的for循环中的output_file.write(i)语句不会导致前面被replace清洗掉的脏数据又被重新覆盖成脏数据么?

supersu097 avatar Sep 28 '23 11:09 supersu097