<i id='PKfRY'><tr id='PKfRY'><dt id='PKfRY'><q id='PKfRY'><span id='PKfRY'><b id='PKfRY'><form id='PKfRY'><ins id='PKfRY'></ins><ul id='PKfRY'></ul><sub id='PKfRY'></sub></form><legend id='PKfRY'></legend><bdo id='PKfRY'><pre id='PKfRY'><center id='PKfRY'></center></pre></bdo></b><th id='PKfRY'></th></span></q></dt></tr></i><div id='PKfRY'><tfoot id='PKfRY'></tfoot><dl id='PKfRY'><fieldset id='PKfRY'></fieldset></dl></div>
    • <bdo id='PKfRY'></bdo><ul id='PKfRY'></ul>

    <small id='PKfRY'></small><noframes id='PKfRY'>

  • <legend id='PKfRY'><style id='PKfRY'><dir id='PKfRY'><q id='PKfRY'></q></dir></style></legend>

      <tfoot id='PKfRY'></tfoot>

        YouTube API v3 返回截断的观看记录

        YouTube API v3 returns truncated watch history(YouTube API v3 返回截断的观看记录)
            • <bdo id='3NutN'></bdo><ul id='3NutN'></ul>
              <tfoot id='3NutN'></tfoot>

              <small id='3NutN'></small><noframes id='3NutN'>

                <tbody id='3NutN'></tbody>

                <legend id='3NutN'><style id='3NutN'><dir id='3NutN'><q id='3NutN'></q></dir></style></legend>

                <i id='3NutN'><tr id='3NutN'><dt id='3NutN'><q id='3NutN'><span id='3NutN'><b id='3NutN'><form id='3NutN'><ins id='3NutN'></ins><ul id='3NutN'></ul><sub id='3NutN'></sub></form><legend id='3NutN'></legend><bdo id='3NutN'><pre id='3NutN'><center id='3NutN'></center></pre></bdo></b><th id='3NutN'></th></span></q></dt></tr></i><div id='3NutN'><tfoot id='3NutN'></tfoot><dl id='3NutN'><fieldset id='3NutN'></fieldset></dl></div>
                  本文介绍了YouTube API v3 返回截断的观看记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我可以通过 YouTube v3 数据 API 访问我的观看历史记录,但它只返回我最近的 30 个视频(尽管我在 YouTube.com 上查看观看历史记录时会看到更多视频).

                  I'm able to access my watch history via the YouTube v3 data API, but it only returns my most recent 30 videos (though I see many more when I view the Watch History on YouTube.com).

                  然后当我看另一个视频时,它返回31.当我看另一个时,32.如果它可以返回超过30,为什么它原来没有返回更多?我知道 API 可能有限制,但为什么从 30 开始然后增长呢?有了分页,真的不应该有限制,对吧?

                  And then when I watch another video, it returns 31. When I watch another, 32. If it can return more than 30, why didn't it return more originally? I understand that the API might have a limit, but why start at 30 then grow? And with paging, there really shouldn't be a limit, right?

                  我一定是做错了什么.这是我的代码:

                  I must be doing something wrong. Here's my code:

                  def getWatchHistory(youtube):
                      playlistId = getWatchHistoryPlaylistId(youtube)
                      videos = retrieveVideos(youtube, playlistId);
                      return videos # Only returns 30, 31, 32 videos, etc. though I have many more in my History
                  
                  def getWatchHistoryPlaylistId(youtube):
                      channels_response = youtube.channels().list(
                          part="contentDetails",
                          mine=True,
                      ).execute()
                  
                      channel = channels_response["items"][0]
                  
                      playlistId = channel["contentDetails"]["relatedPlaylists"]["watchHistory"]
                      return playlistId
                  
                  def retrieveVideos(youtube, playlistId, nextPageToken=None):
                      # Search the specified playlist and list all videos
                      playlistItems_response = youtube.playlistItems().list(
                          part="snippet,contentDetails",
                          playlistId=playlistId,
                          maxResults=50,
                          pageToken=nextPageToken
                      ).execute()
                  
                      results = []
                      for x in playlistItems_response["items"]:
                          videoTitle = x["snippet"]["title"]
                          videoId = x["contentDetails"]["videoId"]
                          videoSpec = videoId + ": " + videoTitle
                          print 'adding to results: ' + videoSpec
                          results.append(videoSpec)
                  
                      if ("nextPageToken" in playlistItems_response):
                          pageToken = playlistItems_response["nextPageToken"]
                          results.extend(retrieveVideos(youtube, playlistId, pageToken));
                          return results
                      else:
                          return results
                  

                  推荐答案

                  更新:自 2016 年 9 月 15 日起,watchHistory 不再以任何身份提供,因此很遗憾,现在已无关紧要.

                  这似乎是 2013 年最初报告的已知错误.在 Google 代码线程中解释了完全相同的行为:https://code.google.com/p/gdata-issues/issues/detail?id=4642

                  我得到了结果,但就像一些海报一样,它们是最近的视频(可能是一天的价值).我似乎找不到任何关于检索时间限制的文档.任何人都找到了解决方法或想通了历史可用多长时间?"(最近对该主题的评论)

                  "I get back results but like a few posters up, they are very recent videos (possibly a day's worth). I can't seem to find any documentation on a time limit for retrieval. Anybody found a workaround or figured out how long the history is available?" (recent comment on the thread)

                  在 Google 决定解决此问题之前,我似乎很不走运.希望有人证明我(以及该 Google 代码线程中的其他人)是错误的.

                  Looks like I'm out of luck until Google decides to fix this. Hopefully someone proves me (and everone else in that Google Code thread) wrong.

                  这篇关于YouTube API v3 返回截断的观看记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                  How to extend Python class init(如何扩展 Python 类初始化)
                  What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                  What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                  Initialize list with same bool value(使用相同的布尔值初始化列表)
                  setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)
                    <tbody id='qr1d6'></tbody>

                      <small id='qr1d6'></small><noframes id='qr1d6'>

                      <i id='qr1d6'><tr id='qr1d6'><dt id='qr1d6'><q id='qr1d6'><span id='qr1d6'><b id='qr1d6'><form id='qr1d6'><ins id='qr1d6'></ins><ul id='qr1d6'></ul><sub id='qr1d6'></sub></form><legend id='qr1d6'></legend><bdo id='qr1d6'><pre id='qr1d6'><center id='qr1d6'></center></pre></bdo></b><th id='qr1d6'></th></span></q></dt></tr></i><div id='qr1d6'><tfoot id='qr1d6'></tfoot><dl id='qr1d6'><fieldset id='qr1d6'></fieldset></dl></div>
                        <bdo id='qr1d6'></bdo><ul id='qr1d6'></ul>

                          <legend id='qr1d6'><style id='qr1d6'><dir id='qr1d6'><q id='qr1d6'></q></dir></style></legend>
                          <tfoot id='qr1d6'></tfoot>