Repository: pymedusa/Medusa

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

### INFO
**Python Version**: `3.8.5 (default, Aug  2 2020, 15:09:07) [GCC 9.3.0]`
**Operating System**: `Linux-4.9.35-v7+-armv7l-with-glibc2.29`
**Locale**: `UTF-8`
**Branch**: [develop](../tree/develop)
**Database**: `44.18`
**Commit**: pymedusa/Medusa@5c8597b932e7975c5619c0ecc906efce625202dc
**Link to Log**: https://gist.github.com/85c8565a27efbcc61281cbd34dec0a9f
### ERROR
<pre>
2021-04-19 03:55:20 ERROR    SNATCHQUEUE-SNATCH-75978 :: [5c8597b] Transmission: Failed Sending Torrent
Traceback (most recent call last):
  File "/home/pi/Medusa/<a href="../blob/5c8597b932e7975c5619c0ecc906efce625202dc/medusa/clients/torrent/generic.py#L257">medusa/clients/torrent/generic.py</a>", line 257, in send_torrent
    r_code = self._add_torrent_file(result)
  File "/home/pi/Medusa/<a href="../blob/5c8597b932e7975c5619c0ecc906efce625202dc/medusa/clients/torrent/transmission.py#L128">medusa/clients/torrent/transmission.py</a>", line 128, in _add_torrent_file
    return self.check_response()
  File "/home/pi/Medusa/<a href="../blob/5c8597b932e7975c5619c0ecc906efce625202dc/medusa/clients/torrent/transmission.py#L47">medusa/clients/torrent/transmission.py</a>", line 47, in check_response
    return self.response.json()['result'] == 'success'
AttributeError: 'NoneType' object has no attribute 'json'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:
Well, is your transmission reachable? It wasn't at the time the error was produced, the connection timed out.

### INFO
**Python Version**: `3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]`
**Operating System**: `Windows-10-10.0.19041-SP0`
**Locale**: `cp1252`
**Branch**: [master](../tree/master)
**Database**: `44.18`
**Commit**: pymedusa/Medusa@4d9c7927ebeb425e386b122a230c849163d065c7
**Link to Log**: **No Log available**
### ERROR
<pre>
2021-06-08 21:17:03 ERROR    SNATCHQUEUE-SNATCH-718 :: [4d9c792] Snatch failed! For result: Jimmy.Fallon.2020-06-04.Bernie.Sanders.1080p.WEB.h264
Traceback (most recent call last):
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/search/queue.py#L516">medusa\search\queue.py</a>", line 516, in run
    self.success = snatch_result(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/search/core.py#L168">medusa\search\core.py</a>", line 168, in snatch_result
    result_downloaded = client.send_torrent(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/clients/torrent/generic.py#L240">medusa\clients\torrent\generic.py</a>", line 240, in send_torrent
    if not self._get_auth():
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/clients/torrent/deluge.py#L138">medusa\clients\torrent\deluge.py</a>", line 138, in _get_auth
    self.auth = self.response.json()['result']
AttributeError: 'NoneType' object has no attribute 'json'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators


### INFO
**Python Version**: `3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]`
**Operating System**: `Windows-10-10.0.19041-SP0`
**Locale**: `cp1252`
**Branch**: [master](../tree/master)
**Database**: `44.18`
**Commit**: pymedusa/Medusa@4d9c7927ebeb425e386b122a230c849163d065c7
**Link to Log**: **No Log available**
### ERROR
<pre>
2021-06-15 16:14:47 ERROR    SNATCHQUEUE-SNATCH-153021 :: [4d9c792] Snatch failed! For result: The.Walking.Dead.S10E20.iNTERNAL.1080p.WEB.H264-GLHF[rartv]
Traceback (most recent call last):
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/search/queue.py#L516">medusa\search\queue.py</a>", line 516, in run
    self.success = snatch_result(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/search/core.py#L168">medusa\search\core.py</a>", line 168, in snatch_result
    result_downloaded = client.send_torrent(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/clients/torrent/generic.py#L240">medusa\clients\torrent\generic.py</a>", line 240, in send_torrent
    if not self._get_auth():
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/clients/torrent/deluge.py#L138">medusa\clients\torrent\deluge.py</a>", line 138, in _get_auth
    self.auth = self.response.json()['result']
AttributeError: 'NoneType' object has no attribute 'json'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators


### INFO
**Python Version**: `3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]`
**Operating System**: `Windows-10-10.0.19041-SP0`
**Locale**: `cp1252`
**Branch**: [master](../tree/master)
**Database**: `44.18`
**Commit**: pymedusa/Medusa@4d9c7927ebeb425e386b122a230c849163d065c7
**Link to Log**: **No Log available**
### ERROR
<pre>
2021-06-15 16:14:32 ERROR    SNATCHQUEUE-SNATCH-153021 :: [4d9c792] Snatch failed! For result: The.Walking.Dead.S10E19.One.More.720p.AMZN.WEBRip.DDP5.1.x264-CasStudio.[eztv]
Traceback (most recent call last):
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/search/queue.py#L516">medusa\search\queue.py</a>", line 516, in run
    self.success = snatch_result(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/search/core.py#L168">medusa\search\core.py</a>", line 168, in snatch_result
    result_downloaded = client.send_torrent(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/clients/torrent/generic.py#L240">medusa\clients\torrent\generic.py</a>", line 240, in send_torrent
    if not self._get_auth():
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/clients/torrent/deluge.py#L138">medusa\clients\torrent\deluge.py</a>", line 138, in _get_auth
    self.auth = self.response.json()['result']
AttributeError: 'NoneType' object has no attribute 'json'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators


### INFO
**Python Version**: `3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]`
**Operating System**: `Windows-10-10.0.19041-SP0`
**Locale**: `cp1252`
**Branch**: [master](../tree/master)
**Database**: `44.18`
**Commit**: pymedusa/Medusa@4d9c7927ebeb425e386b122a230c849163d065c7
**Link to Log**: **No Log available**
### ERROR
<pre>
2021-06-15 16:14:26 ERROR    SNATCHQUEUE-SNATCH-153021 :: [4d9c792] Snatch failed! For result: The.Walking.Dead.S10E19.One.More.1080p.AMZN.WEBRip.DDP5.1.x264-CasStudio.[eztv]
Traceback (most recent call last):
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/search/queue.py#L516">medusa\search\queue.py</a>", line 516, in run
    self.success = snatch_result(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/search/core.py#L168">medusa\search\core.py</a>", line 168, in snatch_result
    result_downloaded = client.send_torrent(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/clients/torrent/generic.py#L240">medusa\clients\torrent\generic.py</a>", line 240, in send_torrent
    if not self._get_auth():
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/clients/torrent/deluge.py#L138">medusa\clients\torrent\deluge.py</a>", line 138, in _get_auth
    self.auth = self.response.json()['result']
AttributeError: 'NoneType' object has no attribute 'json'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators


### INFO
**Python Version**: `3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]`
**Operating System**: `Windows-10-10.0.19041-SP0`
**Locale**: `cp1252`
**Branch**: [master](../tree/master)
**Database**: `44.18`
**Commit**: pymedusa/Medusa@4d9c7927ebeb425e386b122a230c849163d065c7
**Link to Log**: **No Log available**
### ERROR
<pre>
2021-06-15 16:14:19 ERROR    SNATCHQUEUE-SNATCH-153021 :: [4d9c792] Snatch failed! For result: The.Walking.Dead.S10E20.Splinter.1080p.AMZN.WEBRip.DDP5.1.x264-CasStudio[rartv]
Traceback (most recent call last):
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/search/queue.py#L516">medusa\search\queue.py</a>", line 516, in run
    self.success = snatch_result(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/search/core.py#L168">medusa\search\core.py</a>", line 168, in snatch_result
    result_downloaded = client.send_torrent(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/clients/torrent/generic.py#L240">medusa\clients\torrent\generic.py</a>", line 240, in send_torrent
    if not self._get_auth():
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/clients/torrent/deluge.py#L138">medusa\clients\torrent\deluge.py</a>", line 138, in _get_auth
    self.auth = self.response.json()['result']
AttributeError: 'NoneType' object has no attribute 'json'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators


### INFO
**Python Version**: `3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]`
**Operating System**: `Windows-10-10.0.19041-SP0`
**Locale**: `cp1252`
**Branch**: [master](../tree/master)
**Database**: `44.18`
**Commit**: pymedusa/Medusa@4d9c7927ebeb425e386b122a230c849163d065c7
**Link to Log**: **No Log available**
### ERROR
<pre>
2021-06-15 16:14:07 ERROR    SNATCHQUEUE-SNATCH-153021 :: [4d9c792] Snatch failed! For result: The.Walking.Dead.S10E19.One.More.1080p.AMZN.WEBRip.DDP5.1.x264
Traceback (most recent call last):
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/search/queue.py#L516">medusa\search\queue.py</a>", line 516, in run
    self.success = snatch_result(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/search/core.py#L168">medusa\search\core.py</a>", line 168, in snatch_result
    result_downloaded = client.send_torrent(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/clients/torrent/generic.py#L240">medusa\clients\torrent\generic.py</a>", line 240, in send_torrent
    if not self._get_auth():
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/4d9c7927ebeb425e386b122a230c849163d065c7/medusa/clients/torrent/deluge.py#L138">medusa\clients\torrent\deluge.py</a>", line 138, in _get_auth
    self.auth = self.response.json()['result']
AttributeError: 'NoneType' object has no attribute 'json'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators


### INFO
**Python Version**: `3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]`
**Operating System**: `Windows-10-10.0.19041-SP0`
**Locale**: `cp1252`
**Branch**: [master](../tree/master)
**Database**: `44.18`
**Commit**: pymedusa/Medusa@9b23c72f7e24bf638819e32d72f33e433f9649c4
**Link to Log**: **No Log available**
### ERROR
<pre>
2021-07-29 12:09:02 ERROR    SNATCHQUEUE-SNATCH-718 :: [9b23c72] Snatch failed! For result: Jimmy.Fallon.2021.04.23.Anna.Kendrick.1080p.WEB.h264-KOGi[rartv]
Traceback (most recent call last):
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/9b23c72f7e24bf638819e32d72f33e433f9649c4/medusa/search/queue.py#L516">medusa\search\queue.py</a>", line 516, in run
    self.success = snatch_result(result)
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/9b23c72f7e24bf638819e32d72f33e433f9649c4/medusa/search/core.py#L167">medusa\search\core.py</a>", line 167, in snatch_result
    client = torrent.get_client_class(app.TORRENT_METHOD)()
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/9b23c72f7e24bf638819e32d72f33e433f9649c4/medusa/clients/torrent/deluge.py#L123">medusa\clients\torrent\deluge.py</a>", line 123, in __init__
    self._get_auth()
  File "C:\Program Files (x86)\Medusa\Medusa\<a href="../blob/9b23c72f7e24bf638819e32d72f33e433f9649c4/medusa/clients/torrent/deluge.py#L140">medusa\clients\torrent\deluge.py</a>", line 140, in _get_auth
    self.auth = self.response.json()['result']
AttributeError: 'NoneType' object has no attribute 'json'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators

@eddywitkamp The fuck?
@reconman what's wrong?
@eddywitkamp Look at the 50 comments you've posted. That's just spam at this point.
@reconman oh wow....I just pressed the "Report error" button....didn't know it would make a separate post for every error!
Sorry 'bout that, but yeah, this error happens a lot.
@eddywitkamp You can try adding
```self.response.raise_for_status()```
before deluge.py line 140, that will give a hint on what's going wrong
Also do you mind deleting all of your comments except for one?

### INFO
**Python Version**: `3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]`
**Operating System**: `Linux-4.19.0-17-amd64-x86_64-with-debian-10.10`
**Locale**: `UTF-8`
**Branch**: [develop](../tree/develop)
**Database**: `44.18`
**Commit**: pymedusa/Medusa@ac7aafad2a38696558f1c87dc0d671732e29ed1e
**Link to Log**: https://gist.github.com/a326a8202c1fe148d443518b039a09ff
### ERROR
<pre>
2021-10-12 06:03:13 ERROR    SEARCHQUEUE-DAILY-SEARCH :: [PrivateHD] :: [ac7aafa] DailySearchQueueItem Exception, error: AttributeError("'NoneType' object has no attribute 'json'")
Traceback (most recent call last):
  File "/**********/Medusa/medusa/search/queue.py", line 295, in run
    found_results = search_for_needed_episodes(self.scheduler_start_time, force=self.force)
  File "/**********/Medusa/medusa/search/core.py", line 532, in search_for_needed_episodes
    cur_provider.cache.update_cache(scheduler_start_time)
  File "/**********/Medusa/medusa/tv/cache.py", line 226, in update_cache
    data = self._get_rss_data()
  File "/**********/Medusa/medusa/tv/cache.py", line 201, in _get_rss_data
    return {'entries': self.provider.search(self.search_params)}
  File "/**********/Medusa/medusa/providers/torrent/json/privatehd.py", line 62, in search
    if not self.login():
  File "/**********/Medusa/medusa/providers/torrent/json/privatehd.py", line 163, in login
    jdata = response.json()
AttributeError: 'NoneType' object has no attribute 'json'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators


Resolving patch:
diff --git a/medusa/providers/torrent/json/privatehd.py b/medusa/providers/torrent/json/privatehd.py
--- a/medusa/providers/torrent/json/privatehd.py
+++ b/medusa/providers/torrent/json/privatehd.py
@@ -91,7 +91,7 @@ def search(self, search_strings, age=0, ep_obj=None, **kwargs):
                     if not jdata.get('data') or not len(jdata['data']):
                         log.debug('No data returned from provider')
                         continue
-                except ValueError:
+                except (AttributeError, ValueError):
                     log.debug('No data returned from provider')
                     continue
 
@@ -163,7 +163,7 @@ def login(self):
             jdata = response.json()
             if 'message' in jdata:
                 raise AuthException(f"Error trying to auth, {jdata['message']}")
-        except ValueError:
+        except (AttributeError, ValueError):
             log.debug('No data returned from provider')
             raise AuthException('Could not get auth token')
 


Test patch: