amtoaer / bili-sync

由 Rust & Tokio 驱动的哔哩哔哩同步工具
https://bili-sync.allwens.work
MIT License
402 stars 34 forks source link

接口返回错误代码:-400 #46

Closed BigBillZhao closed 5 months ago

BigBillZhao commented 5 months ago

您好!非常感谢开发这个好用的docker镜像; 我这边遇到的问题似乎是因为-400 Bad Request导致无法下载视频,我尝试过更新Cookie(使用无痕模式获取的,尝试了手机短信验证登录和扫码登陆),但是并没有解决这个问题,同时我的收藏夹都是私密的,而程序可以正常获取新添加的视频信息,但是无法下载,因此我认为Cookie并没有失效。 我在美国且有固定公网IP,是否会触发某种检测/限制?我具体的报错信息如下:

2024-02-24 12:13:22.832 | ERROR    | processor:process_favorite_item:331 - Failed to process video BV1i6421M7jg 相机取景器中的雪国!vlog|一年一度北海道的旅行|907X CFV100C, error_code: -400
Traceback (most recent call last):

  File "/app/entry.py", line 54, in <module>
    runner.run(entry())
    │      │   └ <function entry at 0x7fedcc25be20>
    │      └ <function Runner.run at 0x7fedcc24ade0>
    └ <asyncio.runners.Runner object at 0x7fedcc2e1710>

  File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           │    │     │                  └ <Task pending name='Task-1' coro=<entry() running at /app/entry.py:45> wait_for=<_GatheringFuture pending cb=[Task.task_wakeu...
           │    │     └ <method 'run_until_complete' of 'uvloop.loop.Loop' objects>
           │    └ <uvloop.Loop running=True closed=False debug=False>
           └ <asyncio.runners.Runner object at 0x7fedcc2e1710>

  File "/app/processor.py", line 32, in wrapper
    return await func(*args, **kwargs)
                 │     │       └ {}
                 │     └ (<FavoriteItem: 270374>,)
                 └ <function process_favorite_item at 0x7fedc8441300>

> File "/app/processor.py", line 288, in process_favorite_item
    await v.get_download_url(page_index=0)
          │ └ <function Video.get_download_url at 0x7fedca1682c0>
          └ <bilibili_api.video.Video object at 0x7fedc812f850>

  File "/usr/local/lib/python3.11/site-packages/bilibili_api/video.py", line 460, in get_download_url
    await Api(**api, credential=self.credential).update_params(**params).result
          │     │               │    │                           └ {'avid': -746717123, 'cid': 1445832795, 'qn': '127', 'otype': 'json', 'fnval': 4048, 'fourk': 1}
          │     │               │    └ <credential.PersistedCredential object at 0x7fedc841ee10>
          │     │               └ <bilibili_api.video.Video object at 0x7fedc812f850>
          │     └ {'url': 'https://api.bilibili.com/x/player/playurl', 'method': 'GET', 'verify': False, 'params': {'avid': 'int: av 号', 'cid':...
          └ <class 'bilibili_api.utils.network.Api'>
  File "/usr/local/lib/python3.11/site-packages/bilibili_api/utils/network.py", line 271, in result
    self.__result = await self.request()
    │                     │    └ <function retry.<locals>.wrapper.<locals>.inner at 0x7fedca5dee80>
    │                     └ Api(url='https://api.bilibili.com/x/player/playurl', method='GET', comment='视频下载的信息,下载链接需要提供 headers 伪装浏览器请求(Referer 和 User-A...
    └ Api(url='https://api.bilibili.com/x/player/playurl', method='GET', comment='视频下载的信息,下载链接需要提供 headers 伪装浏览器请求(Referer 和 User-A...
  File "/usr/local/lib/python3.11/site-packages/bilibili_api/utils/network.py", line 171, in inner
    return await func(*args, **kwargs)
                 │     │       └ {}
                 │     └ (Api(url='https://api.bilibili.com/x/player/playurl', method='GET', comment='视频下载的信息,下载链接需要提供 headers 伪装浏览器请求(Referer 和 User-...
                 └ <function Api.request at 0x7fedca5dede0>
  File "/usr/local/lib/python3.11/site-packages/bilibili_api/utils/network.py", line 511, in request
    real_data = self._process_response(
                │    └ <function Api._process_response at 0x7fedca5dec00>
                └ Api(url='https://api.bilibili.com/x/player/playurl', method='GET', comment='视频下载的信息,下载链接需要提供 headers 伪装浏览器请求(Referer 和 User-A...
  File "/usr/local/lib/python3.11/site-packages/bilibili_api/utils/network.py", line 556, in _process_response
    raise ResponseCodeException(code, msg, resp_data)
          │                     │     │    └ {'code': -400, 'message': '请求错误', 'ttl': 1}
          │                     │     └ '请求错误'
          │                     └ -400
          └ <class 'bilibili_api.exceptions.ResponseCodeException.ResponseCodeException'>

bilibili_api.exceptions.ResponseCodeException.ResponseCodeException: 接口返回错误代码:-400,信息:请求错误。
{'code': -400, 'message': '请求错误', 'ttl': 1}

请问您是否有什么解决此问题的思路?感谢!

amtoaer commented 5 months ago

你使用的是最新版本吗?这个问题在1.1.4及之前版本存在,1.1.5更新上游依赖后应该修复了,如果是旧版本可以更新一下试试。

BigBillZhao commented 5 months ago

不好意思刚刚才看到closed的issue,然后更新了一下问题解决了,非常感谢您的回复!