YouTube Data API search not honoring publish after date

自古美人都是妖i 提交于 2019-11-27 07:17:56

问题


I have this query

    YouTube.Search.List search = youtube.search().list("id");
    search.setOrder("viewCount");
    search.setMaxResults(50);
    search.setPublishedAfter(new DateTime(publishedAfterDate));
    search.setPublishedBefore(new DateTime(new Date()));
    search.setType("video");
    search.setKey(getYoutubeKey());

Which was working perfectly fine up until a few months ago. Then, all of a sudden it seems that Google must have changed something in their data API and the "PublishedAfter" date is no longer being honored.

I checked in a debugger and the value of "publishedAfterDate" resolves just fine. My query for videos published after one week ago is now returning videos from a year ago. There are no errors or anything of that sort, the API just doesn't return the correct results when the same exact code was working perfectly fine a few months ago.

Any ideas?

Live demo

Full source

Another weird tidbit, on the live demo if you click "All Time", you'll notice that the data API is even returning the same videos more than once. This is very weird and also didn't used to happen a few months ago.


回答1:


This issue is related to the following ones:

  • Order doesn't work when using youtube API v3;
  • publishedAfter parameter appears to be broken now;
  • Youtube Data API v3: Sort by date not working

See also Google's issue #128673552, https://issuetracker.google.com/issues/128673552.



来源:https://stackoverflow.com/questions/55215467/youtube-data-api-search-not-honoring-publish-after-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!