81 lines
2.9 KiB
C#
81 lines
2.9 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using Jellyfin.Data.Entities;
|
|
using Jellyfin.Data.Enums;
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
using Jellyfin.Plugin.SmartPlaylist.Lisp;
|
|
using Jellyfin.Plugin.SmartPlaylist.Lisp.Compiler;
|
|
|
|
namespace Jellyfin.Plugin.SmartPlaylist.ScheduledTasks {
|
|
|
|
public class Common {
|
|
public static readonly BaseItemKind[] AvailableFilterItems = {
|
|
BaseItemKind.Audio,
|
|
BaseItemKind.AudioBook,
|
|
BaseItemKind.Book,
|
|
BaseItemKind.BoxSet,
|
|
BaseItemKind.Channel,
|
|
// BaseItemKind.ChannelFolderItem,
|
|
// BaseItemKind.CollectionFolder,
|
|
BaseItemKind.Episode,
|
|
// BaseItemKind.Folder,
|
|
BaseItemKind.Genre,
|
|
// BaseItemKind.ManualPlaylistsFolder,
|
|
BaseItemKind.Movie,
|
|
BaseItemKind.LiveTvChannel,
|
|
BaseItemKind.LiveTvProgram,
|
|
BaseItemKind.MusicAlbum,
|
|
BaseItemKind.MusicArtist,
|
|
BaseItemKind.MusicGenre,
|
|
BaseItemKind.MusicVideo,
|
|
BaseItemKind.Person,
|
|
BaseItemKind.Photo,
|
|
BaseItemKind.PhotoAlbum,
|
|
BaseItemKind.Playlist,
|
|
// BaseItemKind.PlaylistsFolder,
|
|
BaseItemKind.Program,
|
|
BaseItemKind.Recording,
|
|
BaseItemKind.Season,
|
|
BaseItemKind.Series,
|
|
BaseItemKind.Studio,
|
|
BaseItemKind.Trailer,
|
|
BaseItemKind.TvChannel,
|
|
BaseItemKind.TvProgram,
|
|
BaseItemKind.UserView,
|
|
BaseItemKind.Video,
|
|
BaseItemKind.Year
|
|
};
|
|
|
|
|
|
public readonly ILogger _logger;
|
|
public Common(ILogger logger) {
|
|
_logger = logger;
|
|
}
|
|
public Executor SetupExecutor() {
|
|
var env = new DefaultEnvironment();
|
|
var executor = new Executor(env);
|
|
executor.builtins["logd"] = (x) => {
|
|
_logger.LogDebug(((Lisp.String)x.First()).Value(), x.Skip(1).ToArray());
|
|
return Lisp.Boolean.TRUE;
|
|
};
|
|
executor.builtins["logi"] = (x) => {
|
|
_logger.LogInformation(((Lisp.String)x.First()).Value(), x.Skip(1).ToArray());
|
|
return Lisp.Boolean.TRUE;
|
|
};
|
|
executor.builtins["logw"] = (x) => {
|
|
_logger.LogWarning(((Lisp.String)x.First()).Value(), x.Skip(1).ToArray());
|
|
return Lisp.Boolean.TRUE;
|
|
};
|
|
executor.builtins["loge"] = (x) => {
|
|
_logger.LogError(((Lisp.String)x.First()).Value(), x.Skip(1).ToArray());
|
|
return Lisp.Boolean.TRUE;
|
|
};
|
|
if (Plugin.Instance is not null) {
|
|
executor.eval(Plugin.Instance.Configuration.InitialProgram);
|
|
} else {
|
|
throw new ApplicationException("Plugin Instance is not yet initialized");
|
|
}
|
|
return executor;
|
|
}
|
|
}
|
|
}
|