Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
fd025e4
Initial plan
Copilot Jul 15, 2025
43ab705
Implement core site-tags functionality with database, API, and CLI
Copilot Jul 15, 2025
7e6b639
Add documentation and complete site-tags feature implementation
Copilot Jul 15, 2025
e1db251
Refactor to query and optimize site tag management use cases
marceljungle Jul 16, 2025
472f588
Enhance album search logic to include 'Various Artists' for multiple …
marceljungle Jul 17, 2025
682db6f
Ignore site when scanning for new tags
marceljungle Jul 17, 2025
08ee33e
Only use site param when scanning, site is no longer involved in conv…
marceljungle Jul 17, 2025
bb4107a
Format code to meet pylint requirements
marceljungle Jul 17, 2025
6a5275a
Added --always-skip option for the tags scan
marceljungle Jul 18, 2025
cb97f9a
Change return type of get_rating_keys_by_tags to List[int]
marceljungle Jul 20, 2025
edca31d
Refactor get_rating_keys_by_tags to return List[str] and simplify col…
marceljungle Jul 20, 2025
7a481eb
Add VARIOUS_ARTISTS_TAGS constant and refactor API fetching logic for…
marceljungle Jul 20, 2025
3e2e1cd
Refactor album fetching and collection creation logic to use batch pr…
marceljungle Jul 21, 2025
5c06332
Enhance album search logic with final fallback for album name only an…
marceljungle Jul 21, 2025
38789e4
Add complete site-tags GUI functionality and update README documentation
Copilot Jul 21, 2025
4034822
Correctly map artist name inside the album table and improved 'proces…
marceljungle Jul 21, 2025
da4ef78
Improve album processing log to handle missing artist names and enhan…
marceljungle Jul 21, 2025
7db4fb3
Pylint run
marceljungle Jul 21, 2025
0a12312
Refactor: Rename `site_tag_mappings` to `rating_key_group_id_mappings…
marceljungle Jul 22, 2025
956ec9e
Order unscanned albums by most recently added
marceljungle Jul 23, 2025
c9f67d8
Merge pull request #156 from marceljungle/copilot/fix-5cc2ddd1-aabb-4…
marceljungle Jul 23, 2025
1e51507
Initial plan
Copilot Jul 23, 2025
68228e4
Extract SQL queries from app.py to local_database.py
Copilot Jul 23, 2025
2442754
Split local_database.py into focused modules
Copilot Jul 23, 2025
e34b519
Split cli.py into focused command modules
Copilot Jul 23, 2025
008db2a
Refactor imports and comments, fix minor formatting issues, and updat…
marceljungle Jul 23, 2025
6c0f393
Fix circular imports and modularize app.py into focused route modules
Copilot Jul 23, 2025
dfc10c5
Refactor: Reorder imports for consistency and remove unused import st…
marceljungle Jul 23, 2025
1172ba6
Merge pull request #158 from marceljungle/copilot/fix-157
marceljungle Jul 23, 2025
7c24f87
Initial plan
Copilot Jul 24, 2025
544345f
Implement collection-collage upstream sync functionality
Copilot Jul 24, 2025
282ed48
Fix database method and add comprehensive validation tests
Copilot Jul 24, 2025
744b294
Refactor API methods and add confirmation dialog for upstream sync
Copilot Jul 24, 2025
61eae60
Enhance album processing: filter out invalid artist names, implement …
marceljungle Jul 25, 2025
e93a12e
Refactor: Improve artist filtering, enhance socket status updates, an…
marceljungle Jul 25, 2025
7ee390a
Refactor: Ensure local collections are always updated and fix URL for…
marceljungle Jul 26, 2025
525e193
Add selective album choice to upstream sync with GUI support
Copilot Jul 26, 2025
00d62c1
Refactor: Improve collage sync process with enhanced error handling a…
marceljungle Jul 26, 2025
71628cd
Refactor upstream sync logic into use case and add global log monitor
Copilot Jul 26, 2025
5da3d56
Improve logging consistency, and enhance error handling in upstream s…
marceljungle Jul 26, 2025
826cdfa
Add warning for unsupported site in get_user_collages method
marceljungle Jul 26, 2025
8889b21
Implement conditional "Sync to upstream" button based on user ownership
Copilot Jul 26, 2025
250a958
Remove unused status output block and associated scripts/styles from …
marceljungle Jul 26, 2025
239cb0f
Enhance collage ownership verification and update UI to display only …
marceljungle Jul 26, 2025
3959d47
Rename site tag mapping method
marceljungle Jul 26, 2025
54c2850
Reorganize site-tags to db remote-mappings structure
Copilot Jul 26, 2025
f77b75e
Separate remote-mappings core functionality from site-tags specific f…
Copilot Jul 26, 2025
83ad39a
Refactor remote mappings to return structured data and update related…
marceljungle Jul 26, 2025
df1bd11
Refactor GUI route handlers and CLI commands to reduce duplication, c…
marceljungle Jul 26, 2025
4e74999
Improve database operations to support merging torrent groups, improv…
marceljungle Jul 27, 2025
0871976
Create the collection in DB when it exists in Plex and site, but no m…
marceljungle Jul 31, 2025
b6dccbf
Add comprehensive upstream sync documentation to README
Copilot Aug 3, 2025
ec361ef
Refactor: Update log level in get_user_collages and clean up README c…
marceljungle Aug 4, 2025
b620416
Merge pull request #160 from marceljungle/copilot/fix-159
marceljungle Aug 4, 2025
e2594d6
Merge pull request #162 from marceljungle/main
marceljungle Aug 4, 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
138 changes: 118 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ red-plex now includes a comprehensive web-based GUI for users who prefer a visua
- **⚙️ 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
- **🏷️ Site Tags Operations**: Scan albums using album/artist names and create tag-based collections
- **🗄️ 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
Expand All @@ -45,12 +46,6 @@ 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)
Expand All @@ -62,7 +57,10 @@ The web interface provides the same functionality as the CLI commands but with a
- [Usage & Commands](#usage--commands)
- [Configuration Commands](#configuration-commands)
- [Collages](#collages)
- [Upstream Sync](#upstream-sync)
- [Bookmarks](#bookmarks)
- [Site Tags](#site-tags)
- [Remote Mappings](#remote-mappings)
- [Fetch Mode (-fm)](#fetch-mode--fm)
- [Database Commands](#database-commands)
- [Examples](#examples)
Expand Down Expand Up @@ -152,9 +150,10 @@ OPS:
seconds: 15
```

