This is a script which when given a list of YouTube channel IDs will insert each channel IDs current subscriber count into a new row.
This script runs on AWS Lambda and is triggered periodically.
- Sign up: https://aws.amazon.com/resources/create-account/
- Setup AWS CLI: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html
- Install pipenv: https://github.com/pypa/pipenv
- Install pyenv-virtualenv: https://github.com/pyenv/pyenv-virtualenv#pyenv-virtualenv
- Install serverless: https://www.serverless.com/framework/docs/getting-started/
- Create a new Google Clould Platform project (e.g "Youtube-Subs"): https://console.cloud.google.com/apis/dashboard
- Search for "Youtube Data API v3", "Google Drive API" and "Google Sheets API" and individually "Enable" each API for the project
- Create "Service Account" credentials as mentioned: https://docs.gspread.org/en/v3.7.0/oauth2.html#enable-api-access-for-a-project
- Create a new Google Spreadsheet
- Hit "Share" on the new spreadsheet and add the "client_email" value email specified in the Google service account credentials file previously generated above
- Create a
data.json
fromdata.example.json
creds
values should come from the service account credentions JSON file- Ensure the
private_key
string is double escaped for deployments- Find the
\n
and replace with\\n
- Find the
- Place a list of channel ids in the
channels
array - Provide the name of your
spreadSheetName
and thesheetName
- Edit
serverless.yml
accordingly, you can edit therate
to your liking (default is 1 minute) - Run
sls deploy
- Verify deployment: https://console.aws.amazon.com/lambda/home?region=us-east-1#/functions
- Have the
data.json
file created like in the deployment section- Except, this time have the
private_key
string single escaped- Find the
\\n
and replace with\n
- Find the
- Except, this time have the
- Run local Python code
sls invoke local --function youtube-subs --path data.json
- Or, run currently deployed code
sls invoke --function youtube-subs --path data.json