Skip to content

Commit

Permalink
fix: item not being indexed properly when adding it manually
Browse files Browse the repository at this point in the history
  • Loading branch information
davidemarcoli committed Oct 19, 2024
1 parent 51b64e4 commit 27ac133
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/controllers/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from RTN import Torrent
from sqlalchemy import and_, func, or_, select
from sqlalchemy.exc import NoResultFound
from program.indexers.trakt import create_item_from_imdb_id
from program.indexers.trakt import TraktIndexer, create_item_from_imdb_id
from utils.logger import logger
from utils.torrent import get_type_and_infohash

Expand Down Expand Up @@ -246,11 +246,15 @@ async def add_item_manually(request: Request, imdb_id: str = None, input: str =
if not infohash:
raise HTTPException(status_code=400, detail="No valid input provided")

trakt: TraktIndexer = request.app.program.services.get(TraktIndexer)
downloader: Downloader = request.app.program.services.get(Downloader)
with db.Session() as session:
item = create_item_from_imdb_id(imdb_id)
item.requested_by = "user"
item.requested_at = datetime.now()
item = MediaItem(
{"imdb_id": imdb_id, "requested_by": "user", "requested_at": datetime.now()}
)
item = next(trakt.run(item), None)
if item is None:
raise HTTPException(status_code=500, detail="Failed to index item")

needed_media = get_needed_media(item)
cached_streams = downloader.get_cached_streams([infohash], needed_media)
Expand Down

0 comments on commit 27ac133

Please sign in to comment.