chenxuuu / 24h-raspberry-live-on-bilibili

🎦树莓派/VPS驱动的b站直播弹幕点播台,代码写得很烂,看之前请吃点降压药。已计划重写
http://live.bilibili.com/16703
GNU General Public License v3.0
463 stars 76 forks source link

you-get的参数错误导致视频无法下载 #16

Closed ghost closed 6 years ago

ghost commented 6 years ago

根据我的发现,某些较新的视频下载不了。 比如我想点播av14554845,you-get没有下载到这个视频。

[log][2017-12-27 13:54:09]ClarkeCheng:av14554845
[log]发送弹幕:已收到ClarkeCheng的指令
[log]downloading bilibili video:https://www.bilibili.com/video/av14554845
[log][2017-12-27 13:54:10]ClarkeCheng:已收到ClarkeCheng的指令
[log]发送弹幕:正在下载【鏡音リン &鏡音レン】病名为爱
[log][2017-12-27 13:54:15]ClarkeCheng:正在下载【鏡音リン &鏡音レン】病名为爱
[log]发送弹幕:【Neru】
[log][2017-12-27 13:54:17]ClarkeCheng:【Neru】
you-get: [error] oops, something went wrong.
you-get: don't panic, c'est la vie. please try the following steps:
you-get:   (1) Rule out any network problem.
you-get:   (2) Make sure you-get is up-to-date.
you-get:   (3) Check if the issue is already known, on
you-get:         https://github.com/soimort/you-get/wiki/Known-Bugs
you-get:         https://github.com/soimort/you-get/issues
you-get:   (4) Run the command with '--debug' option,
you-get:       and report this issue with the full output.
site:                Bilibili
title:               【鏡音リン &鏡音レン】病名为爱【Neru】
stream:
you-get https://www.bilibili.com/video/av14554845 --format=flv -o /root/24h-raspberry-live-on-bilibili/downloads -O 1514354059.0rendering1
[log]发送弹幕:视频【鏡音リン &鏡音レン】病名为爱【N
[log][2017-12-27 13:54:22]ClarkeCheng:视频【鏡音リン &鏡音レン】病名为爱【N
[log]发送弹幕:eru】下载完成,等待渲染
[log][2017-12-27 13:54:23]ClarkeCheng:eru】下载完成,等待渲染
[error]弹幕发送失败:视频【鏡音リン &鏡音レン】病名为爱【N
{'data': [], 'code': 0, 'msg': 'msg repeat'}
[log]发送弹幕:eru】正在渲染
[log][2017-12-27 13:54:27]ClarkeCheng:eru】正在渲染
ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.3.0 (Ubuntu 6.3.0-12ubuntu2) 20170406
  configuration: --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --enable-libass --enable-libfreetype --arch=x86_64
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
/root/24h-raspberry-live-on-bilibili/downloads/1514354059.0rendering1.flv: No such file or directory
delete error
[log]发送弹幕:出错了:请检查命令或重试
[log][2017-12-27 13:54:29]ClarkeCheng:出错了:请检查命令或重试

而我点播av14042990p1,you-get却能成功下载到这个视频。

[log][2017-12-27 13:58:07]ClarkeCheng:av14042990p1
[log]发送弹幕:已收到ClarkeCheng的指令
[log]downloading bilibili video:https://www.bilibili.com/video/av14042990/#page=1
[log][2017-12-27 13:58:08]ClarkeCheng:已收到ClarkeCheng的指令
[log]发送弹幕:正在下载【荒野求生】全6 4集 包含拍摄
[log][2017-12-27 13:58:14]ClarkeCheng:正在下载【荒野求生】全6 4集 包含拍摄
[log]发送弹幕:花絮,拍摄团队,后期制作,贝爷带你吃遍地
[log][2017-12-27 13:58:16]ClarkeCheng:花絮,拍摄团队,后期制作,贝爷带你吃遍地
[log]发送弹幕:球
[log][2017-12-27 13:58:17]ClarkeCheng:球
site:                Bilibili
title:               【荒野求生】全64集 包含拍摄花絮,拍摄团队,后期制作,贝爷带你吃遍地球
stream:
    - format:        flv
      container:     flv
      size:          224.1 MiB (234954799 bytes)
    # download-with: you-get --format=flv [URL]

