Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bilibili.py #3005

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jpppppppppppppppppppppppp

I've repair some bugs in downloading bangumi from bilibili.
All problems arise from match1(html_content, r'__INITIAL_STATE__=(.*?);\(function\(\)') because the webpage code had changed.
String "__INITIAL_STATE__" turned to be "initEpList" and some code structure also changed too
I try my best to fit my need so I don't detect its robustness.
Love your works very much. When I was in high school, even before it, I already enjoyed using your code to download my favorite videos. Now as a college student, I can make your code more complete, which is very exciting for me.
顺颂时绥

@soimort-bot
Copy link
Collaborator

Hello @jpppppppppppppppppppppppp,
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.

祝您健康!

@jpppppppppppppppppppppppp
Copy link
Author

jpppppppppppppppppppppppp commented Mar 17, 2023

I found this problem when I run code:you-get -i https://www.bilibili.com/bangumi/play/ep63851

@neoyxm
Copy link

neoyxm commented Apr 23, 2023

It works on bangumi links.
thanks.

you-get "https://www.bilibili.com/bangumi/play/ss27795?from_spmid=666.25.series.0"

@chjfth
Copy link

chjfth commented Jun 9, 2023

@jpppppppppppppppppppppppp Thank you very much, Now it fetches bangumi videos from Bilibili, using anonymous user identity. Like this:

(venv39a) chj@CHJA20 [2023-06-09 21:11:37.52] K:\jinshan\20230505\Videos\Bilibili
> set url
url=https://www.bilibili.com/bangumi/play/ep741435

(venv39a) chj@CHJA20 [2023-06-09 21:12:57.96] K:\jinshan\20230505\Videos\Bilibili
> python d:\github\you-get\you-get --debug  "%url%"  -i
[DEBUG] get_content: https://www.bilibili.com/bangumi/play/ep741435
you-get: This bangumi currently has 189 videos. (use --playlist to download all videos.)
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=0&type=&otype=json&ep_id=741435&fnver=0&fnval=16
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=120&type=&otype=json&ep_id=741435&fnver=0&fnval=8
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=112&type=&otype=json&ep_id=741435&fnver=0&fnval=8
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=80&type=&otype=json&ep_id=741435&fnver=0&fnval=8
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=64&type=&otype=json&ep_id=741435&fnver=0&fnval=8
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=16&type=&otype=json&ep_id=741435&fnver=0&fnval=8
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=120&type=&otype=json&ep_id=741435&fnver=0&fnval=16
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=112&type=&otype=json&ep_id=741435&fnver=0&fnval=16
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=80&type=&otype=json&ep_id=741435&fnver=0&fnval=16
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=64&type=&otype=json&ep_id=741435&fnver=0&fnval=16
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=16&type=&otype=json&ep_id=741435&fnver=0&fnval=16
[DEBUG] get_content: http://comment.bilibili.com/1061444581.xml
site:                Bilibili
title:               《这就是中国》第179集 从“北溪”事件谈起
streams:             # Available quality and codecs
    [ DASH ] ____________________________________
    - format:        dash-flv480
      container:     mp4
      quality:       清晰 480P
      size:          99.9 MiB (104700722 bytes)
    # download-with: you-get --format=dash-flv480 [URL]

    - format:        dash-flv360
      container:     mp4
      quality:       流畅 360P
      size:          58.4 MiB (61217613 bytes)
    # download-with: you-get --format=dash-flv360 [URL]

    [ DEFAULT ] _________________________________
    - format:        flv360
      container:     flv
      quality:       流畅 360P
      size:          59.0 MiB (61906923 bytes)
    # download-with: you-get --format=flv360 [URL]

But there seems still a problem, if I use -c to assign a Firefox cookie file, the program reports error.