### Getting Your Plex Token
### Getting Your Plex HTTPs URL

Visit: https://plex.tv/api/resources?includeHttps=1&X-Plex-Token={YOUR_TOKEN}
Visit: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token
Also visit: https://plex.tv/api/resources?includeHttps=1&X-Plex-Token={YOUR_TOKEN}

## Overview

Expand All @@ -169,7 +168,10 @@ Visit: https://plex.tv/api/resources?includeHttps=1&X-Plex-Token={YOUR_TOKEN}
- **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.
- **Site Tags Mapping**: Map your Plex albums to site groups using album and artist names, then create collections based on specific tags.
- **Upstream Sync**: Push local Plex collection changes back to upstream collages on RED, enabling bidirectional synchronization between Plex collections and site collages.
- **Remote Mappings**: Core functionality that links Plex collections with site group IDs, enabling features like site tags and upstream sync.
- **Local SQLite Database**: All data (albums, collages, bookmarks, site mappings) 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.
Expand Down Expand Up @@ -216,6 +218,40 @@ red-plex collages convert [COLLAGE_IDS] --site [red|ops] --fetch-mode [torrent_n
red-plex collages update --fetch-mode [torrent_name|query]
```

### Upstream Sync

**⚠️ Important Prerequisites:**
- Only works with **RED** (Redacted) - OPS doesn't have the required API operations
- You must **own** the collages on the tracker site
- First **convert the collage** from the site using `red-plex collages convert` (even if the collage is empty)
- Run **remote mappings scan** to link Plex items with site group IDs: `red-plex db remote-mappings scan -s red`

**How it works:**
- Pushes local Plex collection changes back to upstream collages on RED
- Uses fuzzy string matching to find albums on the site (may cause occasional mismatches)
- Shows confirmation dialog with exactly what will be added before making changes
- **Never deletes** anything from upstream collages, only adds missing items
- If you update your Plex library, run a new remote-mappings scan to link new albums

```bash
# Sync all collections to upstream collages
red-plex collages update --push

# Sync specific collections to upstream collages
red-plex collages update 12345 67890 --push

# Alternative flag name
red-plex collages update --update-upstream
```

**Scanning Process:**
- Can be cancelled anytime with **Ctrl+C** and resumed later
- Each mapping is saved to the database during scanning (no data loss)
- Scans latest added entries in Plex, so interrupted scans can continue from where they left off
- ⚠️ **Current limitation**: If you have many unmatched albums (e.g., 200 albums with no matches), they'll appear in the scan queue each time. This is being improved to ignore previously failed matches.

**Available in both CLI and Web Interface**

### Bookmarks

```bash
Expand All @@ -226,6 +262,32 @@ red-plex bookmarks convert --site [red|ops] --fetch-mode [torrent_name|query]
red-plex bookmarks update --fetch-mode [torrent_name|query]
```

### Site Tags

```bash
# Create collections from albums matching specific tags
red-plex extras site-tags convert --tags [tag1,tag2,...] --collection-name [name]
```

### Remote Mappings

Remote mappings are the core functionality that links your Plex music library with site group IDs, enabling features like site tags and upstream sync.

```bash
# Scan albums and create remote mappings using album and artist names
red-plex db remote-mappings scan --site [red|ops] [--always-skip]

# Reset remote mappings (clears the relationship data)
red-plex db remote-mappings reset
```

**Scanning Features:**
- **Interruptible**: Can be cancelled with **Ctrl+C** at any time and resumed later
- **No data loss**: Each mapping is saved to database immediately during the scan
- **Incremental**: Processes latest Plex additions first, so you can resume interrupted scans
- **Fuzzy matching**: Uses string similarity to match Plex albums with site releases
- ⚠️ **Current limitation**: Albums with no matches will reappear in future scans (improvement planned)

### Fetch Mode (-fm)

The `--fetch-mode` (or `-fm`) option controls how red-plex locates albums in Plex:
Expand All @@ -249,6 +311,10 @@ red-plex db collections reset # Clear the collage collections table

# Manage bookmarks table
red-plex db bookmarks reset # Clear the bookmark collections table

# Manage remote mappings (core feature for site tags and upstream sync)
red-plex db remote-mappings scan --site [red|ops] # Create Plex-to-site mappings
red-plex db remote-mappings reset # Clear remote mapping data
```

## Examples
Expand All @@ -264,6 +330,16 @@ red-plex collages convert 1111 2222 3333 --site ops

# From bookmarks (RED or OPS), default mode
red-plex bookmarks convert --site red

# Remote mappings - scan albums and create mappings using album/artist names
red-plex db remote-mappings scan --site red

# Site tags - create collection from specific tags
red-plex extras site-tags convert --tags "electronic,ambient" --collection-name "Electronic Ambient"

# Upstream sync - push Plex collection changes back to RED collages (RED only)
red-plex collages update 12345 --push # Sync specific collage
red-plex collages update --push # Sync all collages
```

### Updating Collections
Expand All @@ -277,6 +353,9 @@ red-plex bookmarks update

# Update albums from Plex
red-plex db albums update

# Sync collections to upstream collages (RED only)
red-plex collages update --push
```

### Using Query Fetch Mode
Expand Down Expand Up @@ -305,9 +384,21 @@ 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
# 5. Scan albums for remote mappings (required for site tags and upstream sync)
red-plex db remote-mappings scan --site red

# 6. Create collections from specific tags
red-plex extras site-tags convert --tags "electronic,downtempo" --collection-name "Electronic Downtempo"

# 7. Sync collections back to upstream collages (RED only, requires ownership)
red-plex collages update --push

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

# 9. If you add new music to Plex, re-scan for new mappings
red-plex db remote-mappings scan --site red
```

#### Web Interface
Expand All @@ -325,7 +416,13 @@ red-plex gui

# 6. Use the Bookmarks page to convert your bookmarks

# 7. Return to Database page later to update all collections
# 7. Use the Remote Mappings page to scan albums and create mappings

# 8. Use Site Tags to create collections from specific tags

# 9. Use the Collages page to sync collections to upstream (RED only)

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

## Configuration Details
Expand Down Expand Up @@ -365,13 +462,6 @@ SECTION_NAME: Music

### 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
Expand Down Expand Up @@ -417,6 +507,16 @@ pip install red-plex --upgrade
- `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
- **Upstream Sync (RED Only)**:
- Only works with RED (Redacted) - OPS doesn't support the required API operations
- You must own the collages you want to sync to
- Convert collages from the site first, even if they're empty
- Run `red-plex db remote-mappings scan --site red` to create the necessary mappings
- Uses fuzzy string matching which may occasionally cause mismatches
- Never deletes items from upstream collages, only adds missing ones
- Can be interrupted with Ctrl+C and resumed later with no data loss
- Re-scan after adding new music to your Plex library
- **Remote Mappings**: Core functionality that links Plex items with site group IDs. Required for both site tags and upstream sync features

## Contributing

Expand All @@ -431,5 +531,3 @@ pip install -e .
```

---

**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.
90 changes: 90 additions & 0 deletions SITE_TAGS_USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Site Tags Feature Usage

This document explains how to use the new site tags functionality to create Plex collections based on site tags.

## Overview

The site tags feature allows you to:
1. Scan your Plex albums and map them to site groups based on filename searches
2. Create Plex collections from albums that match specific tags

## Prerequisites

1. Ensure your Plex server is configured and accessible
2. Configure your RED/OPS API credentials in the config file
3. Populate your albums database with `red-plex db albums update`

## Usage

### 1. Scan Albums for Site Tags

This command scans your albums and creates mappings to site groups:

```bash
# Scan albums for RED
red-plex extras site-tags scan --site red

# Scan albums for OPS
red-plex extras site-tags scan --site ops
```

The scan process:
- Fetches track file paths from each album in Plex
- Searches the site using filenames
- If multiple matches are found, prompts you to choose
- Creates mappings between Plex rating_key and site group_id + tags
- Is incremental - only processes albums not yet scanned

### 2. Create Collections from Tags

Create Plex collections based on tag filters:

```bash
# Create a collection of electronic music
red-plex extras site-tags convert --site red --tags "electronic" --collection-name "Electronic Music"

# Create a collection with multiple tag requirements
red-plex extras site-tags convert --site red --tags "drum.and.bass,liquid" --collection-name "Liquid DNB"
```

### 3. Reset Site Tag Mappings

If you need to reset the mappings:

```bash
# Reset mappings for a specific site
red-plex extras site-tags reset --site red

# Reset all mappings
red-plex extras site-tags reset
```

## Examples

### Example Workflow

1. **Initial scan:**
```bash
red-plex db albums update
red-plex extras site-tags scan --site red
```

2. **Create genre-based collections:**
```bash
red-plex extras site-tags convert --site red --tags "electronic" --collection-name "Electronic"
red-plex extras site-tags convert --site red --tags "jazz" --collection-name "Jazz"
red-plex extras site-tags convert --site red --tags "rock" --collection-name "Rock"
```

3. **Create specific sub-genre collections:**
```bash
red-plex extras site-tags convert --site red --tags "drum.and.bass,liquid" --collection-name "Liquid DNB"
red-plex extras site-tags convert --site red --tags "ambient,dark" --collection-name "Dark Ambient"
```

## Notes

- The scan process handles filename variations (e.g., removes track numbers like "1. " from the beginning)
- Multiple matches require user confirmation to ensure accuracy
- Collections are created/updated in Plex - existing collections with the same name will be replaced
- The tag matching uses AND logic - all specified tags must be present for an album to match
1 change: 1 addition & 0 deletions red_plex/domain/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TorrentGroup:
artists: List[str] = field(default_factory=list)
album_name: str = ""
file_paths: List[str] = field(default_factory=list)
tags: List[str] = field(default_factory=list)

def __hash__(self) -> int:
return hash((self.id, tuple(self.artists), self.album_name, tuple(self.file_paths)))
Expand Down
Loading