Browse Source

更新V4.5 修复了部分视频加密的情况下,程序不解密的问题。修复了本地模式下获取到的视频标题带有符号导致的异常问题

剑断了 2 years ago
parent
commit
a317603d87
2 changed files with 34 additions and 28 deletions
  1. 31 25
      FileOperator.py
  2. 3 3
      main.py

+ 31 - 25
FileOperator.py

@@ -98,30 +98,30 @@ def DecryptMp4(path, aID):
     countDecChar = 0  # 检测'x00'数量
 
     fileList = FindSpecialMp4Files(path, aID)[0]
+    for file in fileList:
+        with open(file, "rb") as f:
+            s = str(f.readline())[3:14]
+        f.close()
+        sList = s.split('\\')  # ['xff', 'xff', 'xff']
+        for item in sList:
+            if 'xff' in item:
+                countEncChar += 1
+            if 'x00' in item:
+                countDecChar += 1
+
+        if countEncChar == 3:
+            isEncrypted = True  # 加密
+        if countDecChar == 3:
+            isEncrypted = False  # 未加密
+
+        countEncChar = 0
+        countDecChar = 0
+        if isEncrypted is None:
+            return
 
-    testFile = fileList[0]
-    with open(testFile, "rb") as f:
-        s = str(f.readline())[3:14]
-    f.close()
-    sList = s.split('\\')  # ['xff', 'xff', 'xff']
-    for item in sList:
-        if 'xff' in item:
-            countEncChar += 1
-        if 'x00' in item:
-            countDecChar += 1
-
-    if countEncChar == 3:
-        isEncrypted = True  # 加密
-    if countDecChar == 3:
-        isEncrypted = False  # 未加密
-
-    if isEncrypted is None:
-        return
-
-    if not isEncrypted:  # 如果未加密
-        pass
-    else:  # 如果加密则解密
-        for file in fileList:
+        if not isEncrypted:  # 如果未加密
+            pass
+        else:  # 如果加密则解密
             encryptedFile = open(file, 'rb')
             encryptedFile.seek(3)
             byte = encryptedFile.read()
@@ -129,8 +129,8 @@ def DecryptMp4(path, aID):
             with open(file, 'wb') as decryptedFile:
                 decryptedFile.write(byte)
 
-        encryptedFile.close()
-        decryptedFile.close()
+            encryptedFile.close()
+            decryptedFile.close()
 
 
 # return fileList
@@ -165,6 +165,7 @@ def DoRename(path, fileName, aID, isLocalPattern):
     for oldDir in fileList:
         filetype = '.' + oldDir.split('.')[-1]
         frontIndex = int(oldDir.split('_')[-2])
+
         if isLocalPattern:
             newDir = os.path.join(path, str(frontIndex) + '. ' + lines[index].strip('\n') + filetype)  # 新的文件路径
             index += 1
@@ -197,7 +198,12 @@ def GetLocalVideoTitle(path, aID):
             lines = f.readlines()
             s = str(lines[0])
             videoTitle = re.findall(findVideoTitle, s)[0]
+            for s in videoTitle:
+                cut = ['|', '\\', '/', ':', '?', '"', '<', '>']
+                if s in cut:
+                    videoTitle = videoTitle.replace(s, ' ')
             titleList.append(videoTitle)
+
     return titleList
 
 

+ 3 - 3
main.py

@@ -42,7 +42,7 @@ class MainApp(QMainWindow, Ui_MainWindow):
         self.isTextFileExists = False
         self.isTextFirstColumnHaveContent = False
         self.isTextSecondColumnHaveContent = False
-        self.InitOutPutPath() # 发布绿色版时注释
+       #  self.InitOutPutPath() # 发布绿色版时注释
 
 
     def InitOutPutPath(self):
@@ -193,7 +193,7 @@ class MainApp(QMainWindow, Ui_MainWindow):
         return True
 
     def ShowAboutDialog(self):
-        about_text = "<p>描述:这是一款致力于解决BiliBili UWP版下载后的视频加密、命名信息丢失和存放位置不合理等痛点的软件</p><p>版本:4.4</p><p>@Author:LZY</p><p>@github:love" \
+        about_text = "<p>描述:这是一款致力于解决BiliBili UWP版下载后的视频加密、命名信息丢失和存放位置不合理等痛点的软件</p><p>版本:4.5</p><p>@Author:LZY</p><p>@github:love" \
                      "-in-cpp</p> "
         QMessageBox.about(self, '说明', about_text)
 
@@ -283,7 +283,7 @@ class MainApp(QMainWindow, Ui_MainWindow):
                     self.Log('输出目录的路径存在非法输入!')
                 else:
                     # 记忆输出目录
-                    FileOperator.WriteForOutput(self.joinedPath, os.path.dirname(downloadPath), self.outputDirEdit.toPlainText()) # 发布绿色版时注释
+                    # FileOperator.WriteForOutput(self.joinedPath, os.path.dirname(downloadPath), self.outputDirEdit.toPlainText()) # 发布绿色版时注释
                     # 解密
                     self.Log("开始解密...")
                     FileOperator.DecryptMp4(downloadPath, dviInfoList[2])