Downloading 【荒野求生】全64集 包含拍摄花絮,拍摄团队,后期制作,贝爷带你吃遍地球.flv ...
 8.0% ( 18.0/224.1MB) ├████────────────────────────────────────────────┤[1/7]   24 MB/s

直接用you-get下载并加上--debug

you-get https://www.bilibili.com/video/av14554845 --format=flv -o /root/24h-raspberry-live-on-bilibili/downloads -O 1514354059.0rendering1 --debug

输出

[DEBUG] url_locations: https://www.bilibili.com/video/av14554845
[DEBUG] get_content: https://www.bilibili.com/video/av14554845/
[DEBUG] get_content: http://interface.bilibili.com/playurl?cid=23733992&player=1&quality=4&ts=1514354735&sign=6c1fcd9f44ab7c3429d8a0cf1cfc980f
[DEBUG] get_content: http://interface.bilibili.com/playurl?cid=23733992&player=1&quality=3&ts=1514354736&sign=4ae38af54b911d9da2a2a962f4a0f772
[DEBUG] get_content: http://interface.bilibili.com/playurl?cid=23733992&player=1&quality=2&ts=1514354736&sign=2826e18594e192a967a9f011f402ae55
[DEBUG] get_content: http://interface.bilibili.com/playurl?cid=23733992&player=1&quality=1&ts=1514354736&sign=ec260f8e6e137ba2695ca9399bc0eca0
[DEBUG] get_content: http://interface.bilibili.com/playurl?cid=23733992&player=1&quality=0&ts=1514354736&sign=788be5f1f9caab526382e33a3a74f919
[DEBUG] get_content: http://comment.bilibili.com/23733992.xml
you-get: version 0.4.1011, a tiny downloader that scrapes the web.
you-get: Namespace(URL=['https://www.bilibili.com/video/av14554845'], cookies=None, debug=True, extractor_proxy=None, force=False, format='flv', help=False, http_proxy=None, info=False, input_file=None, itag=None, json=False, no_caption=False, no_merge=False, no_proxy=False, output_dir='/root/24h-raspberry-live-on-bilibili/downloads', output_filename='1514354059.0rendering1', password=None, player=None, playlist=False, socks_proxy=None, stream=None, timeout=600, url=False, version=False)
site:                Bilibili
title:               【鏡音リン &鏡音レン】病名为爱【Neru】
stream:
Traceback (most recent call last):
  File "/usr/local/bin/you-get", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/you_get/__main__.py", line 92, in main
    main(**kwargs)
  File "/usr/local/lib/python3.5/dist-packages/you_get/common.py", line 1583, in main
    script_main(any_download, any_download_playlist, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/you_get/common.py", line 1472, in script_main
    **extra
  File "/usr/local/lib/python3.5/dist-packages/you_get/common.py", line 1216, in download_main
    download(url, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/you_get/common.py", line 1574, in any_download
    m.download(url, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/you_get/extractor.py", line 59, in download_by_url
    self.download(**kwargs)
  File "/usr/local/lib/python3.5/dist-packages/you_get/extractor.py", line 201, in download
    self.p(stream_id)
  File "/usr/local/lib/python3.5/dist-packages/you_get/extractor.py", line 139, in p
    self.p_stream(stream_id)
  File "/usr/local/lib/python3.5/dist-packages/you_get/extractor.py", line 92, in p_stream
    stream = self.dash_streams[stream_id]
KeyError: 'flv'

根据最后一行KeyError: 'flv',推断问题出在下载时用了format=flv这个参数上,执行

you-get -i https://www.bilibili.com/video/av14554845

输出

site:                Bilibili
title:               【鏡音リン &鏡音レン】病名为爱【Neru】
streams:             # Available quality and codecs
    [ DEFAULT ] _________________________________
    - format:        flv720
      container:     flv
      size:          56.4 MiB (59186599 bytes)
    # download-with: you-get --format=flv720 [URL]

    - format:        mp4
      container:     mp4
      size:          29.3 MiB (30732667 bytes)
    # download-with: you-get --format=mp4 [URL]

可以看到format只有flv720mp4这两种,没有flv这种format。 再执行

you-get -i https://www.bilibili.com/video/av14042990

输出

site:                Bilibili
title:               【荒野求生】全64集 包含拍摄花絮,拍摄团队,后期制作,贝爷带你吃遍地球
streams:             # Available quality and codecs
    [ DEFAULT ] _________________________________
    - format:        flv
      container:     flv
      size:          224.1 MiB (234954799 bytes)
    # download-with: you-get --format=flv [URL]

    - format:        mp4
      container:     mp4
      size:          152.6 MiB (160006334 bytes)
    # download-with: you-get --format=mp4 [URL]

可以看到format里有flv,所以这个视频才能下载进来。所以我认为用you-get下载B站视频时不应该强制使用format=flv,还有一个bug就是视频根本没有下载成功,程序却发弹幕提示下载完成,等待渲染。希望大佬能改进一下,我也在用这个程序24小时直播,但我没有树莓派,我是装在VPS上的。

chenxuuu commented 6 years ago

已改,还没测试,你有空可以测试一下,我到晚上才能测试

chenxuuu commented 6 years ago

另外我的测试,结果和你的不一样:

C:\Users\Administrator>you-get -i https://www.bilibili.com/video/av14554845
site:                Bilibili
title:               【鏡音リン &鏡音レン】病名为爱【Neru】
streams:             # Available quality and codecs
    [ DEFAULT ] _________________________________
    - format:        mp4
      container:     mp4
      size:          29.3 MiB (30732667 bytes)
    # download-with: you-get --format=mp4 [URL]
ghost commented 6 years ago

@chenxuuu 你的you-get版本是多少呢?我的是0.4.1011。

root@a:~/24h-raspberry-live-on-bilibili# pip3 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
chardet (2.3.0)
command-not-found (0.3)
cryptography (1.7.1)
distro-info (0.14build1)
idna (2.2)
keyring (10.3.1)
keyrings.alt (2.2)
language-selector (0.1)
mutagen (1.39)
pip (9.0.1)
pyasn1 (0.1.9)
pycrypto (2.6.1)
pygobject (3.22.0)
python-apt (1.4.0b2)
python-debian (0.1.30)
pyxdg (0.25)
PyYAML (3.12)
requests (2.10.0)
SecretStorage (2.3.1)
setuptools (33.1.1)
six (1.10.0)
ssh-import-id (5.6)
ufw (0.35)
urllib3 (1.15.1)
wheel (0.29.0)
you-get (0.4.1011)
ghost commented 6 years ago

@chenxuuu ,刚刚测试了一下,程序可以下载av14554845了,但它下载的是formatmp4的视频。 我在其他文件夹分别下载了formatflv720mp4的视频,分别用FFmpeg查看了一下视频属性。 首先看的是flv720的,它是720P的。

root@a:~# ffmpeg -i *Neru*.flv
ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.3.0 (Ubuntu 6.3.0-12ubuntu2) 20170406
  configuration: --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --enable-libass --enable-libfreetype --arch=x86_64
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, flv, from '【鏡音リン &鏡音レン】病名为爱【Neru】.flv':
  Metadata:
    description     : Packed by Bilibili XCoder v1.0(fixed_gap:False)
    metadatacreator : Yet Another Metadata Injector for FLV - Version 1.9
    hasKeyframes    : true
    hasVideo        : true
    hasAudio        : true
    hasMetadata     : true
    canSeekToEnd    : true
    datasize        : 59184915
    videosize       : 53473942
    audiosize       : 5645169
    lasttimestamp   : 232
    lastkeyframetimestamp: 232
    lastkeyframelocation: 59186579
  Duration: 00:03:52.19, start: 0.083000, bitrate: 2039 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 1840 kb/s, 24 fps, 23.98 tbr, 1k tbn, 47.95 tbc
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 190 kb/s
At least one output file must be specified

再看mp4的,它是360P的。

root@zyvps:~# ffmpeg -i *Neru*.mp4
ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.3.0 (Ubuntu 6.3.0-12ubuntu2) 20170406
  configuration: --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --enable-libass --enable-libfreetype --arch=x86_64
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '【鏡音リン &鏡音レン】病名为爱【Neru】.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.71.100
    description     : Packed by Bilibili XCoder v1.0(fixed_gap:False)
  Duration: 00:03:52.30, start: 0.000000, bitrate: 1058 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 921 kb/s, 20 fps, 20 tbr, 16k tbn, 40 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 131 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
At least one output file must be specified

建议让程序自动选择画质最高的源视频来下载。用360P的视频渲染成720P的视频总感觉有点别扭。

chenxuuu commented 6 years ago

好了,你看看现在的代码

ghost commented 6 years ago

成功,程序可以下载到flv720的视频了。