Skip to content

Commit

Permalink
[fix] trakt_list: fixed the endpoints for special lists (collection e…
Browse files Browse the repository at this point in the history
…tc.) -- thanks to @kasperj, fixes #2165 #2167
  • Loading branch information
cvium committed Jul 13, 2018
1 parent fd4c830 commit 65b0a10
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions flexget/plugins/list/trakt_list.py
Expand Up @@ -222,14 +222,19 @@ def items(self):
def invalidate_cache(self):
self._items = None

def get_list_endpoint(self, remove=False):
def get_list_endpoint(self, remove=False, submit=False):
# Api restriction, but we could easily extract season and episode info from the 'shows' type
if self.config['list'] in ['collection', 'watched'] and self.config['type'] == 'episodes':
raise plugin.PluginError('`type` cannot be `%s` for %s list.' % (self.config['type'], self.config['list']))

if self.config['list'] in ['collection', 'watchlist', 'watched', 'ratings']:
if self.config.get('account'):
endpoint = ('sync', 'history' if self.config['list'] == 'watched' else self.config['list'])
if self.config['list'] == 'watched':
endpoint = ('sync', 'history')
else:
endpoint = ('sync', self.config['list'])
if not submit:
endpoint += (self.config['type'], )
else:
endpoint = ('users', self.config['username'], self.config['list'], self.config['type'])
else:
Expand Down Expand Up @@ -296,7 +301,7 @@ def submit(self, entries, remove=False):
log.debug('Nothing to submit to trakt.')
return

url = get_api_url(self.get_list_endpoint(remove))
url = get_api_url(self.get_list_endpoint(remove, submit=True))

log.debug('Submitting data to trakt.tv (%s): %s', url, found)
try:
Expand All @@ -323,7 +328,7 @@ def submit(self, entries, remove=False):
log.error('List does not appear to exist on trakt: %s', self.config['list'])
elif result.status_code == 401:
log.error('Authentication error: have you authorized Flexget on Trakt.tv?')
log.debug('trakt response: ' + result.text)
log.debug('trakt response: %s', result.text)
else:
log.error('Unknown error submitting data to trakt.tv: %s', result.text)

Expand Down

0 comments on commit 65b0a10

Please sign in to comment.