Russell-Newton / TikTokPy

Extract data from TikTok without needing any login information or API keys.
https://pypi.org/project/tiktokapipy/
MIT License
213 stars 28 forks source link

Suppressing certain warnings and errors #26

Closed pjn5047 closed 1 year ago

pjn5047 commented 1 year ago

Is there an easy way to suppress some of the warnings related to the comments not loading? I am not trying to collect any comments, so suppressing these would make things easier.

For instance, when I get the following when I start using the API:

site-packages/tiktokapipy/api.py:470: UserWarning: Was unable to collect comments.
A second attempt might work.
  warnings.warn(

Additionally, I get the following for some videos:

  File "pydantic/main.py", line 527, in pydantic.main.BaseModel.parse_obj
  File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 19 validation errors for APIResponse
comments -> 0 -> id
  field required (type=value_error.missing)
comments -> 1 -> id
  field required (type=value_error.missing)
comments -> 2 -> id
  field required (type=value_error.missing)

Any suggestions would be appreciated! Sorry if this is obvious to others.

Russell-Newton commented 1 year ago

When you run your python program, you can use -Wignore to suppress warnings. Also, I fixed the issue that caused the ValidationErrors due to comments in v0.1.10.post2.