• 검색 결과가 없습니다.

YouTube 동영상 메타데이터 수정 API

문서에서 Open API 명세서 작성 가이드라인 (페이지 116-131)

2. API 정의

2.15 YouTube 동영상 메타데이터 수정 API

 Updates a video's metadata.

 출처 : https://developers.google.com/youtube/v3/docs/videos/update

2.15.2 정의

서비스 정보

상세항목 상세내역

기능 YouTube 에 동영상 메타데이터 수정 기능

호출 URL PUT https://www.googleapis.com/youtube/v3/videos

요청 변수 수정할 동영상 정보, 소유자 정보

■ Request-Response

□ Publish-Subscribe

□ Fire-and-Forgot

□ Notification

□ 기타 ( ) 사용 제약 사항 (비고)

2.15.3 요청 변수

 Parameter (https://developers.google.com/youtube/v3/docs/videos/update#parameters)

이름 타입 설명

part string The part parameter serves two purposes in this operation.

It identifies the properties that the write operation will set as well as the properties that the API response will include.

Note that this method will override the existing values for all of the mutable properties that are contained in any parts that the parameter value specifies. For example, a video's privacy setting is contained in the statuspart. As such, if your request is updating a private video, and the request's part parameter value includes the status part, the video's privacy setting will be updated to whatever value the request body specifies. If the request body does not specify a value, the existing privacy setting will be removed and the video will revert to the default privacy setting.

In addition, not all parts contain properties that can be set when inserting or updating a video. For example, the statistics object encapsulates statistics that YouTube calculates for a video and does not contain values that you can set or modify. If the parameter value specifies a part that does not contain mutable values, that part will still be included in the API response.

The following list contains the part names that you can include in the parameter value and the quota cost for each part:

- contentDetails: 2 - fileDetails: 1 - id: 0

- liveStreamingDetails: 2 - localizations: 2

- player: 0

- processingDetails: 1

- recordingDetails: 2 - snippet: 2

- statistics: 2 - status: 2 - suggestions: 1 - topicDetails: 2 onBehalfOfContent

Owner

string This parameter can only be used in a properly authorized request. Note: This parameter is intended exclusively for

YouTube content partners.

The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner.

 Request Body (https://developers.google.com/youtube/v3/docs/videos/update#request-body)

Video resource (https://developers.google.com/youtube/v3/docs/videos#resource)

2.15.4 반환값

 Response Body에 Video resource 포함

(VideoResource, https://developers.google.com/youtube/v3/docs/videos#resource)

2.15.5 에러 코드

https://developers.google.com/youtube/v3/docs/videos/update#errors

HTTP 코드 에러 코드 에러 메시지

badRequest (400) defaultLanguageNotSet The request is trying to add localized video details without specifying the default language of the video details.

badRequest (400) invalidCategoryId The snippet.categoryId property specifies an

invalid category ID. Use

the videoCategories.list method to retrieve supported categories.

badRequest (400) invalidDescription The request metadata specifies an invalid video description.

badRequest (400) invalidFilename The video filename specified in the Slugheader is invalid.

badRequest (400) invalidPublishAt The request metadata specifies an invalid scheduled publishing time.

badRequest (400) invalidRecordingDetails The recordingDetailsobject in the request metadata specifies invalid recording details.

badRequest (400) invalidTags The request metadata specifies invalid video keywords.

badRequest (400) invalidTitle The request metadata specifies an invalid or empty video title.

badRequest (400) invalidVideoGameRating The request metadata specifies an invalid video game rating.

badRequest (400) invalidVideoMetadata The request metadata is invalid.

badRequest (400) mediaBodyRequired The request does not include the video content.

badRequest (400) uploadLimitExceeded The user has exceeded the number of videos they may upload.

forbidden (403) forbidden

forbidden (403) forbiddenLicenseSetting The request attempts to set an invalid license for the video.

forbidden (403) forbiddenPrivacySetting The request attempts to set an invalid privacy setting for the video.

NotFound (404) videoNotFound The video that you are trying to update cannot be found. Check the value of the id field in the request body to ensure that it is correct.

2.15.6 API 호출/결과 예시

호출 (Python)

#!/usr/bin/python

import httplib2 import os

import sys

from apiclient.discovery import build from apiclient.errors import HttpError

from oauth2client.client import flow_from_clientsecrets from oauth2client.file import Storage

from oauth2client.tools import argparser, run_flow

# The CLIENT_SECRETS_FILE variable specifies the name of a file that contains

# the OAuth 2.0 information for this application, including its client_id and

# client_secret. You can acquire an OAuth 2.0 client ID and client secret from

# the {{ Google Cloud Console }} at

# {{ https://cloud.google.com/console }}.

# Please ensure that you have enabled the YouTube Data API for your project.

# For more information about using OAuth2 to access the YouTube Data API, see:

# https://developers.google.com/youtube/v3/guides/authent ication

# For more information about the client_secrets.json file format, see:

# https://developers.google.com/api-client-library/python/guide/aaa_client_secrets CLIENT_SECRETS_FILE = "client_secrets.json"

# This OAuth 2.0 access scope allows for full read/write access to the

# authenticated user's account.

YOUTUBE_READ_WRITE_SCOPE =

"https://www.googleapis.com/auth/youtube"

YOUTUBE_API_SERVICE_NAME = "youtube"

YOUTUBE_API_VERSION = "v3"

# This variable defines a message to display if the CLIENT_SECRETS_FILE is

# missing.

MISSING_CLIENT_SECRETS_MESSAGE = """

WARNING: Please configure OAuth 2.0

To make this sample run you will need to populate the client_secrets.json file

found at:

%s

with information from the {{ Cloud Console }}

{{ https://cloud.google.com/console }}

For more information about the client_secrets.json file format, please visit:

https://developers.google.com/api-client-library/python/guide/aaa_client_secrets

""" %

os.path.abspath(os.path.join(os.path.dirname(__file__), CLIENT_SECRETS_FILE))

def get_authenticated_service(args):

flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE, scope=YOUTUBE_READ_WRITE_SCOPE,

message=MISSING_CLIENT_SECRETS_MESSAGE)

storage = Storage("%s-oauth2.json" % sys.argv[0]) credentials = storage.get()

if credentials is None or credentials.invalid:

credentials = run_flow(flow, storage, args)

return build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION,

http=credentials.authorize(httplib2.Http()))

def update_video(youtube, options):

# Call the API's videos.list method to retrieve the video resource.

videos_list_response = youtube.videos().list(

id=options.video_id, part='snippet'

).execute()

# 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." % options.video_id sys.exit(1)

# Since the request specified a video ID, the response only contains one

# video resource. This code extracts the snippet from that resource.

videos_list_snippet =

videos_list_response["items"][0]["snippet"]

# Preserve any tags already associated with the video. If the video does

# not have any tags, create a new array. Append the provided tag to the

# list of tags associated with the video.

if "tags" not in videos_list_snippet:

videos_list_snippet["tags"] = []

videos_list_snippet["tags"].append(options.tag)

# 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=options.video_id

)).execute()

