Repository: Flexget/Flexget

Issue:
MoreThanTV Plugin - Site URL Needs Updating
### Discussed in https://github.com/Flexget/Flexget/discussions/3492

<div type='discussions-op-text'>

<sup>Originally posted by **spgomez** July  4, 2022</sup>
I'm getting the following error when trying to use the morethantv plugin (within the discover plugin):

> ERROR    discover      Series-Latest   Error searching with morethantv: MoreThanTV login failed: HTTPSConnectionPool(host='www.morethan.tv', port=443): Max retries exceeded with url: /login.php (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000000009E40EB0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

Here is my config file:

```
variables: variables.yml
schedules:
  - tasks: [Series-Latest]
    interval:
      minutes: 30
templates:
  client:
    transmission:
      host: localhost
      port: 9091
      add_paused: No
      ratio: -1
  tv:
    template: client
    series:
      - Dark Winds
      - The Old Man
      - Evil
      - What We Do in the Shadows
      - Y':' The Last Man
      - Doom Patrol
      - Fargo
    quality: 1080p
    set:
      path: D://My Downloads/tv shows/
  movies:
    quality: 1080p
    set:
      path: D://My Downloads/movies/
tasks:
  Sync-Series:
    manual: yes
    filesystem:
      regexp: .*(avi|mkv|mp4)$
      path: D://My Downloads/tv shows/
      recursive: yes
      retrieve: files
    disable: builtins
    all_series: yes
    exec: echo "Found {{title}}"
  Series-Latest:
    template: tv
    discover:
      what:
        - next_series_episodes: yes
      from:
        - morethantv:
            username: '{? mtv.username ?}'
            password: '{? mtv.password ?}'
            category: TV
            all_tags: yes
    notify:
      entries:
        title: >
          {%if task in ["Series-Latest"](/"Series-Latest")%} New Series Episode added to queue
          {%else%}Download Start from task {{Series-Latest}}
          {%endif%}
        message: >
          {%if series_name is defined%}{{series_name}} - {{series_id}} - {{quality|d('')}}
          {%else%}{{title}}
          {%endif%}}
        via:
          - pushsafer:
              private_key: '{? ps.key ?}'
              device: "55172"
              sound: 12
              icon: 28
              vibration: 1
              url: '{{trakt_series_trakt_url}}'
              url_title: Link
```

I believe the issue might stem from the fact the that plugin is using an outdated url. MoreThanTV is now hosted at https://www.morethantv.me/, as you can see from the error above, it's trying to connect to www.morethan.tv.</div>


Discussion:

Resolving patch:
diff --git a/flexget/components/sites/sites/morethantv.py b/flexget/components/sites/sites/morethantv.py
--- a/flexget/components/sites/sites/morethantv.py
+++ b/flexget/components/sites/sites/morethantv.py
@@ -17,12 +17,15 @@
 from flexget.utils.soup import get_soup
 from flexget.utils.tools import parse_filesize
 
+SITE_DOMAIN = 'morethantv.me'
+SITE_URL = f'https://www.{SITE_DOMAIN}/'
+
 logger = logger.bind(name='morethantv')
 Base = db_schema.versioned_base('morethantv', 0)
 
 requests = RequestSession()
 requests.add_domain_limiter(
-    TimedLimiter('morethan.tv', '5 seconds')
+    TimedLimiter(SITE_DOMAIN, '5 seconds')
 )  # TODO find out if they want a delay
 
 CATEGORIES = {'Movies': 'filter_cat[1]', 'TV': 'filter_cat[2]', 'Other': 'filter_cat[3]'}
@@ -129,7 +132,6 @@ class SearchMoreThanTV:
         'additionalProperties': False,
     }
 
-    base_url = 'https://www.morethan.tv/'
     errors = False
 
     def get(self, url, params, username, password, force=False):
@@ -148,7 +150,7 @@ def get(self, url, params, username, password, force=False):
 
         try:
             response = requests.get(url, params=params, cookies=cookies)
-            if self.base_url + 'login.php' in response.url:
+            if SITE_URL + 'login.php' in response.url:
                 invalid_cookie = True
         except TooManyRedirects:
             # Apparently it endlessly redirects if the cookie is invalid?
@@ -192,7 +194,7 @@ def get_login_cookie(self, username, password, force=False):
                     logger.debug('Found valid login cookie')
                     return saved_cookie.cookie
 
-        url = self.base_url + 'login.php'
+        url = SITE_URL + 'login.php'
         try:
             logger.debug('Attempting to retrieve MoreThanTV cookie')
             response = requests.post(
@@ -266,7 +268,7 @@ def search(self, task, entry, config):
             logger.debug('Using search params: {}', params)
             try:
                 page = self.get(
-                    self.base_url + 'torrents.php', params, config['username'], config['password']
+                    SITE_URL + 'torrents.php', params, config['username'], config['password']
                 )
                 logger.debug('requesting: {}', page.url)
             except RequestException as e:
@@ -281,7 +283,7 @@ def search(self, task, entry, config):
                 # TODO: compiling regexp within loop achieves nothing
                 title = group_info.find('a', href=re.compile(r'torrents.php\?id=\d+')).text
                 url = (
-                    self.base_url
+                    SITE_URL
                     + group_info.find('a', href=re.compile(r'torrents.php\?action=download'))[
                         'href'
                     ]


Test patch: