<commit_before># One Time Plex Reloaded (otp-reloaded)

Limit your Plex users to one piece of media

### Core features

- Report user violation <sup>1</sup>
- Handle user violation appropriately
- Easily add user to be monitored
- Easily remove user from being monitored
- Able to add existing Plex accounts to PMS with appropriate access to media
- A terminal client to easily interact with the server

<sup>1</sup> A violation is a user that accesses media they were not assigned to

### Setup
                             
Add a plex webhook and point it to one time plex
The default address (of one time plex) should be `localhost:8080`

### Usage

- On first run it will create a `config.toml` file

- Edit it to your preference

- Make sure you supply a plex token in the config if you plan on inviting the user when using `/api/v1/request/add`

- run `otp`

##### Beware that the endpoints are *currently* NOT secured by an API key (Don't expose this app to the internet!)

`GET /api/v1/monitor/start`:

Will start monitoring your Plex sessions

`POST /api/v1/request/add`:

  - Add query `?plexpass=1` to restrict media with labels

  - By default an invite will be sent to the `plexUsername`. If the user is already invited to your server, then append the query `&invite=0`

  - required in post form:
    - `plexUsername: jrudio-guest`
    
    - `ratingKey: 6` (the id that Plex uses for media)<commit_msg>updated with a clearer vision/goals<commit_after># One Time Plex (OTP)

One Time Plex (OTP) allows a Plex user to access one movie or episode of a tv series from your Plex Media Server. OTP also features a REST api to allow you to interact with it programmatically.

### How It Works

* You (the Plex server owner) share your library to a Plex user (usually a family member or friend)
* Add that user’s Plex user id and the id of the desired media to OTP
* OTP will monitor what this user watches, and prevent the user from watching anything other than what you assigned to them
* Once the user is finished, OTP will automatically stop sharing the library with that Plex user

### Disclaimers

Currently, OTP uses Plex’s web hook feature to monitor users, which is a Plex Pass feature. An option that will not rely on this will be added in the future.

### Setup

- Add a plex webhook on your PMS and point it to one time plex
    The default address (of one time plex) should be `localhost:8080/webhook`

- Run `./otp -write` to create a default configuration file

- Edit it to reflect your settings


### Usage

- Grab the user id of the Plex user you are sharing your library with

- Grab the media id (called the rating key in Plex) of the movie or episode of that user is assigned to

- Make a `POST` request to `/api/users/add` with the following in the body:

  ```bash
    plexuserid: <plex-user-id>
    mediaID: <media-id>
  ```

- That's it!
{'fraction_non_alphanumeric': 0.0655280585569885, 'fraction_numerical': 0.0055768560474032764, 'mean_word_length': 3.484375, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7259976', 'n_tokens_mistral': 843, 'n_tokens_neox': 801, 'n_words': 452}