Skip to content

The error occurs when trying to use you-get to download Bilibili videos outside of China using a non-Chinese IP.#3010

Open
sidouzi123 wants to merge 1 commit intosoimort:developfrom
sidouzi123:develop
Open

The error occurs when trying to use you-get to download Bilibili videos outside of China using a non-Chinese IP.#3010
sidouzi123 wants to merge 1 commit intosoimort:developfrom
sidouzi123:develop

Conversation

@sidouzi123
Copy link
Copy Markdown

@sidouzi123 sidouzi123 commented Jun 1, 2023

The error occurs when trying to use you-get to download Bilibili videos outside of China using a non-Chinese IP.
There are no issues with Chinese IP addresses before or after the fix.
As this is my first time using GitHub, please forgive any formatting errors.

Before the modification:

sidouzi@sdz:~$ you-get --debug "https://b23.tv/BV1yk4y1W7xX"
[DEBUG] get_location: https://b23.tv/BV1yk4y1W7xX
[DEBUG] get_content: https://www.bilibili.com/video/BV1yk4y1W7xX/
[DEBUG] get_content: https://www.bilibili.com/video/BV1yk4y1W7xX/
[DEBUG] get_content: https://api.bilibili.com/x/player/playurl?avid=741737386&cid=1146077095&qn=120&type=&otype=json&fnver=0&fnval=16&fourk=1
you-get: version 0.4.1650, a tiny downloader that scrapes the web.
you-get: Namespace(version=False, help=False, info=False, url=False, json=False, no_merge=False, no_caption=False, postfix=False, force=False, skip_existing_file_size_check=False, format=None, output_filename=None, output_dir='.', player=None, cookies=None, timeout=600, debug=True, input_file=None, password=None, playlist=False, first=None, last=None, size=None, auto_rename=False, insecure=False, http_proxy=None, extractor_proxy=None, no_proxy=False, socks_proxy=None, stream=None, itag=None, m3u8=False, URL=['https://b23.tv/BV1yk4y1W7xX'])
Traceback (most recent call last):
  File "/home/sidouzi/.local/bin/you-get", line 8, in <module>
    sys.exit(main())
  File "/home/sidouzi/.local/lib/python3.10/site-packages/you_get/__main__.py", line 92, in main
    main(**kwargs)
  File "/home/sidouzi/.local/lib/python3.10/site-packages/you_get/common.py", line 1870, in main
    script_main(any_download, any_download_playlist, **kwargs)
  File "/home/sidouzi/.local/lib/python3.10/site-packages/you_get/common.py", line 1762, in script_main
    download_main(
  File "/home/sidouzi/.local/lib/python3.10/site-packages/you_get/common.py", line 1382, in download_main
    download(url, **kwargs)
  File "/home/sidouzi/.local/lib/python3.10/site-packages/you_get/common.py", line 1861, in any_download
    m.download(url, **kwargs)
  File "/home/sidouzi/.local/lib/python3.10/site-packages/you_get/extractor.py", line 48, in download_by_url
    self.prepare(**kwargs)
  File "/home/sidouzi/.local/lib/python3.10/site-packages/you_get/extractors/bilibili.py", line 273, in prepare
    message = api_playinfo['data']['message']
KeyError: 'data'

After the modification:

sidouzi@sdz:~$ you-get --debug "https://b23.tv/BV1yk4y1W7xX"
[DEBUG] get_location: https://b23.tv/BV1yk4y1W7xX
[DEBUG] get_content: https://www.bilibili.com/video/BV1yk4y1W7xX/
[DEBUG] get_content: https://www.bilibili.com/video/BV1yk4y1W7xX/
[DEBUG] get_content: https://api.bilibili.com/x/player/playurl?avid=741737386&cid=1146077095&qn=120&type=&otype=json&fnver=0&fnval=16&fourk=1
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=1146077095&otype=json&qn=120&quality=120&type=&sign=9dc49d7ca85444ea03f2c12b0e19c249
[DEBUG] get_content: https://api.bilibili.com/x/player/playurl?avid=741737386&cid=1146077095&qn=112&type=&otype=json&fnver=0&fnval=16&fourk=1
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=1146077095&otype=json&qn=112&quality=112&type=&sign=07f0780ca903dd889b0f36c5a4845476
[DEBUG] get_content: https://api.bilibili.com/x/player/playurl?avid=741737386&cid=1146077095&qn=80&type=&otype=json&fnver=0&fnval=16&fourk=1
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=1146077095&otype=json&qn=80&quality=80&type=&sign=7053d22c7d6023508052f9221dfa33be
[DEBUG] get_content: https://api.bilibili.com/x/player/playurl?avid=741737386&cid=1146077095&qn=64&type=&otype=json&fnver=0&fnval=16&fourk=1
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=1146077095&otype=json&qn=64&quality=64&type=&sign=08efd2c9094638f34e2975e99d91d02b
[DEBUG] get_content: https://api.bilibili.com/x/player/playurl?avid=741737386&cid=1146077095&qn=32&type=&otype=json&fnver=0&fnval=16&fourk=1
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=1146077095&otype=json&qn=32&quality=32&type=&sign=1695fb2bbc483d773d7e7136358eaa00
[DEBUG] get_content: https://api.bilibili.com/x/player/playurl?avid=741737386&cid=1146077095&qn=16&type=&otype=json&fnver=0&fnval=16&fourk=1
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=1146077095&otype=json&qn=16&quality=16&type=&sign=e4cfa9e44e07cb2de9433d4ba9e724cb
[DEBUG] get_content: http://comment.bilibili.com/1146077095.xml
site:                Bilibili
title:               打工是不可能打工的
stream:
    - format:        flv360
      container:     flv
      quality:       流畅 360P
      size:          3.6 MiB (3820632 bytes)
    # download-with: you-get --format=flv360 [URL]

Downloading 打工是不可能打工的.flv ...
 100% (  3.6/  3.6MB) ├████████████████████████████████████████████████████████████████████████████████┤[1/1]   35 MB/s

Downloading 打工是不可能打工的.cmt.xml ...

修复非中国地区ip下载问题失败
@soimort-bot
Copy link
Copy Markdown
Collaborator

Hello @sidouzi123,
Thanks for the Pull Request. We ❤️ 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.

祝您健康!

@weitaifu
Copy link
Copy Markdown

C:\Users\weitaifu>pip install --upgrade you-get
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: you-get in c:\users\weitaifu\appdata\local\programs\python\python312\lib\site-packages (0.4.1650)

[notice] A new release of pip is available: 23.3.1 -> 23.3.2
[notice] To update, run: python.exe -m pip install --upgrade pip

C:\Users\weitaifu>python.exe -m pip install --upgrade pip
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: pip in c:\users\weitaifu\appdata\local\programs\python\python312\lib\site-packages (23.3.1)
Collecting pip
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/15/aa/3f4c7bcee2057a76562a5b33ecbd199be08cdb4443a02e26bd2c3cf6fc39/pip-23.3.2-py3-none-any.whl (2.1 MB)
---------------------------------------- 2.1/2.1 MB 3.5 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 23.3.1
Uninstalling pip-23.3.1:
Successfully uninstalled pip-23.3.1
Successfully installed pip-23.3.2

C:\Users\weitaifu>you-get -o G:\下载 https://www.bilibili.com/video/BV1UT4y1P7Mf
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.

C:\Users\weitaifu>you-get -o G:\下载 https://www.bilibili.com/video/BV1UT4y1P7Mf --debug
[DEBUG] get_content: https://www.bilibili.com/video/BV1UT4y1P7Mf
[DEBUG] get_content: https://www.bilibili.com/video/BV1UT4y1P7Mf
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=289482292&otype=json&qn=64&quality=64&type=&sign=b4527ec4101a5d3b33cc0a72070a40f1
[DEBUG] HTTP Error with code502
[DEBUG] HTTP Error with code502
[DEBUG] HTTP Error with code502
you-get: version 0.4.1650, a tiny downloader that scrapes the web.
you-get: Namespace(version=False, help=False, info=False, url=False, json=False, no_merge=False, no_caption=False, postfix=False, force=False, skip_existing_file_size_check=False, format=None, output_filename=None, output_dir='G:\下载', player=None, cookies=None, timeout=600, debug=True, input_file=None, password=None, playlist=False, first=None, last=None, size=None, auto_rename=False, insecure=False, http_proxy=None, extractor_proxy=None, no_proxy=False, socks_proxy=None, stream=None, itag=None, m3u8=False, URL=['https://www.bilibili.com/video/BV1UT4y1P7Mf'])
Traceback (most recent call last):
File "", line 198, in run_module_as_main
File "", line 88, in run_code
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Scripts\you-get.exe_main
.py", line 7, in
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get_main
.py", line 92, in main
main(**kwargs)
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\common.py", line 1870, in main
script_main(any_download, any_download_playlist, **kwargs)
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\common.py", line 1762, in script_main
download_main(
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\common.py", line 1382, in download_main
download(url, **kwargs)
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\common.py", line 1861, in any_download
m.download(url, **kwargs)
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\extractor.py", line 48, in download_by_url
self.prepare(**kwargs)
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\extractors\bilibili.py", line 276, in prepare
api_content = get_content(api_url, headers=self.bilibili_headers(referer=self.url))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\common.py", line 477, in get_content
response = urlopen_with_retry(req)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\common.py", line 446, in urlopen_with_retry
raise http_error
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\common.py", line 437, in urlopen_with_retry
return request.urlopen(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 215, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 521, in open
response = meth(req, response)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 630, in http_response
response = self.parent.error(
^^^^^^^^^^^^^^^^^^
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 559, in error
return self._call_chain(*args)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 492, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "C:\Users\weitaifu\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 639, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 502: Bad Gateway

@bigbigtooth
Copy link
Copy Markdown

i got the same problem!!! Can it fix ???

@weitaifu
Copy link
Copy Markdown

weitaifu commented Jan 14, 2024 via email

@chh-wang
Copy link
Copy Markdown

+1 遇到同样的问题,解决了吗?

@weitaifu
Copy link
Copy Markdown

weitaifu commented Jan 30, 2024 via email

@weitaifu
Copy link
Copy Markdown

weitaifu commented Feb 3, 2024 via email

@ZreXoc
Copy link
Copy Markdown

ZreXoc commented Feb 7, 2024

I get error 502 even without using any proxy!!! How cans I fix it?

@YWFhYmJi
Copy link
Copy Markdown

YWFhYmJi commented Mar 7, 2024

update to the lastest develop version (download from github)

@Metasymbols
Copy link
Copy Markdown

@韦太福 你怎么解决这个问题的?

@Chamomile-zh
Copy link
Copy Markdown

i meet the same problem too!!!!how to fix it?

@ChinaNine
Copy link
Copy Markdown

使用you-get下载视频时出错,报错是[error] oops, something went wrong.,确认视频地址是正确的
微信截图_20240701120816

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants