diff options
-rw-r--r-- | module/FileDatabase.py | 5 | ||||
-rw-r--r-- | module/plugins/Crypter.py | 14 | ||||
-rw-r--r-- | module/plugins/accounts/FileserveCom.py | 56 | ||||
-rw-r--r-- | module/plugins/hooks/UnRar.py | 8 | ||||
-rw-r--r-- | module/plugins/hoster/Ftp.py | 20 |
5 files changed, 79 insertions, 24 deletions
diff --git a/module/FileDatabase.py b/module/FileDatabase.py index a71336e07..cbb72b416 100644 --- a/module/FileDatabase.py +++ b/module/FileDatabase.py @@ -189,6 +189,7 @@ class FileHandler: """deletes links""" f = self.getFile(id) + pid = f.packageid if not f: return None @@ -205,6 +206,10 @@ class FileHandler: self.db.deleteLink(f) self.core.pullManager.addEvent(e) + + p = self.getPackage(pid) + if len(p.getChildren()) == 0: + p.delete() #---------------------------------------------------------------------- def releaseLink(self, id): diff --git a/module/plugins/Crypter.py b/module/plugins/Crypter.py index 77dc34990..2b0ba1460 100644 --- a/module/plugins/Crypter.py +++ b/module/plugins/Crypter.py @@ -50,19 +50,9 @@ class Crypter(Plugin): #---------------------------------------------------------------------- def createPackages(self): """ create new packages from self.packages """ - for i, pack in enumerate(self.packages): + for pack in self.packages: self.log.info(_("Parsed package %s with %s links") % (pack[0], len(pack[1]) ) ) - if i == 0: - # replace current package with new one - self.pyfile.package().name = pack[0] - self.pyfile.package().folder = pack[2] if self.core.config["general"]["folder_per_package"] else "" - self.pyfile.package().notifyChange() - - self.core.files.addLinks(pack[1], self.pyfile.package().id) - - self.pyfile.package().sync() - else: - self.core.server_methods.add_package(pack[0], pack[1]) + self.core.server_methods.add_package(pack[0], pack[1]) diff --git a/module/plugins/accounts/FileserveCom.py b/module/plugins/accounts/FileserveCom.py new file mode 100644 index 000000000..2862e5ab0 --- /dev/null +++ b/module/plugins/accounts/FileserveCom.py @@ -0,0 +1,56 @@ +# -*- 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 +import re +from time import strptime, mktime +import hashlib + +class FileserveCom(Account): + __name__ = "FileserveCom" + __version__ = "0.1" + __type__ = "account" + __description__ = """fileserve.com account plugin""" + __author_name__ = ("mkaay") + __author_mail__ = ("mkaay@mkaay.de") + + def getAccountInfo(self, user): + req = self.core.requestFactory.getRequest(self.__name__, user) + + src = req.load("http://fileserve.com/dashboard.php", cookies=True) + + out = Account.getAccountInfo(self, user) + + m = re.search(r"<td><h4>Premium Until</h4></th> <td><h5>(.*?) E(.)T</h5></td>", src) + if m: + zone = -5 if m.group(2) == "S" else -4 + validuntil = int(mktime(strptime(m.group(1), "%d %B %Y"))) + 24*3600 + (zone*3600) + tmp = {"validuntil":validuntil, "trafficleft":-1} + else: + tmp = {"trafficleft":-1} + out.update(tmp) + return out + + def login(self, user, data): + req = self.core.requestFactory.getRequest(self.__name__, user) + req.load("http://fileserve.com/login.php", + post={"loginUserName": user, "loginUserPassword": data["password"], + "autoLogin": "on", "loginFormSubmit": "Login"}, cookies=True) + req.load("http://fileserve.com/dashboard.php", cookies=True) + diff --git a/module/plugins/hooks/UnRar.py b/module/plugins/hooks/UnRar.py index 46e7874d3..71a1ce96a 100644 --- a/module/plugins/hooks/UnRar.py +++ b/module/plugins/hooks/UnRar.py @@ -108,20 +108,28 @@ class UnRar(Hook): try: success = u.crackPassword(passwords=self.passwords, statusFunction=s, overwrite=True, destination=folder, fullPath=self.getConfig("fullpath")) except WrongPasswordError: + self.core.log.info("Unrar of %s failed (wrong password)" % fname) continue except CommandError, e: if re.search("Cannot find volume", e.stderr): + self.core.log.info("Unrar of %s failed (missing volume)" % fname) continue try: if e.getExitCode() == 1 and len(u.listContent(u.getPassword())) == 1: + self.core.log.debug("Unrar of %s ok" % fname) self.removeFiles(pack, fname) except: + self.core.log.info("Unrar of %s failed" % fname) continue except UnknownError: + self.core.log.info("Unrar of %s failed" % fname) continue else: if success: + self.core.log.debug("Unrar of %s ok" % fname) self.removeFiles(pack, fname) + else: + self.core.log.info("Unrar of %s failed (wrong password)" % fname) finally: pyfile.alternativePercent = None pyfile.setStatus("finished") diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index 42ee0f53f..9303b00c8 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -14,7 +14,8 @@ 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: jeix
+ @author: jeix + @author: mkaay
"""
import logging
@@ -29,33 +30,28 @@ from module.plugins.Hoster import Hoster class Ftp(Hoster):
__name__ = "Ftp"
- __version__ = "0.2"
+ __version__ = "0.3"
__pattern__ = r'ftp://(.*?:.*?@)?.*?/.*' # 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")
- __author_mail__ = ("jeix@hasnomail.com")
+ __author_name__ = ("jeix", "mkaay")
+ __author_mail__ = ("jeix@hasnomail.com", "mkaay@mkaay.de")
def process(self, pyfile):
self.req = pyfile.m.core.requestFactory.getRequest(self.__name__, type="FTP")
- pyfile.name = get_file_name()
+ pyfile.name = self.pyfile.url.rpartition('/')[2]
self.doDownload(pyfile.url, pyfile.name)
-
- def get_file_name(self):
- return self.parent.url.rpartition('/')[2]
-
-
def doDownload(self, url, filename):
self.pyfile.setStatus("downloading")
- download_folder = self.config['general']['download_folder']
+ download_folder = self.core.config['general']['download_folder']
location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding()))
if not exists(location):
makedirs(location)
- newname = self.req.download(url, join(location,filename.decode(sys.getfilesystemencoding())))
+ newname = self.req.download(str(url), join(location, filename.decode(sys.getfilesystemencoding())))
self.pyfile.size = self.req.dl_size
if newname:
|