Are upload playlists on Youtube API v3 purpsofully

2019-08-12 22:17发布

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条回答
Explosion°爆炸
2楼-- · 2019-08-12 22:49

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.

查看更多
登录 后发表回答