/** * This function creates a partner-uploaded claim on a video with the specified * asset and policy rules. * @see https://developers.google.com/youtube/partner/docs/v1/claims/insert */functionclaimYourVideoWithMonetizePolicy(){// The ID of the content owner that you are acting on behalf of.constonBehalfOfContentOwner='replaceWithYourContentOwnerID';// A YouTube video ID to claim. In this example, the video must be uploaded// to one of your onBehalfOfContentOwner's linked channels.constvideoId='replaceWithYourVideoID';constassetId='replaceWithYourAssetID';constclaimToInsert={'videoId':videoId,'assetId':assetId,'contentType':'audiovisual',// Set the claim policy to monetize. You can also specify a policy ID here// instead of policy rules.// For details, please refer to the YouTube Content ID API Policies// documentation:// https://developers.google.com/youtube/partner/docs/v1/policies'policy':{'rules':[{'action':'monetize'}]}};try{constclaimInserted=YouTubeContentId.Claims.insert(claimToInsert,{'onBehalfOfContentOwner':onBehalfOfContentOwner});console.log('Claim created on video %s: %s',videoId,claimInserted);}catch(e){console.log('Failed to create claim on video %s, error: %s',videoId,e.message);}}
/** * This function updates your onBehalfOfContentOwner's ownership on an existing * asset. * @see https://developers.google.com/youtube/partner/docs/v1/ownership/update */functionupdateAssetOwnership(){// The ID of the content owner that you are acting on behalf of.constonBehalfOfContentOwner='replaceWithYourContentOwnerID';// Replace values with your asset idconstassetId='replaceWithYourAssetID';// The new ownership here would replace your existing ownership on the asset.constmyAssetOwnership={'general':[{'ratio':100,'owner':onBehalfOfContentOwner,'type':'include','territories':['US','CA']}]};try{constupdatedOwnership=YouTubeContentId.Ownership.update(myAssetOwnership,assetId,{'onBehalfOfContentOwner':onBehalfOfContentOwner});console.log('Ownership updated on asset %s: %s',assetId,updatedOwnership);}catch(e){console.log('Ownership update failed on asset %s, error: %s',assetId,e.message);}}
/** * This function releases an existing claim your onBehalfOfContentOwner has * on a video. * @see https://developers.google.com/youtube/partner/docs/v1/claims/patch */functionreleaseClaim(){// The ID of the content owner that you are acting on behalf of.constonBehalfOfContentOwner='replaceWithYourContentOwnerID';// The ID of the claim to be released.constclaimId='replaceWithYourClaimID';// To release the claim, change the resource's status to inactive.constclaimToBeReleased={'status':'inactive'};try{constclaimReleased=YouTubeContentId.Claims.patch(claimToBeReleased,claimId,{'onBehalfOfContentOwner':onBehalfOfContentOwner});console.log('Claim %s was released: %s',claimId,claimReleased);}catch(e){console.log('Failed to release claim %s, error: %s',claimId,e.message);}}
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eThe YouTube Content ID API allows YouTube partners to manage their copyrighted content and rights through Apps Script.\u003c/p\u003e\n"],["\u003cp\u003eThis advanced service requires prior enabling and is exclusively available to YouTube content partners via the Google Developers Console.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use the API to automate tasks like claiming videos, updating asset ownership, and releasing claims, streamlining content management workflows.\u003c/p\u003e\n"],["\u003cp\u003eThe provided sample code demonstrates how to utilize the YouTube Content ID API for these tasks, offering practical examples for implementation.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the reference documentation and YouTube API support guide for detailed information and troubleshooting assistance.\u003c/p\u003e\n"]]],[],null,["# YouTube Content ID Service\n\nThe YouTube Content ID service allows you to use the\n[YouTube Content ID API](/youtube/partner) in Apps Script. This API lets developers interact\ndirectly with YouTube's Content ID rights management system.\nAs a YouTube partner, you can use the API to create and manage your assets, claims and campaigns.\n| **Warning:** The YouTube Content ID API is intended for use by YouTube content partners and is not accessible to all developers or to all YouTube users. If you do not see the YouTube Content ID API as one of the services listed in the [Google Developers Console](https://console.developers.google.com), you can consider joining the [YouTube Partner Program](https://support.google.com/youtube/answer/72851).\n| **Note:** This is an advanced service that must be [enabled before use](/apps-script/guides/services/advanced).\n\nReference\n---------\n\nFor detailed information on this service, see the\n[reference documentation](/youtube/partner/docs/v1) for the public YouTube Content ID API. Like\nall advanced services in Apps Script, the advanced YouTube Content ID service uses the same objects,\nmethods, and parameters as the public API. For more information, see [How method signatures are determined](/apps-script/guides/services/advanced#how_method_signatures_are_determined).\n\nTo report issues and find other support, see the\n[YouTube API support guide](/youtube/v3/support).\n\nSample code\n-----------\n\nThe sample code below uses [version 1](/youtube/partner/docs/v1) of the YouTube Content ID API.\n\n### Claim your video\n\nThis function creates a partner-uploaded claim on your video with the specified asset and policy\nrules. \nadvanced/youtubeContentId.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/youtubeContentId.gs) \n\n```javascript\n/**\n * This function creates a partner-uploaded claim on a video with the specified\n * asset and policy rules.\n * @see https://developers.google.com/youtube/partner/docs/v1/claims/insert\n */\nfunction claimYourVideoWithMonetizePolicy() {\n // The ID of the content owner that you are acting on behalf of.\n const onBehalfOfContentOwner = 'replaceWithYourContentOwnerID';\n // A YouTube video ID to claim. In this example, the video must be uploaded\n // to one of your onBehalfOfContentOwner's linked channels.\n const videoId = 'replaceWithYourVideoID';\n const assetId = 'replaceWithYourAssetID';\n const claimToInsert = {\n 'videoId': videoId,\n 'assetId': assetId,\n 'contentType': 'audiovisual',\n // Set the claim policy to monetize. You can also specify a policy ID here\n // instead of policy rules.\n // For details, please refer to the YouTube Content ID API Policies\n // documentation:\n // https://developers.google.com/youtube/partner/docs/v1/policies\n 'policy': {'rules': [{'action': 'monetize'}]}\n };\n try {\n const claimInserted = YouTubeContentId.Claims.insert(claimToInsert,\n {'onBehalfOfContentOwner': onBehalfOfContentOwner});\n console.log('Claim created on video %s: %s', videoId, claimInserted);\n } catch (e) {\n console.log('Failed to create claim on video %s, error: %s',\n videoId, e.message);\n }\n}\n```\n\n### Update asset ownership\n\nThis function updates your ownership on an existing asset. \nadvanced/youtubeContentId.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/youtubeContentId.gs) \n\n```javascript\n/**\n * This function updates your onBehalfOfContentOwner's ownership on an existing\n * asset.\n * @see https://developers.google.com/youtube/partner/docs/v1/ownership/update\n */\nfunction updateAssetOwnership() {\n // The ID of the content owner that you are acting on behalf of.\n const onBehalfOfContentOwner = 'replaceWithYourContentOwnerID';\n // Replace values with your asset id\n const assetId = 'replaceWithYourAssetID';\n // The new ownership here would replace your existing ownership on the asset.\n const myAssetOwnership = {\n 'general': [\n {\n 'ratio': 100,\n 'owner': onBehalfOfContentOwner,\n 'type': 'include',\n 'territories': [\n 'US',\n 'CA'\n ]\n }\n ]\n };\n try {\n const updatedOwnership = YouTubeContentId.Ownership.update(myAssetOwnership,\n assetId, {'onBehalfOfContentOwner': onBehalfOfContentOwner});\n console.log('Ownership updated on asset %s: %s', assetId, updatedOwnership);\n } catch (e) {\n console.log('Ownership update failed on asset %s, error: %s',\n assetId, e.message);\n }\n}\n```\n\n### Release a claim\n\nThis function releases an existing claim you have on a video. \nadvanced/youtubeContentId.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/youtubeContentId.gs) \n\n```javascript\n/**\n * This function releases an existing claim your onBehalfOfContentOwner has\n * on a video.\n * @see https://developers.google.com/youtube/partner/docs/v1/claims/patch\n */\nfunction releaseClaim() {\n // The ID of the content owner that you are acting on behalf of.\n const onBehalfOfContentOwner = 'replaceWithYourContentOwnerID';\n // The ID of the claim to be released.\n const claimId = 'replaceWithYourClaimID';\n // To release the claim, change the resource's status to inactive.\n const claimToBeReleased = {\n 'status': 'inactive'\n };\n try {\n const claimReleased = YouTubeContentId.Claims.patch(claimToBeReleased,\n claimId, {'onBehalfOfContentOwner': onBehalfOfContentOwner});\n console.log('Claim %s was released: %s', claimId, claimReleased);\n } catch (e) {\n console.log('Failed to release claim %s, error: %s', claimId, e.message);\n }\n}\n```"]]