From e73dcc969125883b0f462244b9530b83801fe382 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 28 Feb 2013 15:48:51 +0000 Subject: [PATCH] * revert back to using the TCP transport to avoid http auth issues --- website/scripts/amc.groovy | 4 ++-- website/scripts/lib/htpc.groovy | 24 +++++++++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/website/scripts/amc.groovy b/website/scripts/amc.groovy index 1e5afadc..e0cc7c94 100644 --- a/website/scripts/amc.groovy +++ b/website/scripts/amc.groovy @@ -215,8 +215,8 @@ if (getRenameLog().isEmpty()) { xbmc?.each{ host -> println "Notify XBMC: $host" _guarded{ - XBMC(host, 8080).showNotification('FileBot', "Finished processing ${tryQuietly { ut_title } ?: input*.dir.name.unique()} (${getRenameLog().size()} files).", 'http://filebot.sourceforge.net/images/icon.png') - XBMC(host, 8080).scanVideoLibrary() + showNotification(host, 9090, 'FileBot', "Finished processing ${tryQuietly { ut_title } ?: input*.dir.name.unique()} (${getRenameLog().size()} files).", 'http://filebot.sourceforge.net/images/icon.png') + scanVideoLibrary(host, 9090) } } diff --git a/website/scripts/lib/htpc.groovy b/website/scripts/lib/htpc.groovy index 9c7dd645..35792756 100644 --- a/website/scripts/lib/htpc.groovy +++ b/website/scripts/lib/htpc.groovy @@ -9,21 +9,19 @@ import net.sourceforge.filebot.mediainfo.* /** * XBMC helper functions */ -def XBMC(host, port = 8080) { - new XBMCJsonRpc(endpoint:new URL("http://${host}:${port}/jsonrpc")) +def scanVideoLibrary(host, port) { + _guarded { + telnet(host, port) { writer, reader -> + writer.println("""{"jsonrpc":"2.0","method":"VideoLibrary.Scan","id":1}""") + } + } } -class XBMCJsonRpc { - def endpoint - - def invoke(json) { - endpoint.post(json.getBytes('UTF-8'), 'application/json').text - } - def scanVideoLibrary() { - invoke("""{"jsonrpc":"2.0","method":"VideoLibrary.Scan","id":1}""") - } - def showNotification(title, message, image) { - invoke("""{"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"${escapeJavaScript(title)}","message":"${escapeJavaScript(message)}", "image":"${escapeJavaScript(image)}"},"id":1}""") +def showNotification(host, port, title, message, image) { + _guarded { + telnet(host, port) { writer, reader -> + writer.println("""{"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"${escapeJavaScript(title)}","message":"${escapeJavaScript(message)}", "image":"${escapeJavaScript(image)}"},"id":1}""") + } } }