if __name__ == "__main__":

argparser.add_argument("--video-id", help="ID of video to update.",

required=True)

argparser.add_argument("--tag", default="youtube", help="Additional tag to add to video.")

args = argparser.parse_args()

youtube = get_authenticated_service(args) try:

update_video(youtube, args) except HttpError, e: Select APPS SCRIPT

호출 (JAVA)

https://developers.google.com/youtube/v3/docs/videos/update#examples Select JAVA

결과 {

(JSON) "kind": "youtube#video", "etag": etag,

"id": string, "snippet": {

"publishedAt": datetime, "channelId": string, "title": string, "description": string, "thumbnails": { (key): { "url": string,

"width": unsigned integer, "height": unsigned integer }

},

"channelTitle": string, "tags": [

string ],

"categoryId": string,

"liveBroadcastContent": string, "defaultLanguage": string, "localized": {

"title": string, "description": string },

"defaultAudioLanguage": string },

"contentDetails": { "duration": string, "dimension": string, "definition": string, "caption": string,

"licensedContent": boolean, "regionRestriction": { "allowed": [

string ],

"blocked": [ string ] },

"contentRating": { "acbRating": string, "agcomRating": string, "anatelRating": string, "bbfcRating": string, "bfvcRating": string, "bmukkRating": string, "catvRating": string, "catvfrRating": string, "cbfcRating": string, "cccRating": string, "cceRating": string, "chfilmRating": string, "chvrsRating": string, "cicfRating": string, "cnaRating": string, "cncRating": string, "csaRating": string, "cscfRating": string, "czfilmRating": string, "djctqRating": string, "djctqRatingReasons": [, string

],

"ecbmctRating": string, "eefilmRating": string, "egfilmRating": string, "eirinRating": string, "fcbmRating": string, "fcoRating": string,

"fmocRating": string, "fpbRating": string, "fpbRatingReasons": [, string

],

"fskRating": string, "grfilmRating": string, "icaaRating": string, "ifcoRating": string, "ilfilmRating": string, "incaaRating": string, "kfcbRating": string, "kijkwijzerRating": string, "kmrbRating": string, "lsfRating": string, "mccaaRating": string, "mccypRating": string, "mcstRating": string, "mdaRating": string,

"medietilsynetRating": string, "mekuRating": string,

"mibacRating": string, "mocRating": string, "moctwRating": string, "mpaaRating": string, "mtrcbRating": string, "nbcRating": string, "nbcplRating": string, "nfrcRating": string, "nfvcbRating": string, "nkclvRating": string, "oflcRating": string, "pefilmRating": string, "rcnofRating": string,

"resorteviolenciaRating": string, "rtcRating": string,

"rteRating": string, "russiaRating": string, "skfilmRating": string, "smaisRating": string, "smsaRating": string, "tvpgRating": string, "ytRating": string },

"projection": string,

"hasCustomThumbnail": boolean },

"status": {

"uploadStatus": string, "failureReason": string, "rejectionReason": string, "privacyStatus": string, "publishAt": datetime, "license": string,

"embeddable": boolean, "publicStatsViewable": boolean },

"statistics": {

"viewCount": unsigned long, "likeCount": unsigned long, "dislikeCount": unsigned long, "favoriteCount": unsigned long, "commentCount": unsigned long },

"player": {

"embedHtml": string, "embedHeight": long, "embedWidth": long },

"topicDetails": { "topicIds": [ string

],

"relevantTopicIds": [ string

] },

"recordingDetails": {

"locationDescription": string, "location": {

"latitude": double, "longitude": double, "altitude": double },

"recordingDate": datetime },

"fileDetails": { "fileName": string, "fileSize": unsigned long, "fileType": string,

"container": string, "videoStreams": [ {

"widthPixels": unsigned integer, "heightPixels": unsigned integer, "frameRateFps": double,

"aspectRatio": double, "codec": string,

"bitrateBps": unsigned long, "rotation": string,

"vendor": string }

],

"audioStreams": [ {

"channelCount": unsigned integer, "codec": string,

"bitrateBps": unsigned long,

"vendor": string }

],

"durationMs": unsigned long, "bitrateBps": unsigned long, "creationTime": string },

"processingDetails": { "processingStatus": string, "processingProgress": { "partsTotal": unsigned long, "partsProcessed": unsigned long, "timeLeftMs": unsigned long },

"processingFailureReason": string, "fileDetailsAvailability": string, "processingIssuesAvailability": string, "tagSuggestionsAvailability": string, "editorSuggestionsAvailability": string, "thumbnailsAvailability": string

},

"suggestions": { "processingErrors": [ string

],

"processingWarnings": [ string

],

"processingHints": [ string

],

"tagSuggestions": [ {

"tag": string,

"categoryRestricts": [ string

] } ],

"editorSuggestions": [ string

] },

"liveStreamingDetails": { "actualStartTime": datetime, "actualEndTime": datetime, "scheduledStartTime": datetime, "scheduledEndTime": datetime, "concurrentViewers": unsigned long, "activeLiveChatId": string

},

"localizations": { (key): {

"title": string, "description": string }

} }

2.16 YouTube 동영상 삭제 API

문서에서 Open API 명세서 작성 가이드라인 (페이지 116-131)