Skip to content

Commit 672bfbc

Browse files
authored
Merge pull request #139 from cporcellijr/feature/restore-auto-forge-collections
Fix auto forge collections Fix Booklore shelf assignment during batch-match
2 parents b478be7 + c04e4a0 commit 672bfbc

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/services/forge_service.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,22 @@ def _auto_forge_background_task(self, abs_id, text_item, title, author, original
565565
else:
566566
logger.error(f"❌ Auto-Forge: Book {abs_id} not found in DB to update!")
567567

568+
# --- ADD TO COLLECTIONS/SHELVES ---
569+
try:
570+
abs_collection_name = os.environ.get("ABS_COLLECTION_NAME", "Synced with KOReader")
571+
self.abs_client.add_to_collection(abs_id, abs_collection_name)
572+
573+
if self.booklore_client:
574+
shelf_filename = original_filename if original_filename else target_filename
575+
booklore_shelf_name = os.environ.get("BOOKLORE_SHELF_NAME", "Kobo")
576+
self.booklore_client.add_to_shelf(shelf_filename, booklore_shelf_name)
577+
578+
if self.storyteller_client:
579+
self.storyteller_client.add_to_collection(target_filename)
580+
581+
except Exception as e:
582+
logger.warning(f"⚠️ Auto-Forge: Failed to add to collections/shelves: {e}")
583+
568584
# --- CLEANUP ---
569585
AUDIO_EXTENSIONS = {'.mp3', '.m4b', '.m4a', '.flac', '.ogg', '.opus', '.wma', '.wav', '.aac'}
570586
for f in course_dir.iterdir():

src/web_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,8 @@ def batch_match():
14891489

14901490
container.abs_client().add_to_collection(item['abs_id'], ABS_COLLECTION_NAME)
14911491
if container.booklore_client().is_configured():
1492-
container.booklore_client().add_to_shelf(ebook_filename, BOOKLORE_SHELF_NAME)
1492+
shelf_filename = original_ebook_filename or ebook_filename
1493+
container.booklore_client().add_to_shelf(shelf_filename, BOOKLORE_SHELF_NAME)
14931494
if container.storyteller_client().is_configured():
14941495
container.storyteller_client().add_to_collection(ebook_filename)
14951496

0 commit comments

Comments
 (0)