Repository: pyload/pyload

Issue:
Reason for "Download failed | Fallback to free download | Download was already free"
I traced through the functions defined in UploadedTo.py, SimpleHoster.py and Hoster.py a bit to try and find out what is happening.
My log output is the following:

```
06.08.2015 11:58:55 INFO      Download starts: http://uploaded.net/file/sdzkjtrh/File1.rar
06.08.2015 11:58:55 DEBUG     HOOK UserAgentSwitcher: Use custom user-agent string: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
06.08.2015 11:58:55 DEBUG     Redirected import module.plugins.accounts.UploadedTo -> userplugins.accounts.UploadedTo
06.08.2015 11:58:55 DEBUG     Redirected import module.plugins.internal.Account -> userplugins.internal.Account
06.08.2015 11:58:55 DEBUG     HOOK UserAgentSwitcher: Use custom user-agent string: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
06.08.2015 11:58:55 DEBUG     HOSTER UploadedTo[10]: PROCESS URL http://uploaded.net/file/sdzkjtrh/File1.rar | PLUGIN VERSION 0.96
06.08.2015 11:58:55 DEBUG     HOSTER UploadedTo[10]: Config option `fallback` not found, use default `True`
06.08.2015 11:58:55 WARNING   Download failed: http://uploaded.net/file/sdzkjtrh/File1.rar | Fallback to free download | Download was already free
06.08.2015 11:58:55 INFO      HOOK UnSkipOnFail: Looking for skipped duplicates of: http://uploaded.net/file/sdzkjtrh/File1.rar (pid:3)
06.08.2015 11:58:55 INFO      HOOK UnSkipOnFail: No duplicates found
```

So the debug output `PROCESS URL http://uploaded.net/file/sdzkjtrh/File1.rar | PLUGIN VERSION 0.96` is obviously from the function `preprocessing` in `Hoster.py`. After the output the fuction `process` from `SimpleHoster.py` is called which calls the function `prepare` (also in `SimpleHoster.py`).
In this function the lines

```
if not self.get_config('use_premium', True):
                self.restart(nopremium=True)
```

obvious call the function `restart` from `Hoster.py` everytime we are doing a free download. The function `restart` tries to fallback to free which it already was, so it fails:

```
def restart(self, reason=None, nopremium=False):
    if not reason:
        reason = _("Fallback to free download") if nopremium else _("Restart")

    if nopremium:
        if self.premium:
            self.retry_free = True
        else:
            self.fail("%s | %s" % (reason, _("Download was already free")))

    raise Retry(encode(reason))  #@TODO: Remove `encode` in 0.4.10
```

So this CAN'T work, right?



Discussion:

Resolving patch:
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -23,7 +23,7 @@
 class SimpleHoster(Hoster):
     __name__    = "SimpleHoster"
     __type__    = "hoster"
-    __version__ = "1.80"
+    __version__ = "1.81"
     __status__  = "testing"
 
     __pattern__ = r'^unmatchable$'
@@ -209,12 +209,11 @@ def prepare(self):
         self.direct_dl     = False
         self.leech_dl      = False
 
-        if not self.get_config('use_premium', True):
+        if not self.get_config('use_premium', True) and self.premium:
             self.restart(nopremium=True)
 
         if self.LOGIN_PREMIUM and not self.premium:
             self.fail(_("Required premium account not found"))
-            self.LOGIN_ACCOUNT = True
 
         if self.LOGIN_ACCOUNT and not self.account:
             self.fail(_("Required account not found"))


Test patch: