summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/DownloadThread.py2
-rw-r--r--module/PluginManager.py12
-rw-r--r--module/RequestFactory.py25
-rw-r--r--module/config/core_default.xml4
-rwxr-xr-xmodule/network/Request.py26
-rw-r--r--module/plugins/Account.py67
-rw-r--r--module/plugins/accounts/RapidshareCom.py38
-rw-r--r--module/plugins/accounts/UploadedTo.py36
-rw-r--r--module/plugins/accounts/__init__.py0
-rw-r--r--module/plugins/hoster/RapidshareCom.py30
-rw-r--r--module/plugins/hoster/UploadedTo.py19
11 files changed, 232 insertions, 27 deletions
diff --git a/module/DownloadThread.py b/module/DownloadThread.py
index fe371ceba..95e948ec9 100644
--- a/module/DownloadThread.py
+++ b/module/DownloadThread.py
@@ -161,7 +161,7 @@ class DownloadThread(Thread):
elif code == 10:
self.parent.parent.logger.debug(_("Checksum not implemented for %s") % status.filename)
if not check:
- raise Checksum(code, location)
+ raise Checksum(code, status.filename)
status.type = "finished"
diff --git a/module/PluginManager.py b/module/PluginManager.py
index 3bf9345d1..f4ecb8f88 100644
--- a/module/PluginManager.py
+++ b/module/PluginManager.py
@@ -26,6 +26,7 @@ from module.XMLConfigParser import XMLConfigParser
from module.plugins.Hoster import Hoster
from sys import version_info
+import traceback
class PluginManager():
def __init__(self, core):
@@ -49,12 +50,12 @@ class PluginManager():
self.containerPlugins = self.parse(self.core.config["plugins"]["load_container_plugins"], _("Container"))
self.hosterPlugins = self.parse(self.core.config["plugins"]["load_hoster_plugins"], _("Hoster"))
self.captchaPlugins = self.parse(self.core.config["plugins"]["load_captcha_plugins"], _("Captcha"))
- #self.accountPlugins = self.parse(self.core.config["plugins"]["load_account_plugins"], _("Account"))
+ self.accountPlugins = self.parse(self.core.config["plugins"]["load_account_plugins"], _("Account"), create=True)
self.lock.release()
self.logger.info(_("created index of plugins"))
- def parse(self, pluginStr, ptype):
+ def parse(self, pluginStr, ptype, create=False):
plugins = []
for pluginModule in pluginStr.split(","):
pluginModule = pluginModule.strip()
@@ -68,10 +69,13 @@ class PluginManager():
module = __import__(pluginModule, globals(), locals(), [pluginName], -1)
pluginClass = getattr(module, pluginName)
try:
+ if create:
+ pluginClass = pluginClass(self)
plugins.append(pluginClass)
self.logger.debug(_("%(type)s: %(name)s added") % {"name":pluginName, "type":ptype})
except:
- pass
+ if self.core.config['general']['debug_mode']:
+ traceback.print_exc()
return plugins
def getPluginFromPattern(self, urlPattern):
@@ -92,7 +96,7 @@ class PluginManager():
return plugin
return None
- def getAccountPlugin(self, name): # not implemeted yet!
+ def getAccountPlugin(self, name):
for plugin in self.accountPlugins:
if plugin.__name__ == name:
return plugin
diff --git a/module/RequestFactory.py b/module/RequestFactory.py
index 9b56f4778..803e12814 100644
--- a/module/RequestFactory.py
+++ b/module/RequestFactory.py
@@ -20,12 +20,14 @@
from threading import Lock
from module.network.Request import Request
from tempfile import NamedTemporaryFile
+import pycurl
class RequestFactory():
def __init__(self, core):
self.lock = Lock()
self.core = core
self.requests = []
+ self.cookiejars = {}
def getRequest(self, pluginName, account=None):
self.lock.acquire()
@@ -44,7 +46,9 @@ class RequestFactory():
cookieFile = th.name
th.close()
- req = Request(cookieFile)
+ req = Request(str(cookieFile))
+ s = self.getCookieJar(str(cookieFile))
+ req.setCookieJar(s)
self.requests.append((pluginName, account, req))
self.lock.release()
return req
@@ -54,3 +58,22 @@ class RequestFactory():
for req in self.requests:
req[2].clean()
self.lock.release()
+
+ def getCookieJar(self, cookieFile):
+ if self.cookiejars.has_key(cookieFile):
+ return self.cookiejars[cookieFile]
+ j = CookieJar()
+ self.cookiejars[cookieFile] = j
+ return j
+
+class CookieJar():
+ def __init__(self):
+ self.cookies = {}
+
+ def addCookies(self, clist):
+ for c in clist:
+ name = c.split("\t")[5]
+ self.cookies[name] = c
+
+ def getCookies(self):
+ return self.cookies.values()
diff --git a/module/config/core_default.xml b/module/config/core_default.xml
index 4a0145bac..abfe5c986 100644
--- a/module/config/core_default.xml
+++ b/module/config/core_default.xml
@@ -112,5 +112,9 @@
module.plugins.hoster.ZippyshareCom,
module.plugins.hoster.ZshareNet,
</load_hoster_plugins>
+ <load_account_plugins>
+ module.plugins.accounts.RapidshareCom,
+ module.plugins.accounts.UploadedTo,
+ </load_account_plugins>
</plugins>
</config>
diff --git a/module/network/Request.py b/module/network/Request.py
index 3340a74da..b66dd8a0f 100755
--- a/module/network/Request.py
+++ b/module/network/Request.py
@@ -71,6 +71,7 @@ class Request:
cookieFile = th.name
th.close()
self.cookieFile = cookieFile
+ self.cookieJar = None
self.init_curl()
@@ -92,6 +93,7 @@ class Request:
self.pycurl.setopt(pycurl.AUTOREFERER, 1)
self.pycurl.setopt(pycurl.HEADERFUNCTION, self.write_header)
self.pycurl.setopt(pycurl.BUFFERSIZE, self.bufferSize)
+ self.pycurl.setopt(pycurl.SSL_VERIFYPEER, 0)
self.pycurl.setopt(pycurl.USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.10")
@@ -100,7 +102,18 @@ class Request:
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Connection: keep-alive",
"Keep-Alive: 300"])
-
+
+ def setCookieJar(self, j):
+ self.cookieJar = j
+
+ def addCookies(self):
+ #self.cookieJar.addCookies(self.pycurl.getinfo(pycurl.INFO_COOKIELIST))
+ return
+
+ def getCookies(self):
+ #self.pycurl.setopt(pycurl.COOKIELIST, self.cookieJar.getCookies())
+ return
+
def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False):
url = str(url)
@@ -121,6 +134,7 @@ class Request:
if cookies:
self.curl_enable_cookies()
+ self.getCookies()
if post:
self.pycurl.setopt(pycurl.POSTFIELDS, post)
@@ -140,11 +154,14 @@ class Request:
self.pycurl.perform()
self.lastEffectiveURL = self.pycurl.getinfo(pycurl.EFFECTIVE_URL)
+ self.pycurl.setopt(pycurl.COOKIELIST, "FLUSH")
+ self.addCookies()
+
self.lastURL = url
header = self.get_header()
return self.get_rep()
-
+
def curl_enable_cookies(self):
self.pycurl.setopt(pycurl.COOKIEFILE, self.cookieFile)
self.pycurl.setopt(pycurl.COOKIEJAR, self.cookieFile)
@@ -208,6 +225,7 @@ class Request:
if cookies:
self.curl_enable_cookies()
+ self.getCookies()
if post:
self.pycurl.setopt(pycurl.POSTFIELDS, post)
@@ -264,6 +282,8 @@ class Request:
if not code == 23:
raise Exception, e
+ self.pycurl.setopt(pycurl.COOKIELIST, "FLUSH")
+ self.addCookies()
self.fp.close()
if self.abort:
@@ -352,7 +372,7 @@ class Request:
pass
try:
remove(self.cookieFile)
- except Exception as e:
+ except:
pass
def getURL(url):
diff --git a/module/plugins/Account.py b/module/plugins/Account.py
new file mode 100644
index 000000000..3588cd51e
--- /dev/null
+++ b/module/plugins/Account.py
@@ -0,0 +1,67 @@
+# -*- 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
+ the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+ @author: mkaay
+"""
+
+from random import randrange
+
+class Account():
+ __name__ = "Account"
+ __version__ = "0.1"
+ __type__ = "account"
+ __description__ = """Account Plugin"""
+ __author_name__ = ("mkaay")
+ __author_mail__ = ("mkaay@mkaay.de")
+
+ def __init__(self, manager):
+ self.manager = manager
+ self.core = manager.core
+ self.configParser = self.core.parser_plugins
+
+ self.accounts = []
+ self.register = {}
+ self.loadAccounts()
+
+ def login(self):
+ pass
+
+ def getAccountRequest(self, plugin):
+ account = self.getAccountData(plugin)
+ req = self.core.requestFactory.getRequest(self.__name__, account[0])
+ return req
+
+ def loadAccounts(self):
+ usernames = self.configParser.get(self.__name__, "username")
+ passwords = self.configParser.get(self.__name__, "password")
+
+ data = zip(usernames.split("\n"), passwords.split("\n"))
+ self.accounts = []
+ for acc in data:
+ t = (acc[0].strip(), acc[1].strip())
+ if t[0] and t[1]:
+ self.accounts.append(t)
+
+ self.login()
+
+ def getAccountData(self, plugin):
+ if not len(self.accounts):
+ return None
+ if not self.register.has_key(plugin):
+ account = self.accounts[randrange(0, len(self.accounts), 1)]
+ else:
+ account = self.register[plugin]
+ return account
diff --git a/module/plugins/accounts/RapidshareCom.py b/module/plugins/accounts/RapidshareCom.py
new file mode 100644
index 000000000..bd1b944b3
--- /dev/null
+++ b/module/plugins/accounts/RapidshareCom.py
@@ -0,0 +1,38 @@
+# -*- 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
+ the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+ @author: mkaay
+"""
+
+from module.plugins.Account import Account
+
+class RapidshareCom(Account):
+ __name__ = "RapidshareCom"
+ __version__ = "0.1"
+ __type__ = "account"
+ __description__ = """Rapidshare.com account plugin"""
+ __author_name__ = ("mkaay")
+ __author_mail__ = ("mkaay@mkaay.de")
+
+ def getAccountInfo(self):
+ pass
+
+ def login(self):
+ for account in self.accounts:
+ req = self.core.requestFactory.getRequest(self.__name__, account[0])
+ html = req.load("http://ssl.rapidshare.com/cgi-bin/premiumzone.cgi", get={"login":account[0], "password":account[1]}, cookies=True)
+ with open("dump%s.html" % account[0], "w") as f:
+ f.write(html)
diff --git a/module/plugins/accounts/UploadedTo.py b/module/plugins/accounts/UploadedTo.py
new file mode 100644
index 000000000..a477fa6b1
--- /dev/null
+++ b/module/plugins/accounts/UploadedTo.py
@@ -0,0 +1,36 @@
+# -*- 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
+ the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+ @author: mkaay
+"""
+
+from module.plugins.Account import Account
+
+class UploadedTo(Account):
+ __name__ = "UploadedTo"
+ __version__ = "0.1"
+ __type__ = "account"
+ __description__ = """ul.to account plugin"""
+ __author_name__ = ("mkaay")
+ __author_mail__ = ("mkaay@mkaay.de")
+
+ def getAccountInfo(self):
+ pass
+
+ def login(self):
+ for account in self.accounts:
+ req = self.core.requestFactory.getRequest(self.__name__, account[0])
+ req.load("http://uploaded.to/login", None, { "email" : account[0], "password" : account[1]}, cookies=True)
diff --git a/module/plugins/accounts/__init__.py b/module/plugins/accounts/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/module/plugins/accounts/__init__.py
diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py
index cfed29331..da38d4b3a 100644
--- a/module/plugins/hoster/RapidshareCom.py
+++ b/module/plugins/hoster/RapidshareCom.py
@@ -26,13 +26,20 @@ class RapidshareCom(Hoster):
self.no_slots = True
self.api_data = None
self.url = self.parent.url
+ self.props = {}
self.read_config()
+ self.account = None
+ self.multi_dl = False
if self.config['premium']:
- self.multi_dl = True
- self.req.canContinue = True
- else:
- self.multi_dl = False
-
+ self.account = self.parent.core.pluginManager.getAccountPlugin(self.__name__)
+ req = self.account.getAccountRequest(self)
+ if req:
+ self.req = req
+ self.multi_dl = True
+ self.req.canContinue = True
+ else:
+ self.config['premium'] = False
+
self.start_dl = False
def prepare(self, thread):
@@ -73,7 +80,7 @@ class RapidshareCom(Hoster):
"""
api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi"
api_param_file = {"sub": "checkfiles_v1", "files": "", "filenames": "", "incmd5": "1"}
- m = re.compile(self.props['pattern']).search(self.url)
+ m = re.compile(self.__pattern__).search(self.url)
if m:
api_param_file["files"] = m.group(1)
api_param_file["filenames"] = m.group(2)
@@ -122,13 +129,13 @@ class RapidshareCom(Hoster):
def download_html(self):
""" gets the url from self.parent.url saves html in self.html and parses
"""
- self.html[0] = self.load(self.url, cookies=True)
+ self.html[0] = self.load(self.url, cookies=False)
def get_wait_time(self):
"""downloads html with the important informations
"""
file_server_url = re.search(r"<form action=\"(.*?)\"", self.html[0]).group(1)
- self.html[1] = self.load(file_server_url, cookies=True, post={"dl.start": "Free"})
+ self.html[1] = self.load(file_server_url, cookies=False, post={"dl.start": "Free"})
if re.search(r"is already downloading", self.html[1]):
self.logger.info(_("Rapidshare: Already downloading, wait 30 minutes"))
@@ -171,9 +178,10 @@ class RapidshareCom(Hoster):
return self.url.split("/")[-1]
def proceed(self, url, location):
- if self.config['premium']:
- self.req.add_auth(self.config['username'], self.config['password'])
- self.download(url, location)
+ #if self.config['premium']:
+ # data = self.account.getAccountData(self)
+ # self.req.add_auth(data[0], data[1])
+ self.download(url, location, cookies=True)
def check_file(self, local_file):
if self.api_data and self.api_data["checksum"]:
diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py
index 93caa39b3..43f54c099 100644
--- a/module/plugins/hoster/UploadedTo.py
+++ b/module/plugins/hoster/UploadedTo.py
@@ -22,11 +22,17 @@ class UploadedTo(Hoster):
self.api_data = None
self.want_reconnect = False
self.read_config()
+ self.account = None
+ self.multi_dl = False
if self.config['premium']:
- self.multi_dl = True
- self.req.canContinue = True
- else:
- self.multi_dl = False
+ self.account = self.parent.core.pluginManager.getAccountPlugin(self.__name__)
+ req = self.account.getAccountRequest(self)
+ if req:
+ self.req = req
+ self.multi_dl = True
+ self.req.canContinue = True
+ else:
+ self.config['premium'] = False
self.start_dl = False
@@ -35,7 +41,7 @@ class UploadedTo(Hoster):
tries = 0
while not self.pyfile.status.url:
- self.req.clear_cookies()
+ #self.req.clear_cookies()
self.download_html()
self.pyfile.status.exists = self.file_exists()
@@ -68,7 +74,7 @@ class UploadedTo(Hoster):
def download_api_data(self):
url = self.parent.url
- match = re.compile(self.props['pattern']).search(url)
+ match = re.compile(self.__pattern__).search(url)
if match:
src = self.load("http://uploaded.to/api/file", cookies=False, get={"id": match.group(1).split("/")[0]})
if not src.find("404 Not Found"):
@@ -129,7 +135,6 @@ class UploadedTo(Hoster):
def proceed(self, url, location):
if self.config['premium']:
- self.load("http://uploaded.to/login", None, { "email" : self.config['username'], "password" : self.config['password']}, cookies=True)
self.load(url, cookies=True, just_header=True)
if self.cleanUrl(self.req.lastEffectiveURL) == self.cleanUrl(url):
self.logger.info(_("UploadedTo indirect download"))