fix: corriger les imports cassés dans router_watchlist.py
Remplace 'from main import watchlist_manager' par 'from app.watchlist import watchlist_manager' et 'from main import auto_download_scheduler' par 'from app.auto_download_scheduler import auto_download_scheduler'. watchlist_manager n'est pas exposé dans main.py, ce qui causait un ImportError 500 sur GET /api/watchlist. Lié à #15
This commit is contained in:
@@ -47,7 +47,7 @@ async def add_to_watchlist(
|
|||||||
current_user: User = Depends(get_current_user_from_token),
|
current_user: User = Depends(get_current_user_from_token),
|
||||||
):
|
):
|
||||||
"""Add an anime to the watchlist"""
|
"""Add an anime to the watchlist"""
|
||||||
from main import watchlist_manager
|
from app.watchlist import watchlist_manager
|
||||||
|
|
||||||
try:
|
try:
|
||||||
existing = watchlist_manager.get_by_anime_url(
|
existing = watchlist_manager.get_by_anime_url(
|
||||||
@@ -81,7 +81,7 @@ async def get_watchlist(
|
|||||||
html: bool = Query(False),
|
html: bool = Query(False),
|
||||||
current_user: Optional[User] = Depends(get_optional_user),
|
current_user: Optional[User] = Depends(get_optional_user),
|
||||||
):
|
):
|
||||||
from main import watchlist_manager
|
from app.watchlist import watchlist_manager
|
||||||
|
|
||||||
is_htmx = request.headers.get("HX-Request")
|
is_htmx = request.headers.get("HX-Request")
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ async def get_watchlist_settings(
|
|||||||
current_user: User = Depends(get_current_user_from_token),
|
current_user: User = Depends(get_current_user_from_token),
|
||||||
):
|
):
|
||||||
"""Get global watchlist settings"""
|
"""Get global watchlist settings"""
|
||||||
from main import watchlist_manager
|
from app.watchlist import watchlist_manager
|
||||||
|
|
||||||
return watchlist_manager.get_settings()
|
return watchlist_manager.get_settings()
|
||||||
|
|
||||||
@@ -120,7 +120,8 @@ async def update_watchlist_settings(
|
|||||||
current_user: User = Depends(get_current_user_from_token),
|
current_user: User = Depends(get_current_user_from_token),
|
||||||
):
|
):
|
||||||
"""Update global watchlist settings"""
|
"""Update global watchlist settings"""
|
||||||
from main import auto_download_scheduler, watchlist_manager
|
from app.auto_download_scheduler import auto_download_scheduler
|
||||||
|
from app.watchlist import watchlist_manager
|
||||||
|
|
||||||
try:
|
try:
|
||||||
updated_settings = watchlist_manager.update_settings(settings)
|
updated_settings = watchlist_manager.update_settings(settings)
|
||||||
@@ -148,7 +149,7 @@ async def get_watchlist_item(
|
|||||||
current_user: User = Depends(get_current_user_from_token),
|
current_user: User = Depends(get_current_user_from_token),
|
||||||
):
|
):
|
||||||
"""Get a specific watchlist item"""
|
"""Get a specific watchlist item"""
|
||||||
from main import watchlist_manager
|
from app.watchlist import watchlist_manager
|
||||||
|
|
||||||
item = watchlist_manager.get_by_id(item_id)
|
item = watchlist_manager.get_by_id(item_id)
|
||||||
if not item or item.user_id != current_user.id:
|
if not item or item.user_id != current_user.id:
|
||||||
@@ -164,7 +165,7 @@ async def update_watchlist_item(
|
|||||||
current_user: User = Depends(get_current_user_from_token),
|
current_user: User = Depends(get_current_user_from_token),
|
||||||
):
|
):
|
||||||
"""Update a watchlist item"""
|
"""Update a watchlist item"""
|
||||||
from main import watchlist_manager
|
from app.watchlist import watchlist_manager
|
||||||
|
|
||||||
item = watchlist_manager.get_by_id(item_id)
|
item = watchlist_manager.get_by_id(item_id)
|
||||||
if not item or item.user_id != current_user.id:
|
if not item or item.user_id != current_user.id:
|
||||||
@@ -190,7 +191,7 @@ async def delete_from_watchlist(
|
|||||||
current_user: User = Depends(get_current_user_from_token),
|
current_user: User = Depends(get_current_user_from_token),
|
||||||
):
|
):
|
||||||
"""Remove an anime from the watchlist"""
|
"""Remove an anime from the watchlist"""
|
||||||
from main import watchlist_manager
|
from app.watchlist import watchlist_manager
|
||||||
|
|
||||||
item = watchlist_manager.get_by_id(item_id)
|
item = watchlist_manager.get_by_id(item_id)
|
||||||
if not item or item.user_id != current_user.id:
|
if not item or item.user_id != current_user.id:
|
||||||
@@ -219,7 +220,7 @@ async def check_watchlist_now(
|
|||||||
current_user: User = Depends(get_current_user_from_token),
|
current_user: User = Depends(get_current_user_from_token),
|
||||||
):
|
):
|
||||||
"""Trigger an immediate check for new episodes"""
|
"""Trigger an immediate check for new episodes"""
|
||||||
from main import auto_download_scheduler
|
from app.auto_download_scheduler import auto_download_scheduler
|
||||||
|
|
||||||
background_tasks.add_task(auto_download_scheduler.trigger_check_now)
|
background_tasks.add_task(auto_download_scheduler.trigger_check_now)
|
||||||
response.headers["HX-Trigger"] = json.dumps(
|
response.headers["HX-Trigger"] = json.dumps(
|
||||||
@@ -239,6 +240,6 @@ async def get_watchlist_stats(
|
|||||||
current_user: User = Depends(get_current_user_from_token),
|
current_user: User = Depends(get_current_user_from_token),
|
||||||
):
|
):
|
||||||
"""Get watchlist statistics for the user"""
|
"""Get watchlist statistics for the user"""
|
||||||
from main import watchlist_manager
|
from app.watchlist import watchlist_manager
|
||||||
|
|
||||||
return watchlist_manager.get_stats(current_user.id)
|
return watchlist_manager.get_stats(current_user.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user