# Plex Export Project

## Goal
Create a one-off local Python workflow that exports Michael's Plex library into two JSON files so Soren can analyse what is available and later help with recommendations, unwatched content, abandoned shows, and similar watch guidance.

## Why this approach
- Local-first and low-drama
- Avoids direct ongoing live access where possible
- Keeps Plex credentials limited to a local `.env` file
- Produces reusable snapshots Soren can read repeatedly without re-querying Plex every time

## Current project location
- `projects/plex-export/`

## Files created
- `projects/plex-export/export_plex_library.py`
- `projects/plex-export/.env.example`
- `projects/plex-export/README.md`

## Current script behaviour
- Connects to a Plex server using:
  - `PLEX_BASE_URL`
  - `PLEX_TOKEN`
  - optional `PLEX_VERIFY_SSL`
- Automatically fetches Plex library sections
- Exports all sections of type:
  - `movie`
  - `show`
- Writes output to:
  - `projects/plex-export/exports/movies.json`
  - `projects/plex-export/exports/shows.json`
- Groups content by Plex section/library
- Includes useful metadata such as:
  - title
  - year
  - summary
  - genres
  - ratings
  - watched/view count
  - last viewed
  - added date
  - show episode counts
  - unwatched episode count
  - media/codec/file metadata

## Important decisions made
- Do **not** store this under `knowledge/`; keep it as a standalone project under top-level `projects/`
- Separate exports into movies and TV shows
- Section IDs are optional and should be left unset if Michael wants access to all movie/show libraries
- Preferred model is a one-off/local export snapshot, not full-time live Plex integration (at least initially)

## Current blocker
The script is ready but not yet configured because Plex credentials are not in place yet.

Missing local config file:
- `projects/plex-export/.env`

Required values:
- `PLEX_BASE_URL`
- `PLEX_TOKEN`

Optional values:
- `PLEX_VERIFY_SSL=true|false`
- `PLEX_MOVIE_SECTION_IDS=...`
- `PLEX_SHOW_SECTION_IDS=...`

## What Michael asked about
- How to find the Plex token
- Whether section IDs are necessary

## Answers established
- Section IDs are **not needed** if the goal is to export everything available; the script already exports all `movie` and `show` sections by default
- Best token acquisition method suggested:
  1. Open Plex Web
  2. Open browser developer tools
  3. Use the Network tab
  4. Refresh the page
  5. Inspect a request for `X-Plex-Token`

## Next steps for tomorrow
1. Michael obtains Plex token
2. Create `projects/plex-export/.env`
3. Add at least:
   - `PLEX_BASE_URL=http://<plex-host>:32400`
   - `PLEX_TOKEN=<token>`
4. Leave section IDs unset unless filtering is desired
5. Run:
   ```bash
   cd /home/openclaw/.openclaw/workspace/projects/plex-export
   python3 export_plex_library.py
   ```
6. Read and analyse:
   - `projects/plex-export/exports/movies.json`
   - `projects/plex-export/exports/shows.json`

## Intended outcomes after export
Use the exported library snapshot to support conversations like:
- what should we watch tonight?
- what good stuff do we own but haven’t watched?
- what shows were started and abandoned?
- what comfort-watch or sci-fi options are already in the library?
- what’s similar to a given film/show from what is already available locally?
