Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data not being written to csv file #13

Open
birminghamallen opened this issue Aug 30, 2023 · 1 comment
Open

Data not being written to csv file #13

birminghamallen opened this issue Aug 30, 2023 · 1 comment

Comments

@birminghamallen
Copy link

birminghamallen commented Aug 30, 2023

The JSON files being requested appear to be outdated. I am receiving no data written to these files, aside from default variables. Please see the attached image for reference. Image of Issue

@birminghamallen
Copy link
Author

birminghamallen commented Aug 30, 2023

I would like to develop a functional version of this project, as it offers a remarkable competitive advantage for analytics. Furthermore, it has the potential to integrate AI-driven trend analysis and can be offered as a monthly service or product.

@mmich1209
Copy link

You can do some debugging:

def api_request(page_token, country_code):
# Builds the URL and requests the JSON from it
request_url = f"https://www.googleapis.com/youtube/v3/videos?part=id,statistics,snippet{page_token}chart=mostPopular&regionCode={country_code}&maxResults=50&key={api_key}"
request = requests.get(request_url)
if request.status_code == 429:
print("Temp-Banned due to excess requests, please wait and continue later")
sys.exit()
elif request.status_code != 200:
print(f"Error {request.status_code} for country {country_code}")
print(request.json()) # Add this to print the error details
return request.json()

Add this part to the script:   print(request.json())  # Add this to print the error details

I had the same issue, it gave me more infor about the error - it was related to the API key. I generate new API key, added YoutubeAPI from the library and enabled it in the project and then it worked. 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants