Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: TypeError: object of type 'bool' has no len()

### INFO
**Python Version**: `2.7.14 (default, Feb 23 2018, 14:28:08) [GCC 4.9.3 20150311 (prerelease)]`
**Operating System**: `Linux-4.4.15+-x86_64-with-glibc2.2.5`
**Locale**: `None`
**Branch**: [master](../tree/master)
**Database**: `44.9`
**Commit**: pymedusa/Medusa@77b20916ab577b82112ebc624f816054788c63f2
**Link to Log**: https://gist.github.com/a9e8675deaed951b2f10e04f8d5baca0
### ERROR
<pre>
2018-04-23 21:42:52 ERROR    SEARCHQUEUE-DAILY-SEARCH :: [RARBG2] :: [77b2091] DailySearchQueueItem Exception, error: object of type 'bool' has no len()
Traceback (most recent call last):
  File "/volume1/@appstore/sickbeard-custom/var/<a href="../blob/77b20916ab577b82112ebc624f816054788c63f2/SickBeard/medusa/search/queue.py#L263">SickBeard/medusa/search/queue.py</a>", line 263, in run
    found_results = search_for_needed_episodes(force=self.force)
  File "/volume1/@appstore/sickbeard-custom/var/<a href="../blob/77b20916ab577b82112ebc624f816054788c63f2/SickBeard/medusa/search/core.py#L463">SickBeard/medusa/search/core.py</a>", line 463, in search_for_needed_episodes
    cur_provider.cache.update_cache()
  File "/volume1/@appstore/sickbeard-custom/var/<a href="../blob/77b20916ab577b82112ebc624f816054788c63f2/SickBeard/medusa/tv/cache.py#L239">SickBeard/medusa/tv/cache.py</a>", line 239, in update_cache
    cache_db_con.mass_action(results)
  File "/volume1/@appstore/sickbeard-custom/var/<a href="../blob/77b20916ab577b82112ebc624f816054788c63f2/SickBeard/medusa/db.py#L203">SickBeard/medusa/db.py</a>", line 203, in mass_action
    querylist = [i for i in querylist if i is not None and len(i)]
TypeError: object of type 'bool' has no len()
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:
This:
https://github.com/pymedusa/Medusa/blob/77b20916ab577b82112ebc624f816054788c63f2/medusa/db.py#L202-L203
Has at least one `False` item:
https://github.com/pymedusa/Medusa/blob/77b20916ab577b82112ebc624f816054788c63f2/medusa/tv/cache.py#L229-L231
Which probably came from this:
https://github.com/pymedusa/Medusa/blob/77b20916ab577b82112ebc624f816054788c63f2/medusa/tv/cache.py#L313

That function (`_parse_item`) is used in one place only, as far as I can tell.
Should be an easy fix to change that last return to `None` instead of `False`.

Resolving patch:
diff --git a/medusa/db.py b/medusa/db.py
--- a/medusa/db.py
+++ b/medusa/db.py
@@ -198,9 +198,8 @@ def mass_action(self, querylist=None, logTransaction=False, fetchall=False):
         :param fetchall: Boolean, when using a select query force returning all results
         :return: list of results
         """
-        querylist = querylist or []
-        # remove None types
-        querylist = [i for i in querylist if i is not None and len(i)]
+        # Remove Falsey types
+        querylist = (q for q in querylist or [] if q)
 
         sql_results = []
         attempt = 0
@@ -219,7 +218,7 @@ def mass_action(self, querylist=None, logTransaction=False, fetchall=False):
                                 logger.log(qu[0] + " with args " + str(qu[1]), logger.DEBUG)
                             sql_results.append(self._execute(qu[0], qu[1], fetchall=fetchall))
                     self.connection.commit()
-                    logger.log(u"Transaction with " + str(len(querylist)) + u" queries executed", logger.DEBUG)
+                    logger.log(u"Transaction with " + str(len(sql_results)) + u" queries executed", logger.DEBUG)
 
                     # finished
                     break
diff --git a/medusa/tv/cache.py b/medusa/tv/cache.py
--- a/medusa/tv/cache.py
+++ b/medusa/tv/cache.py
@@ -310,7 +310,7 @@ def _parse_item(self, item):
         else:
             log.debug('The data returned from the {0} feed is incomplete,'
                       ' this result is unusable', self.provider.name)
-        return False
+        return None
 
     @property
     def updated(self):


Test patch: