Add per-episode fallback for incomplete TV seasons
When a complete-season pack cannot be found for a missing/partial season, fillMissing now searches each missing SxxExx individually and queues the best episode torrent per gap. Also exposes episode-level detail in the /fill response and season plan. Signed-off-by: William Mantly <wmantly@gmail.com>
This commit is contained in:
@@ -44,25 +44,26 @@ async function movieInLibrary(tmdbId){
|
||||
}
|
||||
}
|
||||
|
||||
// Which episodes of a series are already present, grouped by season( season -> count).
|
||||
// Which episodes of a series are already present, grouped by season.
|
||||
// Returns { owned, seriesId, have: { season: Set(episode) }, counts: { season: n } }.
|
||||
async function seriesInventory(tmdbId){
|
||||
try{
|
||||
let s = await embyGet(`/Items?Recursive=true&IncludeItemTypes=Series&AnyProviderIdEquals=tmdb.${tmdbId}&Fields=ProviderIds`);
|
||||
let series = (s.Items || [])[0];
|
||||
if(!series) return { owned: false, have: {} };
|
||||
if(!series) return { owned: false, have: {}, counts: {} };
|
||||
|
||||
let ep = await embyGet(`/Shows/${series.Id}/Episodes`);
|
||||
let sets = {};
|
||||
let have = {};
|
||||
for(let e of ep.Items || []){
|
||||
let sn = e.ParentIndexNumber, en = e.IndexNumber;
|
||||
if(sn == null || en == null || sn === 0) continue; // skip specials
|
||||
(sets[sn] = sets[sn] || new Set()).add(en);
|
||||
(have[sn] = have[sn] || new Set()).add(en);
|
||||
}
|
||||
let have = {};
|
||||
for(let sn of Object.keys(sets)) have[sn] = sets[sn].size;
|
||||
return { owned: true, seriesId: series.Id, have };
|
||||
let counts = {};
|
||||
for(let sn of Object.keys(have)) counts[sn] = have[sn].size;
|
||||
return { owned: true, seriesId: series.Id, have, counts };
|
||||
}catch(error){
|
||||
return { owned: false, have: {}, unknown: true };
|
||||
return { owned: false, have: {}, counts: {}, unknown: true };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user