summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-10-03 01:14:48 +0200
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-10-03 01:14:48 +0200
commit5658d5525d5088a6254322210c1641cbdba2eb7d (patch)
treef4f256e082d4f906ba11b25ccaedc1e39e652ba3 /module/plugins
parentlittle multihoster fix (diff)
downloadpyload-5658d5525d5088a6254322210c1641cbdba2eb7d.tar.xz
update czshare, little fixes
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/accounts/CzshareCom.py6
-rw-r--r--module/plugins/hoster/CzshareCom.py106
-rw-r--r--module/plugins/hoster/LoadTo.py7
-rw-r--r--module/plugins/hoster/RapidgatorNet.py11
-rw-r--r--module/plugins/internal/CaptchaService.py2
-rw-r--r--module/plugins/internal/MultiHoster.py47
6 files changed, 76 insertions, 103 deletions
diff --git a/module/plugins/accounts/CzshareCom.py b/module/plugins/accounts/CzshareCom.py
index 695e21b18..e68248aa8 100644
--- a/module/plugins/accounts/CzshareCom.py
+++ b/module/plugins/accounts/CzshareCom.py
@@ -24,7 +24,7 @@ import re
class CzshareCom(Account):
__name__ = "CzshareCom"
- __version__ = "0.1"
+ __version__ = "0.11"
__type__ = "account"
__description__ = """czshare.com account plugin"""
__author_name__ = ("zoidberg")
@@ -48,11 +48,11 @@ class CzshareCom(Account):
def login(self, user, data, req):
- html = req.load('http://czshare.com/index.php', post={
+ html = req.load('https://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:
+ if '<div class="login' in html:
self.wrongPassword()
diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py
index 8d035b64c..c8a576b29 100644
--- a/module/plugins/hoster/CzshareCom.py
+++ b/module/plugins/hoster/CzshareCom.py
@@ -17,42 +17,24 @@
"""
import re
-from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo, PluginParseError
-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:
- file_info = parseFileInfo(CzshareCom, url, getURL(info_url, decode=True))
- result.append(file_info)
-
- yield result
+from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
+from module.utils import parseFileSize
class CzshareCom(SimpleHoster):
__name__ = "CzshareCom"
__type__ = "hoster"
__pattern__ = r"http://(\w*\.)*czshare\.(com|cz)/(\d+/|download.php\?).*"
- __version__ = "0.90"
+ __version__ = "0.91"
__description__ = """CZshare.com"""
__author_name__ = ("zoidberg")
FILE_NAME_PATTERN = r'<div class="tab" id="parameters">\s*<p>\s*Cel. n.zev: <a href=[^>]*>(?P<N>[^<]+)</a>'
FILE_SIZE_PATTERN = r'<div class="tab" id="category">(?:\s*<p>[^\n]*</p>)*\s*Velikost:\s*(?P<S>[0-9., ]+)(?P<U>[kKMG])i?B\s*</div>'
FILE_OFFLINE_PATTERN = r'<div class="header clearfix">\s*<h2 class="red">'
+
FILE_SIZE_REPLACEMENTS = [(' ', '')]
+ FILE_URL_REPLACEMENTS = [(r'http://[^/]*/download.php\?.*?id=(\w+).*', r'http://czshare.com/\1/x/')]
+ SH_CHECK_TRAFFIC = True
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>'
@@ -65,20 +47,7 @@ class CzshareCom(SimpleHoster):
self.multiDL = self.resumeDownload = True if self.premium else False
self.chunkLimit = 1
- def process(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)
- self.getFileInfo()
-
- if not self.account or not self.handlePremium():
- self.handleFree()
- self.checkDownloadedFile()
-
- def handlePremium(self):
+ def checkTrafficLeft(self):
# check if user logged in
found = re.search(self.USER_CREDIT_PATTERN, self.html)
if not found:
@@ -89,17 +58,19 @@ class CzshareCom(SimpleHoster):
# check user credit
try:
- credit = float(found.group(1).replace(',','.').replace(' ',''))
- credit = credit * 1024 ** {'KB': 0, 'MB': 1, 'GB': 2}[found.group(2)]
+ credit = parseFileSize(found.group(1).replace(' ',''), found.group(2))
self.logInfo("Premium download for %i KiB of Credit" % (self.pyfile.size / 1024))
- self.logInfo("User %s has %i KiB left" % (self.user, credit))
- if credit * 1024 < self.pyfile.size:
+ self.logInfo("User %s has %i KiB left" % (self.user, credit / 1024))
+ if credit < self.pyfile.size:
self.logInfo("Not enough credit to download file %s" % self.pyfile.name)
- self.resetAccount()
+ return False
except Exception, e:
# let's continue and see what happens...
self.logError('Parse error (CREDIT): %s' % e)
-
+
+ return True
+
+ def handlePremium(self):
# parse download link
try:
form = re.search(self.PREMIUM_FORM_PATTERN, self.html, re.DOTALL).group(1)
@@ -110,7 +81,7 @@ class CzshareCom(SimpleHoster):
# download the file, destination is determined by pyLoad
self.download("http://czshare.com/profi_down.php", cookies=True, post=inputs)
- return True
+ self.checkDownloadedFile()
def handleFree(self):
# get free url
@@ -121,11 +92,9 @@ class CzshareCom(SimpleHoster):
self.logDebug("PARSED_URL:" + parsed_url)
# get download ticket and parse html
- self.html = self.load(parsed_url, cookies=True)
-
- #if not re.search(self.FREE_FORM_PATTERN, self.html):
+ self.html = self.load(parsed_url, cookies=True, decode=True)
if re.search(self.MULTIDL_PATTERN, self.html):
- self.waitForFreeSlot()
+ self.longWait(300, 12)
try:
form = re.search(self.FREE_FORM_PATTERN, self.html, re.DOTALL).group(1)
@@ -135,15 +104,20 @@ class CzshareCom(SimpleHoster):
self.logError(e)
raise PluginParseError('Form')
- # get and decrypt captcha
+ # get and decrypt captcha
captcha_url = 'http://czshare.com/captcha.php'
- inputs['captchastring2'] = self.decryptCaptcha(captcha_url)
- self.logDebug('CAPTCHA_URL:' + captcha_url + ' CAPTCHA:' + inputs['captchastring2'])
-
- self.html = self.load(parsed_url, cookies=True, post=inputs)
-
- if re.search(self.MULTIDL_PATTERN, self.html):
- self.waitForFreeSlot()
+ for i in range(5):
+ inputs['captchastring2'] = self.decryptCaptcha(captcha_url)
+ self.html = self.load(parsed_url, cookies=True, post=inputs, decode=True)
+ if u"<li>Zadaný ověřovací kód nesouhlasí!</li>" in self.html:
+ self.invalidCaptcha()
+ elif re.search(self.MULTIDL_PATTERN, self.html):
+ self.longWait(300, 12)
+ else:
+ self.correctCaptcha()
+ break
+ else:
+ self.fail("No valid captcha code entered")
found = re.search("countdown_number = (\d+);", self.html)
self.setWait(int(found.group(1)) if found else 50)
@@ -158,26 +132,26 @@ class CzshareCom(SimpleHoster):
self.wait()
self.multiDL = True
- self.download(url)
+ self.download(url)
+ self.checkDownloadedFile()
def checkDownloadedFile(self):
# check download
check = self.checkDownload({
- "tempoffline": re.compile(r"^Soubor je do.asn. nedostupn.$"),
+ "tempoffline": re.compile(r"^Soubor je do.*asn.* nedostupn.*$"),
+ "credit": re.compile(r"^Nem.*te dostate.*n.* kredit.$"),
"multi_dl": re.compile(self.MULTIDL_PATTERN),
"captcha_err": "<li>Zadaný ověřovací kód nesouhlasí!</li>"
})
if check == "tempoffline":
self.fail("File not available - try later")
+ if check == "credit":
+ self.resetAccount()
elif check == "multi_dl":
- self.waitForFreeSlot()
+ self.longWait(300, 12)
elif check == "captcha_err":
self.invalidCaptcha()
self.retry()
-
- def waitForFreeSlot(self, wait_time = 300):
- self.multiDL = False
- self.setWait(wait_time, True)
- self.wait()
- self.retry() \ No newline at end of file
+
+getInfo = create_getInfo(CzshareCom) \ No newline at end of file
diff --git a/module/plugins/hoster/LoadTo.py b/module/plugins/hoster/LoadTo.py
index 66bc6f407..babf354a9 100644
--- a/module/plugins/hoster/LoadTo.py
+++ b/module/plugins/hoster/LoadTo.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- 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
@@ -43,7 +43,7 @@ class LoadTo(Hoster):
__name__ = "LoadTo"
__type__ = "hoster"
__pattern__ = r"http://(www.*?\.)?load\.to/.{7,10}?/.*"
- __version__ = "0.1002"
+ __version__ = "0.11"
__description__ = """load.to"""
__author_name__ = ("halfman")
__author_mail__ = ("Pulpan3@gmail.com")
@@ -79,4 +79,5 @@ class LoadTo(Hoster):
self.setWait(timmy.group(1))
self.wait()
- self.download(download_url)
+ self.req.setOption("timeout", 120)
+ self.download(download_url) \ No newline at end of file
diff --git a/module/plugins/hoster/RapidgatorNet.py b/module/plugins/hoster/RapidgatorNet.py
index 291ba4c4b..6c09eabb9 100644
--- a/module/plugins/hoster/RapidgatorNet.py
+++ b/module/plugins/hoster/RapidgatorNet.py
@@ -21,7 +21,7 @@ from pycurl import HTTPHEADER
from random import random
from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
-from module.plugins.internal.CaptchaServices import ReCaptcha, SolveMedia, AdsCaptcha
+from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia, AdsCaptcha
from module.common.json_layer import json_loads
class RapidgatorNet(SimpleHoster):
@@ -42,14 +42,7 @@ class RapidgatorNet(SimpleHoster):
RECAPTCHA_KEY_PATTERN = r'"http://api.recaptcha.net/challenge?k=(.*?)"'
ADSCAPTCHA_SRC_PATTERN = r'(http://api.adscaptcha.com/Get.aspx[^"\']*)'
SOLVEMEDIA_PATTERN = r'http:\/\/api\.solvemedia\.com\/papi\/challenge\.script\?k=(.*?)"'
-
- def process(self, pyfile):
- self.pyfile = pyfile
- if self.premium:
- self.handlePremium()
- else:
- self.fail("NO FREE")
-
+
def getAPIResponse(self, cmd):
json = self.load('%s/%s' % (self.API_URL, cmd),
get = {'sid': self.account.getAccountData(self.user).get('SID'),
diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py
index 8be442d37..f2de00732 100644
--- a/module/plugins/internal/CaptchaService.py
+++ b/module/plugins/internal/CaptchaService.py
@@ -18,7 +18,7 @@
import re
-class CaptchaService()
+class CaptchaService():
__version__ = "0.01"
def __init__(self, plugin):
diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py
index f35f35c5c..a8961aafc 100644
--- a/module/plugins/internal/MultiHoster.py
+++ b/module/plugins/internal/MultiHoster.py
@@ -11,24 +11,20 @@ class MultiHoster(Hook):
Generic MultiHoster plugin
"""
- __version__ = "0.18"
+ __version__ = "0.19"
replacements = [("2shared.com", "twoshared.com"), ("4shared.com", "fourshared.com"), ("cloudnator.com", "shragle.com"),
("ifile.it", "filecloud.io"), ("easy-share.com","crocko.com"), ("freakshare.net","freakshare.com"),
("hellshare.com", "hellshare.cz"), ("share-rapid.cz","sharerapid.com"), ("sharerapid.cz","sharerapid.com"),
("ul.to","uploaded.to"), ("uploaded.net","uploaded.to"), ("1fichier.com", "onefichier.com")]
ignored = []
- interval = 24 * 60 * 60
+ interval = 24 * 60 * 60 # reload hosters daily
def setup(self):
self.hosters = []
self.supported = []
self.new_supported = []
- cfg_interval = self.getConfig("interval", None) # reload interval in hours
- if cfg_interval is not None:
- self.interval = cfg_interval * 60 * 60
-
def getConfig(self, option, default = ''):
"""getConfig with default value - sublass may not implements all config options"""
try:
@@ -63,14 +59,14 @@ class MultiHoster(Hook):
return self.hosters
def toHosterSet(self, hosters):
- hosters = set((x.strip().lower() for x in hosters))
+ hosters = set((str(x).strip().lower() for x in hosters))
for rep in self.replacements:
if rep[0] in hosters:
hosters.remove(rep[0])
hosters.add(rep[1])
- hosters.discard(u'')
+ hosters.discard('')
return hosters
def getHoster(self):
@@ -81,14 +77,27 @@ class MultiHoster(Hook):
raise NotImplementedError
def coreReady(self):
- if not self.interval:
- if self.cb:
- self.core.scheduler.removeJob(self.cb)
- self.overridePlugins()
+ if self.cb:
+ self.core.scheduler.removeJob(self.cb)
+
+ self.setConfig("activated", True) # config not in sync after plugin reload
+
+ cfg_interval = self.getConfig("interval", None) # reload interval in hours
+ if cfg_interval is not None:
+ self.interval = cfg_interval * 60 * 60
+
+ if self.interval:
+ self._periodical()
+ else:
+ self.periodical()
+
+ def initPeriodical(self):
+ pass
def periodical(self):
"""reload hoster list periodically"""
self.logInfo("Reloading supported hoster list")
+
old_supported = self.supported
self.supported, self.new_supported, self.hosters = [], [], []
@@ -96,9 +105,9 @@ class MultiHoster(Hook):
old_supported = [hoster for hoster in old_supported if hoster not in self.supported]
if old_supported:
- self.logDebug("UNLOAD", old_supported)
+ self.logDebug("UNLOAD: %s" % ", ".join(old_supported))
for hoster in old_supported:
- self.unloadHoster(hoster)
+ self.unloadHoster(hoster)
def overridePlugins(self):
pluginMap = {}
@@ -160,7 +169,7 @@ class MultiHoster(Hook):
del dict["new_name"]
def unload(self):
- """remove override for all hosters"""
+ """Remove override for all hosters. Scheduler job is removed by hookmanager"""
for hoster in self.supported:
self.unloadHoster(hoster)
@@ -168,11 +177,7 @@ class MultiHoster(Hook):
klass = getattr(self.core.pluginManager.getPlugin(self.__name__), self.__name__)
dict = self.core.pluginManager.hosterPlugins[self.__name__]
dict["pattern"] = getattr(klass, '__pattern__', r"^unmatchable$")
- dict["re"] = re.compile(dict["pattern"])
-
- # remove scheduler job
- if self.cb:
- self.core.scheduler.removeJob(self.cb)
+ dict["re"] = re.compile(dict["pattern"])
def downloadFailed(self, pyfile):
"""remove plugin override if download fails but not if file is offline/temp.offline"""
@@ -181,4 +186,4 @@ class MultiHoster(Hook):
if "new_name" in hdict and hdict['new_name'] == self.__name__:
self.logDebug("Unload MultiHoster", pyfile.pluginname, hdict)
self.unloadHoster(pyfile.pluginname)
- pyfile.setStatus("queued")
+ pyfile.setStatus("queued") \ No newline at end of file