【问题标题】:How to handle youtube deleted videos using youtube api from json request如何使用来自 json 请求的 youtube api 处理 youtube 删除的视频
【发布时间】:2013-02-16 17:25:59
【问题描述】:

我想使用 json 请求从 youtube api 获取 youtube 视频。现在我使用 json 从 youtube 获取视频。例如,网址中有一些已删除的视频(http://www.youtube.com/watch?v=MlOHWLqgcoY&list=PLD62D6701B15FD3E1),但我只播放视频而不是删除的视频。是否有可能或任何其他方式使用 json 结果处理 youtube 删除的视频。

这是我获取 youtube 视频的代码

string getPlaylistVideoUrl = https://gdata.youtube.com/feeds/api/playlists/PLD62D6701B15FD3E1?v=2&safeSearch=strict&orderby=position&start-index=1&max-results=25&alt=json;
var webRequest = (HttpWebRequest)WebRequest.Create(getPlaylistVideoUrl);
using (WebResponse response=await webRequest.GetResponseAsync())
using (Stream responseStream=response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
{
   var jsonResult = reader.ReadToEnd();
   var videosList = JsonConvert.DeserializeObject<YouTubeVideosByPlaylist>(jsonResult);
   if (videosList.Feed != null)
   {
      if (videosList.Feed.Entry != null)
      {
           //Add entries to class
      }
}

提前致谢。

【问题讨论】:

    标签: windows-8 microsoft-metro youtube-api jsonresult youtube-channels


    【解决方案1】:

    来自 Google 文档“如果视频不可播放,则该视频的条目将不包含 标签。此外,该条目可能包含 标签,其中包含对为什么视频无法播放”

    https://developers.google.com/youtube/2.0/developers_guide_protocol_testing

    【讨论】:

      【解决方案2】:

      我解决了 youtube 删除视频的问题。如果您在 youtube api Url 中获得 format=6 的播放列表。

      string getPlaylistVideoUrl = https://gdata.youtube.com/feeds/api/playlists/PLD62D6701B15FD3E1?v=2&safeSearch=strict&orderby=position&start-index=1&max-results=25&alt=json&format=6;
      

      【讨论】:

        【解决方案3】:

        在使用数据 API v2 检索时,无法播放的视频通常会在其 JSON 响应中设置 app$control 元素。以下是在响应 JSON 中查找内容的示例:

        "app$control": {
         "app$draft": {
          "$t": "yes"
         },
         "yt$state": {
          "$t": "This video is not available in your region.",
          "name": "restricted",
          "reasonCode": "requesterRegion"
         }
        }
        

        other reasons 为何视频在给定的播放场景中可能无法播放,因此缺少app$control 并不能确保视频始终可以播放。但如果app$control存在,则视频无法播放。

        【讨论】:

          猜你喜欢
          • 2012-01-02
          • 1970-01-01
          • 2020-11-17
          • 2015-12-11
          • 2018-11-30
          • 2015-02-16
          • 2018-08-01
          • 1970-01-01
          • 2015-01-03
          相关资源
          最近更新 更多