diff options
-rw-r--r-- | module/PluginThread.py | 6 | ||||
-rw-r--r-- | module/database/DatabaseBackend.py | 16 | ||||
-rw-r--r-- | module/database/FileDatabase.py | 4 | ||||
-rw-r--r-- | module/plugins/accounts/ShareCx.py | 47 | ||||
-rw-r--r-- | module/plugins/hoster/ShareCx.py | 30 | ||||
-rw-r--r-- | module/plugins/hoster/UploadedTo.py | 12 |
6 files changed, 87 insertions, 28 deletions
diff --git a/module/PluginThread.py b/module/PluginThread.py index 391844a62..c91ca1121 100644 --- a/module/PluginThread.py +++ b/module/PluginThread.py @@ -181,7 +181,11 @@ class DownloadThread(PluginThread): continue except Abort: - self.m.log.info(_("Download aborted: %s") % pyfile.name) + try: + self.m.log.info(_("Download aborted: %s") % pyfile.name) + except : + pass + pyfile.setStatus("aborted") self.clean(pyfile) diff --git a/module/database/DatabaseBackend.py b/module/database/DatabaseBackend.py index 02e09b3b3..9e9e73e43 100644 --- a/module/database/DatabaseBackend.py +++ b/module/database/DatabaseBackend.py @@ -16,8 +16,6 @@ @author: RaNaN @author: mkaay """ - -from threading import Lock from threading import Thread from threading import Event from os import remove @@ -97,7 +95,11 @@ class DatabaseJob(): try: self.result = self.f(*self.args, **self.kwargs) except Exception, e: - print "Database Error @", self.f.__name__, self.args[1:], self.kwargs, e + try: + print "Database Error @", self.f.__name__, self.args[1:], self.kwargs, e + except: + pass + print_exc() self.exception = e finally: @@ -147,10 +149,6 @@ class DatabaseBackend(Thread): self.conn.close() break j.processJob() - if j.exception: - self.conn.rollback() - else: - self.conn.commit() @style.queue def shutdown(self): @@ -259,6 +257,10 @@ class DatabaseBackend(Thread): @style.async def commit(self): self.conn.commit() + + @style.queue + def syncSave(self): + self.conn.commit() @style.async def rollback(self): diff --git a/module/database/FileDatabase.py b/module/database/FileDatabase.py index 528bf666d..5c976eda4 100644 --- a/module/database/FileDatabase.py +++ b/module/database/FileDatabase.py @@ -756,10 +756,6 @@ class FileMethods(): def restartPackage(self, id): self.c.execute('UPDATE links SET status=3 WHERE package=?', (str(id),)) - @style.async - def syncSave(self): - self.commit() - @style.queue def getPackage(self, id): """return package instance from id""" diff --git a/module/plugins/accounts/ShareCx.py b/module/plugins/accounts/ShareCx.py new file mode 100644 index 000000000..c4aac257f --- /dev/null +++ b/module/plugins/accounts/ShareCx.py @@ -0,0 +1,47 @@ +# -*- 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: RaNaN +""" + +import re +from time import strptime, mktime + +from module.plugins.Account import Account + +class ShareCx(Account): + __name__ = "ShareCx" + __version__ = "0.1" + __type__ = "account" + __description__ = """share.cx account plugin""" + __author_name__ = ("RaNaN") + __author_mail__ = ("RaNaN@pyload.org") + + def loadAccountInfo(self, user, req): + page = req.load("http://www.share.cx/myaccount") + + valid = re.search("<TR><TD>Valid till</TD><TD>([0-9\.]+)</TD></TR>", page, re.IGNORECASE).group(1) + valid = int(mktime(strptime(valid, "%d.%m.%Y"))) + + return {"trafficleft": -1, "validuntil" : valid} + + + def login(self, user, data,req): + req.cj.setCookie("share.cx", "lang", "english") + page = req.load("http://www.share.cx", None, { "redirect" : "http://www.share.cx/", "login": user, "password" : data['password'], "op" : "login"}) + + if "Incorrect Login or Password" in page: + self.wrongPassword()
\ No newline at end of file diff --git a/module/plugins/hoster/ShareCx.py b/module/plugins/hoster/ShareCx.py index d1a78f0dc..8381c7909 100644 --- a/module/plugins/hoster/ShareCx.py +++ b/module/plugins/hoster/ShareCx.py @@ -36,15 +36,18 @@ class ShareCx(Hoster): __name__ = "ShareCx"
__type__ = "hoster"
__pattern__ = r"http://[\w\.]*?share\.cx/(files|videos)/\d+"
- __version__ = "0.2"
+ __version__ = "0.3"
__description__ = """Share.cx Download Hoster"""
__author_name__ = ("jeix")
__author_mail__ = ("jeix@hasnomail.de")
-
-
- def setup(self):
- self.multiDL = False
-
+
+
+ def init(self):
+ if self.account:
+ self.multiDL = True
+ else:
+ self.multiDL = False
+
def process(self, pyfile):
self.pyfile = pyfile
@@ -53,13 +56,16 @@ class ShareCx(Hoster): self.offline()
pyfile.name = self.get_file_name()
- self.doDownload()
+ if self.account:
+ self.handlePremium()
+ else:
+ self.handleFree()
def download_html(self):
- self.html = self.load(self.pyfile.url)
+ self.html = self.load(self.pyfile.url, cookies=False)
- def doDownload(self):
+ def handleFree(self):
""" returns the absolute downloadable filepath
"""
if self.html is None:
@@ -145,7 +151,7 @@ class ShareCx(Hoster): if self.html is None:
self.download_html()
- name = re.search(r'<title>Download: (.*?) at Share.cx</title>', self.html).group(1)
+ name = re.search(r'/></span>([^/]+)</h3>', self.html).group(1)
return name
def file_exists(self):
@@ -158,5 +164,7 @@ class ShareCx(Hoster): return False
return True
-
+
+ def handlePremium(self):
+ self.download(self.pyfile.url)
diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index 2dff549a4..311170c49 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -35,7 +35,7 @@ class UploadedTo(Hoster): __name__ = "UploadedTo" __type__ = "hoster" __pattern__ = r"http://(?:www\.)?u(?:p)?l(?:oaded)?\.to/(?:file/|\?id=)?(.+)" - __version__ = "0.4" + __version__ = "0.41" __description__ = """Uploaded.to Download Hoster""" __author_name__ = ("spoob", "mkaay") __author_mail__ = ("spoob@pyload.org", "mkaay@mkaay.de") @@ -45,11 +45,14 @@ class UploadedTo(Hoster): self.html = None self.data = {} self.multiDL = False + self.resumeDownload = False self.url = False if self.account: - self.multiDL = True - self.chunkLimit = -1 - self.resumeDownload = True + self.premium = self.account.getAccountInfo(self.user) + if self.premium: + self.multiDL = True + self.chunkLimit = -1 + self.resumeDownload = True self.pyfile.url = self.cleanUrl(self.pyfile.url) @@ -67,7 +70,6 @@ class UploadedTo(Hoster): pyfile.name = self.data["name"] # self.pyfile.name = self.get_file_name() - self.premium = self.account.getAccountInfo(self.user) if self.account and self.premium: self.handlePremium() |