From 30f5a3944cd98f5454b5d537255a19a642b33695 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 16 Feb 2014 14:11:21 +0100 Subject: [PATCH] Use test url for trakt notification test. fix #2798 --- couchpotato/core/notifications/trakt/main.py | 41 +++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/couchpotato/core/notifications/trakt/main.py b/couchpotato/core/notifications/trakt/main.py index c759c6db..399f76d8 100644 --- a/couchpotato/core/notifications/trakt/main.py +++ b/couchpotato/core/notifications/trakt/main.py @@ -10,6 +10,7 @@ class Trakt(Notification): 'base': 'http://api.trakt.tv/%s', 'library': 'movie/library/%s', 'unwatchlist': 'movie/unwatchlist/%s', + 'test': 'account/test/%s', } listen_to = ['movie.downloaded'] @@ -17,25 +18,39 @@ class Trakt(Notification): def notify(self, message = '', data = None, listener = None): if not data: data = {} - post_data = { - 'username': self.conf('automation_username'), - 'password' : self.conf('automation_password'), - 'movies': [{ - 'imdb_id': data['library']['identifier'], - 'title': data['library']['titles'][0]['title'], - 'year': data['library']['year'] - }] if data else [] - } + if listener == 'test': - result = self.call((self.urls['library'] % self.conf('automation_api_key')), post_data) - if self.conf('remove_watchlist_enabled'): - result = result and self.call((self.urls['unwatchlist'] % self.conf('automation_api_key')), post_data) + post_data = { + 'username': self.conf('automation_username'), + 'password': self.conf('automation_password'), + } - return result + result = self.call((self.urls['test'] % self.conf('automation_api_key')), post_data) + + return result + + else: + + post_data = { + 'username': self.conf('automation_username'), + 'password': self.conf('automation_password'), + 'movies': [{ + 'imdb_id': data['library']['identifier'], + 'title': data['library']['titles'][0]['title'], + 'year': data['library']['year'] + }] if data else [] + } + + result = self.call((self.urls['library'] % self.conf('automation_api_key')), post_data) + if self.conf('remove_watchlist_enabled'): + result = result and self.call((self.urls['unwatchlist'] % self.conf('automation_api_key')), post_data) + + return result def call(self, method_url, post_data): try: + response = self.getJsonData(self.urls['base'] % method_url, data = post_data, cache_timeout = 1) if response: if response.get('status') == "success":