you-get icon indicating copy to clipboard operation
you-get copied to clipboard

bilibili download stuck

Open sgyzetrov opened this issue 5 years ago โ€ข 13 comments

Had to use ctrl-c to kill. Then if resume download and wait long enough, download will reach 100% then exceed the file size, and I have to use ctrl-c again. e.g.:

Downloading NONAME.mp4 ...
 100% ( ๐Ÿ˜ฐ๐Ÿ‘‰35.4๐Ÿ‘ˆ/ 31.2MB) โ”œโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ”ค[2/2]  436 MB/s

debug output:

you-get https://www.bilibili.com/video/av52500651\?spm_id_from\=333.6.b_686967685f656e65726779.3 --debug
[DEBUG] get_content: https://www.bilibili.com/video/av52500651?spm_id_from=333.6.b_686967685f656e65726779.3
[DEBUG] get_content: https://www.bilibili.com/video/av52500651?spm_id_from=333.6.b_686967685f656e65726779.3
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=91878701&otype=json&qn=64&quality=64&type=&sign=d6d28e42fa09c20132d856fa30ada039
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=91878701&otype=json&qn=32&quality=32&type=&sign=f8030cd08ffd900e81c4b9e00a39ff34
[DEBUG] get_content: https://api.bilibili.com/x/player/playurl?avid=52500651&cid=91878701&qn=16&type=&otype=json&fnver=0&fnval=16
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=91878701&otype=json&qn=16&quality=16&type=&sign=270a68b322af3db2b2ab6bef664b8e8f
[DEBUG] get_content: http://comment.bilibili.com/91878701.xml
site:                Bilibili
title:               ใ€Moe้…ฑใ€‘็จป้ฆ™ ๅ‘จๆฐไผฆ ๅ‰ไป–ๅผนๅ”ฑ
stream:
    - format:        dash-flv720
      container:     mp4
      quality:       ้ซ˜ๆธ… 720P
      size:          41.6 MiB (43611876 bytes)
    # download-with: you-get --format=dash-flv720 [URL]

Downloading ใ€Moe้…ฑใ€‘็จป้ฆ™ ๅ‘จๆฐไผฆ ๅ‰ไป–ๅผนๅ”ฑ.mp4 ...
98.6% ( 41.0/ 41.6MB) โ”œโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ”€โ”€โ”€โ”ค[2/2]   48 kB/s^CTraceback (most recent call last):
  File "/Users/simonguo/.pyenv/versions/you-get/bin/you-get", line 10, in <module>
    sys.exit(main())
  File "/Users/simonguo/.pyenv/versions/3.6.4/envs/you-get/lib/python3.6/site-packages/you_get/__main__.py", line 92, in main
    main(**kwargs)
  File "/Users/simonguo/.pyenv/versions/3.6.4/envs/you-get/lib/python3.6/site-packages/you_get/common.py", line 1733, in main
    script_main(any_download, any_download_playlist, **kwargs)
  File "/Users/simonguo/.pyenv/versions/3.6.4/envs/you-get/lib/python3.6/site-packages/you_get/common.py", line 1621, in script_main
    **extra
  File "/Users/simonguo/.pyenv/versions/3.6.4/envs/you-get/lib/python3.6/site-packages/you_get/common.py", line 1284, in download_main
    download(url, **kwargs)
  File "/Users/simonguo/.pyenv/versions/3.6.4/envs/you-get/lib/python3.6/site-packages/you_get/common.py", line 1724, in any_download
    m.download(url, **kwargs)
  File "/Users/simonguo/.pyenv/versions/3.6.4/envs/you-get/lib/python3.6/site-packages/you_get/extractor.py", line 61, in download_by_url
    self.download(**kwargs)
  File "/Users/simonguo/.pyenv/versions/3.6.4/envs/you-get/lib/python3.6/site-packages/you_get/extractor.py", line 241, in download
    av=stream_id in self.dash_streams)
  File "/Users/simonguo/.pyenv/versions/3.6.4/envs/you-get/lib/python3.6/site-packages/you_get/common.py", line 977, in download_urls
    headers=headers, **kwargs
  File "/Users/simonguo/.pyenv/versions/3.6.4/envs/you-get/lib/python3.6/site-packages/you_get/common.py", line 738, in url_save
    buffer = response.read(1024 * 256)
  File "/Users/simonguo/.pyenv/versions/3.6.4/lib/python3.6/http/client.py", line 449, in read
    n = self.readinto(b)
  File "/Users/simonguo/.pyenv/versions/3.6.4/lib/python3.6/http/client.py", line 493, in readinto
    n = self.fp.readinto(b)
  File "/Users/simonguo/.pyenv/versions/3.6.4/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
KeyboardInterrupt

