Browse Source

ffmpeg请求伪装

LiuLiu 3 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 string import Template
 
 
 from bilibili_api import live
 from bilibili_api import live
+from fake_useragent import UserAgent
 import ffmpy3
 import ffmpy3
 
 
 class Recorder:
 class Recorder:
@@ -32,7 +33,7 @@ class Recorder:
         })
         })
         f_handler=open("./logs/"+outputName+'.log', 'w') if log else asyncio.subprocess.PIPE
         f_handler=open("./logs/"+outputName+'.log', 'w') if log else asyncio.subprocess.PIPE
         self.ff = ffmpy3.FFmpeg(
         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"}
             outputs={"./videos/"+outputName+".flv":"-c copy -y"}
         )
         )
         self.process = self.ff.run_async(stdout=f_handler, stderr=f_handler)
         self.process = self.ff.run_async(stdout=f_handler, stderr=f_handler)