Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
15 changes: 14 additions & 1 deletion amc.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,20 @@ if (getRenameLog().size() > 0) {
plex.each{ host ->
log.info "Notify Plex: $host"
tryLogCatch {
refreshPlexLibrary(host)
groups.each { group, files ->
if (group.tvs || group.anime) {
log.info "Telling Plex to refresh TV shows"
refreshPlexLibrary(server:host, library:"show")
}
if (group.mov) {
log.info "Telling Plex to refresh movies"
refreshPlexLibrary(server:host, library:"movie")
}
if (group.music) {
log.info "Telling Plex to refresh music"
refreshPlexLibrary(server:host, library:"artist")
}
}
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions lib/htpc.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ def showNotification(host, port, title, message, image) {
/**
* Plex helpers
*/
def refreshPlexLibrary(server, port = 32400) {
def refreshPlexLibrary(Map m = [:]) {
tryLogCatch {
new URL("http://$server:$port/library/sections/all/refresh").get()
def defaultMap = ["server": "localhost", "port": 32400]
m = defaultMap << m
def (server, port, library) = [m["server"], m["port"], m["library"]]
new XmlSlurper().parse("http://$server:$port/library/sections").Directory.each { dir ->
if ("${dir.@type}" == library) {
new URL("http://$server:$port/library/sections/${dir.@key}/refresh").get()
}
}
}
}

Expand Down