diff options
| author | 2011-09-20 17:10:52 +0200 | |
|---|---|---|
| committer | 2011-09-20 17:10:52 +0200 | |
| commit | 924b9e2e7e0d651662b4bd00936b7f4675e7947f (patch) | |
| tree | 8b723b917a95fbb0ab26253e32cdd963cc7f5c44 /module/plugins | |
| parent | general JSON API, url parser (diff) | |
| download | pyload-924b9e2e7e0d651662b4bd00936b7f4675e7947f.tar.xz | |
New plugins: HellspyCz, LetitbitNet, FreevideoCz, StreamCz, UlozToFolder
Diffstat (limited to 'module/plugins')
| -rw-r--r-- | module/plugins/accounts/HellspyCz.py | 82 | ||||
| -rw-r--r-- | module/plugins/crypter/MultiloadCz.py | 29 | ||||
| -rw-r--r-- | module/plugins/crypter/UlozToFolder.py | 40 | ||||
| -rw-r--r-- | module/plugins/hoster/BezvadataCz.py | 18 | ||||
| -rw-r--r-- | module/plugins/hoster/CzshareCom.py | 122 | ||||
| -rw-r--r-- | module/plugins/hoster/FreevideoCz.py | 64 | ||||
| -rw-r--r-- | module/plugins/hoster/HellspyCz.py | 134 | ||||
| -rw-r--r-- | module/plugins/hoster/LetitbitNet.py | 98 | ||||
| -rw-r--r-- | module/plugins/hoster/StreamCz.py | 76 | 
9 files changed, 557 insertions, 106 deletions
| diff --git a/module/plugins/accounts/HellspyCz.py b/module/plugins/accounts/HellspyCz.py new file mode 100644 index 000000000..10c7e3882 --- /dev/null +++ b/module/plugins/accounts/HellspyCz.py @@ -0,0 +1,82 @@ +# -*- 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 +import string + +class HellspyCz(Account): +    __name__ = "HellspyCz" +    __version__ = "0.2" +    __type__ = "account" +    __description__ = """hellspy.cz account plugin""" +    __author_name__ = ("zoidberg") +    __author_mail__ = ("zoidberg@mujmail.cz") +     +    ACTION_PATTERN = r'<div id="snippet--loginBoxSn"><form[^>]*action="([^"]+user_hash=([^"]+))">' +    CREDIT_LEFT_PATTERN = r'<strong class="text-credits">(\d+)</strong>' +    WRONG_PASSWORD_PATTERN = r'<p class="block-error-3 marg-tb-050">\s*Wrong user or password was entered<br />' + +    phpsessid = ''  + +    def loadAccountInfo(self, user, req): +        cj = self.getAccountCookies(user) +        cj.setCookie(".hellspy.com", "PHPSESSID", self.phpsessid)        +     +        html = req.load("http://www.hellspy.com/") +         +        found = re.search(self.CREDIT_LEFT_PATTERN, html) +        if found is None: +            credits = 0 +        else: +            credits = int(found.group(1)) * 1024 +         +        return {"validuntil": -1, "trafficleft": credits} +     +    def login(self, user, data,req):         +        html = req.load('http://www.hellspy.com/') +        found = re.search(self.ACTION_PATTERN, html) +        if found is None: +           self.logError('Parse error (FORM)')  +        action, self.phpsessid = found.group(1).replace('&','&'), found.group(2) +         +        self.logDebug("PHPSESSID:" + self.phpsessid) +        html = req.load("http://www.hellspy.com/--%s-" % self.phpsessid) +         +        html = req.load(action, post={ +                "login": "1", +                "password": data["password"], +                "username": user, +                "redir_url":	'http://www.hellspy.com/?do=loginBox-login', +                "permanent_login": "1" +                })                      +         +        cj = self.getAccountCookies(user) +        cj.setCookie(".hellspy.com", "PHPSESSID", self.phpsessid) +                         +        self.logDebug(req.lastURL) +        self.logDebug(req.lastEffectiveURL) +         +        html = req.load("http://www.hellspy.com/", get = {"do":"loginBox-login"}) +                 +        if not re.search(self.CREDIT_LEFT_PATTERN, html): +            self.wrongPassword() + + +            
\ No newline at end of file diff --git a/module/plugins/crypter/MultiloadCz.py b/module/plugins/crypter/MultiloadCz.py index f34bb3483..e8dff403e 100644 --- a/module/plugins/crypter/MultiloadCz.py +++ b/module/plugins/crypter/MultiloadCz.py @@ -7,14 +7,15 @@ class MultiloadCz(Crypter):      __name__ = "MultiloadCz"      __type__ = "crypter"      __pattern__ = r"http://.*multiload.cz/(stahnout|slozka)/.*" -    __version__ = "0.2b" +    __version__ = "0.3"      __description__ = """multiload.cz""" -    __config__ = [ -        ("usedHoster", "str", "Prefered hoster list (bar-separated) ", "rapidshare.com|uloz.to|quickshare.cz")] +    __config__ = [("usedHoster", "str", "Prefered hoster list (bar-separated) ", ""), +        ("ignoredHoster", "str", "Ignored hoster list (bar-separated) ", "")]      __author_name__ = ("zoidberg") +    __author_mail__ = ("zoidberg@mujmail.cz") -    # LINK_PATTERN = r'<p class="manager-server"><strong>[^<]*</strong></p><p class="manager-linky"><a href="([^"]+)">'      FOLDER_PATTERN = r'<form action="" method="get"><textarea[^>]*>([^>]*)</textarea></form>' +    LINK_PATTERN = r'<p class="manager-server"><strong>([^<]+)</strong></p><p class="manager-linky"><a href="([^"]+)">'      def decrypt(self, pyfile):          self.html = self.load(self.pyfile.url, decode=True) @@ -25,17 +26,19 @@ class MultiloadCz(Crypter):              if found is not None:                  new_links.extend(found.group(1).split())          else: -            link_pattern = re.compile(r'<p class="manager-server"><strong>(' -                                      + self.getConfig("usedHoster") -            + r')</strong></p><p class="manager-linky"><a href="([^"]+)">') +            found = re.findall(self.LINK_PATTERN, self.html) +            if found: +                prefered_set = set(self.getConfig("usedHoster").split('|')) +                def fp(x): return x[0] in prefered_set +                def m(x): return x[1] +                new_links.extend(map(m,filter(fp, found))) -            for found in re.finditer(link_pattern, self.html): -                self.logDebug("ML URL:" + found.group(2)) -                new_links.append(found.group(2)) +                if not new_links: +                    ignored_set = set(self.getConfig("ignoredHoster").split('|')) +                    def fi(x): return x[0] not in ignored_set +                    new_links.extend(map(m,filter(fi, found)))          if new_links:              self.core.files.addLinks(new_links, self.pyfile.package().id) -            #self.packages.append((self.pyfile.package().name, new_links, self.pyfile.package().name))          else: -            self.fail('Could not extract any links') -            
\ No newline at end of file +            self.fail('Could not extract any links')
\ No newline at end of file diff --git a/module/plugins/crypter/UlozToFolder.py b/module/plugins/crypter/UlozToFolder.py new file mode 100644 index 000000000..c6672ea8c --- /dev/null +++ b/module/plugins/crypter/UlozToFolder.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +import re +from module.plugins.Crypter import Crypter + +class UlozToFolder(Crypter): +    __name__ = "UlozToFolder" +    __type__ = "crypter" +    __pattern__ = r"http://.*(uloz\.to|ulozto\.(cz|sk|net)|bagruj.cz|zachowajto.pl)/(m|soubory)/.*" +    __version__ = "0.1a" +    __description__ = """Uloz.to Folder Plugin""" +    __author_name__ = ("zoidberg") +    __author_mail__ = ("zoidberg@mujmail.cz") + +    FOLDER_PATTERN = r'<ul class="profile_files">(.*?)</ul>' +    LINK_PATTERN = r'<br /><a href="/([^"]+)">[^<]+</a>' +    NEXT_PAGE_PATTERN = r'<a class="next " href="/([^"]+)"> </a>' + +    def decrypt(self, pyfile): +        html = self.load(self.pyfile.url) + +        new_links = [] +        for i in range(1,100): +            self.logInfo("Fetching links from page %i" % i) +            found = re.search(self.FOLDER_PATTERN, html, re.DOTALL) +            if found is None: self.fail("Parse error (FOLDER)") + +            new_links.extend(re.findall(self.LINK_PATTERN, found.group(1))) +            found = re.search(self.NEXT_PAGE_PATTERN, html) +            if found: +                html = self.load("http://ulozto.net/" + found.group(1)) +            else: +                break +        else: +            self.logInfo("Limit of 99 pages reached, aborting") + +        if new_links: +            self.core.files.addLinks(map(lambda s:"http://ulozto.net/%s" % s, new_links), self.pyfile.package().id) +        else: +            self.fail('Could not extract any links')
\ No newline at end of file diff --git a/module/plugins/hoster/BezvadataCz.py b/module/plugins/hoster/BezvadataCz.py index f9784142f..71622885a 100644 --- a/module/plugins/hoster/BezvadataCz.py +++ b/module/plugins/hoster/BezvadataCz.py @@ -22,21 +22,22 @@ from module.plugins.Hoster import Hoster  class BezvadataCz(Hoster):      __name__ = "BezvadataCz"      __type__ = "hoster" -    __pattern__ = r"http://(\w*\.)?bezvadata.cz/stahnout/.*" -    __version__ = "0.1" +    __pattern__ = r"http://(\w*\.)*bezvadata.cz/stahnout/.*" +    __version__ = "0.2"      __description__ = """BezvaData.cz"""      __author_name__ = ("zoidberg") +    __author_mail__ = ("zoidberg@mujmail.cz")      ID_PATTERN = r'<input type="hidden" name="souborId" value="([^"]+)">'      HASH_PATTERN = r'<input type="hidden" name="souborHash" value="([^"]+)">' -    FILENAME_PATTERN = r'<title>BezvaData \| St�hnout soubor ([^<]+)</title>' +    FILENAME_PATTERN = r'<title>BezvaData \| Stáhnout soubor ([^<]+)</title>'      OFFLINE_PATTERN = r'<title>BezvaData \| Soubor nenalezen</title>'      def setup(self):          self.multiDL = False      def process(self, pyfile): -        self.html = self.load(pyfile.url, decode=True) +        self.html = self.load(pyfile.url, decode = True)          if re.search(self.OFFLINE_PATTERN, self.html) is not None:              self.offline() @@ -51,16 +52,15 @@ class BezvadataCz(Hoster):              self.fail("Parse error (ID)")          souborId = found.group(1) -        found = re.search(self.ID_PATTERN, self.html) +        found = re.search(self.HASH_PATTERN, self.html)          if found is None:              self.fail("Parse error (HASH)")          souborHash = found.group(1) -        self.logDebug("URL:" + pyfile.url + " ID:" + souborId + " HASH:" + souborHash) +        self.logDebug("URL:"+pyfile.url+" ID:"+souborId+" HASH:"+souborHash) -        self.download(pyfile.url, post={ +        self.download(pyfile.url, post = {              "souborId": souborId,              "souborHash": souborHash,              "_send": 'STAHNOUT SOUBOR' -        }) -        
\ No newline at end of file +        })
\ No newline at end of file diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index 8cab02317..74c582dae 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -24,6 +24,7 @@ def getInfo(urls):      result = []      for url in urls: +          html = getURL(url, decode=True)          if re.search(CzshareCom.FILE_OFFLINE_PATTERN, html):              # File offline @@ -33,36 +34,40 @@ def getInfo(urls):              found = re.search(CzshareCom.FILE_NAME_PATTERN, html)              if found is not None:                  name = found.group(1) -                result.append((name, 0, 2, url)) +                 +                found = re.search(CzshareCom.FILE_SIZE_PATTERN, html) +                if found is not None: +                    size = float(found.group(1).replace(',','.')) +                    units = found.group(2) +                    pow = {'KiB': 1, 'MiB': 2, 'GiB': 3}[units] +                    size = int(size * 1024 ** pow) +                    result.append((name, size, 2, url)) +                else: +                    result.append((name, 0, 2, url))      yield result -  class CzshareCom(Hoster):      __name__ = "CzshareCom"      __type__ = "hoster" -    __pattern__ = r"http://.*czshare\.(com|cz)/.*" -    __version__ = "0.6" +    __pattern__ = r"http://(\w*\.)*czshare\.(com|cz)/.*" +    __version__ = "0.7"      __description__ = """CZshare.com"""      __author_name__ = ("zoidberg") +    __author_mail__ = ("zoidberg@mujmail.cz") -    #FILE_URL_PATTERN = r'<a href="http://czshare.com/([^/]+)/([^/]+)/[^"]*">([^<]+)</a>'      FILE_URL_PATTERN = r'<a href="([^"]+)" class="page-download">[^>]*alt="([^"]+)" /></a>' -    FORM_PATTERN = r'<form action="download.php" method="post">' -    ID_PATTERN = r'<input type="hidden" name="id" value="([^"]+)" />' -    FILE_PATTERN = r'<input type="hidden" name="file" value="([^"]+)" />' -    #TICKET_PATTERN = r'<input type="hidden" name="ticket" value="([^"]+)" />'  -    SUBMIT_PATTERN = r'<input type="submit" name="freedown" value="([^"]+)" class="button" />' -    SIZE_PATTERN = r'<input type="hidden" name="size" value="([^"]+)" />' -    SERVER_PATTERN = r'<input type="hidden" name="server" value="([^"]+)" />' -    FILE_OFFLINE_PATTERN = r'<h2 class="red">Soubor nenalezen<span> </span></h2>' +    FORM_PATTERN = r'<form action="download.php" method="post">\s*<img src="captcha.php" id="captcha" />(.*?)</form>' +    FORM_INPUT_PATTERN = r'<input[^>]* name="([^"]+)" value="([^"]+)"[^>]*/>' +    FILE_OFFLINE_PATTERN = r'<h2 class="red">[^<]*[Ss]oubor (nenalezen|expiroval|je po.kozen)[^<]*<span> </span></h2>'      MULTIDL_PATTERN = r"<p><font color='red'>Z[^<]*PROFI.</font></p>"      FILE_NAME_PATTERN = r'<h1>([^<]+)<span> </span></h1>' +    FILE_SIZE_PATTERN = r'<div class="tab" id="category">\s*Velikost:\s*([0-9.,]+)(KiB|MiB|GiB)\s*</div>'      def setup(self):          self.multiDL = False      def process(self, pyfile): -        self.html = self.load(pyfile.url, decode=True) +        self.html = self.load(pyfile.url, cookies=True, decode=True)          #marks the file as "offline" when the pattern was found on the html-page          if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None: @@ -71,93 +76,42 @@ class CzshareCom(Hoster):          # parse the name from the site and set attribute in pyfile          found = re.search(self.FILE_URL_PATTERN, self.html)          if found is None: -            self.fail("Parse error (URL)") +           self.fail("Parse error (URL)")          pyfile.name = found.group(2)          parsed_url = "http://czshare.com" + found.group(1) -        # get download ticket and parse html       +        # get download ticket and parse html          self.logDebug("PARSED_URL:" + parsed_url)          self.logDebug("NAME:" + pyfile.name) -        self.html = self.load(parsed_url) +        self.html = self.load(parsed_url, cookies=True)          #if not re.search(self.FORM_PATTERN, self.html):          if re.search(self.MULTIDL_PATTERN, self.html): -            self.waitForFreeSlot() - -        parse_err = False - -        found = re.search(self.SERVER_PATTERN, self.html) -        if found is None: -            parse_err = True -            server = "" -        else: -            server = found.group(1) - -        found = re.search(self.ID_PATTERN, self.html) -        if found is None: -            parse_err = True -            file_id = "" -        else: -            file_id = found.group(1) - -        found = re.search(self.FILE_PATTERN, self.html) -        if found is None: -            parse_err = True -            long_id = "" -        else: -            long_id = found.group(1) - -        found = re.search(self.SIZE_PATTERN, self.html) -        if found is None: -            parse_err = True -            size = "" -        else: -            size = found.group(1) - -        self.logDebug("ID:" + file_id + " F:" + long_id + " B:" + size + " S:" + server) - -        if parse_err: -            self.fail("Parse error") - -        found = re.search(self.SUBMIT_PATTERN, self.html) -        if found is None: -            self.fail("Parse error (SUBMIT)") -        else: -            submit = found.group(1) - -            # get and decrypt captcha +           self.waitForFreeSlot() + +        try: +            form = re.search(self.FORM_PATTERN, self.html, re.DOTALL).group(1) +            inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) +            pyfile.size = float(inputs['size'])/1024 +        except Exception, e: +            self.logError(e) +            self.fail("Parse error (FORM)") +         +        # get and decrypt captcha          captcha_url = 'http://czshare.com/captcha.php' -        """ -        if self.getConfig("randomCaptcha") == True: -           captcha = ''.join(random.choice('abcdefghijklmnopqrstuvwxyz') for i in range(5)) -        else: -        """ -        captcha = self.decryptCaptcha(captcha_url) -        self.logDebug('CAPTCHA_URL:' + captcha_url + ' CAPTCHA:' + captcha) - -        """ -        self.setWait(self.getConfig("multiWait"), True) -        self.wait()  -        """ +        inputs['captchastring2'] = self.decryptCaptcha(captcha_url) +        self.logDebug('CAPTCHA_URL:' + captcha_url + ' CAPTCHA:' + inputs['captchastring2'])          # download the file, destination is determined by pyLoad -        #download_url = 'http://czshare.com/free.php' -        self.download(parsed_url, post={ -            "id": file_id, -            "file": long_id, -            "size": size, -            "server": server, -            "captchastring2": captcha, -            "freedown": submit -        }) +        self.download(parsed_url, cookies=True, post=inputs)          # check download          check = self.checkDownload({              "tempoffline": re.compile(r"^Soubor je do.asn. nedostupn.$"),              "multi_dl": re.compile(self.MULTIDL_PATTERN), -            "captcha_err": re.compile(self.SUBMIT_PATTERN) -        }) +            "captcha_err": re.compile(self.FORM_PATTERN) +            })          if check == "tempoffline":              self.fail("File not available - try later") diff --git a/module/plugins/hoster/FreevideoCz.py b/module/plugins/hoster/FreevideoCz.py new file mode 100644 index 000000000..20ff674aa --- /dev/null +++ b/module/plugins/hoster/FreevideoCz.py @@ -0,0 +1,64 @@ +# -*- 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.Hoster import Hoster +from module.network.RequestFactory import getURL + +def getInfo(urls): +    result = [] + +    for url in urls: + +        html = getURL(url) +        if re.search(FreevideoCz.FILE_OFFLINE_PATTERN, html): +            # File offline +            result.append((url, 0, 1, url)) +        else: +            result.append((url, 0, 2, url)) +    yield result + +class FreevideoCz(Hoster): +    __name__ = "FreevideoCz" +    __type__ = "hoster" +    __pattern__ = r"http://www.freevideo.cz/vase-videa/(.*)\.html" +    __version__ = "0.1" +    __description__ = """freevideo.cz""" +    __author_name__ = ("zoidberg") + +    URL_PATTERN = r'clip: {\s*url: "([^"]+)"' +    FILE_OFFLINE_PATTERN = r'<h2 class="red-corner-full">Stránka nebyla nalezena</h2>' + +    def setup(self): +        self.multiDL = True +        self.resumeDownload = True + +    def process(self, pyfile): + +        self.html = self.load(pyfile.url, decode=True) + +        if re.search(self.FILE_OFFLINE_PATTERN, self.html): +           self.offline() + +        found = re.search(self.URL_PATTERN, self.html) +        if found is None: self.fail("Parse error (URL)") +        download_url = found.group(1) + +        pyfile.name = re.search(self.__pattern__, pyfile.url).group(1) + ".mp4" + +        self.download(download_url)
\ No newline at end of file diff --git a/module/plugins/hoster/HellspyCz.py b/module/plugins/hoster/HellspyCz.py new file mode 100644 index 000000000..fb7fa41dc --- /dev/null +++ b/module/plugins/hoster/HellspyCz.py @@ -0,0 +1,134 @@ +# -*- 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.Hoster import Hoster +from module.network.RequestFactory import getURL + +def getInfo(urls): +    result = [] + +    for url in urls: + +        html = getURL(url, decode=True) +        if re.search(HellspyCz.FILE_OFFLINE_PATTERN, html): +            # File offline +            result.append((url, 0, 1, url)) +        else: +            # Get file info +            found = re.search(HellspyCz.FILE_NAME_PATTERN, html) +            if found is not None: +                name = found.group(1) +                found = re.search(HellspyCz.FILE_CREDITS_PATTERN, html) +                if found is not None: +                    size = float(found.group(1)) +                    units = found.group(2) + +                    pow = {'kB' : 1, 'MB' : 2, 'GB' : 3}[units] +                    size = int(size*1024**pow) + +                    result.append((name, size, 2, url)) +    yield result + +class HellspyCz(Hoster): +    __name__ = "HellspyCz" +    __type__ = "hoster" +    __pattern__ = r"http://(?:\w*\.)*hellspy\.(?:cz|com|sk|hu)(/\S+/\d+)/?.*" +    __version__ = "0.2" +    __description__ = """HellSpy.cz""" +    __author_name__ = ("zoidberg") +    __author_mail__ = ("zoidberg@mujmail.cz") + +    FILE_NAME_PATTERN = r'<h1 class="text-yellow-1 " "><span ><span class="text" title="">([^<]+)</span></span></h1>' +    FILE_OFFLINE_PATTERN = r'<h2>(404 - Page|File) not found</h2>' +    FILE_CREDITS_PATTERN = r'<span class="text-credit-taken-1">\s*<span class="text-size"><span class="hidden">Size: </span>(\S+) (kB|MB|GB)</span>\s*<span >\((\d+) credits\)</span>' +    CREDIT_LEFT_PATTERN = r'<strong class="text-credits">(\d+)</strong>' + +    PREMIUM_URL_PATTERN = r"launchFullDownload\('(http://[^']+)',\s*\d*\);" +    DOWNLOAD_AGAIN_PATTERN = r'<a id="button-download-start"[^>]*title="You can download the file without deducting your credit.">' + +    def setup(self): +        self.resumeDownload = self.multiDL = True if self.account else False +        self.chunkLimit = 1 + +    def process(self, pyfile): +        if not self.premium: self.fail("Only premium users can download from HellSpy.cz") +        if not self.account: self.fail("Not logged in") + +        # set PHPSESSID cookie +        cj = self.account.getAccountCookies(self.user) +        cj.setCookie(".hellspy.com", "PHPSESSID", self.account.phpsessid) +        self.logDebug("PHPSESSID: " + cj.getCookie("PHPSESSID")) + +        info = self.account.getAccountInfo(self.user) +        self.logInfo("User %s has %i credits left" % (self.user, info["trafficleft"]/1024)) + +        # load html +        rel_url = re.search(self.__pattern__, pyfile.url).group(1) +        self.html = self.load("http://www.hellspy.com/--%s-/%s" % (self.account.phpsessid, rel_url), decode = True) + +        # get premium download URL +        download_url = self.getPremiumURL() +        if download_url is None: +            self.checkFile(pyfile) +            self.html = self.load("http://www.hellspy.com/%s?download=1" % rel_url) +            download_url = self.getPremiumURL() + +        # download +        if download_url is None: self.fail("Parse error (DOWNLOAD URL)") +        self.logDebug("Download URL: " + download_url) +        self.download(download_url, disposition = True) + +        info = self.account.getAccountInfo(self.user) +        self.logInfo("User %s has %i credits left" % (self.user, info["trafficleft"]/1024)) + +    def checkFile(self, pyfile): +        # marks the file as "offline" when the pattern was found on the html-page +        if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None: +            self.offline() + +        # parse the name from the site and set attribute in pyfile +        found = re.search(self.FILE_NAME_PATTERN, self.html) +        if found is None: +           self.fail("Parse error (FILENAME)") +        pyfile.name = found.group(1) + +        # parse credits left info +        found = re.search(self.CREDIT_LEFT_PATTERN, self.html) +        if found is None: +            self.logInfo("Not logged in... relogin and retry") +            self.account.relogin(self.user) +            self.retry(max_tries = 2, reason = "Not logged in") +        credits_left = int(found.group(1)) +        self.logInfo("User %s has %i credits left" % (self.user, credits_left)) + +        # parse credit needed to proceed +        found = re.search(self.DOWNLOAD_AGAIN_PATTERN, self.html) +        if found: +            self.logInfo("Free download (file downloaded before)") +        else: +            found = re.search(self.FILE_CREDITS_PATTERN, self.html) +            if found is None: self.fail("Parse error (FILE CREDITS)") +            file_credits = int(found.group(3)) +            if file_credits > credits_left: self.fail("Not enough credits left to download file") +            self.logInfo("Premium download for %i credits" % file_credits) + + +    def getPremiumURL(self): +        found = re.search(self.PREMIUM_URL_PATTERN, self.html) +        return found.group(1) if found else None
\ No newline at end of file diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py new file mode 100644 index 000000000..dd65d7e7a --- /dev/null +++ b/module/plugins/hoster/LetitbitNet.py @@ -0,0 +1,98 @@ +# -*- 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.Hoster import Hoster +from module.network.RequestFactory import getURL + +def getInfo(urls): +    result = [] + +    for url in urls: + +        html = getURL(url, decode=True) +        if re.search(LetitbitNet.FILE_OFFLINE_PATTERN, html): +            # File offline +            result.append((url, 0, 1, url)) +        else: +            # Get file info +            found = re.search(r'<input[^>]* name="name" value="([^"]+)" />', html) +            if found is not None: +                name = found.group(1) +                found = re.search(r'<input[^>]* name="sssize" value="([^"]+)" />', html) +                if found is not None: +                    size = float(found.group(1))/1024 +                    result.append((name, size, 2, url)) +    yield result + + +class LetitbitNet(Hoster): +    __name__ = "LetitbitNet" +    __type__ = "hoster" +    __pattern__ = r"http://(?:\w*\.)*letitbit.net/download/.*" +    __version__ = "0.1" +    __description__ = """letitbit.net""" +    __author_name__ = ("zoidberg") +    __author_mail__ = ("zoidberg@mujmail.cz") + +    IFREE_FORM_PATTERN = r'<form id="ifree_form" action="([^"]+)" method="post">(.*?)</form>' +    DVIFREE_FORM_PATTERN = r'<form action="([^"]+)" method="post" id="dvifree">(.*?)</form>' +    FORM_INPUT_PATTERN = r'<input[^>]* name="([^"]+)" value="([^"]+)" />' +    JS_SCRIPT_PATTERN = r'<title>[^<]*</title>\s*<script language="JavaScript">(.*?)</script>' +    JS_VARS_PATTERN = r"(\S+) = '?([^';]+)'?;" + +    FILE_OFFLINE_PATTERN = r'<div id="download_content" class="hide-block">[^<]*<br>File not found<br /></div>' + +    def setup(self): +        self.resumeDownload = self.multiDL = True if self.account else False +        self.chunkLimit = 1 + +    def process(self, pyfile): +        self.html = self.load(pyfile.url, decode=True) +        if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline() + +        try: +            action, form = re.search(self.IFREE_FORM_PATTERN, self.html, re.DOTALL).groups() +            inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) +            pyfile.name = inputs['name'] +            pyfile.size = float(inputs['sssize'])/1024 +        except Exception, e: +            self.logError(e) +            self.fail("Parse error on page 1") + +        self.html = self.load("http://letitbit.net"+action, post = inputs) +        try: +            action, form = re.search(self.DVIFREE_FORM_PATTERN, self.html, re.DOTALL).groups() +            inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) +        except Exception, e: +            self.logError(e) +            self.fail("Parse error on page 2") + +        self.html = self.load(action, post = inputs) +        try: +            form = re.search(self.JS_SCRIPT_PATTERN, self.html, re.DOTALL).group(1) +            js_vars = dict(re.findall(self.JS_VARS_PATTERN, form)) +            ajax_check_url = js_vars['ajax_check_url'] +            self.setWait(int(js_vars['seconds'])+1) +            self.wait() +        except Exception, e: +            self.logError(e) +            self.fail("Parse error on page 3") + +        download_url = self.load(ajax_check_url, post = inputs) +        self.download(download_url)
\ No newline at end of file diff --git a/module/plugins/hoster/StreamCz.py b/module/plugins/hoster/StreamCz.py new file mode 100644 index 000000000..57c00b8ba --- /dev/null +++ b/module/plugins/hoster/StreamCz.py @@ -0,0 +1,76 @@ +# -*- 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.Hoster import Hoster +from module.network.RequestFactory import getURL + +def getInfo(urls): +    result = [] +     +    for url in urls: +         +        html = getURL(url) +        if re.search(StreamCz.FILE_OFFLINE_PATTERN, html): +            # File offline +            result.append((url, 0, 1, url)) +        else: +            result.append((url, 0, 2, url))         +    yield result +     +class StreamCz(Hoster): +    __name__ = "StreamCz" +    __type__ = "hoster" +    __pattern__ = r"http://www.stream.cz/[^/]+/\d+.*" +    __version__ = "0.1" +    __description__ = """stream.cz""" +    __author_name__ = ("zoidberg") +    +    FILE_OFFLINE_PATTERN = r'<h1 class="commonTitle">Stránku nebylo možné nalézt \(404\)</h1>' +    FILE_NAME_PATTERN = r'<link rel="video_src" href="http://www.stream.cz/\w+/(\d+)-([^"]+)" />' +    CDN_PATTERN = r'<param name="flashvars" value="[^"]*&id=(?P<ID>\d+)(?:&cdnLQ=(?P<cdnLQ>\d*))?(?:&cdnHQ=(?P<cdnHQ>\d*))?(?:&cdnHD=(?P<cdnHD>\d*))?&' + +    def setup(self): +        self.multiDL = True +        self.resumeDownload = True + +    def process(self, pyfile):      +         +        self.html = self.load(pyfile.url, decode=True) +         +        if re.search(self.FILE_OFFLINE_PATTERN, self.html):  +            self.offline() +         +        found = re.search(self.CDN_PATTERN, self.html) +        if found is None: self.fail("Parse error (CDN)") +        cdn = found.groupdict() +        self.logDebug(cdn) +        for cdnkey in ("cdnHD", "cdnHQ", "cdnLQ"): +            if cdn.has_key(cdnkey) and cdn[cdnkey] > '':  +                cdnid = cdn[cdnkey] +                break +        else:        +            self.fail("Stream URL not found") +             +        found = re.search(self.FILE_NAME_PATTERN, self.html) +        if found is None: self.fail("Parse error (NAME)") +        pyfile.name = "%s-%s.%s.mp4" % (found.group(2), found.group(1), cdnkey[-2:]) +              +        download_url = "http://cdn-dispatcher.stream.cz/?id=" + cdnid +        self.logInfo("STREAM (%s): %s" % (cdnkey[-2:], download_url)) +        self.download(download_url)          | 
