Repository: pymedusa/Medusa

Issue:
Torrent file content is empty
**Describe the bug**

I have many log like this:

2019-04-25 21:01:35 WARNING SNATCHQUEUE-SNATCH-274431 :: [f46bfac] Torrent file content is empty: Gotham.S04E20.VOSTFR.WebDl.720p.x264.-.Chris44

**Expected behavior**
torrent from yggtorrent dont snatched

**Screenshots**

<img width="1174" alt="Capture d’écran 2019-04-26 à 08 26 25" src="https://user-images.githubusercontent.com/14791276/56787518-0af92e00-67fd-11e9-8c6e-72063f929f3a.png">


**Medusa (please complete the following information):**
 - OS: debian9
 - Branch: master
 - Commit: Branch:master 
                 Commit:                 f46bfacf8763204fbde4f26a5916095371d494d1        
          Version:                 0.3.1

**Logs:**

2019-04-25 21:01:35 WARNING SNATCHQUEUE-SNATCH-274431 :: [f46bfac] Torrent file content is empty: Gotham.S04E20.VOSTFR.WebDl.720p.x264.-.Chris44</details>

**Additional context**
Add any other context about the problem here.



Discussion:
It works fine here, so you are probably getting rate limited or something like that. I can't tell for sure because you haven't posted the debug logs as requested.
2019-04-27 09:40:07 INFO     SEARCHQUEUE-DAILY-SEARCH :: [f46bfac] Downloading MacGyver.2016.S03E01.FASTSUB.VOSTFR.720p.HDTV.x264-GOLD with 4 seeders and 4 leechers and size 1.36 GB from Yggtorrent
2019-04-27 09:40:09 INFO     SNATCHQUEUE-SNATCH-311902 :: [f46bfac] Beginning to snatch release: MacGyver.2016.S03E01.FASTSUB.VOSTFR.720p.HDTV.x264-GOLD
2019-04-27 09:40:09 INFO     SNATCHQUEUE-SNATCH-311902 :: [f46bfac] Downloading MacGyver.2016.S03E01.FASTSUB.VOSTFR.720p.HDTV.x264-GOLD with 4 seeders and 4 leechers and size 1.36 GB from Yggtorrent, through a SearchType.DAILY_SEARCH search
2019-04-27 09:40:09 INFO     SEARCHQUEUE-DAILY-SEARCH :: [f46bfac] Downloading DCs.Legends.of.Tomorrow.S04E02.Witch.Hunt.1080p.VOSTFR.AMZN.WEB-DL.DD+5.1.H.264-HVS with 3 seeders and 3 leechers and size 4.04 GB from Yggtorrent
2019-04-27 09:40:11 INFO     SEARCHQUEUE-DAILY-SEARCH :: [f46bfac] Downloading DCs.Legends.of.Tomorrow.S04E03.FASTSUB.VOSTFR.720p.HDTV.x264-GOLD with 35 seeders and 35 leechers and size 1.07 GB from Yggtorrent
2019-04-27 09:40:11 WARNING  SNATCHQUEUE-SNATCH-311902 :: [f46bfac] Torrent file content is empty: MacGyver.2016.S03E01.FASTSUB.VOSTFR.720p.HDTV.x264-GOLD


How to enable log level : debug ?
2019-04-27 10:15:58 INFO     SEARCHQUEUE-DAILY-SEARCH :: [Yggtorrent] :: [f46bfac] Picked MacGyver.2016.S03E01.FASTSUB.VOSTFR.720p.HDTV.x264-GOLD as the best result.
2019-04-27 10:20:58 INFO     SEARCHQUEUE-DAILY-SEARCH :: [f46bfac] Downloading MacGyver.2016.S03E01.FASTSUB.VOSTFR.720p.HDTV.x264-GOLD with 4 seeders and 4 leechers and size 1.36 GB from Yggtorrent
2019-04-27 10:21:00 INFO     SNATCHQUEUE-SNATCH-311902 :: [f46bfac] Beginning to snatch release: MacGyver.2016.S03E01.FASTSUB.VOSTFR.720p.HDTV.x264-GOLD
2019-04-27 10:21:00 INFO     SNATCHQUEUE-SNATCH-311902 :: [f46bfac] Downloading MacGyver.2016.S03E01.FASTSUB.VOSTFR.720p.HDTV.x264-GOLD with 4 seeders and 4 leechers and size 1.36 GB from Yggtorrent, through a SearchType.DAILY_SEARCH search
2019-04-27 10:21:03 WARNING  SNATCHQUEUE-SNATCH-311902 :: [f46bfac] Torrent file content is empty: MacGyver.2016.S03E01.FASTSUB.VOSTFR.720p.HDTV.x264-GOLD

`How to enable log level : debug ?`
General > Advanced Settings > Enable debug


I have the same issue, and I was able to download the file manually.

Here are my Debug logs:

