diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-07-31 20:44:42 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-07-31 20:44:42 +0200 |
commit | b06286d2d6693931e7956dba10c07073e69b5909 (patch) | |
tree | e195016b9b58b4c0c3e996ffb3a0cb234cafc217 /module/plugins/Crypter.py | |
parent | daily commit (diff) | |
download | pyload-b06286d2d6693931e7956dba10c07073e69b5909.tar.xz |
some changes
Diffstat (limited to 'module/plugins/Crypter.py')
-rw-r--r-- | module/plugins/Crypter.py | 67 |
1 files changed, 59 insertions, 8 deletions
diff --git a/module/plugins/Crypter.py b/module/plugins/Crypter.py index e0459c714..a14a51e79 100644 --- a/module/plugins/Crypter.py +++ b/module/plugins/Crypter.py @@ -19,6 +19,8 @@ from module.plugins.Plugin import Plugin +from os.path import join, exists, basename + class Crypter(Plugin): __name__ = "Crypter" __version__ = "0.1" @@ -27,13 +29,62 @@ class Crypter(Plugin): __description__ = """Base crypter plugin""" __author_name__ = ("mkaay") __author_mail__ = ("mkaay@mkaay.de") - + + def __init__(self, pyfile): + Plugin.__init__(self, pyfile) + + self.packages = [] #put all packages here [ .. (name, folder, [urls]) ..] + #---------------------------------------------------------------------- - def createPackage(self, name, urls): - """ create a new package """ - pass + def preprocessing(self, thread): + """prepare""" + self.thread = thread + + self.decrypt(self.pyfile) + + self.createPackages() + - def fillCurrentPackage(self, name, urls): - """ rename current package and fill with urls""" - pass -
\ No newline at end of file + #---------------------------------------------------------------------- + def loadToDisk(self): + """loads container to disk if its stored remotely and overwrite url, + or check existent on several places at disk""" + + if self.pyfile.url.startswith("http://"): + self.pyfile.name = re.findall("([^\/=]+)", self.pyfile.url)[-1] + content = self.load(self.pyfile.url) + self.pyfile.url = join(self.config["general"]["download_folder"], self.pyfile.name) + f = open(self.pyfile.url, "wb" ) + f.write(content) + f.close() + + else: + self.pyfile.name = basename(self.pyfile.url) + if not exists(self.pyfile.url): + if exists(join(pypath, self.pyfile.url)): + self.pyfile.url = join(pypath, self.pyfile.url) + else: + self.fail(_("File not exists.")) + + + #---------------------------------------------------------------------- + def createPackages(self): + """ create new packages from self.packages """ + i = 0 + 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] + + 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]) + + i += 1 +
\ No newline at end of file |