From e28d4c18f71988f31c2082f2f1e814af70daabb2 Mon Sep 17 00:00:00 2001 From: mmccurdy07 Date: Wed, 3 Dec 2014 21:12:13 +1000 Subject: [PATCH] Change Plex notifications: allow authenticated library updates (port from mmccurdy07) Change to allow authenticated access to Media Server. Change Config/Notifications/Plex logo, description, and label texts. Adapted port commit/955a48b577875ac8e94ea5efb445c28c57b7d9cb from mmccurdy07/Sick-Beard/commits/development (by Supremicus). --- CHANGES.md | 4 +- gui/slick/images/notifiers/plex.png | Bin 4357 -> 2475 bytes .../default/config_notifications.tmpl | 14 +++--- sickbeard/notifiers/plex.py | 41 ++++++++++++++++-- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 32abbd97..2243c5a6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,7 +7,9 @@ * Add TVRage network name standardization * Change some provider images. Add a few new images * Remove redundant Coming Eps template code used in the old UI -* Change update plex notifier (port from SickBeard) +* Change update Plex notifier (port from SickBeard) +* Change Plex notifications to allow authenticated library updates (port from mmccurdy07/Sick-Beard) +* Change Config/Notifications/Plex logo and description (adapted port from mmccurdy07/Sick-Beard) [develop changelog] diff --git a/gui/slick/images/notifiers/plex.png b/gui/slick/images/notifiers/plex.png index 1d97ad229820b6dfaaa8381f3f9d372cc919b1a5..f630f9b261db926aff40cfe5c7e6a0fb9c0dcab4 100644 GIT binary patch literal 2475 zcmaJ@dpwi<8(ujxC1)nB(OVHaFtcTj+f213=8$rj8OBbw$u=EW6p9K_UUJGIhe)C* zhe%Q>rMyn15*4LLysuvUrZ>I6KYsn5&*yo*-~0QyuIs+P_kI2GB)XEFRh9LX0RVui z3lZlgU3HgUMS1CWBnmq(UGxNaZ-F}}SP(_!(E$!YoIpC*g+&dayV0pZqKG?m8vsDY zh(Yldc$0QuXdIR~bqQlGWO1cz0Kmph$feT4=>l*dJ%qu=LZ%v}^MHf)PLKc(F#|W{I@46W2e(4wr0e^=G!m*Hl zit;A8f}J=#Iv8n=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o__A-XM@?>H^%Fh(F2c- z-1D;^|CFlp%&jGi&02Pjr?_W(hFv=nI(n->9V!AT2U$zGT)dL-?o`6~g5})_ z&!LeKRG7bW?&9cK1Ngc5xs{{Gjvp#5FL36}C8~8{)heb}JrmP06B8Ad7HXs;PgA?2 zv=Z~TcUE}$Ps_YETIKANWAt{y*lpp#hacuUPaNmOi4(`i#@>7F!%t~sWaQbKw(&fBbvD0YW|^wSWKqqn9pUu8oboCnui#fqZ6opA2+2OJ^48&LRWN$WQ^fs}9eB{WHZy!4J#RoTjY-4VI zZjS5M#+jPD#mZ6%FG4=wL`P>g{R4vx3=FbRTu4rzKKUJ}dE>_K{;g~Ni}LyW zC-&~$`@ns}!}smky?c8{XJ@hG9-ArRw#1#adeeih%oHh5r};T!aGYM8IXT00000NkvXXu0mjf(P=D9 diff --git a/gui/slick/interfaces/default/config_notifications.tmpl b/gui/slick/interfaces/default/config_notifications.tmpl index 750ae36a..79589cc6 100644 --- a/gui/slick/interfaces/default/config_notifications.tmpl +++ b/gui/slick/interfaces/default/config_notifications.tmpl @@ -159,7 +159,7 @@

Plex Media Server

-

Experience your media on a visually stunning, easy to use interface on your Mac connected to your TV. Your media library has never looked this good!

+

Plex organizes all of your personal media, wherever you keep it, so you can enjoy it on any device

For sending notifications to Plex Home Theater (PHT) clients, use the XBMC notifier with port 3005.

@@ -222,12 +222,12 @@
Click below to test.
diff --git a/sickbeard/notifiers/plex.py b/sickbeard/notifiers/plex.py index 7adc7653..d6ab265b 100644 --- a/sickbeard/notifiers/plex.py +++ b/sickbeard/notifiers/plex.py @@ -156,7 +156,7 @@ class PLEXNotifier: def test_notify(self, host, username, password): return self._notify("This is a test notification from SickGear", "Test", host, username, password, force=True) - def update_library(self, ep_obj=None): + def update_library(self, ep_obj=None, host=None, username=None, password=None): """Handles updating the Plex Media Server host via HTTP API Plex Media Server currently only supports updating the whole video library and not a specific path. @@ -166,14 +166,47 @@ class PLEXNotifier: """ + # fill in omitted parameters + if not host: + host = sickbeard.PLEX_SERVER_HOST + if not username: + username = sickbeard.PLEX_USERNAME + if not password: + password = sickbeard.PLEX_PASSWORD + if sickbeard.USE_PLEX and sickbeard.PLEX_UPDATE_LIBRARY: if not sickbeard.PLEX_SERVER_HOST: logger.log(u"PLEX: No Plex Media Server host specified, check your settings", logger.DEBUG) return False - logger.log(u"PLEX: Updating library for the Plex Media Server host: " + sickbeard.PLEX_SERVER_HOST, logger.MESSAGE) + logger.log(u"PLEX: Updating library for the Plex Media Server host: " + host, logger.MESSAGE) - url = "http://%s/library/sections" % sickbeard.PLEX_SERVER_HOST + # if username and password were provided, fetch the auth token from plex.tv + token_arg = "" + if username and password: + + logger.log(u"PLEX: fetching credentials for Plex user: " + username, logger.DEBUG) + req = urllib2.Request("https://plex.tv/users/sign_in.xml", data="") + base64string = base64.encodestring('%s:%s' % (username, password))[:-1] + authheader = "Basic %s" % base64string + req.add_header("Authorization", authheader) + req.add_header("X-Plex-Client-Identifier", "Sick-Beard-Notifier") + + try: + response = urllib2.urlopen(req) + except urllib2.URLError, e: + logger.log(u"PLEX: Error fetching credentials from from plex.tv for user %s: %s" % (username, ex(e)), logger.MESSAGE) + return False + + try: + auth_tree = etree.parse(response) + token = auth_tree.findall(".//authentication-token")[0].text + token_arg = "?X-Plex-Token=" + token + except (ValueError, IndexError) as e: + logger.log(u"PLEX: Error parsing plex.tv response: " + ex(e), logger.MESSAGE) + return False + + url = "http://%s/library/sections%s" % (sickbeard.PLEX_SERVER_HOST, token_arg) try: xml_tree = etree.parse(urllib.urlopen(url)) media_container = xml_tree.getroot() @@ -188,7 +221,7 @@ class PLEXNotifier: for section in sections: if section.attrib['type'] == "show": - url = "http://%s/library/sections/%s/refresh" % (sickbeard.PLEX_SERVER_HOST, section.attrib['key']) + url = "http://%s/library/sections/%s/refresh%s" % (sickbeard.PLEX_SERVER_HOST, section.attrib['key'], token_arg) try: urllib.urlopen(url) except Exception, e: