Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ee883a5
Merge pull request #146 from marceljungle/main
marceljungle May 26, 2025
19c8f9e
Initial plan
Copilot Jul 8, 2025
2c2c360
Major README improvements with better structure, badges, and comprehe…
Copilot Jul 8, 2025
29225f1
Final improvements: Enhanced setup.py metadata and added Important Co…
Copilot Jul 8, 2025
892c7bb
Fix fetch mode consistency: Replace 'normal' with 'torrent_name' in c…
Copilot Jul 8, 2025
8975911
Remove license section from README.md as requested
Copilot Jul 8, 2025
2338985
Merge pull request #148 from marceljungle/copilot/fix-42177ad9-1e36-4…
marceljungle Jul 13, 2025
c3637b4
Initial plan
Copilot Jul 13, 2025
9a6b520
Implement Flask GUI with Bootstrap for red-plex
Copilot Jul 13, 2025
c107073
Fix WebSocket logging to stream terminal logs to frontend
Copilot Jul 13, 2025
9bbeef9
Add update_collections_from_collages to GUI database update
Copilot Jul 13, 2025
a043f59
Fix WebSocket logging to capture PlexManager logs in GUI
Copilot Jul 13, 2025
6739d6c
Fix GUI hanging issue when Plex server is not accessible
Copilot Jul 13, 2025
bc5094d
Merge pull request #150 from marceljungle/main
marceljungle Jul 13, 2025
45a9be2
Merge remote-tracking branch 'origin/develop' into copilot/fix-a1c88f…
marceljungle Jul 13, 2025
f2372e6
Merge branch 'hotfix/torrent-name-search' into copilot/fix-a1c88fc5-6…
marceljungle Jul 13, 2025
f549441
Improve WebSocket logging setup to ensure real-time log streaming
Copilot Jul 13, 2025
e17e15a
Refactor logging setup and enhance GUI launch with Gunicorn support
marceljungle Jul 14, 2025
cae309b
Improved query and OPS torrent group mapping
marceljungle Jul 15, 2025
5726e34
Added new requirements
marceljungle Jul 15, 2025
a4d776e
Merge pull request #152 from marceljungle/main
marceljungle Jul 15, 2025
1568740
Merge branch 'develop' into copilot/fix-a1c88fc5-62d6-4d07-97b9-cf522…
marceljungle Jul 15, 2025
c774ae1
Update README with comprehensive GUI documentation
Copilot Jul 15, 2025
3b6ddd2
Fix README fetch mode documentation to match CLI implementation
Copilot Jul 15, 2025
85ac3b1
Clarify fetch mode documentation in README for torrent_name usage
marceljungle Jul 15, 2025
8611867
Merge pull request #149 from marceljungle/copilot/fix-a1c88fc5-62d6-4…
marceljungle Jul 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 marceljungle

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
302 changes: 269 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,64 @@
# red-plex

