I'm trying to get a list of all recent Youtube uploads using Python and API v3.0. I'm using youtube.search().list, but the results were all uploaded at seemingly random times in the last few years, and are not ordered by date. I've attached a sample of my code.
def getSearchResults():
""" Perform an empty search """
search_results = youtube.search().list(
part="snippet",
order="date",
maxResults=50,
type="video",
q=""
).execute()
return search_results
def getVideoDetails(video):
""" Get details of search results """
video_id = video["id"]["videoId"]
video_title = video["snippet"]["title"]
video_date = video["snippet"]["publishedAt"]
return video_id, video_title, video_date
search_results = getSearchResults()
for result in search_results["items"]:
print getVideoDetails(result)
Any help is greatly appreciated!
EDIT: After retrying a few times, sometimes I will get the correct output (the most recently uploaded videos sorted by upload date) and sometimes I won't (resulting in videos from seemingly random times). I have no idea what the result depends on, but at certain times of the day it works, at others it doesn't, so the issue seems to be with the API and not my code.
EDIT 2: Further evidence that the API is at fault: ordering by date or title on the API Reference's Try It section for youtube.search().list is wack, too.
UPDATE: Google have acknowledged the issue and seem to have fixed it.