Giter Site home page Giter Site logo

Comments (10)

HFrost0 avatar HFrost0 commented on May 12, 2024 1

@BianTan 👋

下载链接:https://www.bilibili.com/video/BV1JP4y1K774 报错 httpx.LocalProtocolError

我尝试下载了这个链接,在本地python3.8和3.9以及3.10没能复现错误,或许你可以尝试重新下载,看看这个错误是否是因为网络条件不佳导致。作者对目前已知的因为网络原因出现的错误进行了try catch,包括httpx.RemoteProtocolError以及httpx.ReadTimeout。如果证实httpx.LocalProtocolError是因为网络不佳的原因引发,在后续更新中会对其进行catch,并做重试处理。

还有希望可以加上字幕下载功能

谢谢你的建议,在后续更新中会添加此功能

ps:另外我发现这个视频标题中的&没有被正常的解析,这个在后续更新中可能会去修复🥲
类似

from bilix.

HFrost0 avatar HFrost0 commented on May 12, 2024 1

改了还是一样捏,不过我不使用 -num 20 就稳一点了

你指的是-max_con吗,最好别设太大,会有很多问题,感觉5以内已经足够了

from bilix.

BianTan avatar BianTan commented on May 12, 2024

还有希望可以加上字幕下载功能

from bilix.

BianTan avatar BianTan commented on May 12, 2024

或许你可以尝试重新下载,看看这个错误是否是因为网络条件不佳导致。

我使用python3.9和3.10重新测试下载这个链接的视频,每次都是到了
【Udemy付费课程】 Git & GitHub - The Practical Guide -->Git&GitHub 使用指南(中英文字幕)-P51-054 Applying
the Fast-Forward Merge 完成
后面就报错
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/h2/connection.py", line 224, in
process_input
func, target_state = self.transitions[(self.state, input)]
KeyError: (<ConnectionState.CLOSED: 3>, <ConnectionInputs.SEND_HEADERS: 0>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpcore/_async/http2.py", line
105, in handle_async_request
await self._send_request_headers(request=request, stream_id=stream_id)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpcore/_async/http2.py", line
202, in _send_request_headers
self._h2_state.send_headers(stream_id, headers, end_stream=end_stream)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/h2/connection.py", line 766, in
send_headers
self.state_machine.process_input(ConnectionInputs.SEND_HEADERS)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/h2/connection.py", line 228, in
process_input
raise ProtocolError(
h2.exceptions.ProtocolError: Invalid input ConnectionInputs.SEND_HEADERS in state ConnectionState.CLOSED

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpx/_transports/default.py",
line 60, in map_httpcore_exceptions
yield
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpx/_transports/default.py",
line 353, in handle_async_request
resp = await self._pool.handle_async_request(req)
File
"/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpcore/_async/connection_pool.py",
line 253, in handle_async_request
raise exc
File
"/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpcore/_async/connection_pool.py",
line 237, in handle_async_request
response = await connection.handle_async_request(request)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpcore/_async/http_proxy.py",
line 310, in handle_async_request
return await self._connection.handle_async_request(request)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpcore/_async/http2.py", line
141, in handle_async_request
raise LocalProtocolError(exc) # pragma: nocover
httpcore.LocalProtocolError: Invalid input ConnectionInputs.SEND_HEADERS in state ConnectionState.CLOSED

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/biandan/Desktop/Lighting-bilibili-download-0.3/bili_cmd.py", line 56, in
asyncio.run(main(parser.parse_args()))
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 647, in
run_until_complete
return future.result()
File "/Users/biandan/Desktop/Lighting-bilibili-download-0.3/bili_cmd.py", line 9, in main
await d.get_series(args.key, quality=args.q, image=args.image)
File "/Users/biandan/Desktop/Lighting-bilibili-download-0.3/lighting_downloader.py", line 255, in get_series
await asyncio.gather(*cors)
File "/Users/biandan/Desktop/Lighting-bilibili-download-0.3/lighting_downloader.py", line 309, in get_video
await asyncio.gather(
File "/Users/biandan/Desktop/Lighting-bilibili-download-0.3/lighting_downloader.py", line 349, in _get_media
await asyncio.gather(*cors)
File "/Users/biandan/Desktop/Lighting-bilibili-download-0.3/lighting_downloader.py", line 366, in _get_media_part
async with self.client.stream("GET", random.choice(media_urls),
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 181, in aenter
return await self.gen.anext()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpx/_client.py", line 1549, in
stream
response = await self.send(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpx/_client.py", line 1593, in
send
response = await self._send_handling_auth(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpx/_client.py", line 1621, in
_send_handling_auth
response = await self._send_handling_redirects(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpx/_client.py", line 1658, in
_send_handling_redirects
response = await self._send_single_request(request)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpx/_client.py", line 1695, in
_send_single_request
response = await transport.handle_async_request(request)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpx/_transports/default.py",
line 353, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in exit
self.gen.throw(typ, value, traceback)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/httpx/_transports/default.py",
line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.LocalProtocolError: Invalid input ConnectionInputs.SEND_HEADERS in state ConnectionState.CLOSED

谢谢你的建议,在后续更新中会添加此功能

期待😚 希望可以配置单独下载字幕

from bilix.

BianTan avatar BianTan commented on May 12, 2024

设备是 M1 的 Mac mini

from bilix.

BianTan avatar BianTan commented on May 12, 2024

啊,原来报错了不删除文件重新执行命令可以继续下载

from bilix.

HFrost0 avatar HFrost0 commented on May 12, 2024

@BianTan

啊,原来报错了不删除文件重新执行命令可以继续下载

是的,我在特性里面提了一下,看来需要放在更显眼的位置🤣

httpx.LocalProtocolError

我又试了几次,M1芯片的Mac在转译和原生的情况下都能正常运行,我猜测可能是由于我们的地区不同,所请求的b站服务器不一致导致的。错误可能是由于请求的服务器对于http2协议支持出了问题,为了测试这个想法,可以暂时将lighting_downloader.py中的第29行

self.client = httpx.AsyncClient(headers=headers, cookies=cookies, http2=True)

改为

self.client = httpx.AsyncClient(headers=headers, cookies=cookies, http2=False)

使用http1协议访问

from bilix.

BianTan avatar BianTan commented on May 12, 2024

为了测试这个想法,可以暂时将lighting_downloader.py中的第29行

改了还是一样捏,不过我不使用 -num 20 就稳一点了

from bilix.

HFrost0 avatar HFrost0 commented on May 12, 2024

你可能需要的下载字幕功能已经有了,最新版本中使用--subtitle就可以下载rst格式的字幕了

python bili_cmd.py get_series 'url' --subtitle

字幕会下到视频目录下面的extra文件夹里面,我用的IINA播放器是可以自动导入的

from bilix.

HFrost0 avatar HFrost0 commented on May 12, 2024

请问最新版本还存在问题吗?

from bilix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.