Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def update_video(youtube, args):
- # Call the API's videos.list method to retrieve the video resource.
- videos_list_response = youtube.videos().list(
- id=args.video_id,
- part='snippet'
- ).execute()
- print ('Call the APIs videos.list method to retrieve the video resource')
- print(videos_list_response);
- # If the response does not contain an array of 'items' then the video was not found.
- if not videos_list_response['items']:
- print ('Video "%s" was not found.' % args.video_id)
- sys.exit(1)
- print ('Copiando todos los metadatos viejos del video')
- videos_list_snippet = videos_list_response['items'][0]['snippet']
- print('Cambiando el Valor del título del video');
- videos_list_snippet['title'] = "args.title"
- print(videos_list_snippet);
- # Update the video resource by calling the videos.update() method.
- videos_update_response = youtube.videos().update(
- part='snippet',
- body=dict(
- snippet=videos_list_response,
- id=args.video_id
- )).execute()
- print('The updated video metadata is:n' +
- 'Title: ' + videos_update_response['snippet']['title'] + 'n')
- print(videos_list_response);
- {'publishedAt': '2018-04-15T23:40:19.000Z', 'channelId': 'xxxxx', 'title': 'Titulo Viejo', 'description': "Algo", 'defaultAudioLanguage': 'zxx'}
- print('Cambiando el Valor del título del video');
- videos_list_snippet['title'] = "Titulo nuevo"
- print(videos_list_snippet);
- {'publishedAt': '2018-04-15T23:40:19.000Z', 'channelId': 'xxxxx', 'title': 'Titulo nuevo', 'description': "Algo", 'defaultAudioLanguage': 'zxx'}
- # Update the video resource by calling the videos.update() method.
- videos_update_response = youtube.videos().update(
- part='snippet',
- body=dict(
- snippet=videos_list_snippet,
- id=args.video_id
- )).execute()
- An HTTP error 400 occurred:
- b'{n "error": {n "errors": [n {n "domain": "youtube.video",n "reason": "invalidVideoMetadata",n "message": "The request metadata is invalid.",n "locationType": "other",n "location": "body"n }n ],n "code": 400,n "message": "The request metadata is invalid."n }n}n'
- # Update the video resource by calling the videos.update() method.
- videos_update_response = youtube.videos().update(
- part='snippet',
- body=dict(
- snippet=videos_list_response,
- id=args.video_id
- )).execute
- An HTTP error 400 occurred:
- b'{n "error": {n "errors": [n {n "domain": "youtube.video",n "reason": "invalidTitle",n "message": "The request metadata specifies an invalid or empty video title.",n "locationType": "other",n "location": "body.snippet.title"n }n ],n "code": 400,n "message": "The request metadata specifies an invalid or empty video title."n }n}n
Add Comment
Please, Sign In to add comment