pythonyoutubeuploadyoutube-api

Youtube video upload - issues with special characters


Not able to resolve issues with special characters in title and description. I'm using official google example code to upload videos to youtube like below example:

python upload_video.py --file="DU.mp4" --title="Rozporządzenie" --description="Zapraszamy do odsłuchania nowej publikacji dziennika ustaw opublikowanego na stronie sejmu.\n\nTytuł: DU/2025/695 - Rozporzaogon;dzenie Ministra Rolnictwa i Rozwoju Wsi" --keywords="" --category="25" --privacyStatus="private" --noauth_local_webserver 

Acc. to this doc: https://developers.google.com/youtube/v3/guides/uploading_a_video

Simply im using polish special characters and while upload process youtube is returing it like below: enter image description here

Was able to find info in google documentation that by default the title and description are encoded in utf-8, this is visible here: enter image description here

Acc to this doc: https://developers.google.com/youtube/v3/docs/videos#resource

How can I resolve this issue? what am I doing wrong?


Solution

  • I use Linux which uses utf-8 in all places
    but when I use "ą".encode('utf-8').decode('852') then I get '─ů'
    which suggests that you send it as 852.

    It may need to use text = text.encode('852').decode('utf-8') to convert it to utf-8


    I in upload_video.py it may need:

    description=options.description.encode('852').decode('utf-8')
    

    To make it more universal it may need to check what encoding was used in terminal.
    Maybe it could be done with:

    How do you get the encoding of the terminal from within a python script? - Stack Overflow