# python-youtube-utils
YouTube utilities including scripts to clean up BACON issues

## Back BACON

### Installation

```
cd back_bacon
pyvenv env
source env/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
```

Add the YouTube API key file in back_bacon/keys and add the filename and associated service email as environment variables.

### Running

Back BACON has two parts: it reveals videos uploaded by our partner channels that are missing claims, and it creates reference files for existing claims that have no reference files (no activated or deactivated reference files). The user can then take the video ids (emailed to SNS subscribers) and corresponding YouTube account names and enter them into the bulk claiming tool in OA. This will kick off the rest of the BACON claiming process for these videos.

```
cd back_bacon
python back_bacon.py <num_days>
```

## Environment Variables
| Env Variable  | Purpose                                                                                                                   |
| ------------- |-------------------------------------------------------------------------------------------------------------------------- |
| AR_YT_HOST     | Art relations host, if running locally this should be Reports AR instead of the squad DB |
| AR_YT_USER | Art relations user (needs SELECT permissions on art_relations) |
| AR_YT_PASSWORD | Art relations password |
| AR_YT_DATABASE | Art relations database |
| BACON_STATUS_ARN | This is used for the SNS email notification sent out including the details of videos missing claims and references that were created, as well as BACON stats |
| YT_KEY_FILE_NAME | YouTube key file |
| YT_SERVICE_EMAIL | YouTube service email associated with the provided key |
