summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-08-01 22:34:51 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-08-01 22:34:51 +0200
commitb612fbda4fa6ed8cb0b4e2e3015e8127a20aaea2 (patch)
tree5ad7daff9f92555b73bd207447a710e0a01367a9 /module/plugins/internal
parentFix https://github.com/pyload/pyload/issues/1636 (diff)
downloadpyload-b612fbda4fa6ed8cb0b4e2e3015e8127a20aaea2.tar.xz
Fix load_account routine
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/Hoster.py35
-rw-r--r--module/plugins/internal/SimpleCrypter.py25
2 files changed, 34 insertions, 26 deletions
diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py
index 92afd3672..ea54d9589 100644
--- a/module/plugins/internal/Hoster.py
+++ b/module/plugins/internal/Hoster.py
@@ -43,7 +43,7 @@ def create_getInfo(klass):
class Hoster(Plugin):
__name__ = "Hoster"
__type__ = "hoster"
- __version__ = "0.14"
+ __version__ = "0.15"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -142,27 +142,22 @@ class Hoster(Plugin):
def load_account(self):
- oldaccount = self.account
+ if self.req:
+ self.req.close()
if not self.account:
self.account = self.pyload.accountManager.getAccountPlugin(self.__name__)
if self.account:
- if self.user:
- self.account = self.account.is_logged(self.user, relogin=True)
- else:
+ if not self.user:
self.user, data = self.account.select()
- if not self.user:
- self.account = False
- if self.account == oldaccount:
- self.req.clearCookies()
+ if not self.user or not self.account.is_logged(self.user, relogin=True):
+ self.account = False
- elif self.account:
- self.req = self.account.get_request(self.user) #: Browser instance, see `network.Browser`
-
- else:
- self.req = self.pyload.requestFactory.getRequest(self.__name__)
+ #: Browser instance, see `network.Browser`
+ self.req = self.pyload.requestFactory.getRequest(self.__name__,
+ self.user if self.account else None)
def preprocessing(self, thread):
@@ -171,8 +166,6 @@ class Hoster(Plugin):
"""
self.thread = thread
- self.req.renewHTTPRequest()
-
self.load_account()
self._setup()
self.setup()
@@ -516,10 +509,9 @@ class Hoster(Plugin):
header = self.load(url, just_header=True)
except Exception: #: Bad bad bad... rewrite this part in 0.4.10
- req = pyreq.getHTTPRequest()
- res = self.load(url, just_header=True)
-
- req.close()
+ res = self.load(url,
+ just_header=True,
+ req=self.pyload.requestFactory.getRequest())
header = {'code': req.code}
for line in res.splitlines():
@@ -657,7 +649,8 @@ class Hoster(Plugin):
del self.pyfile
if hasattr(self, "req"):
- self.req.close()
+ if self.req:
+ self.req.close()
del self.req
if hasattr(self, "thread"):
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index 20a03df9f..084bc133c 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -10,7 +10,7 @@ from module.utils import fixup, html_unescape
class SimpleCrypter(Crypter, SimpleHoster):
__name__ = "SimpleCrypter"
__type__ = "crypter"
- __version__ = "0.58"
+ __version__ = "0.59"
__status__ = "testing"
__pattern__ = r'^unmatchable$'
@@ -57,10 +57,25 @@ class SimpleCrypter(Crypter, SimpleHoster):
#@TODO: Remove in 0.4.10
- def init(self):
- account_name = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "")
- self.account = self.pyload.accountManager.getAccountPlugin(account_name)
- self.load_account()
+ def load_account(self):
+ accountname = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "")
+
+ if self.req:
+ self.req.close()
+
+ if not self.account:
+ self.account = self.pyload.accountManager.getAccountPlugin(accountname)
+
+ if self.account:
+ if not self.user:
+ self.user, data = self.account.select()
+
+ if not self.user or not self.account.is_logged(self.user, relogin=True):
+ self.account = False
+
+ #: Browser instance, see `network.Browser`
+ self.req = self.pyload.requestFactory.getRequest(accountname,
+ self.user if self.account else None)
def handle_direct(self, pyfile):