Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change type of SubtitleData.format field to str #86

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

amadejkastelic
Copy link
Contributor

@amadejkastelic amadejkastelic commented Jul 4, 2024

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
Copy link
Contributor Author

amadejkastelic commented Jul 4, 2024

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

@hytradebridge
Copy link

any updates?

@amadejkastelic
Copy link
Contributor Author

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

@edshee
Copy link

edshee commented Oct 24, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants