Repository: pymedusa/Medusa

Issue:
Problem with YGGTORRENT because of url change : ww[3].yggtorrent.is
**Describe the bug**
Problem when trying to download episodes with YGGTORRENT provider. 
I see that the URL of yggtorrent has changed since the last version of Medusa, from "ww2.yggtorrent.is" to "ww3.yggtorrent.is". 

**To Reproduce**
Steps to reproduce the behavior:
1. Snatch episode with YGGTORRENT provider.
2. The torrent file won't be downloaded, just downloading an empty file
3. Warning in Medusa and no file downloaded by the torrent client.

**Expected behavior**
Dev : Find a way please to configure the provider URL with the Medusa interface... please, to avoid multiples problems like this because many providers change their url frequently.

**Medusa (please complete the following information):**
 - OS: Windows 10, Medusa is installed in DSM 6 on Synology
 - Branch: master (up to date)




Discussion:
@medariox @supergonkas what you guys think? Is this a case "piratebay"? 
Yeah, if they keep changing the URL every few weeks... It's getting really annoying.
On my side, I use jackett, and configure yggTorrent in jackett . So I can "easily" change the url in jackett, whithout updating the configuration in medusa . ( I put `easily` in quote, because in fact, here is a bug, and we need to manually update the json file )
Dont sweat it. Well make the url field configurable. Its not much work. Just have to wait until someone gets to it. 
During this charming conversation, url of yggtorrent became ww4.yggtorrent.is. 
Why are they changing it? 
It's to prevent dereferencing by Google. 
The download works fine from the browser, even with the old domains. So it should also work for us. There must be an issue with our code somewhere.

Resolving patch:
diff --git a/medusa/providers/torrent/html/yggtorrent.py b/medusa/providers/torrent/html/yggtorrent.py
--- a/medusa/providers/torrent/html/yggtorrent.py
+++ b/medusa/providers/torrent/html/yggtorrent.py
@@ -36,8 +36,9 @@ def __init__(self):
         self.password = None
 
         # URLs
-        self.url = 'https://ww3.yggtorrent.is'
+        self.url = 'https://ww4.yggtorrent.is'
         self.urls = {
+            'auth': urljoin(self.url, 'user/ajax_usermenu'),
             'login': urljoin(self.url, 'user/login'),
             'search': urljoin(self.url, 'engine/search'),
             'download': urljoin(self.url, 'engine/download_torrent?id={0}')
@@ -173,18 +174,19 @@ def login(self):
             'pass': self.password
         }
 
-        login_resp = self.session.post(self.urls['login'], data=login_params)
-        if not login_resp:
-            log.warning('Invalid username or password. Check your settings')
-            return False
+        if not self._is_authenticated():
+            login_url = self.get_redirect_url(self.urls['login'])
+            login_resp = self.session.post(login_url, data=login_params)
+            if not login_resp or not self._is_authenticated():
+                log.warning('Invalid username or password. Check your settings')
+                return False
 
-        response = self.session.get(self.url)
-        if not response:
-            log.warning('Unable to connect to provider')
-            return False
+        return True
 
-        if 'Bienvenue' not in response.text:
-            log.warning('Unable to login to provider')
+    def _is_authenticated(self):
+        response = self.session.get(self.urls['auth'])
+        if not response:
+            log.warning('Unable to connect or login to provider')
             return False
 
         return True


Test patch: