Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: AttributeError: 'NoneType' object has no attribute 'find_all'

### INFO
**Python Version**: `3.7.3rc1 (default, Mar 13 2019, 11:01:15) [GCC 8.2.0]`
**Operating System**: `Linux-4.9.35-v7+-armv7l-with-debian-buster-sid`
**Locale**: `UTF-8`
**Branch**: [develop](../tree/develop)
**Database**: `44.14`
**Commit**: pymedusa/Medusa@429bbf9f1c90de20036a86e3512ed895a0fe5f2c
**Link to Log**: https://gist.github.com/63aae653b5bade13d837f97ec5089a0f
### ERROR
<pre>
2019-05-26 11:01:29 ERROR    SEARCHQUEUE-DAILY-SEARCH :: [BTDB] :: [429bbf9] DailySearchQueueItem Exception, error: 'NoneType' object has no attribute 'find_all'
Traceback (most recent call last):
  File "/home/pi/Medusa/<a href="../blob/429bbf9f1c90de20036a86e3512ed895a0fe5f2c/medusa/search/queue.py#L263">medusa/search/queue.py</a>", line 263, in run
    found_results = search_for_needed_episodes(self.scheduler_start_time, force=self.force)
  File "/home/pi/Medusa/<a href="../blob/429bbf9f1c90de20036a86e3512ed895a0fe5f2c/medusa/search/core.py#L524">medusa/search/core.py</a>", line 524, in search_for_needed_episodes
    cur_provider.cache.update_cache(scheduler_start_time)
  File "/home/pi/Medusa/<a href="../blob/429bbf9f1c90de20036a86e3512ed895a0fe5f2c/medusa/tv/cache.py#L207">medusa/tv/cache.py</a>", line 207, in update_cache
    data = self._get_rss_data()
  File "/home/pi/Medusa/<a href="../blob/429bbf9f1c90de20036a86e3512ed895a0fe5f2c/medusa/tv/cache.py#L190">medusa/tv/cache.py</a>", line 190, in _get_rss_data
    return {'entries': self.provider.search(self.search_params)}
  File "/home/pi/Medusa/<a href="../blob/429bbf9f1c90de20036a86e3512ed895a0fe5f2c/medusa/providers/torrent/html/btdb.py#L78">medusa/providers/torrent/html/btdb.py</a>", line 78, in search
    results += self.parse(response.text, mode)
  File "/home/pi/Medusa/<a href="../blob/429bbf9f1c90de20036a86e3512ed895a0fe5f2c/medusa/providers/torrent/html/btdb.py#L99">medusa/providers/torrent/html/btdb.py</a>", line 99, in parse
    torrent_rows = table_body.find_all('li', class_='recent-item')
AttributeError: 'NoneType' object has no attribute 'find_all'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:

Resolving patch:
diff --git a/medusa/providers/torrent/html/btdb.py b/medusa/providers/torrent/html/btdb.py
--- a/medusa/providers/torrent/html/btdb.py
+++ b/medusa/providers/torrent/html/btdb.py
@@ -91,12 +91,11 @@ def parse(self, data, mode):
         items = []
 
         with BS4Parser(data, 'html5lib') as html:
-            if mode != 'RSS':
-                table_body = html.find('div', class_='search-ret')
-                torrent_rows = table_body.find_all('li', class_='search-ret-item')
-            else:
-                table_body = html.find('div', class_='recent')
-                torrent_rows = table_body.find_all('li', class_='recent-item')
+            cls_name = 'search-ret' if mode != 'RSS' else 'recent'
+            table_body = html.find('div', class_=cls_name)
+            torrent_rows = table_body.find_all(
+                'li', class_='{0}-item'.format(cls_name)
+            ) if table_body else []
 
             # Continue only if at least one release is found
             if not table_body:


Test patch: