summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/CzshareCom.py
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-09-20 17:10:52 +0200
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-09-20 17:10:52 +0200
commit924b9e2e7e0d651662b4bd00936b7f4675e7947f (patch)
tree8b723b917a95fbb0ab26253e32cdd963cc7f5c44 /module/plugins/hoster/CzshareCom.py
parentgeneral JSON API, url parser (diff)
downloadpyload-924b9e2e7e0d651662b4bd00936b7f4675e7947f.tar.xz
New plugins: HellspyCz, LetitbitNet, FreevideoCz, StreamCz, UlozToFolder
Diffstat (limited to 'module/plugins/hoster/CzshareCom.py')
-rw-r--r--module/plugins/hoster/CzshareCom.py122
1 files changed, 38 insertions, 84 deletions
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>&nbsp;</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>&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>'
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")