YuxuanZuo / Bilibili-Live-Recorder

A bilibili hls live stream recorder.
GNU General Public License v3.0
2 stars 3 forks source link

[bug] Live recorder stopped with 403 Forbidden error #1

Closed s-kk closed 4 years ago

s-kk commented 4 years ago

Hello! I've set up this recorder on my PC and when I started it, downloader.py and ffmpeg returned error code 403 Forbidden on m3u8 stream file. Error output:

Traceback (most recent call last):                                                                                                                   
  File "run.py", line 33, in <module>                                                                                                                
    LiveRecorder(cids).main()                                                                                                                        
  File "run.py", line 25, in main                                                                                                                    
    asyncio.run(self._tasks())                                                                                                                       
  File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run                                                                                      
    return loop.run_until_complete(main)                                                                                                             
  File "/usr/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete                                                                  
    return future.result()                                                                                                                           
  File "run.py", line 22, in _tasks                                                                                                                  
    await asyncio.gather(*tasks)                                                                                                                     
  File "/home/user/Projects/Bilibili-Live-Recorder/recorder/monitor.py", line 56, in main                                                            
    return await Download(stream_url, filename, self.executable).start()                                                                             
  File "/home/user/Projects/Bilibili-Live-Recorder/recorder/downloader.py", line 46, in start
    raise FFmpegProcessingError(stderr.decode())
recorder.exceptions.FFmpegProcessingError: ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers

Is it because the upstream streaming server banned direct m3u8 stream? Thanks for help!

YuxuanZuo commented 4 years ago

Thanks for your feedback! it looks like the streaming server needs user agent authentication, i will fix it later

YuxuanZuo commented 4 years ago

problem solved!

s-kk commented 4 years ago

Still getting 403 Forbidden.
Also, new output in FFmpeg

[https @ 0x55e7533318c0] No trailing CRLF found in HTTP header.

Seems like the header is missing CRLF string.

YuxuanZuo commented 4 years ago

Thanks for reminding! The bug has been fixed

s-kk commented 4 years ago

I've read the commit and tried the script and found that FFmpeg does not come with -referer option. FFmpeg stopped with Unrecognized option 'referer'.
Probably need to combine user agent and referer into one -header option.

YuxuanZuo commented 4 years ago

The script works fine on my pc without any further 403 errors. The referer option is valid and it requires a valid address, e.g. ffmpeg -referer "https://live.bilibili.com/h5/15152878"

YuxuanZuo commented 4 years ago

You can also learn more options in the ffmpeg documentation http://ffmpeg.org/ffmpeg-protocols.html#http