From 83e0d2c49dee1bc6e1263cbba37591c612a205dd Mon Sep 17 00:00:00 2001
From: RaNaN <Mast3rRaNaN@hotmail.de>
Date: Fri, 6 May 2011 19:30:41 +0200
Subject: easier implementation of free accounts

---
 module/plugins/Plugin.py                 | 7 +++++--
 module/plugins/accounts/MegauploadCom.py | 2 --
 module/plugins/hoster/MegauploadCom.py   | 8 ++------
 3 files changed, 7 insertions(+), 10 deletions(-)

(limited to 'module')

diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index 32e5e8d4d..4d8766250 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -90,7 +90,10 @@ class Plugin(object):
 
         self.ocr = None  # captcha reader instance
         self.account = pyfile.m.core.accountManager.getAccountPlugin(self.__name__) # account handler instance
+
         self.premium = False
+        self.user = None
+
         if self.account and not self.account.canUse(): self.account = None
         if self.account:
             self.user, data = self.account.selectAccount()
@@ -98,6 +101,7 @@ class Plugin(object):
             self.chunkLimit = -1 #enable chunks for all premium plugins
             self.resumeDownload = True #also enable resume (both will be ignored if server dont accept chunks)
             self.multiDL = True  #every hoster with account should provides multiple downloads
+            self.premium = self.account.isPremium(self.user)  #premium status
         else:
             self.req = pyfile.m.core.requestFactory.getRequest(self.__name__)
         
@@ -113,7 +117,6 @@ class Plugin(object):
 
         self.html = None #some plugins store html code here
 
-        #self.setup()
         self.init()
     
     def getChunkCount(self):
@@ -129,7 +132,7 @@ class Plugin(object):
         pass
 
     def setup(self):
-        """ setup for enviroment and other things"""
+        """ setup for enviroment and other things, called before downloading (possibly more than one time)"""
         pass
 
     def preprocessing(self, thread):
diff --git a/module/plugins/accounts/MegauploadCom.py b/module/plugins/accounts/MegauploadCom.py
index df539507c..b44914a99 100644
--- a/module/plugins/accounts/MegauploadCom.py
+++ b/module/plugins/accounts/MegauploadCom.py
@@ -33,8 +33,6 @@ class MegauploadCom(Account):
     def loadAccountInfo(self, user, req):
         page = req.load("http://www.megaupload.com/?c=account")
 
-        open("mu.html", "wb").write(page)
-
         free = re.findall(r"Account type:\s*</div>\s*<div class=\"acc_txt_bl2\">\s*<b>Regular</b>",page,re.IGNORECASE+re.MULTILINE)
         if free:
             return {"validuntil": -1, "trafficleft":-1, "premium": False}
diff --git a/module/plugins/hoster/MegauploadCom.py b/module/plugins/hoster/MegauploadCom.py
index 9e5081fd3..f73ecf308 100644
--- a/module/plugins/hoster/MegauploadCom.py
+++ b/module/plugins/hoster/MegauploadCom.py
@@ -62,13 +62,9 @@ class MegauploadCom(Hoster):
     def init(self):
         self.html = [None, None]
 
-        if self.account:
-            self.premium = self.account.getAccountInfo(self.user)["premium"]
-            if not self.premium:
-                self.multiDL = False
-                self.chunkLimit = 1
-        else:
+        if not self.premium:
             self.multiDL = False
+            self.chunkLimit = 1
 
         self.api = {}
         none, sep, self.fileID = self.pyfile.url.partition("d=")
-- 
cgit v1.2.3