red-plex is a command-line tool for creating and updating Plex collections based on collages and bookmarks from Gazelle-based music trackers (Redacted “RED” and Orpheus “OPS”). It stores all data in a local SQLite database and provides commands to synchronize your music library with Plex and the torrent data from these trackers.
[![PyPI version](https://badge.fury.io/py/red-plex.svg)](https://badge.fury.io/py/red-plex)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A command-line tool and web interface for creating and updating Plex collections based on collages and bookmarks from Gazelle-based music trackers like **Redacted** ("RED") and **Orpheus Network** ("OPS").

red-plex bridges the gap between your curated music collections on private trackers and your personal Plex media server, automatically creating and maintaining Plex collections that mirror your tracker collages and bookmarks.

## Quick Start

1. **Install red-plex**: `pip install red-plex`
2. **Configure your API keys**: `red-plex config edit`
3. **Create your first collection**:
- **CLI**: `red-plex collages convert 12345 --site red`
- **Web GUI**: `red-plex gui` (then visit http://127.0.0.1:8000)

## Web Interface

red-plex now includes a comprehensive web-based GUI for users who prefer a visual interface over command-line operations.

### Features

- **🌐 Dashboard**: Clean overview with feature cards and navigation
- **⚙️ Configuration Management**: View and edit all settings (API keys, Plex config, rate limits) through web forms
- **🎨 Collage Operations**: Convert new collages and view existing collections
- **🔖 Bookmark Operations**: Convert bookmarks from RED and OPS trackers
- **🗄️ Database Management**: View statistics, update albums, reset tables
- **⚡ Real-time Updates**: Live status updates during long operations via WebSocket
- **📱 Mobile-Responsive**: Bootstrap-based design that works on all devices

### Usage

```bash
# Launch GUI server (default: http://127.0.0.1:8000)
red-plex gui

# Custom host/port
red-plex gui --host 0.0.0.0 --port 8080

# Debug mode with auto-reload
red-plex gui --debug
```

The web interface provides the same functionality as the CLI commands but with a user-friendly visual interface, real-time progress updates, and intuitive navigation.

## What are RED and OPS?

- **Redacted (RED)**: A private music tracker focused on high-quality audio files
- **Orpheus Network (OPS)**: Another private music tracker with curated content
- Both use the Gazelle framework and offer "collages" (curated collections) and personal bookmarks

## Table of Contents
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Getting API Keys](#getting-api-keys)
- [Configuration](#configuration)
- [Web Interface](#web-interface)
- [Overview](#overview)
- [Features](#features)
- [Installation](#installation)
- [Usage & Commands](#usage--commands)
- [Configuration Commands](#configuration-commands)
- [Collages](#collages)
Expand All @@ -18,47 +71,128 @@ red-plex is a command-line tool for creating and updating Plex collections based
- [Using Query Fetch Mode](#using-query-fetch-mode)
- [Configuration Details](#configuration-details)
- [Configuration Tips](#configuration-tips)
- [Considerations](#considerations)
- [Troubleshooting](#troubleshooting)
- [Important Considerations](#important-considerations)
- [Contributing](#contributing)

---

## Prerequisites

- **Python 3.8 or higher**
- **Plex Media Server** with a configured music library
- **Active account** on RED and/or OPS with API access
- **Music library** organized in your Plex server

## Installation

### Using pip (recommended)

```bash
pip install red-plex
```

### Using pipx (isolated environment)

```bash
pipx install red-plex
```

### From source

```bash
git clone https://github.com/marceljungle/red-plex.git
cd red-plex
pip install -e .
```

## Getting API Keys

### For Redacted (RED)
1. Log into your RED account
2. Go to your profile settings
3. Navigate to "Access Settings" or "API"
4. Generate a new API key
5. **Keep this key secure and private**

### For Orpheus Network (OPS)
1. Log into your OPS account
2. Go to your user settings
3. Find the API section
4. Generate a new API key
5. **Keep this key secure and private**

## Configuration

After installation, you need to configure red-plex with your credentials:

```bash
# Open configuration file in your default editor
red-plex config edit
```

Edit the configuration file with your details:

```yaml
LOG_LEVEL: INFO
PLEX_URL: http://localhost:32400
PLEX_TOKEN: your_plex_token_here
SECTION_NAME: Music
RED:
API_KEY: your_red_api_key_here
BASE_URL: https://redacted.sh
RATE_LIMIT:
calls: 10
seconds: 10
OPS:
API_KEY: your_ops_api_key_here
BASE_URL: https://orpheus.network
RATE_LIMIT:
calls: 4
seconds: 15
```

### Getting Your Plex Token

Visit: https://plex.tv/api/resources?includeHttps=1&X-Plex-Token={YOUR_TOKEN}

## Overview

- **Stores Data in SQLite**: Instead of CSV-based caches, red-plex now stores albums, collages, and bookmarks in a lightweight SQLite database.
- **Collages & Bookmarks**: Fetch and manage torrent-based collages or personal bookmarks from Gazelle-based sites.
- **Stores Data in SQLite**: Instead of CSV-based "caches," red-plex now stores albums, collages, and bookmarks in a lightweight SQLite database.
- **Collages & Bookmarks**: Fetch and manage torrent-based "collages" or personal "bookmarks" from Gazelle-based sites.
- **Plex Integration**: Compare the torrent group info with your Plex music library to create or update Plex collections.
- **Flexible Album Matching**: Match albums in Plex using either the original `torrent_name` (directory name) or a query-based approach (`Artist/Album`), ideal for organized libraries (e.g., Beets/Lidarr).
- **Incremental Updating**: Update previously created collections as new albums become available or site data changes.

## Features

- **Multi-Site**: Works with Redacted (“red”) and Orpheus Network (“ops”).
- **Multi-Site**: Works with Redacted ("red") and Orpheus Network ("ops").
- **Web Interface**: Modern Flask-based GUI with Bootstrap styling and real-time updates.
- **Collections from Collages/Bookmarks**: Create or update entire Plex collections for each collage or bookmarked set.
- **Local SQLite Database**: All data (albums, collages, bookmarks) is kept in one DB, no more CSV.
- **Two Fetch Modes**: Choose between `torrent_name` (default) for direct path matching or `query` for metadata-based searches in Plex.
- **Configurable Logging**: Choose between INFO, DEBUG, etc., in `config.yml`.
- **Rate Limiting**: Respects site rate limits and retries on errors.
- **Simple CLI**: All major tasks are accessed via subcommands like `collages`, `bookmarks`, `db`, etc.
- **Dual Interface**: Access all functionality via both command-line interface and web GUI.
- **Python 3.8+ Compatible**: Runs on modern Python versions with no external database dependencies.

## Installation

Install via pip:
## Usage & Commands

```bash
pip install red-plex
```
Type `red-plex --help` for detailed usage. Below is a summary of the main commands.

Or use pipx for an isolated environment:
### Web Interface Commands

```bash
pipx install red-plex
# Launch web GUI server
red-plex gui [--host HOST] [--port PORT] [--debug]

# Examples:
red-plex gui # Default: http://127.0.0.1:8000
red-plex gui --host 0.0.0.0 # Bind to all interfaces
red-plex gui --port 8080 # Custom port
red-plex gui --debug # Debug mode with auto-reload
```

## Usage & Commands

Type `red-plex --help` for detailed usage. Below is a summary of the main commands.

### Configuration Commands

```bash
Expand Down Expand Up @@ -96,10 +230,9 @@ red-plex bookmarks update --fetch-mode [torrent_name|query]

The `--fetch-mode` (or `-fm`) option controls how red-plex locates albums in Plex:

- **torrent_name** (default): Searches for directories matching the torrent folder name.
- **query**: Searches using `Artist` and `Album` metadata, ideal for organized libraries managed by tools like Beets or Lidarr.

This option applies to `collages convert`, `collages update`, `bookmarks convert`, and `bookmarks update`. Defaults to `torrent_name` if omitted.
#### For all commands (`collages convert`, `collages update`, `bookmarks convert`, `bookmarks update`):
- **torrent_name** (default): Searches for directories matching the torrent folder name
- **query**: Searches using `Artist` and `Album` metadata, ideal for organized libraries managed by tools like Beets or Lidarr

### Database Commands

Expand Down Expand Up @@ -149,13 +282,52 @@ red-plex db albums update
### Using Query Fetch Mode

```bash
# Create a collection using query mode
# Create a collection using query mode (for Beets/Lidarr organized libraries)
red-plex collages convert 12345 --site red --fetch-mode query

# Update all bookmarks using query mode
red-plex bookmarks update --site ops -fm query
```

### Complete Workflow Example

#### Command Line Interface
```bash
# 1. First time setup
red-plex config edit # Add your API keys and Plex details

# 2. Update your local album database from Plex
red-plex db albums update

# 3. Create collections from specific collages
red-plex collages convert 12345 67890 --site red

# 4. Create collection from your bookmarks
red-plex bookmarks convert --site red

# 5. Later, update all collections with new releases
red-plex collages update
red-plex bookmarks update
```

#### Web Interface
```bash
# 1. Launch the web interface
red-plex gui

# 2. Open http://127.0.0.1:8000 in your browser

# 3. Navigate to Configuration to add your API keys and Plex details

# 4. Use the Database page to update your local album database

# 5. Use the Collages page to convert specific collages

# 6. Use the Bookmarks page to convert your bookmarks

# 7. Return to Database page later to update all collections
```

## Configuration Details

By default, configuration is stored in `~/.config/red-plex/config.yml`:
Expand Down Expand Up @@ -186,14 +358,78 @@ SECTION_NAME: Music
https://plex.tv/api/resources?includeHttps=1&X-Plex-Token={YOUR_TOKEN}
```
- Look for the `<Device>` node in the XML for a `uri`, use this `plex.direct` address.
- Use `DEBUG` log level for verbose debugging information
- Use `WARNING` log level for minimal output

## Troubleshooting

### Common Issues

#### "No module named 'plexapi'" Error
```bash
pip install plexapi
# or
pip install red-plex --upgrade
```

#### Authentication Errors
- Verify your API keys are correct in `config.yml`
- Check that your Plex token is valid
- Ensure you have access to the sites you're trying to use

## Considerations
#### No Albums Found
- Run `red-plex db albums update` to refresh your Plex library
- Check that your Plex music library is properly configured
- Verify the `SECTION_NAME` in your config matches your Plex music library name

#### Rate Limiting Issues
- The tool respects site rate limits automatically
- If you encounter issues, try reducing the rate limit values in your config

#### Fetch Mode Issues
- Use `torrent_name` mode if your library structure matches torrent folder names
- Use `query` mode if you use Beets, Lidarr, or have renamed your music files
- Try both modes to see which works better for your library

#### Web Interface Issues
- **GUI won't start**: Ensure `gunicorn` and `eventlet` are installed: `pip install gunicorn eventlet`
- **Can't access GUI**: Check if the port is available and not blocked by firewall
- **GUI stuck on "Starting..."**: Check terminal logs for error messages
- **WebSocket connection failed**: Ensure your browser supports WebSockets and isn't blocking them

### Getting Help

1. Check the logs with `LOG_LEVEL: DEBUG` in your config
2. Verify your configuration with `red-plex config show`
3. Test your Plex connection by running `red-plex db albums update`
4. Open an issue on GitHub with detailed error messages

## Important Considerations

- **Album Matching Strategy**:
- `torrent_name` (default): Matches albums by comparing torrent folder names with Plex directory paths
- `query`: Uses artist and album metadata for matching, ideal for libraries organized by Beets, Lidarr, or other tools that rename files
- **Database Management**: All data is stored in `red_plex.db`. Use database reset commands (`db albums reset`, etc.) to clear specific tables when needed
- **Site Credentials**: Ensure your API keys are valid and have proper permissions
- **Rate Limiting**: The tool automatically respects site-specific rate limits to avoid being banned
- **Logging Levels**:
- `DEBUG`: Verbose output for troubleshooting
- `INFO`: Standard information (default)
- `WARNING`: Minimal output
- **Collection Updates**: When you run `collages update` or `bookmarks update`, new albums are added to existing Plex collections, but removed items from tracker collages are not automatically removed from Plex collections

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

### Development Setup

```bash
git clone https://github.com/marceljungle/red-plex.git
cd red-plex
pip install -e .
```

---

- **Album Matching**:
- `torrent_name` (default): Matches folder paths.
- `query`: Uses metadata for reliable matching in renamed libraries.
- **Database**: All data in `red_plex.db`. Reset tables with `db albums reset`, etc.
- **Site Credentials**: Ensure valid API keys in `config.yml`.
- **Rate Limits**: Adheres to site-specific settings.
- **Logging**: Use `DEBUG` for verbose logs or `WARNING` for less output.
- **Updates**: `collages update` and `bookmarks update` add new albums but do not remove existing items in Plex.
**Disclaimer**: This tool is for personal use with your own music library and tracker accounts. Respect the rules and terms of service of the private trackers you use.
Loading
Loading