ytmusicapi:JSON 在 ytmusic.search 中不可序列化

ytmusicapi: JSON is not serializable in ytmusic.search

我在我的项目中使用 ytmusicapi。这是我的代码。

from ytmusicapi import YTMusic
ytmusic = YTMusic()
rawdata = ytmusic.search(query,filter='songs') #error still will occurs without filters

但是我遇到了这个错误:

Object of type Message is not JSON serializable
Traceback (most recent call last):
  File "D:\Desktop\coding\telegram\env\lib\site-packages\pyrogram\dispatcher.py", line 222, in handler_worker
    await handler.callback(self.client, *args)
  File "D:\Desktop\coding\telegram\env\lib\site-packages\pyromod\listen\listen.py", line 93, in resolve_listener
    await self.user_callback(client, message, *args)
  File "d:\Desktop\coding\telegram\main.py", line 84, in start_command
    rawdata = ytmusic.search(query,filter='songs')
  File "D:\Desktop\coding\telegram\env\lib\site-packages\ytmusicapi\mixins\browsing.py", line 145, in search
    response = self._send_request(endpoint, body)
  File "D:\Desktop\coding\telegram\env\lib\site-packages\ytmusicapi\ytmusic.py", line 133, in _send_request
    response = self._session.post(YTM_BASE_API + endpoint + YTM_PARAMS + additionalParams,
  File "D:\Desktop\coding\telegram\env\lib\site-packages\requests\sessions.py", line 577, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "D:\Desktop\coding\telegram\env\lib\site-packages\requests\sessions.py", line 515, in request
    prep = self.prepare_request(req)
  File "D:\Desktop\coding\telegram\env\lib\site-packages\requests\sessions.py", line 443, in prepare_request
    p.prepare(
  File "D:\Desktop\coding\telegram\env\lib\site-packages\requests\models.py", line 321, in prepare
    self.prepare_body(data, files, json)
  File "D:\Desktop\coding\telegram\env\lib\site-packages\requests\models.py", line 473, in prepare_body
    body = complexjson.dumps(json, allow_nan=False)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 234, in dumps
    return cls(
  File "C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Message is not JSON serializable

我该如何解决?我曾在网上搜索文章来解决 JSON is not serializable 但不适用于这种情况。

任何建议或建议都会有所帮助。非常感谢!

我通过使用 pip

更新模块来修复它