summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-09-23 12:25:18 +0200
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-09-23 12:25:18 +0200
commit2839c54c090f2601fcecd0f7fdaeacc40c7716f5 (patch)
treebc6f0524b004425d9bed301e4d34792df9054495 /module/plugins
parentfixed json import (diff)
downloadpyload-2839c54c090f2601fcecd0f7fdaeacc40c7716f5.tar.xz
plugins: czshare premium, czshare/quickshare/filefactory folders
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/accounts/CzshareCom.py58
-rw-r--r--module/plugins/crypter/CzshareComFolder.py30
-rw-r--r--module/plugins/crypter/FilefactoryComFolder.py44
-rw-r--r--module/plugins/crypter/MultiloadCz.py9
-rw-r--r--module/plugins/crypter/QuickshareCzFolder.py30
-rw-r--r--module/plugins/hoster/CzshareCom.py144
6 files changed, 276 insertions, 39 deletions
diff --git a/module/plugins/accounts/CzshareCom.py b/module/plugins/accounts/CzshareCom.py
new file mode 100644
index 000000000..695e21b18
--- /dev/null
+++ b/module/plugins/accounts/CzshareCom.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 string import replace
+import re
+
+class CzshareCom(Account):
+ __name__ = "CzshareCom"
+ __version__ = "0.1"
+ __type__ = "account"
+ __description__ = """czshare.com account plugin"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ CREDIT_LEFT_PATTERN = r'<tr class="active">\s*<td>([0-9 ,]+) (KiB|MiB|GiB)</td>\s*<td>([^<]*)</td>\s*</tr>'
+
+ def loadAccountInfo(self, user, req):
+ self.relogin(user)
+ html = req.load("http://czshare.com/prehled_kreditu/")
+
+ found = re.search(self.CREDIT_LEFT_PATTERN, html)
+ if found is None:
+ credits, validuntil = 0, 0
+ else:
+ credits = float(found.group(1).replace(' ', '').replace(',','.'))
+ credits = credits * 1024**{'KiB' : 0, 'MiB' : 1, 'GiB' : 2}[found.group(2)]
+ validuntil = mktime(strptime(found.group(3), '%d.%m.%y %H:%M'))
+
+ return {"validuntil": validuntil, "trafficleft": credits}
+
+ def login(self, user, data, req):
+
+ html = req.load('http://czshare.com/index.php', post={
+ "Prihlasit": "Prihlasit",
+ "login-password": data["password"],
+ "login-name": user
+ })
+
+ if "<p>You input a wrong user name or wrong password</p>" in html:
+ self.wrongPassword()
diff --git a/module/plugins/crypter/CzshareComFolder.py b/module/plugins/crypter/CzshareComFolder.py
new file mode 100644
index 000000000..c240c6a70
--- /dev/null
+++ b/module/plugins/crypter/CzshareComFolder.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+
+import re
+from module.plugins.Crypter import Crypter
+
+class CzshareComFolder(Crypter):
+ __name__ = "CzshareComFolder"
+ __type__ = "crypter"
+ __pattern__ = r"http://(\w*\.)*czshare\.(com|cz)/folders/.*"
+ __version__ = "0.1"
+ __description__ = """Czshare.com Folder Plugin"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ FOLDER_PATTERN = r'<tr class="subdirectory">\s*<td>\s*<table>(.*?)</table>'
+ LINK_PATTERN = r'<td class="col2"><a href="([^"]+)">info</a></td>'
+ #NEXT_PAGE_PATTERN = r'<a class="next " href="/([^"]+)">&nbsp;</a>'
+
+ def decrypt(self, pyfile):
+ html = self.load(self.pyfile.url)
+
+ new_links = []
+ 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)))
+
+ if new_links:
+ self.core.files.addLinks(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/crypter/FilefactoryComFolder.py b/module/plugins/crypter/FilefactoryComFolder.py
new file mode 100644
index 000000000..32793b491
--- /dev/null
+++ b/module/plugins/crypter/FilefactoryComFolder.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+
+import re
+from module.plugins.Crypter import Crypter
+
+class FilefactoryComFolder(Crypter):
+ __name__ = "FilefactoryComFolder"
+ __type__ = "crypter"
+ __pattern__ = r"(http://(www\.)?filefactory\.com/f/\w+).*"
+ __version__ = "0.1"
+ __description__ = """Filefactory.com Folder Plugin"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ FOLDER_PATTERN = r'<table class="items" cellspacing="0" cellpadding="0">(.*?)</table>'
+ LINK_PATTERN = r'<td class="name"><a href="([^"]+)">'
+ PAGINATOR_PATTERN = r'<div class="list">\s*<label>Pages</label>\s*<ul>(.*?)</ul>\s*</div>'
+ NEXT_PAGE_PATTERN = r'<li class="current">.*?</li>\s*<li class=""><a href="([^"]+)">'
+
+ def decrypt(self, pyfile):
+ url_base = re.search(self.__pattern__, self.pyfile.url).group(1)
+ html = self.load(url_base)
+
+ 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)))
+
+ try:
+ paginator = re.search(self.PAGINATOR_PATTERN, html, re.DOTALL).group(1)
+ next_page = re.search(self.NEXT_PAGE_PATTERN, paginator).group(1)
+ html = self.load("%s/%s" % (url_base, next_page))
+ except Exception, e:
+ break
+ else:
+ self.logInfo("Limit of 99 pages reached, aborting")
+
+ if new_links:
+ self.core.files.addLinks(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/crypter/MultiloadCz.py b/module/plugins/crypter/MultiloadCz.py
index e8dff403e..2c71b8fea 100644
--- a/module/plugins/crypter/MultiloadCz.py
+++ b/module/plugins/crypter/MultiloadCz.py
@@ -7,7 +7,7 @@ class MultiloadCz(Crypter):
__name__ = "MultiloadCz"
__type__ = "crypter"
__pattern__ = r"http://.*multiload.cz/(stahnout|slozka)/.*"
- __version__ = "0.3"
+ __version__ = "0.4"
__description__ = """multiload.cz"""
__config__ = [("usedHoster", "str", "Prefered hoster list (bar-separated) ", ""),
("ignoredHoster", "str", "Ignored hoster list (bar-separated) ", "")]
@@ -29,14 +29,11 @@ class MultiloadCz(Crypter):
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)))
+ new_links.extend([x[1] for x in found if x[0] in prefered_set])
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)))
+ new_links.extend([x[1] for x in found if x[0] not in ignored_set])
if new_links:
self.core.files.addLinks(new_links, self.pyfile.package().id)
diff --git a/module/plugins/crypter/QuickshareCzFolder.py b/module/plugins/crypter/QuickshareCzFolder.py
new file mode 100644
index 000000000..6cb049935
--- /dev/null
+++ b/module/plugins/crypter/QuickshareCzFolder.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+
+import re
+from module.plugins.Crypter import Crypter
+
+class QuickshareCzFolder(Crypter):
+ __name__ = "QuickshareCzFolder"
+ __type__ = "crypter"
+ __pattern__ = r"http://(www\.)?quickshare.cz/slozka-\d+.*"
+ __version__ = "0.1"
+ __description__ = """Quickshare.cz Folder Plugin"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+
+ FOLDER_PATTERN = r'<textarea[^>]*>(.*?)</textarea>'
+ LINK_PATTERN = r'(http://www.quickshare.cz/\S+)'
+
+ def decrypt(self, pyfile):
+ html = self.load(self.pyfile.url)
+
+ new_links = []
+ 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)))
+
+ if new_links:
+ self.core.files.addLinks(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/CzshareCom.py b/module/plugins/hoster/CzshareCom.py
index 74c582dae..f6cbb200a 100644
--- a/module/plugins/hoster/CzshareCom.py
+++ b/module/plugins/hoster/CzshareCom.py
@@ -20,84 +20,160 @@ import re
from module.plugins.Hoster import Hoster
from module.network.RequestFactory import getURL
+def toInfoPage(url):
+ if r"/download.php?" in url:
+ try:
+ id = re.search(r"id=(\d+)", url).group(1)
+ code = re.search(r"code=(\w+)", url).group(1)
+ except Exception, e:
+ return None
+ return "http://czshare.com/%s/%s/" % (id, code)
+ return url
+
def getInfo(urls):
result = []
for url in urls:
+ info_url = toInfoPage(url)
+ if info_url:
+ html = getURL(info_url, decode=True)
+ if re.search(CzshareCom.FILE_OFFLINE_PATTERN, html):
+ # File offline
+ result.append((url, 0, 1, url))
+ else:
+ # Get file info
+ name, size = url, 0
- html = getURL(url, decode=True)
- if re.search(CzshareCom.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- found = re.search(CzshareCom.FILE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
-
found = re.search(CzshareCom.FILE_SIZE_PATTERN, html)
if found is not None:
- size = float(found.group(1).replace(',','.'))
+ size = float(found.group(1).replace(',','.').replace(' ',''))
units = found.group(2)
pow = {'KiB': 1, 'MiB': 2, 'GiB': 3}[units]
size = int(size * 1024 ** pow)
+
+ found = re.search(CzshareCom.FILE_NAME_PATTERN, html)
+ if found is not None:
+ name = found.group(1)
+
+ if found or size > 0:
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://(\w*\.)*czshare\.(com|cz)/.*"
- __version__ = "0.7"
+ __pattern__ = r"http://(\w*\.)*czshare\.(com|cz)/(\d+/|download.php\?).*"
+ __version__ = "0.8"
__description__ = """CZshare.com"""
__author_name__ = ("zoidberg")
- __author_mail__ = ("zoidberg@mujmail.cz")
- FILE_URL_PATTERN = r'<a href="([^"]+)" class="page-download">[^>]*alt="([^"]+)" /></a>'
- FORM_PATTERN = r'<form action="download.php" method="post">\s*<img src="captcha.php" id="captcha" />(.*?)</form>'
+ FREE_URL_PATTERN = r'<a href="([^"]+)" class="page-download">[^>]*alt="([^"]+)" /></a>'
+ FREE_FORM_PATTERN = r'<form action="download.php" method="post">\s*<img src="captcha.php" id="captcha" />(.*?)</form>'
+ PREMIUM_FORM_PATTERN = r'<form action="/profi_down.php" method="post">(.*?)</form>'
FORM_INPUT_PATTERN = r'<input[^>]* name="([^"]+)" value="([^"]+)"[^>]*/>'
- FILE_OFFLINE_PATTERN = r'<h2 class="red">[^<]*[Ss]oubor (nenalezen|expiroval|je po.kozen)[^<]*<span>&nbsp;</span></h2>'
+ FILE_OFFLINE_PATTERN = r'<h2 class="red">[^<]*[Ss]oubor (nenalezen|expiroval|je po.kozen|byl smaz.n)[^<]*<span>&nbsp;</span></h2>'
MULTIDL_PATTERN = r"<p><font color='red'>Z[^<]*PROFI.</font></p>"
- FILE_NAME_PATTERN = r'<h1>([^<]+)<span>&nbsp;</span></h1>'
- FILE_SIZE_PATTERN = r'<div class="tab" id="category">\s*Velikost:\s*([0-9.,]+)(KiB|MiB|GiB)\s*</div>'
+ #FILE_NAME_PATTERN = r'<h1>([^<]+)<span>&nbsp;</span></h1>'
+ FILE_NAME_PATTERN = r'<div class="tab" id="parameters">\s*<p>\s*Cel. n.zev: <a href=[^>]*>([^<]+)</a>'
+ FILE_SIZE_PATTERN = r'<div class="tab" id="category">(?:\s*<p>[^\n]*</p>)*\s*Velikost:\s*([0-9., ]+)(KiB|MiB|GiB)\s*</div>'
+ USER_CREDIT_PATTERN = r'<div class="credit">\s*kredit: <strong>([0-9., ]+)(KB|MB|GB)</strong>\s*</div><!-- .credit -->'
def setup(self):
- self.multiDL = False
+ self.resumeDownload = self.multiDL = True if self.premium else False
+ self.chunkLimit = 1
def process(self, pyfile):
- self.html = self.load(pyfile.url, cookies=True, decode=True)
+ self.getFileInfo(pyfile)
+
+ if self.premium and self.account is not None:
+ for i in range(2):
+ if self.handlePremium(pyfile): break
+ else:
+ self.resetAccount()
+ else:
+ self.handleFree(pyfile)
+ self.checkDownloadedFile()
+
+ def getFileInfo(self, pyfile):
+ url = toInfoPage(pyfile.url)
+ if not url:
+ self.logError(e)
+ self.fail("Invalid URL")
+
+ self.html = self.load(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:
self.offline()
# parse the name from the site and set attribute in pyfile
- found = re.search(self.FILE_URL_PATTERN, self.html)
+ found = re.search(self.FILE_NAME_PATTERN, self.html)
if found is None:
- self.fail("Parse error (URL)")
+ self.fail("Parse error (NAME)")
+ pyfile.name = found.group(1)
+ self.logDebug("NAME:" + pyfile.name)
- pyfile.name = found.group(2)
+ found = re.search(self.FILE_SIZE_PATTERN, self.html)
+ if found is None:
+ self.logError("Parse error (SIZE)")
+ else:
+ size = float(found.group(1).replace(',','.').replace(' ',''))
+ pyfile.size = size * 1024 ** {'KiB': 1, 'MiB': 2, 'GiB': 3}[found.group(2)]
+
+ def handlePremium(self, pyfile):
+ # check user credit
+ found = re.search(self.USER_CREDIT_PATTERN, self.html)
+ if found is None:
+ self.account.relogin(self.user)
+ return False
+
+ try:
+ credit = float(found.group(1).replace(',','.').replace(' ',''))
+ credit = credit * 1024 ** {'KB': 0, 'MB': 1, 'GB': 2}[found.group(2)]
+ self.logInfo("Premium download for %i KiB of Credit" % (pyfile.size / 1024))
+ self.logInfo("User %s has %i KiB left" % (self.user, credit))
+ if credit * 1024 < pyfile.size:
+ self.logInfo("Not enough credit to download file %s" % pyfile.name)
+ self.resetAccount()
+ except Exception, e:
+ # let's continue and see what happens...
+ self.logError('Parse error (CREDIT): %s' % e)
+
+ # parse download link
+ try:
+ form = re.search(self.PREMIUM_FORM_PATTERN, self.html, re.DOTALL).group(1)
+ inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form))
+ except Exception, e:
+ self.logError("Parse error (FORM): %s" % e)
+ self.resetAccount()
+
+ # download the file, destination is determined by pyLoad
+ self.download("http://czshare.com/profi_down.php", cookies=True, post=inputs)
+ return True
+
+ def handleFree(self, pyfile):
+ # get free url
+ found = re.search(self.FREE_URL_PATTERN, self.html)
+ if found is None:
+ self.fail("Parse error (URL)")
parsed_url = "http://czshare.com" + found.group(1)
+ self.logDebug("PARSED_URL:" + parsed_url)
# get download ticket and parse html
- self.logDebug("PARSED_URL:" + parsed_url)
- self.logDebug("NAME:" + pyfile.name)
self.html = self.load(parsed_url, cookies=True)
- #if not re.search(self.FORM_PATTERN, self.html):
+ #if not re.search(self.FREE_FORM_PATTERN, self.html):
if re.search(self.MULTIDL_PATTERN, self.html):
self.waitForFreeSlot()
try:
- form = re.search(self.FORM_PATTERN, self.html, re.DOTALL).group(1)
+ form = re.search(self.FREE_FORM_PATTERN, self.html, re.DOTALL).group(1)
inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form))
- pyfile.size = float(inputs['size'])/1024
+ pyfile.size = int(inputs['size'])
except Exception, e:
self.logError(e)
self.fail("Parse error (FORM)")
-
+
# get and decrypt captcha
captcha_url = 'http://czshare.com/captcha.php'
inputs['captchastring2'] = self.decryptCaptcha(captcha_url)
@@ -106,11 +182,13 @@ class CzshareCom(Hoster):
# download the file, destination is determined by pyLoad
self.download(parsed_url, cookies=True, post=inputs)
+
+ def checkDownloadedFile(self):
# 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.FORM_PATTERN)
+ "captcha_err": re.compile(self.FREE_FORM_PATTERN)
})
if check == "tempoffline":