diff options
Diffstat (limited to 'module/plugins')
| -rw-r--r-- | module/plugins/accounts/MultishareCz.py | 58 | ||||
| -rw-r--r-- | module/plugins/hooks/MultishareCz.py | 36 | ||||
| -rw-r--r-- | module/plugins/hoster/MultishareCz.py | 62 | 
3 files changed, 147 insertions, 9 deletions
| diff --git a/module/plugins/accounts/MultishareCz.py b/module/plugins/accounts/MultishareCz.py new file mode 100644 index 000000000..6b5402c08 --- /dev/null +++ b/module/plugins/accounts/MultishareCz.py @@ -0,0 +1,58 @@ +# -*- 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 +#from time import mktime, strptime +#from pycurl import REFERER +import re +from module.utils import parseFileSize + +class MultishareCz(Account): +    __name__ = "MultishareCz" +    __version__ = "0.01" +    __type__ = "account" +    __description__ = """multishare.cz account plugin""" +    __author_name__ = ("zoidberg") +    __author_mail__ = ("zoidberg@mujmail.cz") +     +    TRAFFIC_LEFT_PATTERN = r'<span class="profil-zvyrazneni">Kredit:</span>\s*<strong>(?P<S>[0-9,]+) (?P<U>\w+)</strong>' +    ACCOUNT_INFO_PATTERN = r'<input type="hidden" id="(u_ID|u_hash)" name="[^"]*" value="([^"]+)">' + +    def loadAccountInfo(self, user, req): +        #self.relogin(user) +        html = req.load("http://www.multishare.cz/profil/", decode = True) +                     +        found = re.search(self.TRAFFIC_LEFT_PATTERN, html)            +        trafficleft = parseFileSize(found.group('S'), found.group('U')) if found else 0 +        self.premium = True if trafficleft else False  +         +        html = req.load("http://www.multishare.cz/", decode = True) +        mms_info = dict(re.findall(self.ACCOUNT_INFO_PATTERN, html)) + +        return dict(mms_info, **{"validuntil": -1, "trafficleft": trafficleft}) +     +    def login(self, user, data, req): +        html = req.load('http://www.multishare.cz/html/prihlaseni_process.php', post = { +            "akce":	"Přihlásit", +            "heslo": data['password'], +            "jmeno": user +            }, decode = True) +         +        if not u'<title>MultiShare.cz :: Profil uživatele</title>' in html: +            self.wrongPassword()
\ No newline at end of file diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py new file mode 100644 index 000000000..a934f43ef --- /dev/null +++ b/module/plugins/hooks/MultishareCz.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +from module.network.RequestFactory import getURL +from module.plugins.internal.MultiHoster import MultiHoster +import re + +def getConfigSet(option): +    s = set(option.lower().split('|')) +    s.discard(u'') +    return s + +class MultishareCz(MultiHoster): +    __name__ = "MultishareCz" +    __version__ = "0.01" +    __type__ = "hook" +    __config__ = [("activated", "bool", "Activated", "False"), +        ("includeHoster", "str", "Use only for downloads from (bar-separated hosters)", ""), +        ("excludeHoster", "str", "Do not use for downloads from (bar-separated hosters)", "rapidshare.com|uloz.to")] +    __description__ = """MultiShare.cz hook plugin""" +    __author_name__ = ("zoidberg") +    __author_mail__ = ("zoidberg@mujmail.cz") + +    #replacements = [("freakshare.net", "freakshare.com")] +    HOSTER_PATTERN = r'<img class="logo-shareserveru"[^>]*alt="([^"]+)"></td>\s*<td class="stav"><img src="/img/loga/ok.png" alt="OK">' + +    def getHoster(self): + +        page = getURL("http://www.multishare.cz/monitoring/") +        hoster = set(m.group(1).lower() for m in re.finditer(self.HOSTER_PATTERN, page))  +         +        option = self.getConfig('includeHoster').strip() +        if option: hoster &= getConfigSet(option) +        option = self.getConfig('excludeHoster').strip() +        if option: hoster -= getConfigSet(option) +         +        return list(hoster)
\ No newline at end of file diff --git a/module/plugins/hoster/MultishareCz.py b/module/plugins/hoster/MultishareCz.py index bf1d9f3bf..e2150a3aa 100644 --- a/module/plugins/hoster/MultishareCz.py +++ b/module/plugins/hoster/MultishareCz.py @@ -17,28 +17,72 @@  """  import re +from random import random  from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo  class MultishareCz(SimpleHoster):      __name__ = "MultishareCz"      __type__ = "hoster"      __pattern__ = r"http://(\w*\.)?multishare.cz/stahnout/.*" -    __version__ = "0.32" +    __version__ = "0.33"      __description__ = """MultiShare.cz"""      __author_name__ = ("zoidberg") -    FILE_ID_PATTERN = r'/stahnout/(\d+)/' -    FILE_INFO_PATTERN = ur'<ul class="no-padding"><li>Název: <strong>(?P<N>[^<]+)</strong></li><li>Velikost: <strong>(?P<S>[^&]+) (?P<U>[^<]+)</strong>' +    FILE_ID_PATTERN = r'/stahnout/(?P<ID>\d+)/' +    FILE_INFO_PATTERN = ur'(?:<li>Název|Soubor): <strong>(?P<N>[^<]+)</strong><(?:/li><li|br)>Velikost: <strong>(?P<S>[^<]+)</strong>'      FILE_OFFLINE_PATTERN = ur'<h1>Stáhnout soubor</h1><p><strong>Požadovaný soubor neexistuje.</strong></p>' +    FILE_SIZE_REPLACEMENTS = [(' ', '')] +     +    def process(self, pyfile): +        if re.match(self.__pattern__, pyfile.url):         +            self.html = self.load(pyfile.url, decode = True)        +            self.getFileInfo()         +            if self.premium: +                self.handlePremium() +            else: +                self.handleFree()          +        else:      +            self.handleOverriden()                 def handleFree(self): -        found = re.search(self.FILE_ID_PATTERN, pyfile.url) -        if found is None: -            self.fail("Parse error (ID)") -        file_id = found.group(1) -          self.download("http://www.multishare.cz/html/download_free.php", get={ -            "ID": file_id +            "ID": self.getFileID() +        }) +         +    def handlePremium(self): +        if not self.checkCredit(): +            self.logWarning("Not enough credit left to download file") +            self.resetAccount()  +                 +        self.download("http://www.multishare.cz/html/download_premium.php", get={ +            "ID": self.getFileID()          }) +     +    def handleOverriden(self): +        if not self.premium:  +            self.fail("Only premium users can download from other hosters") +         +        self.html = self.load('http://www.multishare.cz/html/mms_ajax.php', post = {"link": self.pyfile.url}, decode = True)         +        self.getFileInfo()        +         +        if not self.checkCredit(): +            self.fail("Not enough credit left to download file") +         +        url = "http://dl%d.mms.multishare.cz/html/mms_process.php" % round(random()*10000*random())     +        params = {"u_ID" : self.acc_info["u_ID"], "u_hash" : self.acc_info["u_hash"], "link" : self.pyfile.url} +        self.logDebug(url, params) +        self.download(url, get = params) +     +    def getFileID(self): +        found = re.search(self.FILE_ID_PATTERN, self.pyfile.url) +        if not found: self.fail("Parse error (ID)") +         +        return found.group('ID') +     +    def checkCredit(self):                    +        self.acc_info = self.account.getAccountInfo(self.user, True) +        self.logInfo("User %s has %i MB left" % (self.user, self.acc_info["trafficleft"]/1024)) +                 +        return self.pyfile.size / 1024 <= self.acc_info["trafficleft"]  getInfo = create_getInfo(MultishareCz)
\ No newline at end of file | 
