Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.
/ analytics Public archive

A helper script for getting YouTube analytics.

License

Notifications You must be signed in to change notification settings

Carberra/analytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

retrieve_analytics.py

A helper script for getting YouTube analytic reports.

Setup

In order to run the script, you need to have the following:

  • Python >= 3.8.0, < 3.9.0
  • A Google Developers project with the YouTube Analytics API enabled

Creating a virtual environment

It is recommended you create a virtual environment for the project.

On UNIX-based systems:

python3.8 -m venv .venv
source ./.venv/bin/activate

On Windows:

py -3.8 -m venv .venv
./.venv/Scripts/activate

Creating a Google Developers project

  1. Follow the instructions on the YouTube Analytics API docs.
  2. Download your secrets file to data/secrets.json.

Installing dependencies

You will need to install the script's dependencies before running it.

  1. Install Poetry
  2. Run the following command, making sure the virtual environment is activated:
poetry install --no-dev

If you prefer not to use Poetry, you can install using pip instead:

pip install google google-api-python-client google-auth-oauthlib pandas

Usage

  1. Change directory into the scripts directory.
  2. To see what options you can parse, run:
python retrieve_analytics.py -h
  1. Run the script with the desired options.
  2. Open the provided link in the browser, and follow the on-screen instructions.
  3. Copy the provided code into the terminal, and press ENTER.

Contributing

In order to contribute to the project, you will need to install the development dependencies.

Using Poetry:

poetry install

Using pip:

pip install google google-api-python-client google-auth-oauthlib pandas black mypy

Before submitting any code, make sure to run the following command in the root directory of the project:

black . -l119