summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-07-31 20:44:42 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-07-31 20:44:42 +0200
commitb06286d2d6693931e7956dba10c07073e69b5909 (patch)
treee195016b9b58b4c0c3e996ffb3a0cb234cafc217 /module/plugins
parentdaily commit (diff)
downloadpyload-b06286d2d6693931e7956dba10c07073e69b5909.tar.xz
some changes
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/Crypter.py67
-rw-r--r--module/plugins/Hook.py6
-rw-r--r--module/plugins/Plugin.py20
-rw-r--r--module/plugins/container/LinkList.py56
4 files changed, 107 insertions, 42 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
diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py
index a928d7173..7adbe2bbd 100644
--- a/module/plugins/Hook.py
+++ b/module/plugins/Hook.py
@@ -35,6 +35,9 @@ class Hook():
self.log = core.log
self.config = core.config
+ self.interval = 60
+ self.lastCall = 0
+
self.setup()
def setup(self):
@@ -60,3 +63,6 @@ class Hook():
def afterReconnecting(self, ip):
pass
+
+ def periodical(self):
+ pass
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index d8d8aae3c..1d3fb4309 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -61,14 +61,6 @@ class Plugin(object):
__author_name__ = ("RaNaN", "spoob", "mkaay")
__author_mail__ = ("RaNaN@pyload.org", "spoob@pyload.org", "mkaay@mkaay.de")
- def __new__(cls, *args, **kws):
- for f in dir(cls):
- if not f.startswith("_") and f not in ("checksum"):
- setattr(cls, f, dec(getattr(cls, f)) )
-
- o = super(cls.__class__, cls).__new__(cls)
- #wrap decorator around every method
- return o
def __init__(self, pyfile):
self.config = pyfile.m.core.config
@@ -151,7 +143,7 @@ class Plugin(object):
def wait():
""" waits the time previously set """
- pass
+ if self.pyfile.abort: raise Abort
def fail(self, reason):
""" fail and give reason """
@@ -178,10 +170,10 @@ class Plugin(object):
- ocr = self.core.pluginManager.getCaptchaPlugin(self.__name__)
- if ocr:
- #@TODO decrypt
- result = ""
+ Ocr = self.core.pluginManager.getCaptchaPlugin(self.__name__)
+ if Ocr:
+ ocr = Ocr()
+ result = ocr.get_captcha(temp.name)
else:
captchaManager = self.core.captchaManager
mime = guess_type(temp.name)
@@ -203,6 +195,8 @@ class Plugin(object):
def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False):
""" returns the content loaded """
+ if self.pyfile.abort: raise Abort
+
return self.req.load(url, get, post, ref, cookies, just_header)
def download(self, url, get={}, post={}, ref=True, cookies=True):
diff --git a/module/plugins/container/LinkList.py b/module/plugins/container/LinkList.py
index 3ffeeb193..9668b34ad 100644
--- a/module/plugins/container/LinkList.py
+++ b/module/plugins/container/LinkList.py
@@ -7,38 +7,52 @@ from module.plugins.Container import Container
class LinkList(Container):
__name__ = "LinkList"
__version__ = "0.1"
- __pattern__ = r"(?!http://).*\.txt"
+ __pattern__ = r".*\.txt$"
__description__ = """Read Link Lists in txt format"""
__author_name__ = ("spoob", "jeix")
__author_mail__ = ("spoob@pyload.org", "jeix@hasnomail.com")
- def proceed(self, linkList, location):
- txt = open(linkList, 'r')
+ def decrypt(self, pyfile):
+
+ self.loadToDisk()
+
+ txt = open(pyfile.url, 'r')
links = txt.readlines()
- packages = {"Parsed links":[],}
- curPack = "Parsed links"
+ curPack = "Parsed links %s" % pyfile.name
+
+ packages = {curPack:[],}
+
for link in links:
- if link != "\n":
- link = link.strip()
- if link.startswith(";"):
- continue
- if link.startswith("[") and link.endswith("]"):
- # new package
- curPack = link[1:-1]
- packages[curPack] = []
- continue
- packages[curPack].append(link.replace("\n", ""))
+ link = link.strip()
+ if not link: continue
+
+ if link.startswith(";"):
+ continue
+ if link.startswith("[") and link.endswith("]"):
+ # new package
+ curPack = link[1:-1]
+ packages[curPack] = []
+ continue
+ packages[curPack].append(link.replace("\n", ""))
txt.close()
- # empty Parsed links fix
- if len(packages["Parsed links"]) < 1:
- del packages["Parsed links"]
+ # empty packages fix
- if not self.parent.core.config['general']['debug_mode']:
+ delete = []
+
+ for key,value in packages.iteritems():
+ if not value:
+ delete.append(key)
+
+ for key in delete:
+ del packages[key]
+
+ if not self.core.debug:
txt = open(linkList, 'w')
txt.write("")
txt.close()
#@TODO: maybe delete read txt file?
-
- self.links = packages
+
+ for name, links in packages.iteritems():
+ self.packages.append((name, links, name))