summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar igel-kun <mathiaswe@gmx.de> 2014-09-15 23:10:37 +0200
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-09-15 23:10:37 +0200
commitdf2dcf1ccdbcc5197a224df9946595df907dc749 (patch)
tree6702f023af2829ac7022e89bc039cb103966a693
parent[BasePlugin] Little code cosmetics (diff)
downloadpyload-df2dcf1ccdbcc5197a224df9946595df907dc749.tar.xz
[XFilesharingPro] Embedded urls support
-rw-r--r--module/plugins/hooks/XFileSharingPro.py7
-rw-r--r--module/plugins/hoster/XFileSharingPro.py15
2 files changed, 19 insertions, 3 deletions
diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py
index eb0376921..e19b40e22 100644
--- a/module/plugins/hooks/XFileSharingPro.py
+++ b/module/plugins/hooks/XFileSharingPro.py
@@ -8,7 +8,7 @@ from module.plugins.Hook import Hook
class XFileSharingPro(Hook):
__name__ = "XFileSharingPro"
__type__ = "hook"
- __version__ = "0.11"
+ __version__ = "0.12"
__config__ = [("activated", "bool", "Activated", True),
("loadDefault", "bool", "Include default (built-in) hoster list", True),
@@ -23,6 +23,7 @@ class XFileSharingPro(Hook):
def coreReady(self):
self.loadPattern()
+
def loadPattern(self):
hosterList = self.getConfigSet('includeList')
excludeList = self.getConfigSet('excludeList')
@@ -60,7 +61,7 @@ class XFileSharingPro(Hook):
self.unload()
return
- regexp = r"http://(?:[^/]*\.)?(%s)/\w{12}" % ("|".join(sorted(hosterList)).replace('.', '\.'))
+ regexp = r"http://(?:[^/]*\.)?(%s)/(?:embed-)?\w{12}" % ("|".join(sorted(hosterList)).replace('.', '\.'))
#self.logDebug(regexp)
dict = self.core.pluginManager.hosterPlugins['XFileSharingPro']
@@ -68,10 +69,12 @@ class XFileSharingPro(Hook):
dict['re'] = re.compile(regexp)
self.logDebug("Pattern loaded - handling %d hosters" % len(hosterList))
+
def getConfigSet(self, option):
s = self.getConfig(option).lower().replace('|', ',').replace(';', ',')
return set([x.strip() for x in s.split(',')])
+
def unload(self):
dict = self.core.pluginManager.hosterPlugins['XFileSharingPro']
dict['pattern'] = r'^unmatchable$'
diff --git a/module/plugins/hoster/XFileSharingPro.py b/module/plugins/hoster/XFileSharingPro.py
index 25492fb49..d7e24e0b0 100644
--- a/module/plugins/hoster/XFileSharingPro.py
+++ b/module/plugins/hoster/XFileSharingPro.py
@@ -21,7 +21,7 @@ class XFileSharingPro(SimpleHoster):
"""
__name__ = "XFileSharingPro"
__type__ = "hoster"
- __version__ = "0.32"
+ __version__ = "0.33"
__pattern__ = r'^unmatchable$'
@@ -29,6 +29,8 @@ class XFileSharingPro(SimpleHoster):
__author_name__ = ("zoidberg", "stickell")
__author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it")
+
+ FILE_URL_REPLACEMENTS = [(r'/embed-(\w{12}).*', r'/\1')] #: support embedded files
FILE_INFO_PATTERN = r'<tr><td align=right><b>Filename:</b></td><td nowrap>(?P<N>[^<]+)</td></tr>\s*.*?<small>\((?P<S>[^<]+)\)</small>'
FILE_NAME_PATTERN = r'<input type="hidden" name="fname" value="(?P<N>[^"]+)"'
FILE_SIZE_PATTERN = r'You have requested .*\((?P<S>[\d\.\,]+) ?(?P<U>\w+)?\)</font>'
@@ -55,6 +57,7 @@ class XFileSharingPro(SimpleHoster):
self.chunkLimit = 1
+
def process(self, pyfile):
self.prepare()
@@ -88,6 +91,7 @@ class XFileSharingPro(SimpleHoster):
else:
self.handleFree()
+
def prepare(self):
""" Initialize important variables """
if not hasattr(self, "HOSTER_NAME"):
@@ -98,6 +102,7 @@ class XFileSharingPro(SimpleHoster):
self.captcha = self.errmsg = None
self.passwords = self.getPassword().splitlines()
+
def getDirectDownloadLink(self):
""" Get download link for premium users with direct download enabled """
self.req.http.lastURL = self.pyfile.url
@@ -114,11 +119,13 @@ class XFileSharingPro(SimpleHoster):
return location
+
def handleFree(self):
url = self.getDownloadLink()
self.logDebug("Download URL: %s" % url)
self.startDownload(url)
+
def getDownloadLink(self):
for i in xrange(5):
self.logDebug("Getting download link: #%d" % i)
@@ -145,6 +152,7 @@ class XFileSharingPro(SimpleHoster):
return m.group(1)
+
def handlePremium(self):
self.html = self.load(self.pyfile.url, post=self.getPostParameters())
m = re.search(self.LINK_PATTERN, self.html)
@@ -152,6 +160,7 @@ class XFileSharingPro(SimpleHoster):
self.parseError('DIRECT LINK')
self.startDownload(m.group(1))
+
def handleOverriden(self):
#only tested with easybytez.com
self.html = self.load("http://www.%s/" % self.HOSTER_NAME)
@@ -189,6 +198,7 @@ class XFileSharingPro(SimpleHoster):
else:
self.retry()
+
def startDownload(self, link):
link = link.strip()
if self.captcha:
@@ -196,6 +206,7 @@ class XFileSharingPro(SimpleHoster):
self.logDebug('DIRECT LINK: %s' % link)
self.download(link, disposition=True)
+
def checkErrors(self):
m = re.search(self.ERROR_PATTERN, self.html)
if m:
@@ -227,6 +238,7 @@ class XFileSharingPro(SimpleHoster):
return self.errmsg
+
def getPostParameters(self):
for _ in xrange(3):
if not self.errmsg:
@@ -288,6 +300,7 @@ class XFileSharingPro(SimpleHoster):
else:
self.parseError('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN'))
+
def handleCaptcha(self, inputs):
m = re.search(self.RECAPTCHA_URL_PATTERN, self.html)
if m: