Repository: Flexget/Flexget

Issue:
The torrentleech plugin is not working with their V5 api 
### Expected behaviour:
The first episode of the series is downloaded

### Actual behaviour:
No results are found from the torrentleech search plugin


### Steps to reproduce:
- Step 1: Run flexget with the config supplied in the issue

#### Config:
```
tasks:
  test task:
    series:
      - Rick and Morty:
          begin: S02E01
    discover:
      what:
        - next_series_episodes:
            backfill: yes
      from:
        - torrentleech:
            rss_key: ***********
            username: ***********
            password: ***********
    download: ~/downloads

schedules:
  # Run every 30 minutes
  - tasks: '*'
    schedule:
      minute: "*/20"
```
  
### Additional information:
This seems to be a result of the upgrade to the Torrentleech V5 api. I modified the plugin to use the V4 api and this is working for now as long as they don't remove support for it. Would it be reasonable to put a PR with a Torrentleech plugin that uses the V4 api until support for the V5 api has been implemented? 


- FlexGet version: 2.13.8.dev
- Python version: Python 2.7.14
- Installation method: Latest git version
- Using daemon (yes/no): no
- OS and version: MacOS and Ubuntu Server



Discussion:

Resolving patch:
diff --git a/flexget/plugins/sites/torrentleech.py b/flexget/plugins/sites/torrentleech.py
--- a/flexget/plugins/sites/torrentleech.py
+++ b/flexget/plugins/sites/torrentleech.py
@@ -77,7 +77,7 @@ def url_rewritable(self, task, entry):
         url = entry['url']
         if url.endswith('.torrent'):
             return False
-        if url.startswith('https://www.torrentleech.org/'):
+        if url.startswith('https://v4.torrentleech.org/'):
             return True
         return False
 
@@ -87,7 +87,7 @@ def url_rewrite(self, task, entry):
             log.error("Didn't actually get a URL...")
         else:
             log.debug("Got the URL: %s" % entry['url'])
-        if entry['url'].startswith('https://www.torrentleech.org/torrents/browse/index/query/'):
+        if entry['url'].startswith('https://v4.torrentleech.org/torrents/browse/index/query/'):
             # use search
             results = self.search(task, entry)
             if not results:
@@ -106,7 +106,7 @@ def search(self, task, entry, config=None):
         data = {'username': config['username'], 'password': config['password']}
         # POST the login form:
         try:
-            login = task.requests.post('https://www.torrentleech.org/user/account/login/', data=data)
+            login = task.requests.post('https://v4.torrentleech.org/user/account/login/', data=data)
         except RequestException as e:
             raise PluginError('Could not connect to torrentleech: %s', str(e))
 
@@ -126,7 +126,7 @@ def search(self, task, entry, config=None):
         for search_string in entry.get('search_strings', [entry['title']]):
             query = normalize_unicode(search_string).replace(":", "")
             # urllib.quote will crash if the unicode string has non ascii characters, so encode in utf-8 beforehand
-            url = ('https://www.torrentleech.org/torrents/browse/index/query/' +
+            url = ('https://v4.torrentleech.org/torrents/browse/index/query/' +
                    quote(query.encode('utf-8')) + filter_url)
             log.debug('Using %s as torrentleech search url' % url)
 
@@ -146,7 +146,7 @@ def search(self, task, entry, config=None):
                 # parse link and split along /download/12345 and /name.torrent
                 download_url = re.search('(/download/\d+)/(.+\.torrent)', torrent_url)
                 # change link to rss and splice in rss_key
-                torrent_url = 'https://www.torrentleech.org/rss' + download_url.group(1) + '/' \
+                torrent_url = 'https://v4.torrentleech.org/rss' + download_url.group(1) + '/' \
                               + rss_key + '/' + download_url.group(2)
                 log.debug('RSS-ified download link: %s' % torrent_url)
                 entry['url'] = torrent_url


Test patch: