summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.hgignore2
-rw-r--r--docs/Makefile130
-rw-r--r--docs/access_api.rst64
-rw-r--r--docs/conf.py231
-rw-r--r--docs/docs.conf (renamed from docs.conf)0
-rw-r--r--docs/index.rst29
-rw-r--r--docs/module_overview.rst16
-rwxr-xr-xdocs/write_plugins.rst92
-rw-r--r--module/Api.py5
-rw-r--r--module/PyFile.py4
-rw-r--r--module/PyPackage.py12
-rw-r--r--module/plugins/Account.py5
-rw-r--r--module/plugins/Hook.py3
-rw-r--r--module/plugins/Plugin.py41
14 files changed, 609 insertions, 25 deletions
diff --git a/.hgignore b/.hgignore
index 83a6539a1..31b713e73 100644
--- a/.hgignore
+++ b/.hgignore
@@ -11,6 +11,8 @@ syntax: glob
Downloads/*
container/*
Logs/*
+docs/module/
+docs/_build
module/plugins/container/DLC_*.py
failed_links.txt
module/config/gui.xml
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 000000000..2082e6ef3
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,130 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+ -rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pyLoad.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pyLoad.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/pyLoad"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/pyLoad"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ make -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
diff --git a/docs/access_api.rst b/docs/access_api.rst
new file mode 100644
index 000000000..dd3998df4
--- /dev/null
+++ b/docs/access_api.rst
@@ -0,0 +1,64 @@
+.. _access_api:
+
+*********************
+How to access the API
+*********************
+
+pyLoad has a very powerfull API with can be accessed in several ways.
+
+Overview
+--------
+
+First of all, you need to know what you can do with our API. It lets you do all common task like
+retrieving download status, manage queue, manage accounts, modify config and so on.
+
+This document is not intended to explain every function in detail, for a complete listing
+see :class:`Api <module.Api.Api>`.
+
+Of course its possible to access the ``core.api`` attribute in plugins and hooks, but much more
+interesting is the possibillity to call function from different programs written in many different languages.
+
+pyLoad uses thrift as backend and provides its :class:`Api <module.Api.Api>` as service.
+More information about thrift can be found here http://wiki.apache.org/thrift/.
+
+Using Thrift
+------------
+
+Every thrift service has to define all data structures and declare every method which should be usable via rpc.
+This file is located :file:`module/remote/thriftbackend/pyload.thrift`, its very helpful to inform about
+arguments and detailed structure of return types. However it does not contain any information about what the functions does.
+
+Assuming you want to use the API in any other language than python than check if it is
+supported here http://wiki.apache.org/thrift/LibraryFeatures?action=show&redirect=LanguageSupport.
+
+Now install thrift, for instructions see http://wiki.apache.org/thrift/ThriftInstallation.
+If every thing went fine you are ready to generate the method stubs, the command basically looks like this. ::
+
+ $thrift --gen (language) pyload.thrift
+
+You find now a directory named :file:`gen-(language)`. For instruction how to use the generated files consider the docs
+at the thrift wiki and the examples here http://wiki.apache.org/thrift/ThriftUsage
+
+
+Example
+-------
+In case you want to use python, pyload has already all files included to access the api over rpc.
+A basic script that prints out some information. ::
+
+ from module.remote.thriftbackend.ThriftClient import ThriftClient, WrongLogin
+
+ try:
+ client = ThriftClient(host="127.0.0.1", port=7227, user="User", password="yourpw")
+ except:
+ print "Login was wrong"
+ exit()
+
+ print "Server version:", client.getServerVersion()
+ print client.statusDownloads()
+ q = client.getQueue()
+ for p in q:
+ data = client.getPackageData(p.pid)
+ print "Package Name: ", data.name
+
+That's all for now, pretty easy isn't it?
+If you still have open questions come around in irc or post them at our pyload forum. \ No newline at end of file
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 000000000..cdd2bfc6f
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,231 @@
+# -*- coding: utf-8 -*-
+#
+# pyLoad documentation build configuration file, created by
+# sphinx-quickstart on Sat Jun 4 11:54:34 2011.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+from os.path import dirname, join, abspath
+
+dir_name = join(dirname(abspath("")))
+sys.path.append(dir_name)
+sys.path.append(join(dir_name, "module", "lib"))
+
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode']
+
+autosummary_generate = True
+autodoc_default_flags = ['members']
+autoclass_content = 'both'
+autodoc_member_order = 'bysource'
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'pyLoad'
+copyright = u'2011, pyLoad Team'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.4'
+# The full version, including alpha/beta/rc tags.
+release = '0.4.7'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+html_logo = join(dir_name, "module", "web", "media", "default", "img", "pyload-logo-edited3.5-new-font-small.png")
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+html_favicon = join(dir_name, "icons", "pyload2.ico")
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'pyLoaddoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+ ('index', 'pyLoad.tex', u'pyLoad Documentation',
+ u'pyLoad Team', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ ('index', 'pyload', u'pyLoad Documentation',
+ [u'pyLoad Team'], 1)
+]
+
+
+# Example configuration for intersphinx: refer to the Python standard library.
+intersphinx_mapping = {'http://docs.python.org/': None}
diff --git a/docs.conf b/docs/docs.conf
index e197cfa43..e197cfa43 100644
--- a/docs.conf
+++ b/docs/docs.conf
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 000000000..ce49325e7
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,29 @@
+.. pyLoad documentation master file, created by
+ sphinx-quickstart on Sat Jun 4 11:54:34 2011.
+ You can adapt this file completely to your liking, but it should at least
+ contain the root `toctree` directive.
+
+Welcome to pyLoad's documentation!
+==================================
+
+Great that you found your way to the pyLoad documentation!
+
+We have collected some information here to help developer writing plugins and understandig our code.
+If you want to help us developing visit us in our IRC channel #pyload on freenode.net or leave a message in our forum.
+
+Contents:
+
+.. toctree::
+ :maxdepth: 2
+
+ access_api.rst
+ write_plugins.rst
+ module_overview.rst
+
+.. currentmodule:: module
+
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
diff --git a/docs/module_overview.rst b/docs/module_overview.rst
new file mode 100644
index 000000000..b7ca5e05b
--- /dev/null
+++ b/docs/module_overview.rst
@@ -0,0 +1,16 @@
+Module Overview
+===============
+
+You can find an overview of important classes here:
+
+
+.. autosummary::
+ :toctree: module
+
+ module.Api.Api
+ module.plugins.Plugin.Plugin
+ module.plugins.Crypter.Crypter
+ module.plugins.Account.Account
+ module.plugins.Hook.Hook
+ module.PyFile.PyFile
+ module.PyPackage.PyPackage
diff --git a/docs/write_plugins.rst b/docs/write_plugins.rst
new file mode 100755
index 000000000..0c581cdab
--- /dev/null
+++ b/docs/write_plugins.rst
@@ -0,0 +1,92 @@
+.. _write_plugins:
+
+********************
+How to extend pyLoad
+********************
+
+This page should give you an basic idea, how to extend pyLoad with new features!
+
+Hooks
+-----
+
+A Hook is a module which is located at :file:`module/plugin/hooks` and loaded with the startup. It inherits all methods from the base :class:`Hook <module.plugins.Hook.Hook>` module, make sure to check its documentation!
+
+All Hooks should start with something like this: ::
+
+ from module.plugins.Hook import Hook
+
+ class YourHook(Hook):
+ __name__ = "My own Hook"
+ __version__ = "0.1"
+ __description__ = "Does really cool stuff"
+ __config__ = [ ("activated" , "bool" , "Activated" , "True" ) ]
+ __threaded__ = ["downloadFinished"]
+ __author_name__ = ("Me")
+ __author_mail__ = ("me@has-no-mail.com")
+
+ def setup(self):
+ #init hook and other stuff here
+ pass
+
+Take a closer look at the ``__config__`` parameter. You need at least this option indicating whether your Hook is activated or not.
+You can add more config values as desired by adding tuples of the following format to the config list: ``("name", "type", "description", "default value")``.
+When everything went right you can access your config values with ``self.getConfig(name)``.
+
+The next step is to think about where your Hook action takes places.
+You can overwrite several methods of the base plugin, her name indicates when they gets called.
+See :class:`Hook <module.plugins.Hook.Hook>` page for a complete listing.
+
+You should be aware of the arguments the Hooks are called with, whether its a :class:`PyFile <module.FileDatabase.PyFile>` or :class:`PyPackage <module.FileDatabase.PyPackage>` you should read its related documentation to know how to access her great power and manipulate them.
+
+Another important feature to mention can be seen at the ``__threaded__`` parameter. Function names listed will be executed in a thread, in order to not block the main thread. This should be used for all kind of longer processing tasks.
+
+
+Plugins
+-------
+
+A Plugin in pyLoad sense is a module, that will be loaded and executed when its pattern match to a url that was been added to pyLoad.
+
+There are three kinds of different plugins: **Hoster**, **Crypter**, **Container**.
+All kind of plugins inherit from the base :class:`Plugin <module.plugins.Plugin.Plugin>`. You should know its convenient methods, they make your work easier ;-)
+
+We take a look how basis hoster plugin header could look like: ::
+
+ from module.plugin.Hoster import Hoster
+
+ class MyFileHoster(Hoster):
+ __name__ = "MyFileHoster"
+ __version__ = "0.1"
+ __pattern__ = r"http://myfilehoster.example.com/file_id/[0-9]+"
+ __config__ = []
+
+Thats it, like above with :ref:`Hooks` you can add config values exatly the same way.
+
+The ``__pattern__`` property is very important, it will be checked against every added url and if it matches your plugin will be choosed to do the grateful task of processing this download! In case you dont already spotted it, ``__pattern__`` has to be a regexp of course.
+
+We head to the next important section, the ``process`` method of your plugin.
+In fact the ``process`` method is the only functionality your plugin has to provide, but its always a good idea to split up tasks to not produce spaghetti code.
+An example ``process`` function could look like this ::
+
+ def process(self, pyfile):
+ html = self.load(pyfile.url) #load the content of the orginal pyfile.url to html
+
+ pyfile.name = self.myFunctionToParseTheName(html) #parse the name from the site and write it to pyfile
+ parsed_url = self.myFunctionToParseUrl(html)
+
+ self.download(parsed_url) # download the file
+
+You need to know about the :class:`PyFile <module.FileDatabase.PyFile>` class, since a instance of it is given as parameter to every pyfile.
+Some tasks your plugin should handle: proof if file is online, get filename, wait if needed, download the file, etc..
+
+There are also some functions to mention which are provided by the base Plugin: ``self.wait()``, ``self.decryptCaptcha()``
+Read about there functionality in the :class:`Plugin <module.plugins.Plugin.Plugin>` doc.
+
+What about Decrypter and Container plugins?
+Well, they work nearly the same, only that the function they have to provide is named ``decrypt``
+
+Example: ::
+
+ def decrypt(self, pyfile):
+ self.packages.append((name, urls, folder)) # urls list of urls
+
+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.
diff --git a/module/Api.py b/module/Api.py
index 85e3d233a..d4dae3966 100644
--- a/module/Api.py
+++ b/module/Api.py
@@ -31,11 +31,12 @@ from module.utils import freeSpace, compare_time
class Api(Iface):
"""
- ===pyLoads API===
+ **pyLoads API**
+
+ This is accessible either internal via core.api or via thrift backend.
see Thrift specification file remote/thriftbackend/pyload.thrift\
for information about data structures and what methods are usuable with rpc.
-
"""
def __init__(self, core):
diff --git a/module/PyFile.py b/module/PyFile.py
index b5384c399..b230f9e0b 100644
--- a/module/PyFile.py
+++ b/module/PyFile.py
@@ -48,7 +48,9 @@ def setSize(self, value):
self._size = int(value)
class PyFile(object):
-
+ """
+ Represents a file object at runtime
+ """
__slots__ = ("m", "id", "url", "name", "size", "_size", "status", "pluginname", "packageid",
"error", "order", "lock", "plugin", "waitUntil", "active", "abort",
"reconnected", "progress", "pluginmodule", "pluginclass")
diff --git a/module/PyPackage.py b/module/PyPackage.py
index 42fa129f9..bc9b8094f 100644
--- a/module/PyPackage.py
+++ b/module/PyPackage.py
@@ -20,6 +20,9 @@
from module.PullEvents import UpdateEvent
class PyPackage():
+ """
+ Represents a package object at runtime
+ """
def __init__(self, manager, id, name, folder, site, password, queue, order, priority):
self.m = manager
self.m.packageCache[int(id)] = self
@@ -37,14 +40,9 @@ class PyPackage():
self.setFinished = False
def toDict(self):
- """return data as dict
-
- format:
-
- {
- id: {'name': name ... 'links': {} } }
- }
+ """ Returns a dictionary representation of the data.
+ :return: dict: {id: { attr: value }}
"""
return {
self.id: {
diff --git a/module/plugins/Account.py b/module/plugins/Account.py
index 732133d3a..adee39559 100644
--- a/module/plugins/Account.py
+++ b/module/plugins/Account.py
@@ -28,6 +28,11 @@ class WrongPassword(Exception):
class Account():
+ """
+ Base class for every Account plugin.
+ Just overwrite `login` and cookies will be stored and account becomes accessible in\
+ associated hoster plugin. Plugin should also provide `loadAccountInfo`
+ """
__name__ = "Account"
__version__ = "0.2"
__type__ = "account"
diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py
index 5c8a3384f..8a6355fcd 100644
--- a/module/plugins/Hook.py
+++ b/module/plugins/Hook.py
@@ -40,6 +40,9 @@ def threaded(f):
return run
class Hook():
+ """
+ Base class for hook plugins.
+ """
__name__ = "Hook"
__version__ = "0.2"
__type__ = "hook"
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index 9caf4d81a..4eb0ee477 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -68,6 +68,10 @@ class SkipDownload(Exception):
class Plugin(object):
+ """
+ Base plugin for hoster/crypter.
+ Overwrite `process` / `decrypt` in your subclassed plugin.
+ """
__name__ = "Plugin"
__version__ = "0.4"
__pattern__ = None
@@ -82,16 +86,20 @@ class Plugin(object):
self.core = pyfile.m.core
self.wantReconnect = False
- self.multiDL = True #: enables simultaneous processing of multiple downloads
+ #: enables simultaneous processing of multiple downloads
+ self.multiDL = True
self.limitDL = 0
+ #: chunk limit
self.chunkLimit = 1
self.resumeDownload = False
- self.waitUntil = 0 #: time() + wait in seconds
+ #: time() + wait in seconds
+ self.waitUntil = 0
self.waiting = False
self.ocr = None #captcha reader instance
- self.account = pyfile.m.core.accountManager.getAccountPlugin(self.__name__) #: account handler instance, see :py:class:`Account`
+ #: account handler instance, see :py:class:`Account`
+ self.account = pyfile.m.core.accountManager.getAccountPlugin(self.__name__)
self.premium = False
self.user = None
@@ -101,10 +109,12 @@ class Plugin(object):
self.user, data = self.account.selectAccount()
#: Browser instance, see `network.Browser`
self.req = self.account.getAccountRequest(self.user)
- self.chunkLimit = -1 #: chunk limit, -1 for unlimited
- self.resumeDownload = True #: enables resume (will be ignored if server dont accept chunks)
+ self.chunkLimit = -1 # chunk limit, -1 for unlimited
+ #: enables resume (will be ignored if server dont accept chunks)
+ self.resumeDownload = True
self.multiDL = True #every hoster with account should provide multiple downloads
- self.premium = self.account.isPremium(self.user) #: premium status
+ #: premium status
+ self.premium = self.account.isPremium(self.user)
else:
self.req = pyfile.m.core.requestFactory.getRequest(self.__name__)
@@ -113,13 +123,16 @@ class Plugin(object):
self.pyfile = pyfile
self.thread = None # holds thread in future
- self.lastDownload = "" #: location where the last call to download was saved
- self.lastCheck = None #: re match of the last call to `checkDownload`
- self.js = self.core.js #: js engine, see `JsEngine`
+ #: location where the last call to download was saved
+ self.lastDownload = ""
+ #: re match of the last call to `checkDownload`
+ self.lastCheck = None
+ #: js engine, see `JsEngine`
+ self.js = self.core.js
self.cTask = None #captcha task
- self.retries = 0 #: amount of retries already made
- self.html = None #some plugins store html code here
+ self.retries = 0 # amount of retries already made
+ self.html = None # some plugins store html code here
self.init()
@@ -132,9 +145,7 @@ class Plugin(object):
return self.__name__
def init(self):
- """
- initialize the plugin (in addition to `__init__`)
- """
+ """initialize the plugin (in addition to `__init__`)"""
pass
def setup(self):
@@ -156,7 +167,7 @@ class Plugin(object):
return self.process(self.pyfile)
- #----------------------------------------------------------------------
+
def process(self, pyfile):
"""the 'main' method of every plugin, you **have to** overwrite it"""
raise NotImplementedError