summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-10-19 14:35:53 +0200
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-10-19 14:35:53 +0200
commitbb1f6b3cbfc34914a1a336f8f5a2e15b57e2b5f5 (patch)
tree418ca12dba84c99cbaabd413c73fd547c6781450 /module
parentFix XDCCRequest _keepAlive (diff)
downloadpyload-bb1f6b3cbfc34914a1a336f8f5a2e15b57e2b5f5.tar.xz
parseError -> error now calls Fail instead Exception
Diffstat (limited to 'module')
-rw-r--r--module/plugins/internal/SimpleCrypter.py9
-rw-r--r--module/plugins/internal/SimpleHoster.py29
-rw-r--r--module/plugins/internal/XFSPHoster.py17
3 files changed, 24 insertions, 31 deletions
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index 3c1dc3244..b45e503d5 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -3,14 +3,15 @@
import re
from module.plugins.Crypter import Crypter
-from module.plugins.internal.SimpleHoster import PluginParseError, replace_patterns, set_cookies
+from module.plugins.Plugin import Fail
+from module.plugins.internal.SimpleHoster import replace_patterns, set_cookies
from module.utils import fixup, html_unescape
class SimpleCrypter(Crypter):
__name__ = "SimpleCrypter"
__type__ = "crypter"
- __version__ = "0.15"
+ __version__ = "0.16"
__pattern__ = None
@@ -156,5 +157,5 @@ class SimpleCrypter(Crypter):
self.package_links += self.getLinks()
- def parseError(self, msg):
- raise PluginParseError(msg)
+ def error(self, reason):
+ raise Fail("Parse error (%s) - crypter plugin may be out of date" % reason)
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index c2bc4909e..bbd37e978 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -8,7 +8,8 @@ from urlparse import urlparse
from module.network.CookieJar import CookieJar
from module.network.RequestFactory import getURL
from module.plugins.Hoster import Hoster
-from module.utils import fixup, html_unescape, parseFileSize
+from module.plugins.Plugin import Fail
+reasonfrom module.utils import fixup, html_unescape, parseFileSize
def replace_patterns(string, ruleslist):
@@ -139,20 +140,10 @@ def timestamp():
return int(time() * 1000)
-class PluginParseError(Exception):
-
- def __init__(self, msg):
- Exception.__init__(self)
- self.value = 'Parse error (%s) - plugin may be out of date' % msg
-
- def __str__(self):
- return repr(self.value)
-
-
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "0.38"
+ __version__ = "0.39"
__pattern__ = None
@@ -249,7 +240,7 @@ class SimpleHoster(Hoster):
self.tempOffline()
elif status != 2:
self.logDebug(self.file_info)
- self.parseError('File info')
+ self.error('File info')
if name:
self.pyfile.name = name
@@ -272,7 +263,7 @@ class SimpleHoster(Hoster):
try:
m = re.search(self.LINK_FREE_PATTERN, self.html)
if m is None:
- self.parseError("Free download link not found")
+ self.error("Free download link not found")
link = m.group(1)
except Exception, e:
@@ -288,7 +279,7 @@ class SimpleHoster(Hoster):
try:
m = re.search(self.LINK_PREMIUM_PATTERN, self.html)
if m is None:
- self.parseError("Premium download link not found")
+ self.error("Premium download link not found")
link = m.group(1)
except Exception, e:
@@ -297,10 +288,6 @@ class SimpleHoster(Hoster):
self.download(link, ref=True, cookies=True, disposition=True)
- def parseError(self, msg):
- raise PluginParseError(msg)
-
-
def longWait(self, wait_time=None, max_tries=3):
if wait_time and isinstance(wait_time, (int, long, float)):
time_str = "%dh %dm" % divmod(wait_time / 60, 60)
@@ -334,3 +321,7 @@ class SimpleHoster(Hoster):
if seconds:
self.setWait(seconds, reconnect)
super(SimpleHoster, self).wait()
+
+
+ def error(self, reason):
+ raise Fail("Parse error (%s) - hoster plugin may be out of date" % reason)
diff --git a/module/plugins/internal/XFSPHoster.py b/module/plugins/internal/XFSPHoster.py
index abf71b033..0b656c67c 100644
--- a/module/plugins/internal/XFSPHoster.py
+++ b/module/plugins/internal/XFSPHoster.py
@@ -9,14 +9,15 @@ from urlparse import urlparse
from module.network.RequestFactory import getURL
from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia
-from module.plugins.internal.SimpleHoster import create_getInfo, PluginParseError, replace_patterns, set_cookies, SimpleHoster
+from module.plugins.internal.SimpleHoster import create_getInfo, replace_patterns, set_cookies, SimpleHoster
+from module.plugins.Plugin import Fail
from module.utils import html_unescape
class XFSPHoster(SimpleHoster):
__name__ = "XFSPHoster"
__type__ = "hoster"
- __version__ = "0.03"
+ __version__ = "0.04"
__pattern__ = None
@@ -92,7 +93,7 @@ class XFSPHoster(SimpleHoster):
# Can be reverted in 0.4.10 as the cookies bug has been fixed.
self.html = getURL(pyfile.url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES)
self.file_info = self.getFileInfo()
- except PluginParseError:
+ except Fail:
self.file_info = None
self.location = self.getDirectDownloadLink()
@@ -163,7 +164,7 @@ class XFSPHoster(SimpleHoster):
self.html = self.load(self.pyfile.url, post=self.getPostParameters())
m = re.search(self.LINK_PATTERN, self.html)
if m is None:
- self.parseError('LINK_PATTERN not found')
+ self.error('LINK_PATTERN not found')
self.startDownload(m.group(1))
@@ -184,7 +185,7 @@ class XFSPHoster(SimpleHoster):
action, inputs = self.parseHtmlForm('F1')
if not inputs:
- self.parseError('TEXTAREA not found')
+ self.error('TEXTAREA not found')
self.logDebug(self.HOSTER_NAME, inputs)
if inputs['st'] == 'OK':
self.html = self.load(action, post=inputs)
@@ -196,7 +197,7 @@ class XFSPHoster(SimpleHoster):
#get easybytez.com link for uploaded file
m = re.search(self.OVR_LINK_PATTERN, self.html)
if m is None:
- self.parseError('OVR_LINK_PATTERN not found')
+ self.error('OVR_LINK_PATTERN not found')
self.pyfile.url = m.group(1)
header = self.load(self.pyfile.url, just_header=True)
if 'location' in header: # Direct link
@@ -261,7 +262,7 @@ class XFSPHoster(SimpleHoster):
if self.errmsg:
self.retry()
else:
- self.parseError("Form not found")
+ self.error("Form not found")
self.logDebug(self.HOSTER_NAME, inputs)
@@ -304,7 +305,7 @@ class XFSPHoster(SimpleHoster):
self.errmsg = None
else:
- self.parseError('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN'))
+ self.error('FORM: %s' % (inputs['op'] if 'op' in inputs else 'UNKNOWN'))
def handleCaptcha(self, inputs):