ankenyr / jellyfin-smartplaylist-plugin

GNU Affero General Public License v3.0
52 stars 12 forks source link

MenberName compare with a string #4

Open stilobique opened 3 years ago

stilobique commented 3 years ago

Hello, thanks with your plugin. It's really awesome.

I don't know if it's a bug ; hovewer, if i'm write a playlist with a MemberName type string, Jellyfin give me an error. I don't find a good operator to find a string.

With this example, i have this error :

{
    "MemberName": "Name",
    "Operator": "Contains",
    "TargetValue": "String"
}
Ambiguous match found. at System.RuntimeType.GetMethodImplCommon(String name, Int32 genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
 at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers) 
 at System.Type.GetMethod(String name, BindingFlags bindingAttr) at Jellyfin.Plugin.SmartPlaylist.QueryEngine.Engine.BuildExpr[T](Expression r, ParameterExpression param) 
 at Jellyfin.Plugin.SmartPlaylist.QueryEngine.Engine.CompileRule[T](Expression r) 
 at Jellyfin.Plugin.SmartPlaylist.SmartPlaylist.<>c.b__29_0(Expression r) 
 at System.Linq.Enumerable.SelectListIterator`2.ToList() 
 at Jellyfin.Plugin.SmartPlaylist.SmartPlaylist.CompileRuleSets() 
 at Jellyfin.Plugin.SmartPlaylist.SmartPlaylist.FilterPlaylistItems(IEnumerable`1 items, ILibraryManager libraryManager, User user) 
 at Jellyfin.Plugin.SmartPlaylist.ScheduleTasks.RefreshAllPlaylists.Execute(CancellationToken cancellationToken, IProgress`1 progress) 
 at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)

No error with other List type. My operator is bad ? If i'm use an Operator type Equal, no error.

ankenyr commented 3 years ago

Thanks for the compliment!

I think the problem is that Contains is not valid for a string https://github.com/ankenyr/jellyfin-smartplaylist-plugin/blob/master/Jellyfin.Plugin.SmartPlaylist/QueryEngine/Operand.cs#L15

Are you trying to find media that has a title that contains, for example, "Dark" to get the movies "Dark City" and "The Dark Knight" etc etc?

stilobique commented 3 years ago

Are you trying to find media that has a title that contains, for example, "Dark" to get the movies "Dark City" and "The Dark Knight" etc etc?

Yes, exactly ; i wish find all medias with the keyword "Dark".

ankenyr commented 3 years ago

Good question, sadly I seem to have garbage collected most of this info. My intention was to flesh this out more but I have been pretty busy with work and family. I plan on taking a vacation in a few weeks after my team launched our new project. During that time I was going to give this, my other plugin, and possibly the jellyfin android app some love.

In general though the commands such as "Contains" or "Equals" are related to linq and are functions called on the object. IIRC contains has multiple signatures and this is matching more than one so linq has no idea which one to call. The solution was to implement my own methods that call the specific method since we are using reflection.

If you have experience in C# please feel free to try and fix it. If not I will keep this open and resolve it when I get some time.

stilobique commented 3 years ago

Hi, thanks for your answers. I don't have experience with C# ; maybe it's time to try this language. But i don't have the time to test now. Once again, thanks for your work and your answer ;) .