zhangyong 7 months ago
parent
commit
ce08489cb1
1 changed files with 6 additions and 4 deletions
  1. 6 4
      video_processing/video_processing.py

+ 6 - 4
video_processing/video_processing.py

@@ -1,4 +1,5 @@
 import re
+import time
 
 import requests
 import json
@@ -24,12 +25,12 @@ class VideoProcessing:
             print(response)
             result = response['result']
             print(result)
-            cleaned_string = result.split( 'json\n', 1 )[-1].strip()
+            # 去除不必要的前缀
+            cleaned_string = result.split( 'json\n', '')[-1].strip()
             # 清除控制字符
             cleaned_string = re.sub( r'[\x00-\x1F]+', '', cleaned_string )
-
-            # 修复引号等格式问题(确保字符串用双引号包围)
-            cleaned_string = cleaned_string.replace( "\n", "" ).replace( "\\", "" ).strip()
+            # 打印出清理后的 JSON 字符串以供检查
+            print( "清理后的 JSON 字符串:", cleaned_string )
             json_data = json.loads( cleaned_string )
             print(json_data)
             return json_data
@@ -42,6 +43,7 @@ class VideoProcessing:
         video_data = get_video_data()
         if not video_data:
             print("没有获取到视频内容")
+            time.sleep(1008611)
             return
         # 解码为字符串
         data_str = video_data.decode( 'utf-8' )