Browse Source

ffmpeg请求伪装

LiuLiu 2 years ago
parent
commit
1785b89385
1 changed files with 2 additions and 1 deletions
  1. 2 1
      core/recorder.py

+ 2 - 1
core/recorder.py

@@ -3,6 +3,7 @@ from datetime import datetime
 from string import Template
 
 from bilibili_api import live
+from fake_useragent import UserAgent
 import ffmpy3
 
 class Recorder:
@@ -32,7 +33,7 @@ class Recorder:
         })
         f_handler=open("./logs/"+outputName+'.log', 'w') if log else asyncio.subprocess.PIPE
         self.ff = ffmpy3.FFmpeg(
-            inputs={url:" -v debug"},
+            inputs={url:" -v debug -user-agent \""+str(UserAgent().random)+"\" -referer \"https://live.bilibili.com/"+str(self.ROOM_DISPLAY_ID)+"\""},
             outputs={"./videos/"+outputName+".flv":"-c copy -y"}
         )
         self.process = self.ff.run_async(stdout=f_handler, stderr=f_handler)