summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-11-25 19:18:50 +0100
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-11-25 19:18:50 +0100
commit6aefe12d783c19e9e983b599903738dbb3de9587 (patch)
tree91c38e3094172fa7e0d2ce4a6601cf690a355541
parentupdate zippyshare, uploadbox (diff)
downloadpyload-6aefe12d783c19e9e983b599903738dbb3de9587.tar.xz
add fshare.vn premium
-rw-r--r--module/plugins/accounts/FshareVn.py59
-rw-r--r--module/plugins/hoster/FshareVn.py49
2 files changed, 101 insertions, 7 deletions
diff --git a/module/plugins/accounts/FshareVn.py b/module/plugins/accounts/FshareVn.py
new file mode 100644
index 000000000..46d2d5166
--- /dev/null
+++ b/module/plugins/accounts/FshareVn.py
@@ -0,0 +1,59 @@
+# -*- 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
+
+class FshareVn(Account):
+ __name__ = "FshareVn"
+ __version__ = "0.01"
+ __type__ = "account"
+ __description__ = """fshare.vn account plugin"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ VALID_UNTIL_PATTERN = ur'<dt>Thời hạn dùng:</dt>\s*<dd>([^<]+)</dd>'
+ TRAFFIC_LEFT_PATTERN = ur'<dt>Bandwidth Còn Lại</dt>\s*<dd[^>]*>([0-9.]+) ([kKMG])B</dd>'
+ DIRECT_DOWNLOAD_PATTERN = ur'<input type="checkbox"\s*([^=>]*)[^>]*/>Kích hoạt download trực tiếp</dt>'
+
+ def loadAccountInfo(self, user, req):
+ #self.relogin(user)
+ html = req.load("http://www.fshare.vn/account_info.php", decode = True)
+
+ found = re.search(self.VALID_UNTIL_PATTERN, html)
+ validuntil = mktime(strptime(found.group(1), '%I:%M:%S %p %d-%m-%Y')) if found else 0
+
+ found = re.search(self.TRAFFIC_LEFT_PATTERN, html)
+ trafficleft = float(found.group(1)) * 1024 ** {'k': 0, 'K': 0, 'M': 1, 'G': 2}[found.group(2)] if found else 0
+
+ return {"validuntil": validuntil, "trafficleft": trafficleft}
+
+ def login(self, user, data, req):
+ req.http.c.setopt(REFERER, "http://www.fshare.vn/login.php")
+
+ html = req.load('http://www.fshare.vn/login.php', post = {
+ "login_password" : data['password'],
+ "login_useremail" : user,
+ "url_refe" : "http://www.fshare.vn/login.php"
+ }, referer = True, decode = True)
+
+ if not '<img alt="VIP"' in html:
+ self.wrongPassword() \ No newline at end of file
diff --git a/module/plugins/hoster/FshareVn.py b/module/plugins/hoster/FshareVn.py
index 13f15716f..91cc167b1 100644
--- a/module/plugins/hoster/FshareVn.py
+++ b/module/plugins/hoster/FshareVn.py
@@ -1,26 +1,51 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
+from module.network.RequestFactory import getURL
import re
+def getInfo(urls):
+ for url in urls:
+ html = getURL('http://www.fshare.vn/check_link.php', post = {
+ "action" : "check_link",
+ "arrlinks" : url
+ }, decode = True)
+
+ file_info = parseFileInfo(FshareVn, url, html)
+
+ yield file_info
+
class FshareVn(SimpleHoster):
__name__ = "FshareVn"
__type__ = "hoster"
__pattern__ = r"http://(www\.)?fshare.vn/file/.*"
- __version__ = "0.10"
+ __version__ = "0.11"
__description__ = """FshareVn Download Hoster"""
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
- FILE_INFO_PATTERN = ur'<p><b>Tên file:</b>\s*(?P<N>[^<]+)</p>\s*<p><b>Dung lượng file:</b>\s*(?P<S>[0-9,.]+)\s*(?P<U>[kKMG])i?B</p>'
- FILE_OFFLINE_PATTERN = r'<span class="error_number">511</span>'
+ FILE_INFO_PATTERN = r'<p>(?P<N>[^<]+)<\\/p>\\r\\n\s*<p>(?P<S>[0-9,.]+)\s*(?P<U>[kKMG])i?B<\\/p>'
+ FILE_OFFLINE_PATTERN = r'<div class=\\"f_left file_(enable|w)\\">'
DOWNLOAD_URL_PATTERN = r"<a class=\"bt_down\" id=\"down\".*window.location='([^']+)'\">"
FORM_PATTERN = r'<form action="" method="post" name="frm_download">(.*?)</form>'
FORM_INPUT_PATTERN = r'<input[^>]* name="?([^" ]+)"? value="?([^" ]+)"?[^>]*>'
+ VIP_URL_PATTERN = r'<form action="([^>]+)" method="get" name="frm_download">'
+
+ def process(self, pyfile):
+ self.html = self.load('http://www.fshare.vn/check_link.php', post = {
+ "action": "check_link",
+ "arrlinks": pyfile.url
+ }, decode = True)
+ self.getFileInfo()
+ if self.account:
+ self.handlePremium()
+ else:
+ self.handleFree()
def handleFree(self):
+ self.html = self.load(self.pyfile.url, decode = True)
found = re.search(self.FORM_PATTERN, self.html, re.DOTALL)
if not found: self.parseError('FORM')
form = found.group(1)
@@ -37,6 +62,16 @@ class FshareVn(SimpleHoster):
self.wait()
self.download(url)
-
-getInfo = create_getInfo(FshareVn)
- \ No newline at end of file
+
+ def handlePremium(self):
+ header = self.load(self.pyfile.url, just_header = True)
+ if 'location' in header and header['location'].startswith('http://download'):
+ self.logDebug('Direct download')
+ self.download(self.pyfile.url)
+ else:
+ self.html = self.load(self.pyfile.url)
+ found = re.search(self.VIP_URL_PATTERN, self.html)
+ if not found: self.parseError('VIP URL')
+ url = found.group(1)
+ self.logDebug('VIP URL: ' + url)
+ self.download(url) \ No newline at end of file