From 3b4346b053021c10972b52a37367bd4786130812 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Fri, 9 Jan 2015 21:41:45 +0100 Subject: [PATCH 1/2] Fix for: 'NoneType' object is not iterable in trakt module --- sickbeard/notifiers/trakt.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/sickbeard/notifiers/trakt.py b/sickbeard/notifiers/trakt.py index 840d2567..d0905d29 100644 --- a/sickbeard/notifiers/trakt.py +++ b/sickbeard/notifiers/trakt.py @@ -83,23 +83,24 @@ class TraktNotifier: # Start by getting all episodes in the watchlist watchlist = TraktCall("user/watchlist/episodes.json/%API%/" + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD) - # Convert watchlist to only contain current show - for show in watchlist: - # Check if tvdb_id exists - if 'tvdb_id' in show: - if unicode(data['shows'][0]['tvdb_id']) == show['tvdb_id']: - data_show = { - 'title': show['title'], - 'tvdb_id': show['tvdb_id'], - 'episodes': [] - } - - # Add series and episode (number) to the arry - for episodes in show['episodes']: - ep = {'season': episodes['season'], 'episode': episodes['number']} - data_show['episodes'].append(ep) - if data_show is not None: - TraktCall("show/episode/unwatchlist/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, data_show) + if watchlist is not None: + # Convert watchlist to only contain current show + for show in watchlist: + # Check if tvdb_id exists + if 'tvdb_id' in show: + if unicode(data['shows'][0]['tvdb_id']) == show['tvdb_id']: + data_show = { + 'title': show['title'], + 'tvdb_id': show['tvdb_id'], + 'episodes': [] + } + + # Add series and episode (number) to the arry + for episodes in show['episodes']: + ep = {'season': episodes['season'], 'episode': episodes['number']} + data_show['episodes'].append(ep) + if data_show is not None: + TraktCall("show/episode/unwatchlist/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, data_show) def test_notify(self, api, username, password): """ From a36fe55d413bdda27d53a3023c578d260f1eba67 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 10 Jan 2015 10:21:53 +0800 Subject: [PATCH 2/2] Add log message for when trakt does not return a watchlist --- CHANGES.md | 2 ++ sickbeard/notifiers/trakt.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 6adf19de..d3d1b7bb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -77,6 +77,8 @@ * Fix restart issue * Fix to use new TorrentDay URLs * Fix typo in menu item Manage/Update XBMC +* Fix 'NoneType' object is not iterable in trakt module +* Add log message for when trakt does not return a watchlist ### 0.4.0 (2014-12-04 10:50:00 UTC) diff --git a/sickbeard/notifiers/trakt.py b/sickbeard/notifiers/trakt.py index d0905d29..c58fa11f 100644 --- a/sickbeard/notifiers/trakt.py +++ b/sickbeard/notifiers/trakt.py @@ -101,6 +101,9 @@ class TraktNotifier: data_show['episodes'].append(ep) if data_show is not None: TraktCall("show/episode/unwatchlist/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, data_show) + else: + logger.log('Failed to get watchlist from trakt. Unable to remove episode from watchlist', + logger.ERROR) def test_notify(self, api, username, password): """