Are upload playlists on Youtube API v3 purpsofully slow to be updated?

此生再无相见时 提交于 2019-12-24 10:34:49

问题


I have a line of python code in my bot:

    playlist_snippet = self.youtube.playlistItems().list(
        playlistId=playlistId, part='snippet',
        maxResults=50, pageToken=next_page_token
        ).execute()

The playlistId is the id of the user upload playlist. I've noticed that this seems to be updated 10 - 50 mins after the playlist is updated on the youtube website and also the equivalent API v2 call.

Is there a better API call to make? Is this purposefully untimely?

p.s. for anyone interested this is my code: https://github.com/notatallshaw/arandabot/blob/master/ytvideos.py

Edit: The more I test this the more I get examples of it taking over an hour to update the user upload playist via API v3 vs. the website or API v2.


回答1:


Yep I have noticed this to, I run a bot that is pretty reliant on speed and this is the only reason I have been using v2 instead of v3, v3 is so god damn slow. But now that Google is shutting down v2 it's time to move. The fastest endpoint i've found in v3 is the search one, it usually takes like 60-120 seconds to update(the v2 uploads endpoint updated immediately)

Use it like this:

https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&order=date&channelId={channelId}&key={api_key}

and it will give you the latest upload from the specified channel. Also, having:'Cache-Control': 'max-age=0, no-cache' in your headers helps a good bit too.



来源:https://stackoverflow.com/questions/29204271/are-upload-playlists-on-youtube-api-v3-purpsofully-slow-to-be-updated

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