Remember unavailable movies and auto-grab them later (wishlist)
When Smart Search finds no good copy of a movie (unreleased / only CAMs), we now record it instead of dropping it: - New Wanted model + migration (dedup by tmdbId, status wanted|fulfilled). - POST /__api/search/releases remembers a movie when it returns no options, and the UI confirms it was added to the wishlist. - controller/wantedWatcher re-runs Smart Search for wishlisted items every 6h (and on boot); when a good copy appears it queues the recommended release, which then flows through the normal download + organize pipeline, and marks the item fulfilled. - GET/DELETE /__api/search/wanted to view/remove the wishlist. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+36
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
const router = require('express').Router();
|
||||
const search = require('>/controller/search');
|
||||
const { Torrent } = require('>/models');
|
||||
const { Torrent, Wanted } = require('>/models');
|
||||
|
||||
// Step 1: fuzzy query -> a few TMDB title candidates( with posters) to confirm.
|
||||
router.get('/title', async function(req, res, next){
|
||||
@@ -16,7 +16,41 @@ router.get('/title', async function(req, res, next){
|
||||
// Step 2: confirmed title -> TPB search + LLM-curated release options.
|
||||
router.post('/releases', async function(req, res, next){
|
||||
try{
|
||||
res.json(await search.findReleases(req.body.tmdbId, req.body.mediaType));
|
||||
let result = await search.findReleases(req.body.tmdbId, req.body.mediaType);
|
||||
|
||||
// Nothing good yet( e.g. unreleased) -> remember it and grab it later.
|
||||
if(!result.options.length && result.mediaType !== 'tv' && result.tmdbId){
|
||||
await Wanted.upsert({
|
||||
tmdbId: String(result.tmdbId),
|
||||
mediaType: result.mediaType,
|
||||
title: result.title,
|
||||
year: result.year,
|
||||
status: 'wanted',
|
||||
requestedBy: req.user.username,
|
||||
});
|
||||
result.remembered = true;
|
||||
}
|
||||
|
||||
res.json(result);
|
||||
}catch(error){
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
// Wishlist: things we couldn't find yet and are watching for.
|
||||
router.get('/wanted', async function(req, res, next){
|
||||
try{
|
||||
res.json(await Wanted.findAll({ order: [['createdAt', 'DESC']] }));
|
||||
}catch(error){
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
router.delete('/wanted/:tmdbId', async function(req, res, next){
|
||||
try{
|
||||
let wanted = await Wanted.findByPk(req.params.tmdbId);
|
||||
if(wanted) await wanted.destroy();
|
||||
res.json({ deleted: true });
|
||||
}catch(error){
|
||||
next(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user