# README

## General Purpose of the Refresh Script
- The purpose of this script is to send the current Master Rights Registry data for given ISRCs/TUIDs to YouTube.
This can be useful if some updates did not make it to YouTube, and the YouTube CMS does not show the same
ownership data as the Master Rights Registry.
- The script expects a .csv file as an input. This file needs to contain two columns: `isrc` and `tuid`. Please
note that the headers are case sensitive.
- For each of these, the `ows-masters-registry.theorchard.io/ownership/isrc/{isrc}/refresh` endpoint will be called,
which triggers ows-masters-registry to check the current ownership state and puts an according update into the
youtube daemon queue.

## Technical Prerequisites
- You will need ssh access to `devorch@shared-jump-box.shared.theorchard.io`. You can try it out via
`ssh devorch@shared-jump-box.shared.theorchard.io`, if that fails, please follow the steps outlined [here](https://www.notion.so/SSH-key-setup-for-dev-boxes-jump-box-5689b3c8cb204b63b488a179fecea9d5)

## Running The Script
- Create a .csv file with the ISRCs/TUIDs to update. If you have more than 20,000 items to update, consider 
splitting them up into smaller files. Make sure that the headers are called `isrc` and `tuid` (lowercase). See also
the `sample.csv` file in this folder.
- ssh onto the devbox via `ssh devorch@shared-jump-box.shared.theorchard.io`
- navigate to the script's location: `cd collab/mhirth/refresh-masters-registry`
- make sure your .csv file is present here. Feel free to create the .csv file on your machine, add it to this repo,
and create/merge a PR for it. On the devbox, run `git pull`
- Run the script via `python3.11 refresh_masters_registry_script.py your_custom_file.csv`
- The script will print a progress report every 100 calls, and will let you know once it's done.

## Monitoring the Progress
- Before, while and after the script is running, you can check the current load on the YouTube daemon's queue in 
the [aws console](https://us-east-1.console.aws.amazon.com/sqs/v3/home?region=us-east-1#/queues/https%3A%2F%2Fsqs.us-east-1.amazonaws.com%2F437795906767%2Fprod-yt-ownership-1)
- Navigate to the "Monitoring" tab. The "Approximate Number Of Messages Visible" graph is the one to pay attention to
- Once that graph is back to close to zero, you can consider your refresh "done"