summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-02-02 01:41:15 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-02-02 01:41:15 +0100
commitd622107c1c869dd27f2104f97184e24bc35c48be (patch)
tree3cc1e52a8fafd6af1fbd81a1c245050fc8f8b913
parentCaptcha9Kw should be initialized activated false (diff)
downloadpyload-d622107c1c869dd27f2104f97184e24bc35c48be.tar.xz
[MultiHoster][SimpleHoster] Improve info stuff
-rw-r--r--module/plugins/hoster/BasePlugin.py11
-rw-r--r--module/plugins/hoster/RapiduNet.py6
-rw-r--r--module/plugins/hoster/UploadableCh.py6
-rw-r--r--module/plugins/internal/MultiHoster.py5
-rw-r--r--module/plugins/internal/SimpleHoster.py43
5 files changed, 33 insertions, 38 deletions
diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py
index 4f9e25a35..f9eb695ca 100644
--- a/module/plugins/hoster/BasePlugin.py
+++ b/module/plugins/hoster/BasePlugin.py
@@ -13,7 +13,7 @@ from module.plugins.Hoster import Hoster
class BasePlugin(Hoster):
__name__ = "BasePlugin"
__type__ = "hoster"
- __version__ = "0.33"
+ __version__ = "0.34"
__pattern__ = r'^unmatchable$'
@@ -25,10 +25,11 @@ class BasePlugin(Hoster):
@classmethod
def getInfo(cls, url="", html=""): #@TODO: Move to hoster class in 0.4.10
- url = unquote(url)
- return {'name' : (urlparse(url).path.split('/')[-1]
- or urlparse(url).query.split('=', 1)[::-1][0].split('&', 1)[0]
- or _("Unknown")),
+ url = unquote(url)
+ url_p = urlparse(url)
+ return {'name' : (url_p.path.split('/')[-1]
+ or url_p.query.split('=', 1)[::-1][0].split('&', 1)[0]
+ or url_p.netloc.split('.', 1)[0]),
'size' : 0,
'status': 3 if url else 8,
'url' : url}
diff --git a/module/plugins/hoster/RapiduNet.py b/module/plugins/hoster/RapiduNet.py
index b6806e49b..350572eef 100644
--- a/module/plugins/hoster/RapiduNet.py
+++ b/module/plugins/hoster/RapiduNet.py
@@ -13,7 +13,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
class RapiduNet(SimpleHoster):
__name__ = "RapiduNet"
__type__ = "hoster"
- __version__ = "0.06"
+ __version__ = "0.07"
__pattern__ = r'https?://(?:www\.)?rapidu\.net/(?P<ID>\d{10})'
@@ -24,8 +24,8 @@ class RapiduNet(SimpleHoster):
COOKIES = [("rapidu.net", "rapidu_lang", "en")]
- FILE_INFO_PATTERN = r'<h1 title="(?P<N>.*)">.*</h1>\s*<small>(?P<S>\d+(\.\d+)?)\s(?P<U>\w+)</small>'
- OFFLINE_PATTERN = r'404 - File not found'
+ INFO_PATTERN = r'<h1 title="(?P<N>.*)">.*</h1>\s*<small>(?P<S>\d+(\.\d+)?)\s(?P<U>\w+)</small>'
+ OFFLINE_PATTERN = r'404 - File not found'
ERROR_PATTERN = r'<div class="error">'
diff --git a/module/plugins/hoster/UploadableCh.py b/module/plugins/hoster/UploadableCh.py
index be4cb5b06..11cf3d321 100644
--- a/module/plugins/hoster/UploadableCh.py
+++ b/module/plugins/hoster/UploadableCh.py
@@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
class UploadableCh(SimpleHoster):
__name__ = "UploadableCh"
__type__ = "hoster"
- __version__ = "0.07"
+ __version__ = "0.08"
__pattern__ = r'http://(?:www\.)?uploadable\.ch/file/(?P<ID>\w+)'
@@ -21,9 +21,9 @@ class UploadableCh(SimpleHoster):
("Walter Purcaro", "vuolter@gmail.com")]
- FILE_URL_REPLACEMENTS = [(__pattern__ + ".*", r'http://www.uploadable.ch/file/\g<ID>')]
+ URL_REPLACEMENTS = [(__pattern__ + ".*", r'http://www.uploadable.ch/file/\g<ID>')]
- FILE_INFO_PATTERN = r'div id=\"file_name\" title=.*>(?P<N>.+)<span class=\"filename_normal\">\((?P<S>[\d.]+) (?P<U>\w+)\)</span><'
+ INFO_PATTERN = r'div id=\"file_name\" title=.*>(?P<N>.+)<span class=\"filename_normal\">\((?P<S>[\d.]+) (?P<U>\w+)\)</span><'
OFFLINE_PATTERN = r'>(File not available|This file is no longer available)'
TEMP_OFFLINE_PATTERN = r'<div class="icon_err">'
diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py
index ad5b6283e..63b7d76b1 100644
--- a/module/plugins/internal/MultiHoster.py
+++ b/module/plugins/internal/MultiHoster.py
@@ -8,7 +8,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, r
class MultiHoster(SimpleHoster):
__name__ = "MultiHoster"
__type__ = "hoster"
- __version__ = "0.36"
+ __version__ = "0.37"
__pattern__ = r'^unmatchable$'
@@ -45,8 +45,7 @@ class MultiHoster(SimpleHoster):
else:
self.directDL = self.DIRECT_LINK
- self.pyfile.url = replace_patterns(self.pyfile.url,
- self.FILE_URL_REPLACEMENTS if hasattr(self, "FILE_URL_REPLACEMENTS") else self.URL_REPLACEMENTS) #@TODO: Remove FILE_URL_REPLACEMENTS check in 0.4.10
+ self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS)
def process(self, pyfile):
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index da178ef9c..4a1f62395 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -108,13 +108,14 @@ def parseFileInfo(plugin, url="", html=""):
info = plugin.getInfo(url, html)
res = info['name'], info['size'], info['status'], info['url']
else:
- url = unquote(url)
- res = ((urlparse(url).path.split('/')[-1]
- or urlparse(url).query.split('=', 1)[::-1][0].split('&', 1)[0]
- or _("Unknown")),
- 0,
- 3 if url else 8,
- url)
+ url = unquote(url)
+ url_p = urlparse(url)
+ res = ((url_p.path.split('/')[-1]
+ or url_p.query.split('=', 1)[::-1][0].split('&', 1)[0]
+ or url_p.netloc.split('.', 1)[0]),
+ 0,
+ 3 if url else 8,
+ url)
return res
@@ -245,7 +246,7 @@ def secondsToMidnight(gmt=0):
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "1.12"
+ __version__ = "1.13"
__pattern__ = r'^unmatchable$'
@@ -315,16 +316,17 @@ class SimpleHoster(Hoster):
@classmethod
def parseInfos(cls, urls): #@TODO: Built-in in 0.4.10 core, then remove from plugins
for url in urls:
- url = replace_patterns(url, cls.FILE_URL_REPLACEMENTS if hasattr(cls, "FILE_URL_REPLACEMENTS") else cls.URL_REPLACEMENTS) #@TODO: Remove FILE_URL_REPLACEMENTS check in 0.4.10
+ url = replace_patterns(url, cls.URL_REPLACEMENTS)
yield cls.getInfo(url)
@classmethod
def apiInfo(cls, url="", get={}, post={}):
- url = unquote(url)
- return {'name' : (urlparse(url).path.split('/')[-1]
- or urlparse(url).query.split('=', 1)[::-1][0].split('&', 1)[0]
- or _("Unknown")),
+ url = unquote(url)
+ url_p = urlparse(url)
+ return {'name' : (url_p.path.split('/')[-1]
+ or url_p.query.split('=', 1)[::-1][0].split('&', 1)[0]
+ or url_p.netloc.split('.', 1)[0]),
'size' : 0,
'status': 3 if url else 8,
'url' : url}
@@ -366,17 +368,11 @@ class SimpleHoster(Hoster):
if hasattr(cls, "OFFLINE_PATTERN") and re.search(cls.OFFLINE_PATTERN, html):
info['status'] = 1
- elif hasattr(cls, "FILE_OFFLINE_PATTERN") and re.search(cls.FILE_OFFLINE_PATTERN, html): #@TODO: Remove in 0.4.10
- info['status'] = 1
-
elif hasattr(cls, "TEMP_OFFLINE_PATTERN") and re.search(cls.TEMP_OFFLINE_PATTERN, html):
info['status'] = 6
else:
- for pattern in ("FILE_INFO_PATTERN", "INFO_PATTERN",
- "FILE_NAME_PATTERN", "NAME_PATTERN",
- "FILE_SIZE_PATTERN", "SIZE_PATTERN",
- "HASHSUM_PATTERN"): #@TODO: Remove old patterns starting with "FILE_" in 0.4.10
+ for pattern in ("INFO_PATTERN", "NAME_PATTERN", "SIZE_PATTERN", "HASHSUM_PATTERN"):
try:
attr = getattr(cls, pattern)
pdict = re.search(attr, html).groupdict()
@@ -395,11 +391,11 @@ class SimpleHoster(Hoster):
if 'N' in info['pattern']:
info['name'] = replace_patterns(unquote(info['pattern']['N'].strip()),
- cls.FILE_NAME_REPLACEMENTS if hasattr(cls, "FILE_NAME_REPLACEMENTS") else cls.NAME_REPLACEMENTS) #@TODO: Remove FILE_NAME_REPLACEMENTS check in 0.4.10
+ cls.NAME_REPLACEMENTS)
if 'S' in info['pattern']:
size = replace_patterns(info['pattern']['S'] + info['pattern']['U'] if 'U' in info['pattern'] else info['pattern']['S'],
- cls.FILE_SIZE_REPLACEMENTS if hasattr(cls, "FILE_SIZE_REPLACEMENTS") else cls.SIZE_REPLACEMENTS) #@TODO: Remove FILE_SIZE_REPLACEMENTS check in 0.4.10
+ cls.SIZE_REPLACEMENTS)
info['size'] = parseFileSize(size)
elif isinstance(info['size'], basestring):
@@ -448,8 +444,7 @@ class SimpleHoster(Hoster):
else:
self.directDL = self.DIRECT_LINK
- self.pyfile.url = replace_patterns(self.pyfile.url,
- self.FILE_URL_REPLACEMENTS if hasattr(self, "FILE_URL_REPLACEMENTS") else self.URL_REPLACEMENTS) #@TODO: Remove FILE_URL_REPLACEMENTS check in 0.4.10
+ self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS)
def preload(self):