TikTokPy icon indicating copy to clipboard operation
TikTokPy copied to clipboard

Change type of SubtitleData.format field to str

Open amadejkastelic opened this issue 1 year ago • 5 comments

SubtitleData.format field can also be a string. Here is one such example:

video-embed-bot_1  | 2024-07-04 22:04:07,035 ERROR Failed downloading https://vm.tiktok.com/ZGesWbcYj/: 1 validation error for VideoPage
video-embed-bot_1  | itemInfo.itemStruct.video.subtitleInfos.0.Version
video-embed-bot_1  |   Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='1:whisper_lid', input_type=str]
video-embed-bot_1  |     For further information visit https://errors.pydantic.dev/2.7/v/int_parsing
video-embed-bot_1  | 2024-07-04 22:04:07,534 ERROR Ignoring exception in on_message
video-embed-bot_1  | Traceback (most recent call last):
video-embed-bot_1  |   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.12/site-packages/discord/client.py", line 449, in _run_event
video-embed-bot_1  |     await coro(*args, **kwargs)
video-embed-bot_1  |   File "/app/bots/discord/client.py", line 73, in on_message
video-embed-bot_1  |     raise e
video-embed-bot_1  |   File "/app/bots/discord/client.py", line 66, in on_message
video-embed-bot_1  |     post = await client.get_post()
video-embed-bot_1  |            ^^^^^^^^^^^^^^^^^^^^^^^
video-embed-bot_1  |   File "/app/downloader/tiktok.py", line 31, in get_post
video-embed-bot_1  |     video = await api.video(clean_url)
video-embed-bot_1  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
video-embed-bot_1  |   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.12/site-packages/tiktokapipy/async_api.py", line 191, in video
video-embed-bot_1  |     response = VideoPage.model_validate(
video-embed-bot_1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^
video-embed-bot_1  |   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.12/site-packages/pydantic/main.py", line 551, in model_validate
video-embed-bot_1  |     return cls.__pydantic_validator__.validate_python(
video-embed-bot_1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
video-embed-bot_1  | pydantic_core._pydantic_core.ValidationError: 1 validation error for VideoPage
video-embed-bot_1  | itemInfo.itemStruct.video.subtitleInfos.0.Version
video-embed-bot_1  |   Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='1:whisper_lid', input_type=str]

Tested by monkey-patching the lib.

amadejkastelic avatar Jul 04 '24 20:07 amadejkastelic

Tests failed due to #82. I think this is safe to merge.

amadejkastelic avatar Jul 04 '24 21:07 amadejkastelic

any updates?

hytradebridge avatar Oct 23 '24 20:10 hytradebridge

You can monkeypatch it like this in your code until (if ever) this gets merged: https://github.com/amadejkastelic/discord-video-embed-bot/blob/develop/bot%2Fintegrations%2Ftiktok%2F__init__.py

amadejkastelic avatar Oct 23 '24 20:10 amadejkastelic

You can monkeypatch it like this in your code until (if ever) this gets merged: https://github.com/amadejkastelic/discord-video-embed-bot/blob/develop/bot%2Fintegrations%2Ftiktok%2F__init__.py

Just wanted to say thank you for this. It's fixed the formatting error for me. Hopefully it'll get merged soon.

edshee avatar Oct 24 '24 16:10 edshee

can we merge this please?

jrmatos avatar May 10 '25 15:05 jrmatos