diff options
| author | 2012-01-11 17:41:00 +0100 | |
|---|---|---|
| committer | 2012-01-11 17:41:00 +0100 | |
| commit | 69ffe7a95e7bd136e6ab1a4cf8d96cf2a5fdeba6 (patch) | |
| tree | 2def041b62835e6c7cf57d9c4b07ee88c79fd664 /module | |
| parent | uloz.to premium, update linkdecrypter.com (diff) | |
| download | pyload-69ffe7a95e7bd136e6ab1a4cf8d96cf2a5fdeba6.tar.xz | |
premium4.me error handling
Diffstat (limited to 'module')
| -rw-r--r-- | module/plugins/hoster/Premium4Me.py | 37 | 
1 files changed, 31 insertions, 6 deletions
| diff --git a/module/plugins/hoster/Premium4Me.py b/module/plugins/hoster/Premium4Me.py index 1d97e21b1..beccdf572 100644 --- a/module/plugins/hoster/Premium4Me.py +++ b/module/plugins/hoster/Premium4Me.py @@ -6,7 +6,7 @@ from module.plugins.Hoster import Hoster  class Premium4Me(Hoster):
      __name__ = "Premium4Me"
 -    __version__ = "0.01"
 +    __version__ = "0.02"
      __type__ = "hoster"
      __pattern__ = r"http://premium4.me/.*"
 @@ -15,7 +15,6 @@ class Premium4Me(Hoster):      __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz")
      def setup(self):
 -        self.chunkLimit = 3
          self.resumeDownload = True
      def process(self, pyfile):
 @@ -23,10 +22,36 @@ class Premium4Me(Hoster):              self.logError(_("Please enter your premium4.me account or deactivate this plugin"))
              self.fail("No premium4.me account provided")
 -        self.log.debug("premium4.me: Old URL: %s" % pyfile.url)
 -        new_url = "http://premium4.me/api/getfile.php?authcode=%s&link=%s" % (self.account.authcode, quote(pyfile.url, ""))
 +        self.logDebug("premium4.me: Old URL: %s" % pyfile.url)
 +        tra = self.getTraffic()
 +        
          #raise timeout to 2min
          self.req.setOption("timeout", 120)
 -
 -        self.download(new_url, disposition=True)
\ No newline at end of file +        
 +        self.download("http://premium4.me/api/getfile.php?authcode=%s&link=%s" % (self.account.authcode, quote(pyfile.url, "")), disposition=True)
 +        
 +        err = ''       
 +        if self.req.http.code == '420':
 +            # Custom error code send - fail
 +            lastDownload = fs_encode(self.lastDownload)
 +            
 +            if exists(lastDownload): 
 +                f = open(lastDownload, "rb")
 +                err = f.read(256).strip()
 +                f.close()
 +                remove(lastDownload)
 +            else:
 +                err = 'File does not exist'
 +        
 +        trb = self.getTraffic()
 +        self.logInfo("Filesize: %d, Traffic used %d, traffic left %d" % (pyfile.size, tra-trb, trb))
 +                    
 +        if err: self.fail(err)
 +        
 +    def getTraffic(self):
 +        try:
 +            traffic = int(self.load ("http://premium4.me/api/traffic.php?authcode=%s" % self.account.authcode))
 +        except:
 +            traffic = 0 
 +        return traffic       
\ No newline at end of file | 
