Этот код, который я запускал много раз раньше, теперь дает сбой. Я считаю, что это связано с изменением описания фрагмента видео. Это выдает мне backendError.
Когда у меня есть следующий код:
Код: Выделить всё
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)
Код: Выделить всё
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
Код: Выделить всё
{'message': 'Backend Error', 'domain': 'global', 'reason': 'backendError'}
< /code>
Однако, когда я выпускаю эту строку из запроса: < /p>
"description": video_description,
Я распечатал video_description, который был:
Код: Выделить всё
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."
Вот код для 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()}."
Я немного поискал, но не видел, чтобы кто-нибудь сталкивался с этой проблемой.
Давайте Я знаю, нужна ли вам дополнительная информация, и спасибо за вашу помощь.
Подробнее здесь: https://stackoverflow.com/questions/793 ... equest-ret