diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-01-29 22:57:41 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-01-29 22:57:41 +0100 |
commit | 7df4718276a12b7f19a73d3b789c791d57bf4342 (patch) | |
tree | d61d720ed9e2a9d568465b715d41be486395065c /docs/plugins/crypter_plugin.rst | |
parent | doc for base plugin (diff) | |
download | pyload-7df4718276a12b7f19a73d3b789c791d57bf4342.tar.xz |
doc for crypter plugin
Diffstat (limited to 'docs/plugins/crypter_plugin.rst')
-rw-r--r-- | docs/plugins/crypter_plugin.rst | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/docs/plugins/crypter_plugin.rst b/docs/plugins/crypter_plugin.rst index 639d58abf..1497ced07 100644 --- a/docs/plugins/crypter_plugin.rst +++ b/docs/plugins/crypter_plugin.rst @@ -3,23 +3,53 @@ Crypter - Extract links from pages ================================== -What about Decrypter and Container plugins? -Well, they work nearly the same, only that the function they have to provide is named ``decrypt`` - -Example: :: +We are starting with the simplest plugin, the :class:`Crypter <module.plugins.Crypter.Crypter>`. +It's job is it to take a url as input and generate new package or links, for example by filtering the urls or +loading a page and extracting links from the html code. You need to define the ``__pattern__`` to match +target urls and subclass from :class:`Crypter <module.plugins.Crypter.Crypter>`. :: from module.plugin.Crypter import Crypter class MyFileCrypter(Crypter): - """ - plugin code - """ - def decrypt(self, pyfile): + __pattern__ = r"mycrypter.com/id/([0-9]+)" + + def decryptURL(self, url): urls = ["http://get.pyload.org/src", "http://get.pyload.org/debian", "http://get.pyload.org/win"] + return urls + +You have to overwrite at least one of ``.decryptFile``, ``.decryptURL``, ``.decryptURLs``. The first one +is only useful for container files, whereas the last is usefull when it's possible to handle a bunch of urls +at once. If in doubt, just overwrite `decryptURL`. + +Generating Packages +------------------- + +When finished with decrypting just return the urls as list and they will be added to the package. You can also +create new Packages if needed by instantiating a :class:`Package` instance, which will look like the following:: + + from module.plugin.Crypter import Crypter, Package + + class MyFileCrypter(Crypter): + + def decryptURL(self, url): + + html = self.load(url) + + # .decrypt_from_content is only a example method here and will return a list of urls + urls = self.decrypt_from_content(html) + return Package("my new package", urls) + +And that's basically all you need to know. Just as little side-note if you want to use decrypter in +your code you can use:: + + plugin = self.core.pluginManager.loadClass("crypter", "NameOfThePlugin") + # decrypted will be a list of urls + decrypted = plugin.decrypt(urls) - self.packages.append(("pyLoad packages", urls, "pyLoad packages")) # urls list of urls +Testing +------- -They can access all the methods from :class:`Plugin <module.plugins.Plugin.Plugin>`, but the important thing is they -have to append all packages they parsed to the `self.packages` list. Simply append tuples with `(name, urls, folder)`, -where urls is the list of urls contained in the packages. Thats all of your work, pyLoad will know what to do with them. +Please append a test link at :file:`tests/crypterlinks.txt` followed by `||xy`, where xy is the number of +expected links/packages to extract. +Our testrunner will be able to check your plugin periodical for functionality.
\ No newline at end of file |