Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions kodi-plugin.coffee
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ module.exports = (env) ->
info.label
else ''
)
@_setCurrentArtist(if info.artist? then info.artist else "")
@_setCurrentArtist(if info.artist.lenght > 0 then info.artist[0] else "")
else
@_setCurrentArtist ''
@_setCurrentTitle ''
Expand Down Expand Up @@ -325,14 +325,14 @@ module.exports = (env) ->
return {
token: match
nextInput: input.substring(match.length)
actionHandler: new KodiExecuteOpenActionHandler(device, @config, state)
actionHandler: new KodiExecuteOpenActionHandler(@framework, device, @config, state)
}
else
return null

class KodiExecuteOpenActionHandler extends env.actions.ActionHandler

constructor: (@device, @config, @name) ->
constructor: (@framework, @device, @config, @name) ->
@debug = kodiPlugin.config.debug ? false
@base = commons.base @, "KodiExecuteOpenActionHandler"

Expand All @@ -345,8 +345,19 @@ module.exports = (env) ->
for command in @config.customOpenCommands
@base.debug "checking for (1): #{command.name} == #{@name}"
if command.name is @name
return @device.executeOpenCommand(
command.command).then( => __("executed %s", @device.name)

{variables, functions} = @framework.variableManager.getVariablesAndFunctions()
input = __('"%s"', command.command)
context = M.createParseContext(variables, functions)
match = null
m = M(input, context)
parseCommand = (m, tokens) => match = tokens
m.matchStringWithVars(parseCommand)

return @framework.variableManager.evaluateStringExpression(match).then( (cmd) =>
@device.executeOpenCommand(cmd).then( =>
__("executed %s on %s", command.name, @device.name)
)
)

class PlayingPredicateProvider extends env.predicates.PredicateProvider
Expand Down