1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-17 23:05:03 -05:00

* revert back to using the TCP transport to avoid http auth issues

This commit is contained in:
Reinhard Pointner 2013-02-28 15:48:51 +00:00
parent 07f6bb9ec3
commit e73dcc9691
2 changed files with 13 additions and 15 deletions

View File

@ -215,8 +215,8 @@ if (getRenameLog().isEmpty()) {
xbmc?.each{ host -> xbmc?.each{ host ->
println "Notify XBMC: $host" println "Notify XBMC: $host"
_guarded{ _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') showNotification(host, 9090, 'FileBot', "Finished processing ${tryQuietly { ut_title } ?: input*.dir.name.unique()} (${getRenameLog().size()} files).", 'http://filebot.sourceforge.net/images/icon.png')
XBMC(host, 8080).scanVideoLibrary() scanVideoLibrary(host, 9090)
} }
} }

View File

@ -9,21 +9,19 @@ import net.sourceforge.filebot.mediainfo.*
/** /**
* XBMC helper functions * XBMC helper functions
*/ */
def XBMC(host, port = 8080) { def scanVideoLibrary(host, port) {
new XBMCJsonRpc(endpoint:new URL("http://${host}:${port}/jsonrpc")) _guarded {
telnet(host, port) { writer, reader ->
writer.println("""{"jsonrpc":"2.0","method":"VideoLibrary.Scan","id":1}""")
}
}
} }
class XBMCJsonRpc { def showNotification(host, port, title, message, image) {
def endpoint _guarded {
telnet(host, port) { writer, reader ->
def invoke(json) { writer.println("""{"jsonrpc":"2.0","method":"GUI.ShowNotification","params":{"title":"${escapeJavaScript(title)}","message":"${escapeJavaScript(message)}", "image":"${escapeJavaScript(image)}"},"id":1}""")
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}""")
} }
} }