sgyzetrov avatar May 18 '19 05:05 sgyzetrov

Hello @sgyzetrov, Thanks for the Pull Request. We :heart: our contributors! Please wait for one of our human maintainers to review your patches. This may take a few days to weeks. Also, please understand that although your Pull Request may or may not be eventually merged, we value all contributions equally.

็ฅๆ‚จๅฅๅบท!

soimort-bot avatar May 18 '19 05:05 soimort-bot

Yeah...so as I said before, resuming download will get the progress bar to reach 100%, but also exceed the original say .mp4 file size. By killing it again and then resuming again, you-get WILL complete the download, but the audio of say .mp4 file was partially lost...

sgyzetrov avatar May 18 '19 06:05 sgyzetrov

Can't reproduce. It's most likely a temporary CDN/network-related problem.

soimort avatar May 19 '19 14:05 soimort

I also encountered the same problem. The link of the video is "https://www.bilibili.com/video/av21781975?from=search&seid=11572859925132900428." bug_you-get

weidongzhou1994 avatar May 24 '19 14:05 weidongzhou1994

I also encountered the same problem. Any information I can provide to reproduce the problem?

ghoslin01 avatar May 25 '19 23:05 ghoslin01

@soimort Thank you for looking into this. Any theories or workarounds would be really helpful.

At this time, the problem seems to occur when the user is using Chinese ISP (I have tried using servers in HK, did not reproduce the bug. @weidongzhou1994 @ghoslin01 could you please confirm your network service provider? Is it also Chinese-based ISP like China Telecom, China Unicom, etc.?).

Best, Simon

sgyzetrov avatar May 26 '19 08:05 sgyzetrov

Thank you, My network is Chinese-based ISP.

weidongzhou1994 avatar May 26 '19 09:05 weidongzhou1994

The problem seems to be that the program failed to properly utilize the temporary .download file after interruption (by connection error, user intervention, whatsoever).

If you observed carefully: you shall notice that the total size (to finish after interruption) equals to the downloaded size (before interruption) + expected size.


[*] Do note that the program attempts to retry upon interruptions (errors).



~~To workaround this problem~~:

Quote "/README.md" ยง Pause and resume a download:

To enforce re-downloading, use the --force/-f option. (Warning: doing so will overwrite any existing file or temporary file with the same name!)

It failed... Didn't overwrite the temp file but instead started the writing on top of it.

And eventually ended up with AssertionError... (size mismatch)


So?.. (I think you've known enough regarding the problem)



Probably fixed:

Quote cww0614:

When url_save is passed a list of urls (is_chunked = True), and the download is aborted, then the next time that you-get resumes the download, it will append the video data from beginning to the .download file, because it does not send a correct Range header when resuming.

Several "exceeding 100%" issues might be related to this: #2703, #2768

Steps to reproduce:

...

Basically, the idea of this pull request is to maintain the starting and ending offset for each chunk. And when resuming, it skips downloaded chunks by comparing the file size and ending offsets, and computes the correct Range for the first unfinished chunk.

gdgsdg123 avatar Jul 11 '19 01:07 gdgsdg123

ไธบไป€ไนˆๆˆ‘ๆ— ๆณ•ๅˆ›ๅปบๆ–ฐ็š„issue

YouZhengChuan avatar Jul 11 '19 07:07 YouZhengChuan

How to download live files

whiteyun avatar Mar 07 '20 06:03 whiteyun

I'm having a differnet stuck problem: The cursor flashes and stuck... It appears even if i updated. The only thing I can do is wait...and it works.

Hope helpful to others.

CPCer avatar Mar 17 '20 19:03 CPCer

With -f enabled, I have met this issue on several different bilibili videos today. A retry is always working so I'm not sure how to reproduce it. BTW my you-get was running on an American VPS.

sankoshine avatar Mar 31 '20 02:03 sankoshine

ๆˆ‘ไนŸ้‡ๅˆฐไบ†่ฟ™ไธช้—ฎ้ข˜ใ€‚ๆˆ‘ๅฐ่ฏ•ไบ†ๅ‡ ็งไธ‹่ฝฝ่ฝฏไปถ๏ผŒ้ƒฝไธ่กŒใ€‚ ็ป™ไธ€ไธชๅœฐๅ€ไฝ ไปฌๅฅฝๅฅฝ็ ”็ฉถไธ‹ใ€‚ you-get https://v.qq.com/x/cover/j6o4g5envbm8aip/j0136uvp03u.html lux https://v.qq.com/x/cover/j6o4g5envbm8aip/j0136uvp03u.html ykdl https://v.qq.com/x/cover/j6o4g5envbm8aip/j0136uvp03u.html ้ƒฝๅกไฝๅœจ95% ....

iliaokun avatar Apr 16 '23 04:04 iliaokun