From 68c5d65dba7a1c64d87b0279759868afe394d8ec Mon Sep 17 00:00:00 2001
From: Alexandre Beloin <alexandre.beloin@gmail.com>
Date: Mon, 20 Apr 2015 10:07:41 -0400
Subject: [PATCH] T411: Catch invalid data, log, and continue

---
 sickbeard/providers/t411.py | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/sickbeard/providers/t411.py b/sickbeard/providers/t411.py
index 880efdf4..6c0c7811 100644
--- a/sickbeard/providers/t411.py
+++ b/sickbeard/providers/t411.py
@@ -182,19 +182,21 @@ class T411Provider(generic.TorrentProvider):
 
                         if len(torrents) > 0:
                             for torrent in torrents:
-
-                                torrent_name = torrent['name']
-                                torrent_id = torrent['id']
-                                torrent_download_url = (self.urls['download'] % torrent_id).encode('utf8')
-
-                                if not torrent_name or not torrent_download_url:
+                                try:
+                                    torrent_name = torrent['name']
+                                    torrent_id = torrent['id']
+                                    torrent_download_url = (self.urls['download'] % torrent_id).encode('utf8')
+
+                                    if not torrent_name or not torrent_download_url:
+                                        continue
+
+                                    item = torrent_name, torrent_download_url
+                                    logger.log(u"Found result: " + torrent_name + " (" + torrent_download_url + ")",
+                                               logger.DEBUG)
+                                    items[mode].append(item)
+                                except Exception as e:
+                                    logger.log(u"Invalid torrent data, skipping results: {0}".format(str(torrent)), logger.DEBUG)
                                     continue
-
-                                item = torrent_name, torrent_download_url
-                                logger.log(u"Found result: " + torrent_name + " (" + torrent_download_url + ")",
-                                           logger.DEBUG)
-                                items[mode].append(item)
-
                         else:
                             logger.log(u"The Data returned from " + self.name + " do not contains any torrent",
                                        logger.WARNING)
-- 
GitLab