(venv39a) chj@CHJA20 [2023-06-09 21:15:27.98] K:\jinshan\20230505\Videos\Bilibili
> python d:\github\you-get\you-get --debug  "%url%" -c %AppData%\Mozilla\Firefox\Profiles\fe8vu06r.default\cookies.sqlite  -i
[DEBUG] get_content: https://www.bilibili.com/bangumi/play/ep741435
[DEBUG] HTTP Error with code431
[DEBUG] HTTP Error with code431
[DEBUG] HTTP Error with code431
you-get: version 0.4.1650, a tiny downloader that scrapes the web.
you-get: Namespace(version=False, help=False, info=True, url=False, json=False, no_merge=False, no_caption=False, postfix=False, prefix=None, force=False, skip_existing_file_size_check=False, format=None, output_filename=None, output_dir='.', player=None, cookies='C:\\Users\\chj\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\fe8vu06r.default\\cookies.sqlite', 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/bangumi/play/ep741435'])
Traceback (most recent call last):
  File "d:\github\you-get\you-get", line 11, in <module>
    you_get.main(repo_path=_filepath)
  File "D:\github\you-get/src\you_get\__main__.py", line 92, in main
    main(**kwargs)
  File "D:\github\you-get/src\you_get\common.py", line 1879, in main
    script_main(any_download, any_download_playlist, **kwargs)
  File "D:\github\you-get/src\you_get\common.py", line 1771, in script_main
    download_main(
  File "D:\github\you-get/src\you_get\common.py", line 1385, in download_main
    download(url, **kwargs)
  File "D:\github\you-get/src\you_get\common.py", line 1870, in any_download
    m.download(url, **kwargs)
  File "D:\github\you-get/src\you_get\extractor.py", line 48, in download_by_url
    self.prepare(**kwargs)
  File "D:\github\you-get/src\you_get\extractors\bilibili.py", line 337, in prepare
    initial_state_text = '{' + match1(html_content, r'("initEpList":.*?),"initSections"') + '}'
TypeError: can only concatenate str (not "NoneType") to str

Could you investigate further to solve this problem?

@studentnice05
Copy link

@jpppppppppppppppppppppppp Thank you very much, Now it fetches bangumi videos from Bilibili, using anonymous user identity. Like this:

(venv39a) chj@CHJA20 [2023-06-09 21:11:37.52] K:\jinshan\20230505\Videos\Bilibili
> set url
url=https://www.bilibili.com/bangumi/play/ep741435

(venv39a) chj@CHJA20 [2023-06-09 21:12:57.96] K:\jinshan\20230505\Videos\Bilibili
> python d:\github\you-get\you-get --debug  "%url%"  -i
[DEBUG] get_content: https://www.bilibili.com/bangumi/play/ep741435
you-get: This bangumi currently has 189 videos. (use --playlist to download all videos.)
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=0&type=&otype=json&ep_id=741435&fnver=0&fnval=16
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=120&type=&otype=json&ep_id=741435&fnver=0&fnval=8
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=112&type=&otype=json&ep_id=741435&fnver=0&fnval=8
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=80&type=&otype=json&ep_id=741435&fnver=0&fnval=8
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=64&type=&otype=json&ep_id=741435&fnver=0&fnval=8
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=16&type=&otype=json&ep_id=741435&fnver=0&fnval=8
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=120&type=&otype=json&ep_id=741435&fnver=0&fnval=16
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=112&type=&otype=json&ep_id=741435&fnver=0&fnval=16
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=80&type=&otype=json&ep_id=741435&fnver=0&fnval=16
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=64&type=&otype=json&ep_id=741435&fnver=0&fnval=16
[DEBUG] get_content: https://api.bilibili.com/pgc/player/web/playurl?avid=526305495&cid=1061444581&qn=16&type=&otype=json&ep_id=741435&fnver=0&fnval=16
[DEBUG] get_content: http://comment.bilibili.com/1061444581.xml
site:                Bilibili
title:               《这就是中国》第179集 从“北溪”事件谈起
streams:             # Available quality and codecs
    [ DASH ] ____________________________________
    - format:        dash-flv480
      container:     mp4
      quality:       清晰 480P
      size:          99.9 MiB (104700722 bytes)
    # download-with: you-get --format=dash-flv480 [URL]

    - format:        dash-flv360
      container:     mp4
      quality:       流畅 360P
      size:          58.4 MiB (61217613 bytes)
    # download-with: you-get --format=dash-flv360 [URL]

    [ DEFAULT ] _________________________________
    - format:        flv360
      container:     flv
      quality:       流畅 360P
      size:          59.0 MiB (61906923 bytes)
    # download-with: you-get --format=flv360 [URL]

But there seems still a problem, if I use -c to assign a Firefox cookie file, the program reports error.

(venv39a) chj@CHJA20 [2023-06-09 21:15:27.98] K:\jinshan\20230505\Videos\Bilibili
> python d:\github\you-get\you-get --debug  "%url%" -c %AppData%\Mozilla\Firefox\Profiles\fe8vu06r.default\cookies.sqlite  -i
[DEBUG] get_content: https://www.bilibili.com/bangumi/play/ep741435
[DEBUG] HTTP Error with code431
[DEBUG] HTTP Error with code431
[DEBUG] HTTP Error with code431
you-get: version 0.4.1650, a tiny downloader that scrapes the web.
you-get: Namespace(version=False, help=False, info=True, url=False, json=False, no_merge=False, no_caption=False, postfix=False, prefix=None, force=False, skip_existing_file_size_check=False, format=None, output_filename=None, output_dir='.', player=None, cookies='C:\\Users\\chj\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\fe8vu06r.default\\cookies.sqlite', 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/bangumi/play/ep741435'])
Traceback (most recent call last):
  File "d:\github\you-get\you-get", line 11, in <module>
    you_get.main(repo_path=_filepath)
  File "D:\github\you-get/src\you_get\__main__.py", line 92, in main
    main(**kwargs)
  File "D:\github\you-get/src\you_get\common.py", line 1879, in main
    script_main(any_download, any_download_playlist, **kwargs)
  File "D:\github\you-get/src\you_get\common.py", line 1771, in script_main
    download_main(
  File "D:\github\you-get/src\you_get\common.py", line 1385, in download_main
    download(url, **kwargs)
  File "D:\github\you-get/src\you_get\common.py", line 1870, in any_download
    m.download(url, **kwargs)
  File "D:\github\you-get/src\you_get\extractor.py", line 48, in download_by_url
    self.prepare(**kwargs)
  File "D:\github\you-get/src\you_get\extractors\bilibili.py", line 337, in prepare
    initial_state_text = '{' + match1(html_content, r'("initEpList":.*?),"initSections"') + '}'
TypeError: can only concatenate str (not "NoneType") to str

Could you investigate further to solve this problem?

Maybe it's a problem about cookies.sqlit. When I use cookies from Firefox the error also occur. But when I try cookies.txt which exported by plugin, it can download videos successfully. If you want to export your cookies, you can use addon of browser, for example, I use Edge and install the addon from "https://microsoftedge.microsoft.com/addons/detail/j2team-cookies/lmakhegealefmkbnagibiebebncemhgn", you can also use other tools that can export your cookies and save as "cookies.txt".

@chjfth
Copy link

chjfth commented Jul 2, 2023

@studentnice05 Thank you for the workaround, After converting/exporting the cookie data to cookies.txt, this patch works smoothly.

cookies.txt is something like this:

# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file!  Do not edit.

.bilibili.com	TRUE	/	FALSE	0	innersign	0
.bilibili.com	TRUE	/	FALSE	1719850064	buvid3	52BD48B7-34A8-A28E-7C87-9B1F54DD91A863355infoc
.bilibili.com	TRUE	/	FALSE	1719850064	b_nut	1688314063
.bilibili.com	TRUE	/	FALSE	1719850064	i-wanna-go-back	-1
.bilibili.com	TRUE	/	FALSE	1719850064	b_ut	7
.bilibili.com	TRUE	/	FALSE	0	b_lsid	F3A472D10_189175C2D30
.bilibili.com	TRUE	/	FALSE	1719850064	_uuid	6D58CD88-D2610-A72C-8116-7181F5684F2A64184infoc
.bilibili.com	TRUE	/	FALSE	1719850064	FEED_LIVE_VERSION	V8
.bilibili.com	TRUE	/	FALSE	1719850064	header_theme_version	undefined
.bilibili.com	TRUE	/	FALSE	1722874065	buvid_fp	2574b07e21e09d407bafdffda493cfcd
.bilibili.com	TRUE	/	FALSE	1719850064	home_feed_column	4
.bilibili.com	TRUE	/	FALSE	1719850064	browser_resolution	1332-920
.bilibili.com	TRUE	/	FALSE	1722874065	buvid4	9E9B28A0-60F3-2E6D-9C4E-2E8BEBFA4A5464254-023070300-b1nz50QSFWBDBCQM6JLH3g%3D%3D
.bilibili.com	TRUE	/	TRUE	1703866107	SESSDATA	c8a86562%2C1703866106%2C..........(remaining sequences stripped off)
.bilibili.com	TRUE	/	FALSE	1703866107	bili_jct	2bfad5239a48d32777391ff7c5847e2a
.bilibili.com	TRUE	/	FALSE	1703866107	DedeUserID	2003585538
.bilibili.com	TRUE	/	FALSE	1703866107	DedeUserID__ckMd5	dccd1862e52c9353
.bilibili.com	TRUE	/	FALSE	1703866107	sid	e22u5sky

@Sora2480
Copy link

I got an error like this:

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.

@Phoupraw
Copy link

I got an error like this:

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.

Me, too. Here is the full debug output:

PS C:\Users\46793\Downloads> you-get --debug https://www.bilibili.com/video/BV1XL411S7FJ
[DEBUG] get_content: https://www.bilibili.com/video/BV1XL411S7FJ
[DEBUG] get_content: https://www.bilibili.com/video/BV1XL411S7FJ
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=1078254197&otype=json&qn=120&quality=120&type=&sign=40c74ca9be16773aece06ea767de18f8
[DEBUG] HTTP Error with code403
[DEBUG] HTTP Error with code403
[DEBUG] HTTP Error with code403
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://www.bilibili.com/video/BV1XL411S7FJ'])
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\46793\AppData\Local\Programs\Python\Python312\Scripts\you-get.exe\__main__.py", line 7, in <module>
  File "C:\Users\46793\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\__main__.py", line 92, in main
    main(**kwargs)
  File "C:\Users\46793\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\46793\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\common.py", line 1762, in script_main
    download_main(
  File "C:\Users\46793\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\common.py", line 1382, in download_main
    download(url, **kwargs)
  File "C:\Users\46793\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\common.py", line 1861, in any_download
    m.download(url, **kwargs)
  File "C:\Users\46793\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\extractor.py", line 48, in download_by_url
    self.prepare(**kwargs)
  File "C:\Users\46793\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\46793\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\46793\AppData\Local\Programs\Python\Python312\Lib\site-packages\you_get\common.py", line 446, in urlopen_with_retry
    raise http_error
  File "C:\Users\46793\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\46793\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 215, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\46793\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 521, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\46793\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 630, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "C:\Users\46793\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 559, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\46793\AppData\Local\Programs\Python\Python312\Lib\urllib\request.py", line 492, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "C:\Users\46793\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 403: Forbidden

Since this PR hasn't been merged, so the error might be fixed by this PR.

@594373975
Copy link

can not download videos from Bilibili.com. It‘s not a list of VIP videos,but return a 403 problem!
when i download all other videos,it‘s always return 403!

C:\Users\admin>you-get -o E:\Download --playlist https://www.bilibili.com/video/BV1CY4y1a78X --debug
[DEBUG] get_content: https://www.bilibili.com/video/BV1CY4y1a78X
[DEBUG] get_content: https://www.bilibili.com/video/av640922174?p=1
[DEBUG] get_content: https://www.bilibili.com/video/av640922174?p=1
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=584417572&otype=json&qn=64&quality=64&type=&sign=892a4e281f107b859b0e91530749b74b
[DEBUG] HTTP Error with code403
[DEBUG] HTTP Error with code403
[DEBUG] HTTP Error with code403
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='E:\Download', player=None, cookies=None, timeout=600, debug=True, input_file=None, password=None, playlist=True, 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/BV1CY4y1a78X'])
Traceback (most recent call last):
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\Scripts\you-get.exe_main
.py", line 7, in
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get_main
.py", line 92, in main
main(**kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 1870, in main
script_main(any_download, any_download_playlist, **kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 1762, in script_main
download_main(
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 1380, in download_main
download_playlist(url, **kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 1866, in any_download_playlist
m.download_playlist(url, **kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\extractors\bilibili.py", line 658, in download_playlist_by_url
self.class().download_by_url(purl, **kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\extractor.py", line 48, in download_by_url
self.prepare(**kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\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\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 477, in get_content
response = urlopen_with_retry(req)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 446, in urlopen_with_retry
raise http_error
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 437, in urlopen_with_retry
return request.urlopen(*args, **kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 525, in open
response = meth(req, response)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 563, in error
return self._call_chain(*args)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

C:\Users\admin>you-get -i https://www.bilibili.com/video/BV1AJ4m1T7GV --debug
[DEBUG] get_content: https://www.bilibili.com/video/BV1AJ4m1T7GV
[DEBUG] get_content: https://www.bilibili.com/video/BV1AJ4m1T7GV
[DEBUG] get_content: https://interface.bilibili.com/v2/playurl?appkey=iVGUTjsxvpLeuDCf&cid=1536646842&otype=json&qn=120&quality=120&type=&sign=8a6e6e8016cad651ea3627d0830261de
[DEBUG] HTTP Error with code403
[DEBUG] HTTP Error with code403
[DEBUG] HTTP Error with code403
you-get: version 0.4.1650, a tiny downloader that scrapes the web.
you-get: Namespace(version=False, help=False, info=True, 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://www.bilibili.com/video/BV1AJ4m1T7GV'])
Traceback (most recent call last):
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\Scripts\you-get.exe_main
.py", line 7, in
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get_main
.py", line 92, in main
main(**kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 1870, in main
script_main(any_download, any_download_playlist, **kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 1762, in script_main
download_main(
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 1382, in download_main
download(url, **kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 1861, in any_download
m.download(url, **kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\extractor.py", line 48, in download_by_url
self.prepare(**kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\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\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 477, in get_content
response = urlopen_with_retry(req)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 446, in urlopen_with_retry
raise http_error
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\site-packages\you_get\common.py", line 437, in urlopen_with_retry
return request.urlopen(*args, **kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 525, in open
response = meth(req, response)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 563, in error
return self._call_chain(*args)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
File "C:\Users\admin\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

@l1t1
Copy link

l1t1 commented Jun 26, 2024

two questions

  1. version 0.4.1710 cannot run
pip install you-get==0.4.1710
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting you-get==0.4.1710
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/78/5f/a9f22c80088f3e7987d9cfb24686aa00e0ce77016381cec803450b428e83/you_get-0.4.1710-py3-none-any.whl (188 kB)
     ---------------------------------------- 189.0/189.0 kB 5.8 MB/s eta 0:00:00
Collecting dukpy (from you-get==0.4.1710)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/db/18/a0f1f9ef0e1cba82c38bbb4951e38e08721515d7c7070cb410ce31397fb9/dukpy-0.4.0-cp38-cp38-win_amd64.whl (1.3 MB)
     ---------------------------------------- 1.3/1.3 MB 13.8 MB/s eta 0:00:00
Collecting mutf8 (from dukpy->you-get==0.4.1710)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/28/c3/f3f7b0f9000ebdbad8440941a7926b02c28231e434fb0fd7c80aad2b940c/mutf8-1.0.6-cp38-cp38-win_amd64.whl (11 kB)
Installing collected packages: mutf8, dukpy, you-get
  Attempting uninstall: you-get
    Found existing installation: you-get 0.4.1650
    Uninstalling you-get-0.4.1650:
      Successfully uninstalled you-get-0.4.1650
Successfully installed dukpy-0.4.0 mutf8-1.0.6 you-get-0.4.1710

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

D:\bilibili>you-get https://www.bilibili.com/video/BV1f4411379X/
you-get: Please install dukpy in order to extract videos from YouTube:
you-get: $ pip install dukpy
  1. version 0.4.1700 can download the file,but it has no sound stream
    I use you-get https://www.bilibili.com/video/BV147411K7xu/ to download a mp4 file ,rename it to a.mp4
    I use VLC media player can play the video and cannot output sounds
D:\bilibili>pip install you-get==0.4.1700
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting you-get==0.4.1700
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/99/ba/603e965c4e482adb74e74e37f2eea3fd901ef4d2b69f273759b7e0f3287e/you_get-0.4.1700-py3-none-any.whl (231 kB)
     ---------------------------------------- 231.3/231.3 kB 2.8 MB/s eta 0:00:00
Installing collected packages: you-get
  Attempting uninstall: you-get
    Found existing installation: you-get 0.4.1710
    Uninstalling you-get-0.4.1710:
      Successfully uninstalled you-get-0.4.1710
Successfully installed you-get-0.4.1700

D:\ffmpeg\bin\ffmpeg -v error -i a.mp4 -vn output.mp3
Output file #0 does not contain any stream

@BanVaveLor
Copy link

在下载UP主空间视频时,会出现以下错误。

此问题从2023年5月开始,目前仍然存在。

以下为输出信息。

C:\Users\BanVaveLor>you-get -l -d --cookies=G:\文件\cookies.sqlite -o=H:\新建文件夹 https://space.bilibili.com/2948981/video
[DEBUG] get_content: https://space.bilibili.com/2948981/video
[DEBUG] get_content: https://api.bilibili.com/x/space/arc/search?mid=2948981&pn=1&ps=50&tid=0&keyword=&order=pubdate&jsonp=jsonp
you-get: version 0.4.1730, 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, prefix=None, force=False, skip_existing_file_size_check=False, format=None, output_filename=None, output_dir='H:\\新建文件夹', player=None, cookies='G:\\文 件\\cookies.sqlite', timeout=600, debug=True, input_file=None, password=None, playlist=True, 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://space.bilibili.com/2948981/video'])
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\program files\python311\scripts\you-get.exe\__main__.py", line 7, in <module>
  File "C:\Program Files\Python311\Lib\site-packages\you_get\__main__.py", line 92, in main
    main(**kwargs)
  File "C:\Program Files\Python311\Lib\site-packages\you_get\common.py", line 1883, in main
    script_main(any_download, any_download_playlist, **kwargs)
  File "C:\Program Files\Python311\Lib\site-packages\you_get\common.py", line 1772, in script_main
    download_main(
  File "C:\Program Files\Python311\Lib\site-packages\you_get\common.py", line 1384, in download_main
    download_playlist(url, **kwargs)
  File "C:\Program Files\Python311\Lib\site-packages\you_get\common.py", line 1879, in any_download_playlist
    m.download_playlist(url, **kwargs)
  File "C:\Program Files\Python311\Lib\site-packages\you_get\extractors\bilibili.py", line 823, in download_playlist_by_url
    pc = math.ceil(videos_info['data']['page']['count'] / videos_info['data']['page']['ps'])
                   ~~~~~~~~~~~^^^^^^^^
KeyError: 'data'

请帮帮我!

@jpppppppppppppppppppppppp
Copy link
Author

在下载UP主空间视频时,会出现以下错误。

此问题从2023年5月开始,目前仍然存在。

以下为输出信息。

C:\Users\BanVaveLor>you-get -l -d --cookies=G:\文件\cookies.sqlite -o=H:\新建文件夹 https://space.bilibili.com/2948981/video
[DEBUG] get_content: https://space.bilibili.com/2948981/video
[DEBUG] get_content: https://api.bilibili.com/x/space/arc/search?mid=2948981&pn=1&ps=50&tid=0&keyword=&order=pubdate&jsonp=jsonp
you-get: version 0.4.1730, 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, prefix=None, force=False, skip_existing_file_size_check=False, format=None, output_filename=None, output_dir='H:\\新建文件夹', player=None, cookies='G:\\文 件\\cookies.sqlite', timeout=600, debug=True, input_file=None, password=None, playlist=True, 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://space.bilibili.com/2948981/video'])
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\program files\python311\scripts\you-get.exe\__main__.py", line 7, in <module>
  File "C:\Program Files\Python311\Lib\site-packages\you_get\__main__.py", line 92, in main
    main(**kwargs)
  File "C:\Program Files\Python311\Lib\site-packages\you_get\common.py", line 1883, in main
    script_main(any_download, any_download_playlist, **kwargs)
  File "C:\Program Files\Python311\Lib\site-packages\you_get\common.py", line 1772, in script_main
    download_main(
  File "C:\Program Files\Python311\Lib\site-packages\you_get\common.py", line 1384, in download_main
    download_playlist(url, **kwargs)
  File "C:\Program Files\Python311\Lib\site-packages\you_get\common.py", line 1879, in any_download_playlist
    m.download_playlist(url, **kwargs)
  File "C:\Program Files\Python311\Lib\site-packages\you_get\extractors\bilibili.py", line 823, in download_playlist_by_url
    pc = math.ceil(videos_info['data']['page']['count'] / videos_info['data']['page']['ps'])
                   ~~~~~~~~~~~^^^^^^^^
KeyError: 'data'

请帮帮我!

大部分的接口都需要更换

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