summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-09-24 23:54:50 +0200
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-09-24 23:54:50 +0200
commitb65c4091d5c5e793d8a9df17a46657d45c3a1292 (patch)
tree40a420e5213d28634b75408059a2dc3687e461d1
parentupdate hellshare/hellspy patterns (diff)
downloadpyload-b65c4091d5c5e793d8a9df17a46657d45c3a1292.tar.xz
multihosters - closed #618, store http/ftp accounts, add uptobox.com premium
-rw-r--r--module/plugins/accounts/Ftp.py13
-rw-r--r--module/plugins/accounts/Http.py13
-rw-r--r--module/plugins/accounts/UptoboxCom.py12
-rw-r--r--module/plugins/hooks/AlldebridCom.py17
-rw-r--r--module/plugins/hooks/Checksum.py53
-rw-r--r--module/plugins/hooks/EasybytezCom.py24
-rw-r--r--module/plugins/hooks/MultishareCz.py16
-rw-r--r--module/plugins/hooks/Premium4Me.py15
-rw-r--r--module/plugins/hooks/PremiumizeMe.py19
-rw-r--r--module/plugins/hooks/RealdebridCom.py17
-rw-r--r--module/plugins/hooks/RehostTo.py2
-rw-r--r--module/plugins/hooks/ZeveraCom.py22
-rw-r--r--module/plugins/hoster/BasePlugin.py58
-rw-r--r--module/plugins/hoster/Ftp.py73
-rw-r--r--module/plugins/hoster/UptoboxCom.py20
-rw-r--r--module/plugins/internal/MultiHoster.py111
-rw-r--r--module/plugins/internal/XFSPAccount.py2
17 files changed, 304 insertions, 183 deletions
diff --git a/module/plugins/accounts/Ftp.py b/module/plugins/accounts/Ftp.py
new file mode 100644
index 000000000..9c1081662
--- /dev/null
+++ b/module/plugins/accounts/Ftp.py
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+
+from module.plugins.Account import Account
+
+class Ftp(Account):
+ __name__ = "Ftp"
+ __version__ = "0.01"
+ __type__ = "account"
+ __description__ = """Ftp dummy account plugin"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ login_timeout = info_threshold = 1000000 \ No newline at end of file
diff --git a/module/plugins/accounts/Http.py b/module/plugins/accounts/Http.py
new file mode 100644
index 000000000..805d19900
--- /dev/null
+++ b/module/plugins/accounts/Http.py
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+
+from module.plugins.Account import Account
+
+class Http(Account):
+ __name__ = "Http"
+ __version__ = "0.01"
+ __type__ = "account"
+ __description__ = """Http dummy account plugin"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ login_timeout = info_threshold = 1000000 \ No newline at end of file
diff --git a/module/plugins/accounts/UptoboxCom.py b/module/plugins/accounts/UptoboxCom.py
new file mode 100644
index 000000000..b07991817
--- /dev/null
+++ b/module/plugins/accounts/UptoboxCom.py
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+from module.plugins.internal.XFSPAccount import XFSPAccount
+
+class UptoboxCom(XFSPAccount):
+ __name__ = "UptoboxCom"
+ __version__ = "0.01"
+ __type__ = "account"
+ __description__ = """DDLStorage.com account plugin"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ MAIN_PAGE = "http://uptobox.com/" \ No newline at end of file
diff --git a/module/plugins/hooks/AlldebridCom.py b/module/plugins/hooks/AlldebridCom.py
index f9657ed8c..91a0a6e5b 100644
--- a/module/plugins/hooks/AlldebridCom.py
+++ b/module/plugins/hooks/AlldebridCom.py
@@ -7,7 +7,7 @@ from module.plugins.internal.MultiHoster import MultiHoster
class AlldebridCom(MultiHoster):
__name__ = "AlldebridCom"
- __version__ = "0.11"
+ __version__ = "0.12"
__type__ = "hook"
__config__ = [("activated", "bool", "Activated", "False"),
@@ -19,21 +19,8 @@ class AlldebridCom(MultiHoster):
__author_name__ = ("Andy, Voigt")
__author_mail__ = ("spamsales@online.de")
- replacements = [("freakshare.net", "freakshare.com")]
-
def getHoster(self):
https = "https" if self.getConfig("https") else "http"
page = getURL(https + "://www.alldebrid.com/api.php?action=get_host").replace("\"","").strip()
- hosters = set([x.strip() for x in page.split(",") if x.strip()])
-
- configMode = self.getConfig('hosterListMode')
- if configMode in ("listed", "unlisted"):
- configList = set(self.getConfig('hosterList').strip().lower().replace('|',',').replace(';',',').split(','))
- configList.discard(u'')
- if configMode == "listed":
- hosters &= configList
- else:
- hosters -= configList
-
- return list(hosters)
+ return [x.strip() for x in page.split(",") if x.strip()]
diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py
index aec4bd0d7..b290838bb 100644
--- a/module/plugins/hooks/Checksum.py
+++ b/module/plugins/hooks/Checksum.py
@@ -19,7 +19,8 @@
from __future__ import with_statement
import hashlib, zlib
from os import remove
-from os.path import getsize, isfile
+from os.path import getsize, isfile, splitext
+import re
from module.utils import save_join, fs_encode
from module.plugins.Hook import Hook
@@ -50,7 +51,7 @@ def computeChecksum(local_file, algorithm):
class Checksum(Hook):
__name__ = "Checksum"
- __version__ = "0.06"
+ __version__ = "0.07"
__description__ = "Verify downloaded file size and checksum (enable in general preferences)"
__config__ = [("activated", "bool", "Activated", True),
("action", "fail;retry;nothing", "What to do if check fails?", "retry"),
@@ -58,12 +59,19 @@ class Checksum(Hook):
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
+ methods = { 'sfv':'crc32', 'crc': 'crc32', 'hash': 'md5'}
+ regexps = { 'sfv': r'^(?P<name>[^;].+)\s+(?P<hash>[0-9A-Fa-f]{8})$',
+ 'md5': r'^(?P<name>[0-9A-Fa-f]{32}) (?P<file>.+)$',
+ 'crc': r'filename=(?P<name>.+)\nsize=(?P<size>\d+)\ncrc32=(?P<hash>[0-9A-Fa-f]{8})$',
+ 'default': r'^(?P<hash>[0-9A-Fa-f]+)\s+\*?(?P<name>.+)$' }
+
def setup(self):
- self.algorithms = sorted(getattr(hashlib, "algorithms", ("md5", "sha1", "sha224", "sha256", "sha384", "sha512")), reverse = True)
- self.algorithms.extend(["crc32", "adler32"])
-
if not self.config['general']['checksum']:
- self.logInfo("Checksum validation is disabled in general configuration")
+ self.logInfo("Checksum validation is disabled in general configuration")
+
+ self.algorithms = sorted(getattr(hashlib, "algorithms", ("md5", "sha1", "sha224", "sha256", "sha384", "sha512")), reverse = True)
+ self.algorithms.extend(["crc32", "adler32"])
+ self.formats = self.algorithms + ['sfv', 'crc', 'hash']
def downloadFinished(self, pyfile):
"""
@@ -127,4 +135,35 @@ class Checksum(Hook):
elif action == "retry":
if local_file:
remove(local_file)
- pyfile.plugin.retry(reason = msg, max_tries = self.getConfig("max_tries")) \ No newline at end of file
+ pyfile.plugin.retry(reason = msg, max_tries = self.getConfig("max_tries"))
+
+
+ def packageFinished(self, pypack):
+ download_folder = save_join(self.config['general']['download_folder'], pypack.folder, "")
+
+ for link in pypack.getChildren().itervalues():
+ file_type = splitext(link["name"])[1][1:].lower()
+ #self.logDebug(link, file_type)
+
+ if file_type not in self.formats:
+ continue
+
+ hash_file = fs_encode(save_join(download_folder, link["name"]))
+ if not isfile(hash_file):
+ self.logWarning("File not found: %s" % link["name"])
+ continue
+
+ with open(hash_file) as f:
+ text = f.read()
+
+ for m in re.finditer(self.regexps.get(file_type, self.regexps['default']), text):
+ data = m.groupdict()
+ self.logDebug(link["name"], data)
+
+ local_file = fs_encode(save_join(download_folder, data["name"]))
+ algorithm = self.methods.get(file_type, file_type)
+ checksum = computeChecksum(local_file, algorithm)
+ if checksum == data["hash"]:
+ self.logInfo('File integrity of "%s" verified by %s checksum (%s).' % (data["name"], algorithm, checksum))
+ else:
+ self.logWarning("%s checksum for file %s does not match (%s != %s)" % (algorithm, data["name"], checksum, data["hash"])) \ No newline at end of file
diff --git a/module/plugins/hooks/EasybytezCom.py b/module/plugins/hooks/EasybytezCom.py
index 21a988555..22b9050b4 100644
--- a/module/plugins/hooks/EasybytezCom.py
+++ b/module/plugins/hooks/EasybytezCom.py
@@ -11,7 +11,7 @@ def getConfigSet(option):
class EasybytezCom(MultiHoster):
__name__ = "EasybytezCom"
- __version__ = "0.02"
+ __version__ = "0.03"
__type__ = "hook"
__config__ = [("activated", "bool", "Activated", "False"),
("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"),
@@ -21,16 +21,16 @@ class EasybytezCom(MultiHoster):
__author_mail__ = ("zoidberg@mujmail.cz")
def getHoster(self):
-
- hoster = set(['2shared.com', 'easy-share.com', 'filefactory.com', 'fileserve.com', 'filesonic.com', 'hotfile.com', 'mediafire.com', 'megaupload.com', 'netload.in', 'rapidshare.com', 'uploading.com', 'wupload.com', 'oron.com', 'uploadstation.com', 'ul.to', 'uploaded.to'])
+ self.account = self.core.accountManager.getAccountPlugin(self.__name__)
+ user = self.account.selectAccount()[0]
- configMode = self.getConfig('hosterListMode')
- if configMode in ("listed", "unlisted"):
- configList = set(self.getConfig('hosterList').strip().lower().replace('|',',').replace(';',',').split(','))
- configList.discard(u'')
- if configMode == "listed":
- hoster &= configList
- else:
- hoster -= configList
+ try:
+ req = self.account.getAccountRequest(user)
+ page = req.load("http://www.easybytez.com")
- return list(hoster) \ No newline at end of file
+ found = re.search(r'</textarea>\s*Supported sites:(.*)', page)
+ return found.group(1).split(',')
+ except Exception, e:
+ self.logDebug(e)
+ self.logWarning("Unable to load supported hoster list, using last known")
+ return ['bitshare.com', 'crocko.com', 'ddlstorage.com', 'depositfiles.com', 'extabit.com', 'hotfile.com', 'mediafire.com', 'netload.in', 'rapidgator.net', 'rapidshare.com', 'uploading.com', 'uload.to', 'uploaded.to'] \ No newline at end of file
diff --git a/module/plugins/hooks/MultishareCz.py b/module/plugins/hooks/MultishareCz.py
index a00c6cb2b..f8fa9290a 100644
--- a/module/plugins/hooks/MultishareCz.py
+++ b/module/plugins/hooks/MultishareCz.py
@@ -11,7 +11,7 @@ def getConfigSet(option):
class MultishareCz(MultiHoster):
__name__ = "MultishareCz"
- __version__ = "0.03"
+ __version__ = "0.04"
__type__ = "hook"
__config__ = [("activated", "bool", "Activated", "False"),
("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"),
@@ -20,21 +20,9 @@ class MultishareCz(MultiHoster):
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
- replacements = [("share-rapid.cz", "sharerapid.com")]
HOSTER_PATTERN = r'<img class="logo-shareserveru"[^>]*?alt="([^"]+)"></td>\s*<td class="stav">[^>]*?alt="OK"'
def getHoster(self):
page = getURL("http://www.multishare.cz/monitoring/")
- hosters = set(h.lower().strip() for h in re.findall(self.HOSTER_PATTERN, page))
-
- configMode = self.getConfig('hosterListMode')
- if configMode in ("listed", "unlisted"):
- configList = set(self.getConfig('hosterList').strip().lower().replace('|',',').replace(';',',').split(','))
- configList.discard(u'')
- if configMode == "listed":
- hosters &= configList
- elif configMode == "unlisted":
- hosters -= configList
-
- return list(hosters) \ No newline at end of file
+ return re.findall(self.HOSTER_PATTERN, page) \ No newline at end of file
diff --git a/module/plugins/hooks/Premium4Me.py b/module/plugins/hooks/Premium4Me.py
index fc3ce2343..b49eb41a9 100644
--- a/module/plugins/hooks/Premium4Me.py
+++ b/module/plugins/hooks/Premium4Me.py
@@ -15,23 +15,10 @@ class Premium4Me(MultiHoster):
__author_name__ = ("RaNaN", "zoidberg")
__author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz")
- replacements = [("freakshare.net", "freakshare.com")]
-
def getHoster(self):
page = getURL("http://premium4.me/api/hosters.php?authcode=%s" % self.account.authcode)
- hosters = set([x.strip() for x in page.replace("\"", "").split(";")])
-
- configMode = self.getConfig('hosterListMode')
- if configMode in ("listed", "unlisted"):
- configList = set(self.getConfig('hosterList').strip().lower().replace(',','|').split('|'))
- configList.discard(u'')
- if configMode == "listed":
- hosters &= configList
- elif configMode == "unlisted":
- hosters -= configList
-
- return list(hosters)
+ return [x.strip() for x in page.replace("\"", "").split(";")]
def coreReady(self):
diff --git a/module/plugins/hooks/PremiumizeMe.py b/module/plugins/hooks/PremiumizeMe.py
index 3825e9219..37905c23e 100644
--- a/module/plugins/hooks/PremiumizeMe.py
+++ b/module/plugins/hooks/PremiumizeMe.py
@@ -5,7 +5,7 @@ from module.network.RequestFactory import getURL
class PremiumizeMe(MultiHoster):
__name__ = "PremiumizeMe"
- __version__ = "0.1"
+ __version__ = "0.11"
__type__ = "hook"
__description__ = """Premiumize.Me hook plugin"""
@@ -16,8 +16,6 @@ class PremiumizeMe(MultiHoster):
__author_name__ = ("Florian Franzen")
__author_mail__ = ("FlorianFranzen@gmail.com")
- replacements = [("freakshare.net", "freakshare.com")]
-
interval = 0 # Disable periodic calls, we dont use them anyway
def getHoster(self):
@@ -38,20 +36,7 @@ class PremiumizeMe(MultiHoster):
return []
# Extract hosters from json file
- hosters = set(data['result']['hosterlist'])
-
-
- # Read config to check if certain hosters should not be handled
- configMode = self.getConfig('hosterListMode')
- if configMode in ("listed", "unlisted"):
- configList = set(self.getConfig('hosterList').strip().lower().replace('|',',').replace(';',',').split(','))
- configList.discard(u'')
- if configMode == "listed":
- hosters &= configList
- else:
- hosters -= configList
-
- return list(hosters)
+ return data['result']['hosterlist']
def coreReady(self):
# Get account plugin and check if there is a valid account available
diff --git a/module/plugins/hooks/RealdebridCom.py b/module/plugins/hooks/RealdebridCom.py
index bd3179673..0f06d14bc 100644
--- a/module/plugins/hooks/RealdebridCom.py
+++ b/module/plugins/hooks/RealdebridCom.py
@@ -5,7 +5,7 @@ from module.plugins.internal.MultiHoster import MultiHoster
class RealdebridCom(MultiHoster):
__name__ = "RealdebridCom"
- __version__ = "0.41"
+ __version__ = "0.42"
__type__ = "hook"
__config__ = [("activated", "bool", "Activated", "False"),
@@ -16,21 +16,8 @@ class RealdebridCom(MultiHoster):
__author_name__ = ("Devirex, Hazzard")
__author_mail__ = ("naibaf_11@yahoo.de")
- replacements = [("freakshare.net", "freakshare.com")]
-
def getHoster(self):
https = "https" if self.getConfig("https") else "http"
page = getURL(https + "://real-debrid.com/api/hosters.php").replace("\"","").strip()
- hosters = set([x.strip() for x in page.split(",") if x.strip()])
-
- configMode = self.getConfig('hosterListMode')
- if configMode in ("listed", "unlisted"):
- configList = set(self.getConfig('hosterList').strip().lower().replace('|',',').replace(';',',').split(','))
- configList.discard(u'')
- if configMode == "listed":
- hosters &= configList
- else:
- hosters -= configList
-
- return list(hosters)
+ return [x.strip() for x in page.split(",") if x.strip()]
diff --git a/module/plugins/hooks/RehostTo.py b/module/plugins/hooks/RehostTo.py
index b16987f5c..8903bd07f 100644
--- a/module/plugins/hooks/RehostTo.py
+++ b/module/plugins/hooks/RehostTo.py
@@ -14,8 +14,6 @@ class RehostTo(MultiHoster):
__author_name__ = ("RaNaN")
__author_mail__ = ("RaNaN@pyload.org")
- replacements = [("freakshare.net", "freakshare.com")]
-
def getHoster(self):
page = getURL("http://rehost.to/api.php?cmd=get_supported_och_dl&long_ses=%s" % self.long_ses)
diff --git a/module/plugins/hooks/ZeveraCom.py b/module/plugins/hooks/ZeveraCom.py
index 46c752c21..cadf60069 100644
--- a/module/plugins/hooks/ZeveraCom.py
+++ b/module/plugins/hooks/ZeveraCom.py
@@ -5,29 +5,15 @@ from module.plugins.internal.MultiHoster import MultiHoster
class ZeveraCom(MultiHoster):
__name__ = "ZeveraCom"
- __version__ = "0.01"
+ __version__ = "0.02"
__type__ = "hook"
__config__ = [("activated", "bool", "Activated", "False"),
("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"),
("hosterList", "str", "Hoster list (comma separated)", "")]
__description__ = """Real-Debrid.com hook plugin"""
- __author_name__ = ("Devirex, Hazzard")
- __author_mail__ = ("naibaf_11@yahoo.de")
-
- replacements = [("freakshare.net", "freakshare.com"), ("2shared.com", "twoshared.com"), ("4shared.com", "fourshared.com"),
- ("easy-share.com", "crocko.com"), ("hellshare.com", "hellshare.cz")]
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
def getHoster(self):
page = getURL("http://www.zevera.com/jDownloader.ashx?cmd=gethosters")
- hosters = set([x.strip() for x in page.replace("\"", "").split(",")])
-
- configMode = self.getConfig('hosterListMode')
- if configMode in ("listed", "unlisted"):
- configList = set(self.getConfig('hosterList').strip().lower().replace('|',',').replace(';',',').split(','))
- configList.discard(u'')
- if configMode == "listed":
- hosters &= configList
- else:
- hosters -= configList
-
- return list(hosters) \ No newline at end of file
+ return [x.strip() for x in page.replace("\"", "").split(",")] \ No newline at end of file
diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py
index 1ac33931f..14dfbba62 100644
--- a/module/plugins/hoster/BasePlugin.py
+++ b/module/plugins/hoster/BasePlugin.py
@@ -12,10 +12,10 @@ class BasePlugin(Hoster):
__name__ = "BasePlugin"
__type__ = "hoster"
__pattern__ = r"^unmatchable$"
- __version__ = "0.151"
+ __version__ = "0.16"
__description__ = """Base Plugin when any other didnt fit"""
- __author_name__ = ("RaNaN", 'hagg')
- __author_mail__ = ("RaNaN@pyload.org", '')
+ __author_name__ = ("RaNaN")
+ __author_mail__ = ("RaNaN@pyload.org")
def setup(self):
self.chunkLimit = -1
@@ -47,15 +47,22 @@ class BasePlugin(Hoster):
except BadHeader, e:
if e.code in (401, 403):
self.logDebug("Auth required")
-
- pwd = pyfile.package().password.strip()
- if ":" not in pwd:
- self.fail(_("Authorization required (username:password)"))
-
- self.req.addAuth(pwd)
+
+ servers = [ x['login'] for x in core.accountManager.getAccountPlugin('Http').getAllAccounts() ]
+ server = urlparse(pyfile.url).netloc
+
+ if server in servers:
+ self.logDebug("Logging on to %s" % server)
+ self.req.addAuth(self.account.accounts[server]["password"])
+ else:
+ for pwd in pyfile.package().password.splitlines()
+ if ":" in pwd:
+ self.req.addAuth(pwd.strip())
+ break
+ else:
+ self.fail(_("Authorization required (username:password)"))
+
self.downloadFile(pyfile)
- elif e.code == 404:
- self.offline()
else:
raise
@@ -64,18 +71,21 @@ class BasePlugin(Hoster):
def downloadFile(self, pyfile):
- header = self.load(pyfile.url, just_header = True)
- #self.logDebug(header)
-
- # self.load does not raise a BadHeader on 404 responses, do it here
- if header.has_key('code') and header['code'] == 404:
- raise BadHeader(404)
-
- if 'location' in header:
- self.logDebug("Location: " + header['location'])
- url = unquote(header['location'])
- else:
- url = pyfile.url
+ url = pyfile.url
+
+ for i in range(5):
+ header = self.load(pyfile.url, just_header = True)
+
+ # self.load does not raise a BadHeader on 404 responses, do it here
+ if header.has_key('code') and header['code'] == 404:
+ raise BadHeader(404)
+
+ if 'location' in header:
+ self.logDebug("Location: " + header['location'])
+ url = unquote(header['location'])
+ self.logDebug("URL: %s" % url, html_unescape(unquote(urlparse(url).path.split("/")[-1])))
+ else:
+ break
name = html_unescape(unquote(urlparse(url).path.split("/")[-1]))
@@ -92,4 +102,4 @@ class BasePlugin(Hoster):
if not name: name = url
pyfile.name = name
self.logDebug("Filename: %s" % pyfile.name)
- self.download(url, disposition=True)
+ self.download(url, disposition=True) \ No newline at end of file
diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py
index 7c2af85ed..3bda3b32e 100644
--- a/module/plugins/hoster/Ftp.py
+++ b/module/plugins/hoster/Ftp.py
@@ -17,24 +17,75 @@
@author: jeix
@author: mkaay
"""
+from urlparse import urlparse, urljoin
+from urllib import quote, unquote
+import pycurl, re
from module.plugins.Hoster import Hoster
-
+from module.network.HTTPRequest import BadHeader
class Ftp(Hoster):
__name__ = "Ftp"
- __version__ = "0.31"
+ __version__ = "0.41"
__pattern__ = r'(ftps?|sftp)://(.*?:.*?@)?.*?/.*' # ftp://user:password@ftp.server.org/path/to/file
__type__ = "hoster"
__description__ = """A Plugin that allows you to download from an from an ftp directory"""
- __author_name__ = ("jeix", "mkaay")
- __author_mail__ = ("jeix@hasnomail.com", "mkaay@mkaay.de")
+ __author_name__ = ("jeix", "mkaay", "zoidberg")
+ __author_mail__ = ("jeix@hasnomail.com", "mkaay@mkaay.de", "zoidberg@mujmail.cz")
- def process(self, pyfile):
- pyfile.name = self.pyfile.url.rpartition('/')[2]
-
+ def setup(self):
self.chunkLimit = -1
- self.resumeDownload = True
-
- self.download(pyfile.url)
-
+ self.resumeDownload = True
+
+ def process(self, pyfile):
+ parsed_url = urlparse(pyfile.url)
+ netloc = parsed_url.netloc
+
+ pyfile.name = parsed_url.path.rpartition('/')[2]
+ try:
+ pyfile.name = unquote(str(pyfile.name)).decode('utf8')
+ except:
+ pass
+
+ if not "@" in netloc:
+ servers = [ x['login'] for x in self.account.getAllAccounts() ] if self.account else []
+
+ if netloc in servers:
+ self.logDebug("Logging on to %s" % netloc)
+ self.req.addAuth(self.account.accounts[netloc]["password"])
+ else:
+ for pwd in pyfile.package().password.splitlines():
+ if ":" in pwd:
+ self.req.addAuth(pwd.strip())
+ break
+
+ self.req.http.c.setopt(pycurl.NOBODY, 1)
+
+ try:
+ response = self.load(pyfile.url)
+ except pycurl.error, e:
+ self.fail("Error %d: %s" % e.args)
+
+ self.req.http.c.setopt(pycurl.NOBODY, 0)
+ self.logDebug(self.req.http.header)
+
+ found = re.search(r"Content-Length:\s*(\d+)", response)
+ if found:
+ pyfile.size = int(found.group(1))
+ self.download(pyfile.url)
+ else:
+ #Naive ftp directory listing
+ if re.search(r'^25\d.*?"', self.req.http.header, re.M):
+ pyfile.url = pyfile.url.rstrip('/')
+ pkgname = "/".join((pyfile.package().name,urlparse(pyfile.url).path.rpartition('/')[2]))
+ pyfile.url += '/'
+ self.req.http.c.setopt(48, 1) # CURLOPT_DIRLISTONLY
+ response = self.load(pyfile.url, decode = False)
+ links = [ pyfile.url + quote(x) for x in response.splitlines() ]
+ self.logDebug("LINKS", links)
+ self.core.api.addPackage(pkgname, links, 1)
+ #self.core.files.addLinks(links, pyfile.package().id)
+ else:
+ self.fail("Unexpected server response")
+
+ \ No newline at end of file
diff --git a/module/plugins/hoster/UptoboxCom.py b/module/plugins/hoster/UptoboxCom.py
new file mode 100644
index 000000000..ae2f14a14
--- /dev/null
+++ b/module/plugins/hoster/UptoboxCom.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo
+
+class UptoboxCom(XFileSharingPro):
+ __name__ = "UptoboxCom"
+ __type__ = "hoster"
+ __pattern__ = r"http://(?:\w*\.)*?uptobox.com/\w{12}"
+ __version__ = "0.06"
+ __description__ = """Uptobox.com hoster plugin"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ FILE_INFO_PATTERN = r'<h2>\s*Download File\s*<span[^>]*>(?P<N>[^>]+)</span></h2>\s*[^\(]*\((?P<S>[^\)]+)\)</h2>'
+ HOSTER_NAME = "uptobox.com"
+
+ def setup(self):
+ self.resumeDownload = self.multiDL = self.premium
+ self.chunkLimit = 1
+
+getInfo = create_getInfo(UptoboxCom) \ No newline at end of file
diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py
index e9e321c06..0f25eb8d2 100644
--- a/module/plugins/internal/MultiHoster.py
+++ b/module/plugins/internal/MultiHoster.py
@@ -11,32 +11,54 @@ class MultiHoster(Hook):
Generic MultiHoster plugin
"""
- __version__ = "0.12"
+ __version__ = "0.15"
interval = 0
hosters = []
- replacements = []
+ 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"),
+ ("ul.to","uploaded.to"), ("uploaded.net","uploaded.to")]
supported = []
ignored = []
+ new_supported = []
def getHosterCached(self):
if not self.hosters:
try:
- self.hosters = [x.strip() for x in self.getHoster()]
- self.hosters = filter(lambda x: x and x not in self.ignored, self.hosters)
+ hosterSet = self.toHosterSet(self.getHoster()) - set(self.ignored)
except Exception, e:
self.logError("%s" % str(e))
return []
-
- for rep in self.replacements:
- if rep[0] in self.hosters:
- self.hosters.remove(rep[0])
- if rep[1] not in self.hosters:
- self.hosters.append(rep[1])
+
+ try:
+ configMode = self.getConfig('hosterListMode')
+ if configMode in ("listed", "unlisted"):
+ configSet = self.toHosterSet(self.getConfig('hosterList').replace('|',',').replace(';',',').split(','))
+
+ if configMode == "listed":
+ hosterSet &= configSet
+ else:
+ hosterSet -= configSet
+
+ except Exception, e:
+ self.logError("%s" % str(e))
+
+ self.hosters = list(hosterSet)
return self.hosters
-
+
+ def toHosterSet(self, hosters):
+ hosters = set((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'')
+ return hosters
def getHoster(self):
"""Load list of supported hoster
@@ -49,23 +71,29 @@ class MultiHoster(Hook):
pluginMap = {}
for name in self.core.pluginManager.hosterPlugins.keys():
pluginMap[name.lower()] = name
-
- new_supported = []
+
+ accountList = [ name.lower() for name, data in self.core.accountManager.accounts.items() if data ]
+ excludedList = []
for hoster in self.getHosterCached():
name = remove_chars(hoster.lower(), "-.")
- if name in pluginMap:
- self.supported.append(pluginMap[name])
+ if name in accountList:
+ excludedList.append(hoster)
else:
- new_supported.append(hoster)
+ if name in pluginMap:
+ self.supported.append(pluginMap[name])
+ else:
+ self.new_supported.append(hoster)
- if not self.supported and not new_supported:
+ if not self.supported and not self.new_supported:
self.logError(_("No Hoster loaded"))
return
module = self.core.pluginManager.getPlugin(self.__name__)
klass = getattr(module, self.__name__)
+
+ print module, klass
# inject plugin plugin
self.logDebug("Overwritten Hosters: %s" % ", ".join(sorted(self.supported)))
@@ -73,25 +101,42 @@ class MultiHoster(Hook):
dict = self.core.pluginManager.hosterPlugins[hoster]
dict["new_module"] = module
dict["new_name"] = self.__name__
+
+ if excludedList:
+ self.logInfo("The following hosters were not overwritten - account exists: %s" % ", ".join(sorted(excludedList)))
+
+ if self.new_supported:
+ self.logDebug("New Hosters: %s" % ", ".join(sorted(self.new_supported)))
+
+ # create new regexp
+ if not klass.__pattern__:
+ regexp = r".*(%s).*" % "|".join([x.replace(".", "\\.") for x in new_supported])
+ else:
+ regexp = r"%s|.*(%s).*" % ([klass.__pattern__], "|".join([x.replace(".", "\\.") for x in self.new_supported]))
+ self.logDebug("Regexp: %s" % regexp)
+
+ dict = self.core.pluginManager.hosterPlugins[self.__name__]
+ dict["pattern"] = regexp
+ dict["re"] = re.compile(regexp)
- self.logDebug("New Hosters: %s" % ", ".join(sorted(new_supported)))
-
- # create new regexp
- if not klass.__pattern__:
- regexp = r".*(%s).*" % "|".join([x.replace(".", "\\.") for x in new_supported])
- else:
- regexp = r".*(%s).*" % "|".join([klass.__pattern__] + [x.replace(".", "\\.") for x in new_supported])
- dict = self.core.pluginManager.hosterPlugins[self.__name__]
- dict["pattern"] = regexp
- dict["re"] = re.compile(regexp)
+ def unloadHoster(self, hoster):
+ dict = self.core.pluginManager.hosterPlugins[hoster]
+ self.logDebug(dict)
+ if "module" in dict:
+ del dict["module"]
+ if "new_module" in dict:
+ del dict["new_module"]
+ del dict["new_name"]
def unload(self):
for hoster in self.supported:
- dict = self.core.pluginManager.hosterPlugins[hoster]
- if "module" in dict:
- del dict["module"]
-
- del dict["new_module"]
- del dict["new_name"]
+ self.unloadHoster(hoster)
+
+ def downloadFailed(self, pyfile):
+ hdict = self.core.pluginManager.hosterPlugins[pyfile.pluginname]
+ self.logDebug("Unload MultiHoster", pyfile.pluginname, hdict)
+ if "new_name" in hdict and hdict['new_name'] == self.__name__:
+ self.unloadHoster(pyfile.pluginname)
+ pyfile.setStatus("queued") \ No newline at end of file
diff --git a/module/plugins/internal/XFSPAccount.py b/module/plugins/internal/XFSPAccount.py
index ad25ad2c8..8333c7265 100644
--- a/module/plugins/internal/XFSPAccount.py
+++ b/module/plugins/internal/XFSPAccount.py
@@ -33,7 +33,7 @@ class XFSPAccount(Account):
MAIN_PAGE = None
- VALID_UNTIL_PATTERN = r'>Premium account expire:</TD><TD><b>([^<]+)</b>'
+ VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:</TD><TD><b>([^<]+)</b>'
TRAFFIC_LEFT_PATTERN = r'>Traffic available today:</TD><TD><b>([^<]+)</b>'
def loadAccountInfo(self, user, req):