youtube - 有什么方法可以避免在搜索结果中获取带有 “sign in to confirm your age”的视频?

标签 youtube youtube-api youtube-data-api

如果我没有登录youtube,则当我们单击以播放某些视频时,我们会显示消息“登录以确认您的年龄”。
在这些视频的页面中,我们的分类刚刚超过类别:
“注意有年龄限制的视频(基于社区准则)”。

我的问题是:正如我们可以在搜索中设置一些参数一样,这些参数与我们正在搜索的视频(例如时长等)有关。有什么办法可以避免在搜索结果中出现此类视频?

具有年龄限制的视频样本:
https://www.youtube.com/watch?v=txKsYpYtxq4

(必须不记录)

提前致谢。

更新

寻找有关此视频的信息,我得到以下信息:

响应

{  
   "kind":"youtube#videoListResponse",
   "etag":"\"XI7nbFXulYBIpL0ayR_gDh3eu1k/QZtBV_JWvHNT9ClkQ0eYuktRtbA\"",
   "pageInfo":{  
      "totalResults":1,
      "resultsPerPage":1
   },
   "items":[  
      {  
         "kind":"youtube#video",
         "etag":"\"XI7nbFXulYBIpL0ayR_gDh3eu1k/f87eqCBLTBWB7VX3U7MeBERp-P0\"",
         "id":"txKsYpYtxq4",
         "snippet":{  
            "publishedAt":"2017-05-30T19:39:53.000Z",
            "channelId":"UCcepdparhCfkNMZGzhKyZYA",
            "title":"DJ Scuff - Plakiti (Pla Pla) NUEVA VAINA",
            "description":"PARA CONTRATACIONES: 809-907-4426 O 646-932-3378\n\nMP3: https://app.box.com/s/iv4bnfjbdo48xt4c6a2b0dip5nydzh3s",
            "thumbnails":{  
               "default":{  
                  "url":"https://i.ytimg.com/vi/txKsYpYtxq4/default.jpg",
                  "width":120,
                  "height":90
               },
               "medium":{  
                  "url":"https://i.ytimg.com/vi/txKsYpYtxq4/mqdefault.jpg",
                  "width":320,
                  "height":180
               },
               "high":{  
                  "url":"https://i.ytimg.com/vi/txKsYpYtxq4/hqdefault.jpg",
                  "width":480,
                  "height":360
               },
               "standard":{  
                  "url":"https://i.ytimg.com/vi/txKsYpYtxq4/sddefault.jpg",
                  "width":640,
                  "height":480
               },
               "maxres":{  
                  "url":"https://i.ytimg.com/vi/txKsYpYtxq4/maxresdefault.jpg",
                  "width":1280,
                  "height":720
               }
            },
            "channelTitle":"djscuff",
            "tags":[  
               "dj",
               "scuff",
               "mezcla",
               "fiesta",
               "urbano",
               "dembow",
               "latino",
               "latin",
               "party",
               "plakiti",
               "nueva",
               "vaina"
            ],
            "categoryId":"10",
            "liveBroadcastContent":"none",
            "localized":{  
               "title":"DJ Scuff - Plakiti (Pla Pla) NUEVA VAINA",
               "description":"PARA CONTRATACIONES: 809-907-4426 O 646-932-3378\n\nMP3: https://app.box.com/s/iv4bnfjbdo48xt4c6a2b0dip5nydzh3s"
            }
         },
         "contentDetails":{  
            "duration":"PT2M15S",
            "dimension":"2d",
            "definition":"hd",
            "caption":"false",
            "licensedContent":true,
            "contentRating":{  
               "ytRating":"ytAgeRestricted"
            },
            "projection":"rectangular"
         }
      }
   ]
}

在底部,我可以看到:

"contentRating": { "ytRating": "ytAgeRestricted" }



当我使用以下代码搜索此特定视频时:
https://www.googleapis.com/youtube/v3/search?part=snippet&q=txKsYpYtxq4&key=MY_KEY

我得到匹配查询的视频。

问题是:是否有任何参数可用于排除所有具有contentRating“ytAgeRestricted”的视频?

还是独特的方式是在搜索后一一询问?

最佳答案

search.list方法中的q参数将对视频的标题和描述进行全文搜索。

q string

The q parameter specifies the query term to search for.

Your request can also use the Boolean NOT (-) and OR (|) operators to exclude videos or to find videos that are associated with one of several search terms. For example, to search for videos matching either "boating" or "sailing", set the q parameter value to boating|sailing. Similarly, to search for videos matching either "boating" or "sailing" but not "fishing", set the q parameter value to boating|sailing -fishing. Note that the pipe character must be URL-escaped when it is sent in your API request. The URL-escaped value for the pipe character is %7C.


search.list方法没有用于限制ytAgeRestricted的参数。但是,有一种名为safeSearch的方法可能有效,但我无法找到有关此方法的确切信息,这与我怀疑的PG等级有关
IMO这可能很有用,您可能要考虑将此添加为功能请求Youtube issue forum

关于youtube - 有什么方法可以避免在搜索结果中获取带有 “sign in to confirm your age”的视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51998777/

相关文章:

node.js - 使用现有凭据向 youtube 数据 api 发出请求

javascript - YouTube嵌入了react控件,播放onclick

android - Youtube API或其他不允许使用的API

javascript - 使用 HTTP GET 请求返回对象未定义

java - 使用服务帐户的 Youtube 视频 ID - 收到错误 403 响应

javascript - YouTube JS API : play by random time point on button click

node.js - 使用 node.js 将视频上传到 youtube

python - 将文件上传到 YouTube 时出现 404 错误

ios - 谷歌 API : YouTube video uplaod error = 403

python - Python 3.4 中的 YouTube API UnicodeEncodeError