Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3710

When updating the video description through youtube data api v3, the request returns backendError. Previously worked

$
0
0

Initial description:This code that I've run many times before is now failing. I believe it has to do with the video snippet description changing. It is giving me a backendError.

When I have the following code:

    request = youtube_client.videos().update(            part="snippet,status,localizations",            body={"id": VIDEO_ID,"localizations": translations,"snippet": {"categoryId": 22,"defaultLanguage": "en","description": video_description, # todo: fix ; back end error occurs here "tags": ["automation","python","youtube api"                    ],"title": title,                },"status": {"privacyStatus": "public"                },            }        )        response = execute_request(request)

where execute_request is the following for additional context:

def execute_request(request: HttpRequest) -> dict:    try:        response = request.execute()    except HttpError as err:        print()        error_details = err.error_details[0]        print(f"{error_details=}")        if (error_details and             err.__dict__["resp"]["status"]):            display_error_and_exit(f"HTTP error: {error_details["message"]}")        else:            display_error_and_exit(f"An unexpected HTTPError occurred while executing a request: {err}")    except Exception as err:        display_error_and_exit(f"An unexpected error occurred while executing a request: {err}")    return response

it gives me this error when I run the code:

{'message': 'Backend Error', 'domain': 'global', 'reason': 'backendError'}

However, when I leave out this line from the request:

"description": video_description, 

and run the code, the request is successful.

I printed video_description which was:

video_description ="time: 01/25/2025 16:50:06 UTC\n\nthis channel has 8 subscribers.\n\nthis video was published 21 days ago in UTC.\n\nviews: 57\ncomments: 2\nlikes: 1\nfavorites: 0\n\nthese numbers were retrieved using the Youtube Data V3 API.\n\nthis video's title, description, and translations update approximately every 9 minutes.\nthe thumbnail updates once a day.\n\nthe translations were automated as well using the deepl deep-translator.\ntry switching to one of the following languages: english, spanish, german, french, and japanese."

This corresponds to the localization "en" which is in translations so it's surprising to me that if I leave out the "description" in the request, the description for the video is updated to be empty.

Here is the code for video_description:

    video_description = f"time: {formatted_now} UTC\n\nthis channel has {subscriber_count} {plural_sub_text}.\n\nthis video was published {time_since_published} days ago in UTC.\n\nviews: {views}\ncomments: {comments}\nlikes: {likes}\nfavorites: {favorites}\n\nthese numbers were retrieved using the Youtube Data V3 API.\n\nthis video's title, description, and translations update approximately every 9 minutes.\nthe thumbnail updates once a day.\n\nthe translations were automated as well using the deepl deep-translator.\ntry switching to one of the following languages: {join_languages()}."

This code has previously worked many times. I even have it running on a cron job / schedule in AWS. But now the logs are showing this backendError. I'm wondering if it is a character issue within video_description.

I've done some searching but I haven't seen anyone encounter this issue.Let me know if you need more info and thank you for your help.


Viewing all articles
Browse latest Browse all 3710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>