* added plex integration sample
This commit is contained in:
parent
2217eed537
commit
24ea7ab334
|
@ -75,7 +75,7 @@ URL.metaClass.post = { Map parameters -> post(delegate.openConnection(), paramet
|
||||||
URL.metaClass.post = { byte[] data, contentType = 'application/octet-stream' -> post(delegate.openConnection(), data, contentType) }
|
URL.metaClass.post = { byte[] data, contentType = 'application/octet-stream' -> post(delegate.openConnection(), data, contentType) }
|
||||||
URL.metaClass.post = { String text, csn = 'utf-8' -> delegate.post(text.getBytes(csn), 'text/plain') }
|
URL.metaClass.post = { String text, csn = 'utf-8' -> delegate.post(text.getBytes(csn), 'text/plain') }
|
||||||
|
|
||||||
ByteBuffer.metaClass.saveAs = { f -> f = f as File; f.parentFile.mkdirs(); writeFile(delegate.duplicate(), f); f.absoluteFile }
|
ByteBuffer.metaClass.saveAs = { f -> f = f as File; f = f.absoluteFile; f.parentFile.mkdirs(); writeFile(delegate.duplicate(), f); f }
|
||||||
URL.metaClass.saveAs = { f -> fetch(delegate).saveAs(f) }
|
URL.metaClass.saveAs = { f -> fetch(delegate).saveAs(f) }
|
||||||
String.metaClass.saveAs = { f, csn = "utf-8" -> Charset.forName(csn).encode(delegate).saveAs(f) }
|
String.metaClass.saveAs = { f, csn = "utf-8" -> Charset.forName(csn).encode(delegate).saveAs(f) }
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
// plex functions
|
||||||
|
def refreshPlexLibrary(server, port = 32400, files = null) {
|
||||||
|
def sections = new URL("http://$server:$port/plex").getXml()
|
||||||
|
def locations = sections.Directory.Location.collect{ [path:it.'@path', key:it.parent().'@key'] }
|
||||||
|
|
||||||
|
// limit refresh locations
|
||||||
|
if (files != null) {
|
||||||
|
locations = locations.findAll{ loc -> files.find{ it.path; it.path.startsWith(loc.path) }}
|
||||||
|
}
|
||||||
|
|
||||||
|
locations*.key.unique().each{ key ->
|
||||||
|
new URL("http://$server:$port/library/sections/$key/refresh/").get()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue