YouTube Content ID सेवा

YouTube Content ID सेवा की मदद से, Apps Script में YouTube Content ID API का इस्तेमाल किया जा सकता है. इस एपीआई की मदद से डेवलपर, YouTube के Content ID के अधिकारों को मैनेज करने वाले सिस्टम के साथ सीधे तौर पर इंटरैक्ट कर सकते हैं. YouTube पार्टनर के तौर पर, एपीआई का इस्तेमाल करके अपनी ऐसेट, दावे, और कैंपेन बनाए और मैनेज किए जा सकते हैं.

रेफ़रंस

इस सेवा के बारे में ज़्यादा जानकारी के लिए, YouTube Content ID API के रेफ़रंस दस्तावेज़ देखें. Apps Script की सभी ऐडवांस सेवाओं की तरह, YouTube Content ID की ऐडवांस सेवा भी सार्वजनिक एपीआई के ऑब्जेक्ट, तरीकों, और पैरामीटर का इस्तेमाल करती है. ज़्यादा जानकारी के लिए, तरीके के सिग्नेचर कैसे तय किए जाते हैं लेख पढ़ें.

समस्याओं की शिकायत करने और अन्य सहायता पाने के लिए, YouTube API की सहायता गाइड देखें.

नमूना कोड

यहां दिए गए सैंपल कोड में, YouTube Content ID API के वर्शन 1 का इस्तेमाल किया गया है.

अपने वीडियो पर दावा करना

इस फ़ंक्शन की मदद से, आपकी वीडियो पर पार्टनर के ज़रिए अपलोड किया गया दावा बनाया जाता है. इसमें ऐसेट और नीति के नियमों के बारे में जानकारी दी जाती है.

advanced/youtubeContentId.gs
/**
 * 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
 */
function claimYourVideoWithMonetizePolicy() {
  // The ID of the content owner that you are acting on behalf of.
  const onBehalfOfContentOwner = 'replaceWithYourContentOwnerID';
  // A YouTube video ID to claim. In this example, the video must be uploaded
  // to one of your onBehalfOfContentOwner's linked channels.
  const videoId = 'replaceWithYourVideoID';
  const assetId = 'replaceWithYourAssetID';
  const claimToInsert = {
    '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 {
    const claimInserted = 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);
  }
}

ऐसेट के मालिकाना हक की जानकारी अपडेट करना

यह फ़ंक्शन, किसी मौजूदा ऐसेट पर आपके मालिकाना हक को अपडेट करता है.

advanced/youtubeContentId.gs
/**
 * This function updates your onBehalfOfContentOwner's ownership on an existing
 * asset.
 * @see https://developers.google.com/youtube/partner/docs/v1/ownership/update
 */
function updateAssetOwnership() {
  // The ID of the content owner that you are acting on behalf of.
  const onBehalfOfContentOwner = 'replaceWithYourContentOwnerID';
  // Replace values with your asset id
  const assetId = 'replaceWithYourAssetID';
  // The new ownership here would replace your existing ownership on the asset.
  const myAssetOwnership = {
    'general': [
      {
        'ratio': 100,
        'owner': onBehalfOfContentOwner,
        'type': 'include',
        'territories': [
          'US',
          'CA'
        ]
      }
    ]
  };
  try {
    const updatedOwnership = 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);
  }
}

दावा वापस लेना

इस फ़ंक्शन से, किसी वीडियो पर किए गए मौजूदा दावे को रिलीज़ किया जाता है.

advanced/youtubeContentId.gs
/**
 * This function releases an existing claim your onBehalfOfContentOwner has
 * on a video.
 * @see https://developers.google.com/youtube/partner/docs/v1/claims/patch
 */
function releaseClaim() {
  // The ID of the content owner that you are acting on behalf of.
  const onBehalfOfContentOwner = 'replaceWithYourContentOwnerID';
  // The ID of the claim to be released.
  const claimId = 'replaceWithYourClaimID';
  // To release the claim, change the resource's status to inactive.
  const claimToBeReleased = {
    'status': 'inactive'
  };
  try {
    const claimReleased = 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);
  }
}