Skip to content

Commit 9c6c8ce

Browse files
committed
feat: bypass maintainerr api limits using media-server endpoint (v2.0.2)
1 parent 4de548c commit 9c6c8ce

3 files changed

Lines changed: 28 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[![Docker Build](https://github.com/00Scooby/maintainerr-plex-sync/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/00Scooby/maintainerr-plex-sync/actions/workflows/docker-publish.yml)
55
[![Docker Package](https://img.shields.io/badge/docker-ghcr.io-blue.svg)](https://github.com/00Scooby/maintainerr-plex-sync/pkgs/container/maintainerr-plex-sync)
6-
[![Version](https://img.shields.io/badge/version-2.0.1-brightgreen.svg)](https://github.com/00Scooby/maintainerr-plex-sync/releases/latest)
6+
[![Version](https://img.shields.io/badge/version-2.0.2-brightgreen.svg)](https://github.com/00Scooby/maintainerr-plex-sync/releases/latest)
77
[![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/)
88
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
99

README_DE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[![Docker Build](https://github.com/00Scooby/maintainerr-plex-sync/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/00Scooby/maintainerr-plex-sync/actions/workflows/docker-publish.yml)
55
[![Docker Package](https://img.shields.io/badge/docker-ghcr.io-blue.svg)](https://github.com/00Scooby/maintainerr-plex-sync/pkgs/container/maintainerr-plex-sync)
6-
[![Version](https://img.shields.io/badge/version-2.0.1-brightgreen.svg)](https://github.com/00Scooby/maintainerr-plex-sync/releases/latest)
6+
[![Version](https://img.shields.io/badge/version-2.0.2-brightgreen.svg)](https://github.com/00Scooby/maintainerr-plex-sync/releases/latest)
77
[![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/)
88
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
99

main.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
PLEX_URL = os.environ.get("PLEX_URL")
1717
PLEX_TOKEN = os.environ.get("PLEX_TOKEN")
1818
MAINTAINERR_URL = os.environ.get("MAINTAINERR_URL")
19-
CURRENT_VERSION = "2.0.1"
19+
CURRENT_VERSION = "2.0.2"
2020

2121
def load_config():
2222
try:
@@ -164,15 +164,36 @@ def sync_collections():
164164
delete_days = coll.get("deleteAfterDays", 30)
165165
media_list = coll.get("media", [])
166166

167-
logging.info(f"✅ Kollektion '{coll_title}' in Maintainerr gefunden. Verarbeite {len(media_list)} Items...")
167+
# --- NEU: Paginierung / Media-Server Workaround ---
168+
media_count = coll.get("mediaCount", len(media_list))
169+
plex_collection_id = coll.get("mediaServerId")
170+
171+
if media_count > len(media_list) and plex_collection_id:
172+
logging.info(f"🔍 API-Limit erkannt ({len(media_list)}/{media_count} geliefert). Lade komplette Liste für '{coll_title}' via Media-Server Endpoint...")
173+
try:
174+
children_api = f"{MAINTAINERR_URL}/api/media-server/collection/{plex_collection_id}/children"
175+
c_resp = requests.get(children_api, headers={"Accept": "application/json"})
176+
c_resp.raise_for_status()
177+
178+
# Die kurze Liste mit der vollständigen überschreiben
179+
media_list = c_resp.json()
180+
logging.info(f"✅ Erfolgreich {len(media_list)} Items nachgeladen.")
181+
except Exception as e:
182+
logging.error(f"❌ Fehler beim Nachladen der Items für '{coll_title}': {e}")
183+
# --------------------------------------------------
184+
185+
logging.info(f"▶️ Verarbeite {len(media_list)} Items aus Kollektion '{coll_title}'...")
168186

169187
sortable_items = []
170188
for item in media_list:
171-
plex_id = item.get("mediaServerId")
172-
add_date = item.get("addDate")
189+
# Flexibel auf Maintainerr- und Media-Server-Datenstruktur reagieren
190+
plex_id = item.get("mediaServerId") or item.get("ratingKey")
191+
add_date = item.get("addDate") or item.get("addedAt")
192+
173193
if not plex_id or not add_date: continue
174194

175-
days_left = calculate_days_left(add_date, delete_days)
195+
# Dank unserer Normalisierung von vorhin frisst er hier jedes Format!
196+
days_left = calculate_days_left(str(add_date), delete_days)
176197
sortable_items.append({"plex_id": int(plex_id), "days_left": days_left})
177198

178199
sortable_items.sort(key=lambda x: x["days_left"])

0 commit comments

Comments
 (0)