خدمة Content ID في YouTube

تتيح لك خدمة Content ID في YouTube استخدام YouTube Content ID API في "برمجة التطبيقات". تتيح واجهة برمجة التطبيقات هذه للمطوّرين التفاعل مباشرةً مع نظام إدارة الحقوق في Content ID على YouTube. بصفتك أحد شركاء YouTube، يمكنك استخدام واجهة برمجة التطبيقات لإنشاء مواد العرض والمطالبات والحملات وإدارتها.

مَراجع

للحصول على معلومات مفصّلة حول هذه الخدمة، يُرجى مراجعة المستندات المرجعية حول واجهة برمجة تطبيقات Content ID المتاحة للجميع في YouTube. على غرار جميع الخدمات المتقدّمة في "برمجة التطبيقات"، تستخدم خدمة Content ID المتقدّمة في YouTube العناصر والطرق والمعلَمات نفسها المستخدَمة في واجهة برمجة التطبيقات العامة. لمزيد من المعلومات، يُرجى الاطّلاع على كيفية تحديد توقيعات الطرق.

للإبلاغ عن المشاكل والعثور على خدمات دعم أخرى، يُرجى مراجعة دليل دعم واجهة برمجة تطبيقات YouTube.

نموذج التعليمات البرمجية

يستخدم الرمز النموذجي أدناه الإصدار 1 من YouTube Content ID API.

المطالبة بالفيديو

تنشئ هذه الدالة مطالبة حمّلها أحد الشركاء بملكية الفيديو الخاص بك يتضمّن قواعد مادة العرض والسياسات المحدّدة.

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);
  }
}