AnthonyMusgrove / Emby-ScripterX

Run custom external application or script (batch/bash/powershell/php/python/node.js/custom) on various events within the Emby Server.
https://emby-scripterx.com
76 stars 6 forks source link

Token for ID %recording.tuner.friendlyname% does not exist #45

Closed sfatula closed 3 years ago

sfatula commented 4 years ago

Describe the bug I have an action for OnRecordingTimerCreated. In the where clause, I reference %recording.tuner.friendlyname% but it no longer works.

To Reproduce Steps to reproduce the behavior:

  1. Create some sort of OnRecordingTimerCreated action.
  2. In the where clause, use %recording.tuner.friendlyname%
  3. You will see in the Emby log an error

Expected behavior It should check the condition

Desktop (please complete the following information):

Additional context

Application directory: /opt/emby-server/system
System.Exception: System.Exception: Token for ID %recording.tuner.friendlyname% does not exist.
at EmbyScripterX.Core.ScripterXEventContext.getTokenbyId(String token_id)
at EmbyScripterX.Core.ScripterXEventContext.checkConditions()
at EmbyScripterX.Core.ScripterXEventContext.Process(EmbyScripterXAction withAction)
at EmbyScripterX.ScripterXDVRMonitor._embyTv_TimerCreated(Object sender, GenericEventArgs`1 e)
at Emby.LiveTV.EmbyTV.CreateTimer(TimerInfo timer, CancellationToken cancellationToken)
at Emby.LiveTV.LiveTvManager.CreateTimer(TimerInfoDto timer, CancellationToken cancellationToken)
at Emby.Server.Implementations.Services.ServiceController.GetTaskResult(Task task)
at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost appHost, IRequest httpReq, IResponse httpRes, RestPath restPath, String responseContentType, CancellationToken cancellationToken)
at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, ReadOnlyMemory`1 urlString, ReadOnlyMemory`1 localPath, CancellationToken cancellationToken)
Source: EmbyScripterX
TargetSite: EmbyScripterX.Core.TokenVariable getTokenbyId(System.String)
AnthonyMusgrove commented 3 years ago

hi @sfatula, thank you for reporting this one.

The _onRecordingTimerCreated event only populates %recording.tuner.friendlyname% if it can get the active tuner info, retrieved by the active tuner host ID.

So I've now added an else clause, where if the tuner information cannot be retrieved, it will set the token values to:

%recording.tuner.friendlyname% -> tunerInfo (friendlyname) is empty for TunerHostId (TunerHostId)
%recording.tuner.source% -> tunerInfo (source) is empty for TunerHostId (TunerHostId)
%recording.tuner.count% -> 0
%recording.tuner.type% -> tunerInfo (type) is empty for TunerHostId (TunerHostId)
%recording.tuner.url% -> tunerInfo (URL) is empty for TunerHostId (TunerHostId)
%recording.tuner.deviceid% -> tunerInfo (device ID) is empty for TunerHostId (TunerHostId)
%recording.tuner.retrieval.error% -> any logical error that is returned if the tuner info isn't retrievable

(I've also added %recording.tuner.retrieval.error% (incase there is a logical error in your implementation for the tuner info to fail being retrieved)) These changes will be available soon in the next catalog release (v3.0.5.3). Please test this for me and let me know if there's any logical errors occuring, so I can possibly investigate further.

Thank you, kindest regards, Anthony