```
2019-05-07 15:31:21 INFO     SNATCHQUEUE-SNATCH-267440 :: [94fae84] Beginning to snatch release: Shingeki.no.Kyojin.S03E13.1080p.VOSTFR.WEBRip.AAC.x264-WKN
2019-05-07 15:31:21 INFO     SNATCHQUEUE-SNATCH-267440 :: [94fae84] Downloading Shingeki.no.Kyojin.S03E13.1080p.VOSTFR.WEBRip.AAC.x264-WKN with 209 seeders and 120 leechers and size 1.05 GB from Yggtorrent, through a SearchType.MANUAL_SEARCH search
2019-05-07 15:31:21 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] GET URL: https://www.yggtorrent.to/user/ajax_usermenu [Status: 301]
2019-05-07 15:31:21 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] User-Agent: Medusa/0.3.1 (Linux; 4.15.18-12-pve; 508306fd-70cb-11e9-8c37-0242ac120005)
2019-05-07 15:31:21 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] GET URL: https://www2.yggtorrent.gg/user/ajax_usermenu [Status: 301]
2019-05-07 15:31:21 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] User-Agent: Medusa/0.3.1 (Linux; 4.15.18-12-pve; 508306fd-70cb-11e9-8c37-0242ac120005)
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] GET URL: https://www2.yggtorrent.ch/user/ajax_usermenu [Status: 307]
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] User-Agent: Medusa/0.3.1 (Linux; 4.15.18-12-pve; 508306fd-70cb-11e9-8c37-0242ac120005)
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] GET URL: https://www2.yggtorrent.ch/engine/error?http_code=403 [Status: 403]
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] User-Agent: Medusa/0.3.1 (Linux; 4.15.18-12-pve; 508306fd-70cb-11e9-8c37-0242ac120005)
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] The response returned a non-200 response while requesting url https://www.yggtorrent.to/user/ajax_usermenu Error: HTTPError(u'403 Client Error: Forbidden for url: https://www2.yggtorrent.ch/engine/error?http_code=403',)
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] Retrieving redirect URL for https://www.yggtorrent.to/user/login
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] GET URL: https://www.yggtorrent.to/user/login [Status: 301]
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] User-Agent: Medusa/0.3.1 (Linux; 4.15.18-12-pve; 508306fd-70cb-11e9-8c37-0242ac120005)
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] POST URL: https://www2.yggtorrent.gg/user/login [Status: 301]
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] User-Agent: Medusa/0.3.1 (Linux; 4.15.18-12-pve; 508306fd-70cb-11e9-8c37-0242ac120005)
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] With post data: id=**********&pass=**********
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] GET URL: https://www2.yggtorrent.ch/user/login [Status: 200]
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] User-Agent: Medusa/0.3.1 (Linux; 4.15.18-12-pve; 508306fd-70cb-11e9-8c37-0242ac120005)
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] GET URL: https://www.yggtorrent.to/user/ajax_usermenu [Status: 301]
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] User-Agent: Medusa/0.3.1 (Linux; 4.15.18-12-pve; 508306fd-70cb-11e9-8c37-0242ac120005)
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] GET URL: https://www2.yggtorrent.gg/user/ajax_usermenu [Status: 301]
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] User-Agent: Medusa/0.3.1 (Linux; 4.15.18-12-pve; 508306fd-70cb-11e9-8c37-0242ac120005)
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] GET URL: https://www2.yggtorrent.ch/user/ajax_usermenu [Status: 307]
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] User-Agent: Medusa/0.3.1 (Linux; 4.15.18-12-pve; 508306fd-70cb-11e9-8c37-0242ac120005)
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] GET URL: https://www2.yggtorrent.ch/engine/error?http_code=403 [Status: 403]
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] User-Agent: Medusa/0.3.1 (Linux; 4.15.18-12-pve; 508306fd-70cb-11e9-8c37-0242ac120005)
2019-05-07 15:31:22 DEBUG    SNATCHQUEUE-SNATCH-267440 :: [94fae84] The response returned a non-200 response while requesting url https://www.yggtorrent.to/user/ajax_usermenu Error: HTTPError(u'403 Client Error: Forbidden for url: https://www2.yggtorrent.ch/engine/error?http_code=403',)
2019-05-07 15:31:22 WARNING  SNATCHQUEUE-SNATCH-267440 :: [94fae84] Unable to connect or login to provider
2019-05-07 15:31:22 WARNING  SNATCHQUEUE-SNATCH-267440 :: [94fae84] Torrent file content is empty: Shingeki.no.Kyojin.S03E13.1080p.VOSTFR.WEBRip.AAC.x264-WKN
```

Resolving patch:
diff --git a/medusa/providers/torrent/torrent_provider.py b/medusa/providers/torrent/torrent_provider.py
--- a/medusa/providers/torrent/torrent_provider.py
+++ b/medusa/providers/torrent/torrent_provider.py
@@ -146,12 +146,13 @@ def _get_pubdate(self, item):
         return pubdate
 
     def get_redirect_url(self, url):
-        """Get the address that the provided URL redirects to."""
+        """Get the final address that the provided URL redirects to."""
         log.debug('Retrieving redirect URL for {url}', {'url': url})
 
-        response = self.session.get(url, allow_redirects=False)
-        if response and response.headers.get('Location'):
-            return response.headers['Location']
+        response = self.session.get(url, stream=True)
+        if response:
+            response.close()
+            return response.url
 
         log.debug('Unable to retrieve redirect URL for {url}', {'url': url})
         return url


Test patch: