diff options
author | Stefano <l.stickell@yahoo.it> | 2013-06-20 16:47:24 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2013-06-20 16:47:24 +0200 |
commit | a672b812ba74aadceda950d36dcffcb27d2a8604 (patch) | |
tree | b57acdd5298a7c210a4bbed8bc2905078425ecab | |
parent | UnrestrictLi: get API data for size/checksum (diff) | |
download | pyload-a672b812ba74aadceda950d36dcffcb27d2a8604.tar.xz |
FilerNet: premium support
-rw-r--r-- | module/plugins/accounts/FilerNet.py | 63 | ||||
-rw-r--r-- | module/plugins/hoster/FilerNet.py | 30 |
2 files changed, 86 insertions, 7 deletions
diff --git a/module/plugins/accounts/FilerNet.py b/module/plugins/accounts/FilerNet.py new file mode 100644 index 000000000..7afd00f25 --- /dev/null +++ b/module/plugins/accounts/FilerNet.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- + +############################################################################ +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU Affero 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 Affero General Public License for more details. # +# # +# You should have received a copy of the GNU Affero General Public License # +# along with this program. If not, see <http://www.gnu.org/licenses/>. # +############################################################################ + +import re +import _strptime +import time + +from module.plugins.Account import Account +from module.utils import parseFileSize + + +class FilerNet(Account): + __name__ = "FilerNet" + __version__ = "0.01" + __type__ = "account" + __description__ = """Filer.net account plugin""" + __author_name__ = ("stickell") + __author_mail__ = ("l.stickell@yahoo.it") + + TOKEN_PATTERN = r'_csrf_token" value="([^"]+)" />' + WALID_UNTIL_PATTERN = r"Der Premium-Zugang ist gültig bis (.+)\.\s*</td>" + TRAFFIC_PATTERN = r'Traffic</th>\s*<td>([^<]+)</td>' + FREE_PATTERN = r'Account Status</th>\s*<td>\s*Free' + + def loadAccountInfo(self, user, req): + self.html = req.load("https://filer.net/profile") + + # Free user + if re.search(self.FREE_PATTERN, self.html): + return {"premium": False, "validuntil": None, "trafficleft": None} + + until = re.search(self.WALID_UNTIL_PATTERN, self.html) + traffic = re.search(self.TRAFFIC_PATTERN, self.html) + if until and traffic: + validuntil = int(time.mktime(time.strptime(until.group(1), "%d.%m.%Y %H:%M:%S"))) + trafficleft = parseFileSize(traffic.group(1)) / 1024 + return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft} + else: + self.logError('Unable to retrieve account information - Plugin may be out of date') + return {"premium": False, "validuntil": None, "trafficleft": None} + + def login(self, user, data, req): + self.html = req.load("https://filer.net/login") + token = re.search(self.TOKEN_PATTERN, self.html).group(1) + self.html = req.load("https://filer.net/login_check", + post={"_username": user, "_password": data["password"], + "_remember_me": "on", "_csrf_token": token, "_target_path": "https://filer.net/"}) + if 'Logout' not in self.html: + self.wrongPassword() diff --git a/module/plugins/hoster/FilerNet.py b/module/plugins/hoster/FilerNet.py index 9693723f9..815685ef8 100644 --- a/module/plugins/hoster/FilerNet.py +++ b/module/plugins/hoster/FilerNet.py @@ -30,7 +30,7 @@ class FilerNet(SimpleHoster): __name__ = "FilerNet" __type__ = "hoster" __pattern__ = r"https?://(www\.)?filer\.net/get/(\w+)" - __version__ = "0.01" + __version__ = "0.02" __description__ = """Filer.net Download Hoster""" __author_name__ = ("stickell") __author_mail__ = ("l.stickell@yahoo.it") @@ -38,10 +38,17 @@ class FilerNet(SimpleHoster): FILE_INFO_PATTERN = r'<h1 class="page-header">Free Download (?P<N>\S+) <small>(?P<S>[\w.]+) (?P<U>\w+)</small></h1>' FILE_OFFLINE_PATTERN = r'Nicht gefunden' RECAPTCHA_KEY = '6LcFctISAAAAAAgaeHgyqhNecGJJRnxV1m_vAz3V' + DIRECT_LINK_PATTERN = r'href="([^"]+)">Get download</a>' def process(self, pyfile): + if self.premium and (not self.SH_CHECK_TRAFFIC or self.checkTrafficLeft()): + self.handlePremium() + else: + self.handleFree() + + def handleFree(self): self.req.setOption("timeout", 120) - self.html = self.load(pyfile.url, decode=not self.SH_BROKEN_ENCODING, cookies=self.SH_COOKIES) + self.html = self.load(self.pyfile.url, decode=not self.SH_BROKEN_ENCODING, cookies=self.SH_COOKIES) # Wait between downloads m = re.search(r'musst du <span id="time">(\d+)</span> Sekunden warten', self.html) @@ -50,12 +57,7 @@ class FilerNet(SimpleHoster): self.retry(3, waittime, 'Wait between free downloads') self.getFileInfo() - if self.premium and (not self.SH_CHECK_TRAFFIC or self.checkTrafficLeft()): - self.handlePremium() - else: - self.handleFree() - def handleFree(self): self.html = self.load(self.pyfile.url, decode=True) inputs = self.parseHtmlForm(input_names='token')[1] @@ -99,5 +101,19 @@ class FilerNet(SimpleHoster): self.download(downloadURL, disposition=True) + def handlePremium(self): + header = self.load(self.pyfile.url, just_header=True) + if 'location' in header: # Direct Download ON + dl = self.pyfile.url + else: # Direct Download OFF + html = self.load(self.pyfile.url) + m = re.search(self.DIRECT_LINK_PATTERN, html) + if not m: + self.parseError("Unable to detect direct link, try to enable 'Direct download' in your user settings") + dl = 'http://filer.net' + m.group(1) + + self.logDebug('Direct link: ' + dl) + self.download(dl, disposition=True) + getInfo = create_getInfo(FilerNet) |