Browse Source

Only attach imdb url when available

pull/1680/merge
Ruud 12 years ago
parent
commit
080da48223
  1. 13
      couchpotato/core/notifications/pushover/main.py

13
couchpotato/core/notifications/pushover/main.py

@ -1,4 +1,5 @@
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
from couchpotato.core.helpers.variable import getTitle
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification from couchpotato.core.notifications.base import Notification
from httplib import HTTPSConnection from httplib import HTTPSConnection
@ -14,19 +15,23 @@ class Pushover(Notification):
http_handler = HTTPSConnection("api.pushover.net:443") http_handler = HTTPSConnection("api.pushover.net:443")
data = { api_data = {
'user': self.conf('user_key'), 'user': self.conf('user_key'),
'token': self.app_token, 'token': self.app_token,
'message': toUnicode(message), 'message': toUnicode(message),
'priority': self.conf('priority'), 'priority': self.conf('priority'),
'url': toUnicode("http://www.imdb.com/title/%s" % data['library']['identifier']) if data else "",
'url_title': toUnicode("%s on IMDb" % data['library']['titles'][0]['title']) if data else ""
} }
if data and data.get('library'):
api_data.extend({
'url': toUnicode('http://www.imdb.com/title/%s/' % data['library']['identifier']),
'url_title': toUnicode('%s on IMDb' % getTitle(data['library'])),
})
http_handler.request('POST', http_handler.request('POST',
"/1/messages.json", "/1/messages.json",
headers = {'Content-type': 'application/x-www-form-urlencoded'}, headers = {'Content-type': 'application/x-www-form-urlencoded'},
body = tryUrlencode(data) body = tryUrlencode(api_data)
) )
response = http_handler.getresponse() response = http_handler.getresponse()

Loading…
Cancel
Save