Compare commits
2 commits
3f1a1e1a78
...
81184c23a7
Author | SHA1 | Date | |
---|---|---|---|
81184c23a7 | |||
0059fc43e1 |
3 changed files with 27 additions and 2 deletions
|
@ -113,7 +113,7 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp {
|
|||
|
||||
public class Builtins : Dictionary<string, Function> {
|
||||
|
||||
private static Dictionary<string, Assembly> AssemblyMapping = new Dictionary<string, Assembly>();
|
||||
private static Dictionary<string, Type?> ResolvedTypes = new Dictionary<string, Type?>();
|
||||
|
||||
public Builtins() : base() {
|
||||
this["atom"] = _atom;
|
||||
|
@ -261,12 +261,17 @@ namespace Jellyfin.Plugin.SmartPlaylist.Lisp {
|
|||
}
|
||||
|
||||
private static Type? GetType(string name) {
|
||||
return Type.GetType(
|
||||
if (ResolvedTypes.ContainsKey(name)) {
|
||||
return ResolvedTypes[name];
|
||||
}
|
||||
var t = Type.GetType(
|
||||
name,
|
||||
(name) => { return AppDomain.CurrentDomain.GetAssemblies().Where(z => (z.FullName != null) && z.FullName.StartsWith(name.FullName)).FirstOrDefault(); },
|
||||
null,
|
||||
true
|
||||
);
|
||||
ResolvedTypes[name] = t;
|
||||
return t;
|
||||
}
|
||||
|
||||
private static Expression _invoke_generic(IEnumerable<Expression> args) {
|
||||
|
|
|
@ -98,6 +98,24 @@ namespace Jellyfin.Plugin.SmartPlaylist.ScheduledTasks {
|
|||
List<BaseItem> results = new List<BaseItem>();
|
||||
Expression expression = new Parser(StringTokenStream.generate(smartPlaylist.Program)).parse(); // parse here, so that we don't repeat the work for each item
|
||||
Executor executor = new Executor(new DefaultEnvironment());
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
executor.environment.Set("user", Lisp_Object.FromBase(user));
|
||||
if (Plugin.Instance is not null) {
|
||||
executor.eval(Plugin.Instance.Configuration.InitialProgram);
|
||||
|
|
|
@ -129,6 +129,8 @@ the items by name you could use the following program:
|
|||
- **is-type**: matches the type of item look at
|
||||
[BaseItemKind.cs](https://github.com/jellyfin/jellyfin/blob/master/Jellyfin.Data/Enums/BaseItemKind.cs)
|
||||
for a list of items. The plugin has enabled support for `Audio, MusicAlbum, Playlist` (`(is-type "Audio")`)
|
||||
- **log[diwe]**: write to the logger with the respective levels (`debug`, `information`, `warning`, `error`).
|
||||
Takes the same arguments as `Logger.LogInformation(...)`.
|
||||
|
||||
### Filename
|
||||
|
||||
|
|
Loading…
Reference in a new issue