You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.0 KiB

14 years ago
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
from xml.dom import minidom
log = CPLog(__name__)
class Plex(Notification):
def notify(self, message = '', data = {}):
if self.isDisabled(): return
14 years ago
log.info('Sending notification to Plex')
hosts = [x.strip() for x in self.conf('host').split(",")]
for host in hosts:
source_type = ['movie']
base_url = 'http://%s/library/sections' % host
refresh_url = '%s/%%s/refresh' % base_url
try:
14 years ago
xml_sections = minidom.parse(self.urlopen(base_url))
14 years ago
sections = xml_sections.getElementsByTagName('Directory')
for s in sections:
if s.getAttribute('type') in source_type:
url = refresh_url % s.getAttribute('key')
14 years ago
x = self.urlopen(url)
14 years ago
except:
log.error('Plex library update failed for %s.' % host)
return True