Skip to content

Commit

Permalink
youtube_metadata: check for response
Browse files Browse the repository at this point in the history
  • Loading branch information
dale-wahl committed Jan 8, 2024
1 parent 02acd86 commit a56e731
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions processors/metrics/youtube_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ def request_youtube_api(self, ids, custom_key=None, object_type="video"):
time.sleep(self.sleep_time) # Wait a bit before trying again
pass

response = None
while retries < self.max_retries:
try:
if object_type == "video":
Expand Down Expand Up @@ -484,17 +485,17 @@ def request_youtube_api(self, ids, custom_key=None, object_type="video"):
time.sleep(self.sleep_time) # Wait a bit before trying again
pass

# Do nothing with the results if the requests failed
if retries > self.max_retries:
# Do nothing with the results if the requests failed after retries
if retries >= self.max_retries:
self.dataset.update_status("Failed to get metadata from " + str(ids_string) + " after " + str(retries) + " retries.")
if self.api_limit_reached == True:
self.dataset.update_status("Daily YouTube API requests exceeded.")

return results

else:

elif response is not None:
# Sometimes there's no results,
# and "respoonse" won't have an item key.
# and "response" won't have an item key.
if "items" not in response:
continue

Expand Down

0 comments on commit a56e731

Please sign in to comment.