# youtube-claims-api-support

This is a fork of [https://github.com/theorchard/collab/tree/master/ingaku/youtube-claims-api-support](https://github.com/theorchard/collab/tree/master/ingaku/youtube-claims-api-support)


## References

* [YouTube Content ID API](https://developers.google.com/youtube/partner)
* [YouTube Data API](https://developers.google.com/youtube/v3/docs)
* [BACON Troubleshooting Docs](https://www.notion.so/Reference-Claims-in-Youtube-13d97177520f80bb8bdceec6317d32a6)
* [BACON Logs](https://app.datadoghq.com/logs?query=environment%3Aprod%20service%3Abacon-%2A&agg_m=count&agg_m_source=base&agg_t=count&cols=%40correlation_id&fromUser=true&messageDisplay=inline&refresh_mode=sliding&storage=hot&stream_sort=time%2Cdesc&viz=stream&from_ts=1743705705586&to_ts=1743792105586&live=true)
* [Bulk Claiming Tool](https://oa.theorchard.com/youtubevideoclaim/)

## Setup

### Get App Credentials
* Go to [Debug/Testing Client Application Configuration Page](https://console.cloud.google.com/auth/clients/6909281553-rvgavn85u6poqjrtd8fnvaka43tfvc2s.apps.googleusercontent.com?inv=1&invt=AbwE-Q&project=theorchard.com:api-project-6909281553&supportedpurview=project&pli=1)
* In the "Client Secret" section, disable and delete all existing secrets.
* Create a new secret and immediately download it before the options disappear
* Rename the resulting JSON file to "client_secrets.json" and move it to this directory


### Setup Database Credentials

```bash
cp .env.shadow .env
```
* Fill in username and password

### Install Packages

```bash
python -m venv env
source env/bin/activate
pip install -r requirements.txt
```

## Process Video IDs

```bash
source env/bin/activate
python run.py {video_ids} {filename.csv}
```
* `video_ids` is a comma separated list
* Starts OAuth process in browser if `token.json` does not exist
* `filename.csv` is updated with a `result` column with analysis output
* rows with `notes` column not empty will be skipped

### Reprocessing
* Handle rows in status `NeedsManualProcessing` by following instructions in "notes" column
* Review rows in status `NeedsAttention`, might not be fixable
* Investigate rows in status `UnableToTriage` and develop a plan to fix them

## Regenerate Auth Token

```bash
source env/bin/activate
python run.py
```

## Reporting

* Add results in [this sheet](https://docs.google.com/spreadsheets/d/1Q8yzE5TKXim0MepfxgtYDDwJaIyK7O8jUps8cI9Nbdg/) as a new tab with the JIRA ticket number

## Linting

```bash
env/bin/ruff format run.py connectors/ && env/bin/mypy run.py
```

