Add library/genres commands and recommendation skills
- bin/audiobooks: add library [limit] [--full] and genres commands - bin/jellyfin: add library [limit] [--full] and genres commands - skills/book-recommender: new skill for audiobook recommendations - skills/media-recommender: new skill for movie/show recommendations
This commit is contained in:
parent
503f88820d
commit
df0693f01d
4 changed files with 112 additions and 1 deletions
35
bin/jellyfin
35
bin/jellyfin
|
|
@ -219,6 +219,39 @@ const commands = {
|
|||
console.log(`Episodes watched:\t${episodes.TotalRecordCount}`);
|
||||
},
|
||||
|
||||
async library(limitArg) {
|
||||
const uid = await getUserId();
|
||||
const full = process.argv.includes('--full');
|
||||
const [movies, shows] = await Promise.all([
|
||||
api(`/Users/${uid}/Items?IncludeItemTypes=Movie&Recursive=true&SortBy=SortName&Fields=Genres,OfficialRating,Overview,RunTimeTicks&Limit=${limitArg && limitArg !== '--full' ? limitArg : 10000}`),
|
||||
api(`/Users/${uid}/Items?IncludeItemTypes=Series&Recursive=true&SortBy=SortName&Fields=Genres,OfficialRating,Overview,RunTimeTicks&Limit=${limitArg && limitArg !== '--full' ? limitArg : 10000}`)
|
||||
]);
|
||||
console.log('TYPE\tTITLE\tYEAR\tGENRES\tRATING\tDURATION\tSTATUS\tDESCRIPTION');
|
||||
const printItem = (type, i) => {
|
||||
const genres = (i.Genres || []).join(',') || '-';
|
||||
const rating = i.OfficialRating || '-';
|
||||
const overview = i.Overview || '';
|
||||
const desc = full ? overview.replace(/[\t\n\r]/g, ' ') : (overview.length > 100 ? overview.slice(0, 100).replace(/[\t\n\r]/g, ' ') + '...' : overview.replace(/[\t\n\r]/g, ' ')) || '-';
|
||||
const status = pct(i.UserData, i.RunTimeTicks) || '-';
|
||||
console.log([type, i.Name, i.ProductionYear || '', genres, rating, dur(i.RunTimeTicks), status, desc].join('\t'));
|
||||
};
|
||||
(movies.Items || []).forEach(i => printItem('MOV', i));
|
||||
(shows.Items || []).forEach(i => printItem('SHOW', i));
|
||||
},
|
||||
|
||||
async genres() {
|
||||
const uid = await getUserId();
|
||||
const [movies, shows] = await Promise.all([
|
||||
api(`/Users/${uid}/Items?IncludeItemTypes=Movie&Recursive=true&Fields=Genres&Limit=10000`),
|
||||
api(`/Users/${uid}/Items?IncludeItemTypes=Series&Recursive=true&Fields=Genres&Limit=10000`)
|
||||
]);
|
||||
const counts = {};
|
||||
[...(movies.Items || []), ...(shows.Items || [])].forEach(i => {
|
||||
(i.Genres || []).forEach(g => { counts[g] = (counts[g] || 0) + 1; });
|
||||
});
|
||||
Object.entries(counts).sort((a, b) => b[1] - a[1]).forEach(([g, c]) => console.log(`${g}\t${c}`));
|
||||
},
|
||||
|
||||
async libraries() {
|
||||
const uid = await getUserId();
|
||||
const r = await api(`/Users/${uid}/Views`);
|
||||
|
|
@ -242,6 +275,8 @@ if (!cmd || !commands[cmd]) {
|
|||
console.log(' movies All movies');
|
||||
console.log(' search <query> Search library');
|
||||
console.log(' stats Watch statistics');
|
||||
console.log(' library [limit] All movies & shows with metadata (--full for full descriptions)');
|
||||
console.log(' genres List genres with counts');
|
||||
console.log(' libraries List libraries');
|
||||
process.exit(0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue