HFrost0 / bilix

⚡️Lightning-fast async download tool for bilibili and more
Apache License 2.0
1.58k stars 165 forks source link

【bilix get_up 】KeyError: 'list' #222

Closed FFFFFcl closed 2 months ago

FFFFFcl commented 2 months ago

运行: PS D:\bilix> bilix get_up 'https://space.bilibili.com/1372241958' --num 10 返回: Traceback (most recent call last): File "C:\Python311\Lib\site-packages\bilix\download\utils.py", line 90, in wrapped return await func(client, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\bilix\sites\bilibili\api.py", line 196, in get_up_video_info up_name = info["data"]["list"]["vlist"][0]["author"]


KeyError: 'list'

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

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:\Python311\Scripts\bilix.exe\__main__.py", line 7, in <module>
  File "C:\Python311\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\bilix\cli\main.py", line 374, in main
    loop.run_until_complete(cor)
  File "C:\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\bilix\sites\bilibili\downloader.py", line 251, in get_up
    up_name, total_size, bv_ids = await api.get_up_video_info(self.client, url_or_mid, 1, ps, order, keyword)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\bilix\download\utils.py", line 94, in wrapped
    raise APIParseError(e, func) from e
bilix.exception.APIParseError: APIParseError Caused by KeyError in <bilix.sites.bilibili.api:get_up_video_info>

**debug:**
PS D:\bilix> bilix get_up 'https://space.bilibili.com/1372241958' --num 10 --debug
DEBUG    Debug on, more information will be shown
DEBUG    CLI KEY METHOD and OPTIONS: {'num': 10, 'method': 'get_up', 'keys': ('https://space.bilibili.com/1372241958',), 'path': WindowsPath('videos'), 'quality': 0, 'video_concurrency': 3, 'part_concurrency':
         10, 'cookie': None, 'days': 7, 'order': 'pubdate', 'keyword': None, 'series': True, 'hierarchy': True, 'image': False, 'subtitle': False, 'dm': False, 'only_audio': False, 'p_range': None, 'codec': '',
         'speed_limit': None, 'stream_retry': 5, 'browser': None, 'time_range': None}
DEBUG    import cost 0.426857 s <module 'bilix.sites.bilibili'>
DEBUG    kwarg browser:None has been drop due to type hint missmatch
DEBUG    auto assemble <function DownloaderBilibili.get_up at 0x0000029847D00EA0> by {'num': 10, 'path': WindowsPath('videos'), 'quality': 0, 'order': 'pubdate', 'keyword': None, 'series': True, 'image': False,
         'subtitle': False, 'dm': False, 'only_audio': False, 'codec': ''}
DEBUG    Assign to DownloaderBilibili

┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐
│ C:\Python311\Lib\site-packages\bilix\download\utils.py:90 in wrapped                             │
│                                                                                                  │
│   87 │   @wraps(func)                                                                            │
│   88 │   async def wrapped(client: httpx.AsyncClient, *args, **kwargs):                          │
│   89 │   │   try:                                                                                │
│ > 90 │   │   │   return await func(client, *args, **kwargs)                                      │
│   91 │   │   except (APIError, httpx.HTTPError):                                                 │
│   92 │   │   │   raise                                                                           │
│   93 │   │   except Exception as e:                                                              │
│                                                                                                  │
│ C:\Python311\Lib\site-packages\bilix\sites\bilibili\api.py:196 in get_up_video_info              │
│                                                                                                  │
│   193 │                                                                                          │
│   194 │   res = await req_retry(client, "https://api.bilibili.com/x/space/wbi/arc/search", par   │
│   195 │   info = json.loads(res.text)                                                            │
│ > 196 │   up_name = info["data"]["list"]["vlist"][0]["author"]                                   │
│   197 │   total_size = info["data"]["page"]["count"]                                             │
│   198 │   bv_ids = [i["bvid"] for i in info["data"]["list"]["vlist"]]                            │
│   199 │   return up_name, total_size, bv_ids                                                     │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
KeyError: 'list'

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

┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐
│ in _run_module_as_main:198                                                                       │
│ in _run_code:88                                                                                  │
│                                                                                                  │
│ in <module>:7                                                                                    │
│                                                                                                  │
│ C:\Python311\Lib\site-packages\click\core.py:1157 in __call__                                    │
│                                                                                                  │
│   1154 │                                                                                         │
│   1155 │   def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Any:                           │
│   1156 │   │   """Alias for :meth:`main`."""                                                     │
│ > 1157 │   │   return self.main(*args, **kwargs)                                                 │
│   1158                                                                                           │
│   1159                                                                                           │
│   1160 class Command(BaseCommand):                                                               │
│                                                                                                  │
│ C:\Python311\Lib\site-packages\click\core.py:1078 in main                                        │
│                                                                                                  │
│   1075 │   │   try:                                                                              │
│   1076 │   │   │   try:                                                                          │
│   1077 │   │   │   │   with self.make_context(prog_name, args, **extra) as ctx:                  │
│ > 1078 │   │   │   │   │   rv = self.invoke(ctx)                                                 │
│   1079 │   │   │   │   │   if not standalone_mode:                                               │
│   1080 │   │   │   │   │   │   return rv                                                         │
│   1081 │   │   │   │   │   # it's not safe to `ctx.exit(rv)` here!                               │
│                                                                                                  │
│ C:\Python311\Lib\site-packages\click\core.py:1434 in invoke                                      │
│                                                                                                  │
│   1431 │   │   │   echo(style(message, fg="red"), err=True)                                      │
│   1432 │   │                                                                                     │
│   1433 │   │   if self.callback is not None:                                                     │
│ > 1434 │   │   │   return ctx.invoke(self.callback, **ctx.params)                                │
│   1435 │                                                                                         │
│   1436 │   def shell_complete(self, ctx: Context, incomplete: str) -> t.List["CompletionItem"]:  │
│   1437 │   │   """Return a list of completions for the incomplete value. Looks                   │
│                                                                                                  │
│ C:\Python311\Lib\site-packages\click\core.py:783 in invoke                                       │
│                                                                                                  │
│    780 │   │                                                                                     │
│    781 │   │   with augment_usage_errors(__self):                                                │
│    782 │   │   │   with ctx:                                                                     │
│ >  783 │   │   │   │   return __callback(*args, **kwargs)                                        │
│    784 │                                                                                         │
│    785 │   def forward(                                                                          │
│    786 │   │   __self, __cmd: "Command", *args: t.Any, **kwargs: t.Any  # noqa: B902             │
│                                                                                                  │
│ C:\Python311\Lib\site-packages\bilix\cli\main.py:374 in main                                     │
│                                                                                                  │
│   371 │   │   │   kwargs['path'].mkdir(parents=True)                                             │
│   372 │   │   │   logger.info(f'Directory {kwargs["path"]} not exists, auto created')            │
│   373 │   │   executor, cor = assign(kwargs)                                                     │
│ > 374 │   │   loop.run_until_complete(cor)                                                       │
│   375 │   except HandleError as e:  # method no match                                            │
│   376 │   │   logger.error(e)                                                                    │
│   377 │   except KeyboardInterrupt:                                                              │
│                                                                                                  │
│ C:\Python311\Lib\asyncio\base_events.py:653 in run_until_complete                                │
│                                                                                                  │
│    650 │   │   if not future.done():                                                             │
│    651 │   │   │   raise RuntimeError('Event loop stopped before Future completed.')             │
│    652 │   │                                                                                     │
│ >  653 │   │   return future.result()                                                            │
│    654 │                                                                                         │
│    655 │   def stop(self):                                                                       │
│    656 │   │   """Stop running the event loop.                                                   │
│                                                                                                  │
│ C:\Python311\Lib\site-packages\bilix\sites\bilibili\downloader.py:251 in get_up                  │
│                                                                                                  │
│   248 │   │   :return:                                                                           │
│   249 │   │   """                                                                                │
│   250 │   │   ps = 30                                                                            │
│ > 251 │   │   up_name, total_size, bv_ids = await api.get_up_video_info(self.client, url_or_mi   │
│   252 │   │   if self.hierarchy:                                                                 │
│   253 │   │   │   path /= legal_title(f"【up】{up_name}")                                        │
│   254 │   │   │   path.mkdir(parents=True, exist_ok=True)                                        │
│                                                                                                  │
│ C:\Python311\Lib\site-packages\bilix\download\utils.py:94 in wrapped                             │
│                                                                                                  │
│   91 │   │   except (APIError, httpx.HTTPError):                                                 │
│   92 │   │   │   raise                                                                           │
│   93 │   │   except Exception as e:                                                              │
│ > 94 │   │   │   raise APIParseError(e, func) from e                                             │
│   95 │                                                                                           │
│   96 │   return wrapped                                                                          │
│   97                                                                                             │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
APIParseError: APIParseError Caused by KeyError in <bilix.sites.bilibili.api:get_up_video_info>
FFFFFcl commented 2 months ago

其他的方法,如get_series,可以正常使用。也许是api变了?

HFrost0 commented 2 months ago

登录后试下,有些接口只有登录后才能正常返回数据