so I have a working code and I am getting the data fields that I want. However, I have run into the issue where the code is churning out seemingly random videos in my limited results.
I would just scrape all video objects, but for my channels of interest, this would exceed my daily quota for using the API of 10,000. My best solution would be the ability to pick a specific date, and then retrieve all video dated from then until now. I have briefly looked into this and observed that there are apparently long-standing issues with ordering these results via the API backend. Also I am not sure how to implement ordering into the code that I am working with. Therefore, is this possible, and how should I do it? Thanks
EDIT: Actually, I just realized that this codeblock is irrelevant to this issue, since it is the prior codeblock that is parsing through videos to retrieve video IDs. This is the codeblock where I need to implement the order, although I am unsure how to implement the GET function into this
limit = 5
video_Ids = []
nextPageToken ="" #for 0th iteration let it be null
for i in range(limit):
url = f"https://www.googleapis.com/youtube/v3/search?key={api_key}&part=snippet&channelId={channel_Id}&maxResults=50&pageToken={nextPageToken}"
data = json.loads(requests.get(url).text)
for key in data['items']:
if 'videoId' in key['id']:
video_Id = key['id']['videoId']
video_Ids.append(video_Id)
nextPageToken = data['nextPageToken']
EDIT2: I've just been adding "&publishedAfter=" and "order=" into the URL and it appears to be a limited success. Unfortunately it orders in reverse chronological order, and the documentation doesn't say how to reverse it.
It could be fine, if I can figure out how to make this run without the limitations and just collect all data objects in the temporal parameters.