From d4751c2d0797796af14c4a8ab0746eba91cebc99 Mon Sep 17 00:00:00 2001
From: zoidberg10 <zoidberg@mujmail.cz>
Date: Fri, 3 Feb 2012 00:47:08 +0100
Subject: fix ul.to

---
 module/plugins/accounts/FilejungleCom.py |  4 +--
 module/plugins/accounts/YibaishiwuCom.py | 51 ++++++++++++++++++++++++++++
 module/plugins/hoster/CoolshareCz.py     | 57 ++++++++++++++++++++++++++++++++
 module/plugins/hoster/UploadedTo.py      |  6 +++-
 module/plugins/hoster/YibaishiwuCom.py   | 24 +++++---------
 5 files changed, 123 insertions(+), 19 deletions(-)
 create mode 100644 module/plugins/accounts/YibaishiwuCom.py
 create mode 100644 module/plugins/hoster/CoolshareCz.py

(limited to 'module')

diff --git a/module/plugins/accounts/FilejungleCom.py b/module/plugins/accounts/FilejungleCom.py
index 4fa4a06d8..8ac25c201 100644
--- a/module/plugins/accounts/FilejungleCom.py
+++ b/module/plugins/accounts/FilejungleCom.py
@@ -23,7 +23,7 @@ from time import mktime, strptime
 
 class FilejungleCom(Account):
     __name__ = "FilejungleCom"
-    __version__ = "0.1"
+    __version__ = "0.11"
     __type__ = "account"
     __description__ = """filejungle.com account plugin"""
     __author_name__ = ("zoidberg")
@@ -40,7 +40,7 @@ class FilejungleCom(Account):
         found = re.search(self.TRAFFIC_LEFT_PATTERN, html)
         if found:
             premium = True
-            validuntil = mktime(strptime(found.group(1), "%d %B %Y"))
+            validuntil = mktime(strptime(found.group(1), "%d %b %Y"))
         else:
             premium = False 
             validuntil = -1
