我如何过滤视频从YouTube数据API v3被封锁在版权的理由



这是我的代码。

$videosResponse = $youtube->videos->listVideos('status, fileDetails, snippet, recordingDetails, topicDetails', array(
                            'id' => $id,
                            'maxResults' => 1,
                            'part' => 'status,snippet',
                          ));

这是响应

object(Google_Service_YouTube_VideoListResponse)#73 (16) {
          ["collection_key":protected]=>
          string(5) "items"
          ["internal_gapi_mappings":protected]=>
          array(0) {
          }
          ["etag"]=>
          string(57) ""fpJ9onbY0Rl_LqYLG6rOCJ9h9N8/lnLk97dQDMUpWh4EJfvVHiKXvG8""
          ["eventId"]=>
          NULL
          ["itemsType":protected]=>
          string(28) "Google_Service_YouTube_Video"
          ["itemsDataType":protected]=>
          string(5) "array"
          ["kind"]=>
          string(25) "youtube#videoListResponse"
          ["nextPageToken"]=>
          NULL
          ["pageInfoType":protected]=>
          string(31) "Google_Service_YouTube_PageInfo"
          ["pageInfoDataType":protected]=>
          string(0) ""
          ["prevPageToken"]=>
          NULL
          ["tokenPaginationType":protected]=>
          string(38) "Google_Service_YouTube_TokenPagination"
          ["tokenPaginationDataType":protected]=>
          string(0) ""
          ["visitorId"]=>
          NULL
          ["modelData":protected]=>
          array(2) {
            ["pageInfo"]=>
            array(2) {
              ["totalResults"]=>
              int(1)
              ["resultsPerPage"]=>
              int(1)
            }
            ["items"]=>
            array(1) {
              [0]=>
              array(5) {
                ["kind"]=>
                string(13) "youtube#video"
                ["etag"]=>
                string(57) ""fpJ9onbY0Rl_LqYLG6rOCJ9h9N8/NCacXkm79gLd-LDp1PS5m7Z_FFc""
                ["id"]=>
                string(11) "bdzxVW3zlZ0"
                ["snippet"]=>
                array(10) {
                  ["publishedAt"]=>
                  string(24) "2011-11-10T07:13:44.000Z"
                  ["channelId"]=>
                  string(24) "UColEueTkpUJjnDlaO-P14DQ"
                  ["title"]=>
                  string(32) "Leap of Faith Movie_Steve Martin"
                  ["description"]=>
                  string(82) "I created this video with the YouTube Video Editor (http://www.youtube.com/editor)"
                  ["thumbnails"]=>
                  array(4) {
                    ["default"]=>
                    array(3) {
                      ["url"]=>
                      string(46) "https://i.ytimg.com/vi/bdzxVW3zlZ0/default.jpg"
                      ["width"]=>
                      int(120)
                      ["height"]=>
                      int(90)
                    }
                    ["medium"]=>
                    array(3) {
                      ["url"]=>
                      string(48) "https://i.ytimg.com/vi/bdzxVW3zlZ0/mqdefault.jpg"
                      ["width"]=>
                      int(320)
                      ["height"]=>
                      int(180)
                    }
                    ["high"]=>
                    array(3) {
                      ["url"]=>
                      string(48) "https://i.ytimg.com/vi/bdzxVW3zlZ0/hqdefault.jpg"
                      ["width"]=>
                      int(480)
                      ["height"]=>
                      int(360)
                    }
                    ["standard"]=>
                    array(3) {
                      ["url"]=>
                      string(48) "https://i.ytimg.com/vi/bdzxVW3zlZ0/sddefault.jpg"
                      ["width"]=>
                      int(640)
                      ["height"]=>
                      int(480)
                    }
                  }
                  ["channelTitle"]=>
                  string(10) "nenbanogon"
                  ["tags"]=>
                  array(1) {
                    [0]=>
                    string(14) "YouTube editor"
                  }
                  ["categoryId"]=>
                  string(2) "24"
                  ["liveBroadcastContent"]=>
                  string(4) "none"
                  ["localized"]=>
                  array(2) {
                    ["title"]=>
                    string(32) "Leap of Faith Movie_Steve Martin"
                    ["description"]=>
                    string(82) "I created this video with the YouTube Video Editor (http://www.youtube.com/editor)"
                  }
                }
                ["status"]=>
                array(5) {
                  ["uploadStatus"]=>
                  string(9) "processed"
                  ["privacyStatus"]=>
                  string(6) "public"
                  ["license"]=>
                  string(7) "youtube"
                  ["embeddable"]=>
                  bool(true)
                  ["publicStatsViewable"]=>
                  bool(true)
                }
              }
            }
          }
          ["processed":protected]=>
          array(0) {
          }
        }

在响应对象中有一个'状态'数组,我可以过滤私有和不可嵌入的视频

    ["status"]=>
    array(5) {
      ["uploadStatus"]=>
      string(9) "processed"
      ["privacyStatus"]=>
      string(6) "public"
      ["license"]=>
      string(7) "youtube"
      ["embeddable"]=>
      bool(true)
      ["publicStatsViewable"]=>
      bool(true)
    }

但是我不能过滤那些因为版权原因被屏蔽的视频。

这里是类似的问题我如何过滤视频从YouTube数据API v3

您可以根据regionRestriction属性进行筛选。

请尝试使用安全搜索。

$videosResponse = $youtube->videos->listVideos('status, fileDetails, snippet, recordingDetails, topicDetails', array(
                        'id' => $id,
                        'maxResults' => 1,
                        'part' => 'status,snippet',
                        'safeSearch' => 'strict',
                      ));

相关内容

  • 没有找到相关文章

最新更新