zhangyong 9 months ago
parent
commit
323f16578a
1 changed files with 12 additions and 8 deletions
  1. 12 8
      data_channel/piaoquan.py

+ 12 - 8
data_channel/piaoquan.py

@@ -289,15 +289,19 @@ class PQ:
     "视频号加密视频解密"
     @classmethod
     def decrypt_video(cls, data: bytes, decode_key: int, enc_length: int = 131072) -> bytes:
-        ffi = cffi.FFI()
-        # lib = ffi.dlopen(r'/Users/tzld/Desktop/video_rewriting/libsph_decrypt.dylib')
-        lib = ffi.dlopen(r'/root/video_rewriting/libsph_decrypt.so')
-        ffi.cdef('void decrypt(unsigned char *data, const size_t data_length, const uint32_t key);')
+        try:
+            ffi = cffi.FFI()
+            # lib = ffi.dlopen(r'/Users/tzld/Desktop/video_rewriting/libsph_decrypt.dylib')
+            lib = ffi.dlopen(r'/root/video_rewriting/libsph_decrypt.so')
+            ffi.cdef('void decrypt(unsigned char *data, const size_t data_length, const uint32_t key);')
 
-        c_data = ffi.new('unsigned char[]', list(data))
-        lib.decrypt(c_data, enc_length, decode_key)
-        data = bytes(ffi.buffer(c_data, len(data))[:])
-        return data
+            c_data = ffi.new('unsigned char[]', list(data))
+            lib.decrypt(c_data, enc_length, decode_key)
+            data = bytes(ffi.buffer(c_data, len(data))[:])
+            return data
+        except Exception as e:
+            print(e)
+            return data
 
     """
     视频下载