diff --git a/module/plugins/accounts/YibaishiwuCom.py b/module/plugins/accounts/YibaishiwuCom.py
new file mode 100644
index 000000000..e2aa6f11d
--- /dev/null
+++ b/module/plugins/accounts/YibaishiwuCom.py
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+
+"""
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 3 of the License,
+    or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+    See the GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+    @author: zoidberg
+"""
+
+from module.plugins.Account import Account
+import re
+
+class YibaishiwuCom(Account):
+    __name__ = "YibaishiwuCom"
+    __version__ = "0.01"
+    __type__ = "account"
+    __description__ = """115.com account plugin"""
+    __author_name__ = ("zoidberg")
+    __author_mail__ = ("zoidberg@mujmail.cz")
+
+    ACCOUNT_INFO_PATTERN = r'var USER_PERMISSION = {(.*?)}'
+
+    def loadAccountInfo(self, user, req):
+        #self.relogin(user)
+        html = req.load("http://115.com/", decode = True)
+        
+        found = re.search(self.ACCOUNT_INFO_PATTERN, html, re.S)
+        premium = True if (found and 'is_vip: 1' in found.group(1)) else False
+        validuntil = trafficleft = (-1 if found else 0)
+        return dict({"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium})
+
+    def login(self, user, data, req):
+        html = req.load('http://passport.115.com/?ac=login', post = {
+            "back": "http://www.115.com/",
+            "goto": "http://115.com/",
+            "login[account]": user,
+            "login[passwd]": data['password']
+            }, decode = True)
+
+        if not 'var USER_PERMISSION = {' in html:
+            self.wrongPassword()
\ No newline at end of file
diff --git a/module/plugins/hoster/CoolshareCz.py b/module/plugins/hoster/CoolshareCz.py
new file mode 100644
index 000000000..63bc4cf37
--- /dev/null
+++ b/module/plugins/hoster/CoolshareCz.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+"""
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 3 of the License,
+    or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+    See the GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+    @author: zoidberg
+"""
+
+import re
+from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
+from module.network.HTTPRequest import BadHeader
+
+class CoolshareCz(SimpleHoster):
+    __name__ = "CoolshareCz"
+    __type__ = "hoster"
+    __pattern__ = r"http://(?:\w*\.)?coolshare.cz/stahnout/(?P<ID>\d+)/.+"
+    __version__ = "0.1"
+    __description__ = """CoolShare.cz"""
+    __author_name__ = ("zoidberg")
+
+    FILE_NAME_PATTERN = r'<h1>(?P<N>[^<]+)</h1>'
+    FILE_SIZE_PATTERN = r'<li>Velikost: <strong>(?P<S>[^<]+)</strong>'
+    FILE_OFFLINE_PATTERN = r'<h1>Soubor nenalezen</h1>'
+    
+    PREMIUM_URL_PATTERN = r'<div class="cleaner oddelovac"><!-- --></div>\s*<p><a href="([^"]*)"'
+    
+    SH_CHECK_TRAFFIC = True             
+              
+    def handleFree(self):
+        try:      
+            self.download("http://csd01.coolshare.cz/dwn-free.php?fid=%s" % self.file_info['ID'])
+        except BadHeader, e:
+            if e.code == 403:
+                self.setWait(300, True)
+                self.wait()
+                self.retry(max_tries = 24, reason = "Download limit reached")
+            else: raise
+        
+    def handlePremium(self):
+        found = re.search(self.PREMIUM_URL_PATTERN, self.html)
+        if not found: self.parseError("Premium URL")
+        url = found.group(1)
+        self.logDebug("Premium URL: " + url)        
+        if not url.startswith("http://"): self.resetAccount()
+        self.download(url)
+
+getInfo = create_getInfo(CoolshareCz)
\ No newline at end of file
diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py
index 39483cf86..656977426 100644
--- a/module/plugins/hoster/UploadedTo.py
+++ b/module/plugins/hoster/UploadedTo.py
@@ -84,7 +84,7 @@ class UploadedTo(Hoster):
     __name__ = "UploadedTo"
     __type__ = "hoster"
     __pattern__ = r"(http://[\w\.-]*?uploaded\.to/.*?(file/|\?id=|&id=)[\w]+/?)|(http://[\w\.]*?ul\.to/(\?id=|&id=)?[\w\-]+/.+)|(http://[\w\.]*?ul\.to/(\?id=|&id=)?[\w\-]+/?)"
-    __version__ = "0.53"
+    __version__ = "0.54"
     __description__ = """Uploaded.to Download Hoster"""
     __author_name__ = ("spoob", "mkaay")
     __author_mail__ = ("spoob@pyload.org", "mkaay@mkaay.de")
@@ -162,6 +162,10 @@ class UploadedTo(Hoster):
 
     def handleFree(self):
         self.html = self.load(self.pyfile.url, decode=True)
+        
+        if 'var free_enabled = false;' in self.html:
+            self.logError("Free-download capacities exhausted.")
+            self.retry(24, 300)
 
         wait = re.search(r"Current waiting period: <span>(\d+)</span> seconds", self.html).group(1)
         self.setWait(wait)
diff --git a/module/plugins/hoster/YibaishiwuCom.py b/module/plugins/hoster/YibaishiwuCom.py
index be4742715..5926cc227 100644
--- a/module/plugins/hoster/YibaishiwuCom.py
+++ b/module/plugins/hoster/YibaishiwuCom.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
 """
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@ class YibaishiwuCom(SimpleHoster):
     __name__ = "YibaishiwuCom"
     __type__ = "hoster"
     __pattern__ = r"http://(?:www\.)?(?:u\.)?115.com/file/(?P<ID>\w+)"
-    __version__ = "0.1"
+    __version__ = "0.11"
     __description__ = """115.com"""
     __author_name__ = ("zoidberg")
 
@@ -32,24 +32,16 @@ class YibaishiwuCom(SimpleHoster):
     FILE_SIZE_PATTERN = r"file_size: '(?P<S>[^']+)'"
     FILE_OFFLINE_PATTERN = ur'<h3><i style="color:red;">哎呀!提取码不存在!不妨搜搜看吧!</i></h3>'
     
-    AJAX_GUEST_URL_PATTERN = r'url: "(/\?ct=pickcode[^"]+)"'
-    AJAX_FREEUSER_URL_PATTERN = r'url: "(/\?ct=download&ac=get^"]+)"'    
+    AJAX_URL_PATTERN = r'(/\?ct=(pickcode|download)[^"\']+)'    
               
     def handleFree(self):
-        url = False
-        if self.account:
-            found = re.search(self.AJAX_FREEUSER_URL_PATTERN, self.html)
-            if found: 
-                url = found.group(1)
-                self.logDebug('FREEUSER URL: ' + url)
-        if not url:
-            found = re.search(self.AJAX_GUEST_URL_PATTERN, self.html)
-            if not found: self.parseError("AJAX URL")
-            url = found.group(1)
-            self.logDebug('GUEST URL: ' + url)
+        found = re.search(self.AJAX_URL_PATTERN, self.html)
+        if not found: self.parseError("AJAX URL")
+        url = found.group(1)
+        self.logDebug(('FREEUSER' if found.group(2) == 'download' else 'GUEST') + ' URL', url)
         
         response = json_loads(self.load("http://115.com" + url, decode = False))
-        for mirror in response['data']:
+        for mirror in (response['urls'] if 'urls' in response else response['data'] if 'data' in response else []): 
             try:
                 url = mirror['url'].replace('\\','')
                 self.logDebug("Trying URL: " + url)
-- 
cgit v1.2.3