Coder Social home page Coder Social logo

prem-ium / youtube-analytics-bot Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 1.0 2.64 MB

πŸ€– Discord bot to receive YouTube Analytics statistics such as views, estimated ad revenue, & more!πŸ•΅πŸ“Š

License: BSD 3-Clause "New" or "Revised" License

Python 99.68% Dockerfile 0.32%
content-creator youtube youtube-analytics youtube-analytics-api youtube-api youtube-api-v3 discord discord-bot adsense monetization

youtube-analytics-bot's Introduction

prem-ium

Hi there , I'm Prem-ium (Prem Patel)

🧠 Premium Software Engineer

LinkedInGmail Github Sponsor Buy Me A Coffee

🀝 Open to Opportunities

πŸ“« Let's get in touch

🎯 Connect with me on LinkedIn

βœ‰ Email me at: premiumcspatel [at] gmail.com (No spam or marketing please!)

πŸš€ About Me

  • 🌱 I’m currently further expanding my knowledge in Ruby
  • ⚑ Fun fact I love eating spicy food 🌢️ & talking about spaceπŸŒŒπŸ§‘β€πŸš€

πŸ“ˆ My Github Stats:

prem-iumprem-ium

πŸ”§ Languages & Tools I Primarily Use

TypeScript JavaScript HTML5 Bootstrap CSS3 NodeJS Python Java Express.js Markdown Flask OpenCV Docker Selenium Keras NumPy Pandas Firebase Netlify Google Cloud GitHub Actions AWS Replit PyCharm Visual Studio Code Eclipse IntelliJ IDEA Git GitHub

πŸ“ŒMore Stats

🎯 Metrics

Metrics

πŸ’« Repo Star Data

Stargazers

πŸ“ Habits

habits

πŸ“‚ Featured Repos

repos

youtube-analytics-bot's People

Contributors

prem-ium avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

gokulkannant

youtube-analytics-bot's Issues

I have got a forbidden error during collect the revenue information

googleapiclient.errors.HttpError: <HttpError 403 when requesting https://youtubeanalytics.googleapis.com/v2/reports?ids=channel%3D%3DMINE&startDate=2023-01-01&endDate=2023-04-11&metrics=views%2CestimatedMinutesWatched%2CsubscribersGained%2CsubscribersLost%2CestimatedRevenue%2Ccpm%2CmonetizedPlaybacks%2CplaybackBasedCpm%2CadImpressions%2Clikes%2Cdislikes%2CaverageViewDuration%2Cshares%2CaverageViewPercentage%2CsubscribersGained%2CsubscribersLost&alt=json returned "Forbidden">

HttpAccessTokenRefreshError: invalid_grant: Token has been expired or revoked.

Exception:
oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Token has been expired or revoked.

Traceback:

Traceback (most recent call last):
  File "c:\Users\Frost\Desktop\CodingProjects\youtube-analytics-bot\main.py", line 138, in get_stats
    response = execute_api_request(
  File "c:\Users\Frost\Desktop\CodingProjects\youtube-analytics-bot\main.py", line 85, in execute_api_request
    return client_library_function(**kwargs).execute()
  File "C:\Python310\lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Python310\lib\site-packages\googleapiclient\http.py", line 923, in execute
    resp, content = _retry_request(
  File "C:\Python310\lib\site-packages\googleapiclient\http.py", line 191, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "C:\Python310\lib\site-packages\oauth2client\transport.py", line 186, in new_request
    credentials._refresh(orig_request_method)
  File "C:\Python310\lib\site-packages\oauth2client\client.py", line 761, in _refresh
    self._do_refresh_request(http)
  File "C:\Python310\lib\site-packages\oauth2client\client.py", line 819, in _do_refresh_request
    raise HttpAccessTokenRefreshError(error_msg, status=resp.status)
oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Token has been expired or revoked.

Task:

Find a way to prevent token from having to be refreshed / re-authenticated every couple of weeks manually when credentials.json expire.

Notes/Potential Patches:

  • The --noauth_local_webserver command line argument may be used however it requires a verification code to be sent through the terminal. There is also the issue of how to send the URL from the terminal to Discord for ease of access and if possible input verification code without having to remote into PC/Docker to rebuild the image & container with updated credentials.json.

Example output:

python main.py --noauth_local_webserver
2023-02-09 23:23:02 INFO     discord.client logging in using static token
2023-02-09 23:23:03 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: XX).
Updating dates to 2023-02-01 - 2023-02-09

Go to the following link in your browser:
https://accounts.google.com/o/oauth2/auth?client_id=XX-XX.apps.googleusercontent.com&redirect_uri=urn%X%X%X%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube.readonly+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyt-analytics-monetary.readonly&access_type=offline&response_type=code

Enter verification code: 

An ideal potential middle ground solution would be to retrieve the URL from the terminal, send it as a message on discord, allow the user to authenticate, and send the code inside of discord for the bot to receive, parse, and push to terminal as input.

  • refresh_token() method fails to solve this issue as well and will be stripped in next commit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.