Use test url for trakt notification test. fix #2798
This commit is contained in:
1 parent
a1c0b000a4
commit
30f5a3944c
1 file changed
+28
-13
@@ -10,6 +10,7 @@ class Trakt(Notification):
|
|||||||
'base': 'http://api.trakt.tv/%s',
|
'base': 'http://api.trakt.tv/%s',
|
||||||
'library': 'movie/library/%s',
|
'library': 'movie/library/%s',
|
||||||
'unwatchlist': 'movie/unwatchlist/%s',
|
'unwatchlist': 'movie/unwatchlist/%s',
|
||||||
|
'test': 'account/test/%s',
|
||||||
}
|
}
|
||||||
|
|
||||||
listen_to = ['movie.downloaded']
|
listen_to = ['movie.downloaded']
|
||||||
@@ -17,25 +18,39 @@ class Trakt(Notification):
|
|||||||
def notify(self, message = '', data = None, listener = None):
|
def notify(self, message = '', data = None, listener = None):
|
||||||
if not data: data = {}
|
if not data: data = {}
|
||||||
|
|
||||||
post_data = {
|
if listener == 'test':
|
||||||
'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)
|
post_data = {
|
||||||
if self.conf('remove_watchlist_enabled'):
|
'username': self.conf('automation_username'),
|
||||||
result = result and self.call((self.urls['unwatchlist'] % self.conf('automation_api_key')), post_data)
|
'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):
|
def call(self, method_url, post_data):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
response = self.getJsonData(self.urls['base'] % method_url, data = post_data, cache_timeout = 1)
|
response = self.getJsonData(self.urls['base'] % method_url, data = post_data, cache_timeout = 1)
|
||||||
if response:
|
if response:
|
||||||
if response.get('status') == "success":
|
if response.get('status') == "success":
|
||||||
|
|||||||
Reference in new issue
Block a user