summaryrefslogtreecommitdiffstats
path: root/pyload/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/plugins')
-rw-r--r--pyload/plugins/Account.py2
-rw-r--r--pyload/plugins/Addon.py2
-rw-r--r--pyload/plugins/Base.py8
-rw-r--r--pyload/plugins/Crypter.py30
-rw-r--r--pyload/plugins/Hoster.py2
-rw-r--r--pyload/plugins/crypter/DebugCrypter.py29
-rw-r--r--pyload/plugins/hoster/DebugHoster.py30
7 files changed, 91 insertions, 12 deletions
diff --git a/pyload/plugins/Account.py b/pyload/plugins/Account.py
index 4e6f174d2..cbf545611 100644
--- a/pyload/plugins/Account.py
+++ b/pyload/plugins/Account.py
@@ -45,6 +45,8 @@ class Account(Base):
return cls(m, info.loginname, info.owner,
True if info.activated else False, True if info.shared else False, password, options)
+ __type__ = "account"
+
def __init__(self, manager, loginname, owner, activated, shared, password, options):
Base.__init__(self, manager.core, owner)
diff --git a/pyload/plugins/Addon.py b/pyload/plugins/Addon.py
index da5bbc1d7..7e331d324 100644
--- a/pyload/plugins/Addon.py
+++ b/pyload/plugins/Addon.py
@@ -100,6 +100,8 @@ class Addon(Base):
#: periodic call interval in seconds
interval = 0
+ __type__ = "addon"
+
def __init__(self, core, manager, user=None):
Base.__init__(self, core, user)
diff --git a/pyload/plugins/Base.py b/pyload/plugins/Base.py
index 9dcb99453..97fb027d8 100644
--- a/pyload/plugins/Base.py
+++ b/pyload/plugins/Base.py
@@ -40,7 +40,10 @@ class Base(object):
"""
The Base plugin class with all shared methods and every possible attribute for plugin definition.
"""
+ #: Version as string or number
__version__ = "0.1"
+ # Type of the plugin, will be inherited and should not be set!
+ __type__ = ""
#: Regexp pattern which will be matched for download/crypter plugins
__pattern__ = r""
#: Internal addon plugin which is always loaded
@@ -150,6 +153,11 @@ class Base(object):
""" Name of the plugin class """
return self.__name__
+ @property
+ def pattern(self):
+ """ Gives the compiled pattern of the plugin """
+ return self.core.pluginManager.getPlugin(self.__type__, self.__name__).re
+
def setConfig(self, option, value):
""" Set config value for current plugin """
self.core.config.set(self.__name__, option, value)
diff --git a/pyload/plugins/Crypter.py b/pyload/plugins/Crypter.py
index a81fffafa..b6bdb1edd 100644
--- a/pyload/plugins/Crypter.py
+++ b/pyload/plugins/Crypter.py
@@ -6,11 +6,19 @@ from pyload.utils.fs import exists, remove, fs_encode
from Base import Base, Retry
+# represent strings as LinkStatus
+def to_link_list(links, status=DS.Queued):
+ return [LinkStatus(link, link, -1, status) if isinstance(link, basestring) else link
+ for link in links]
+
+
class Package:
""" Container that indicates that a new package should be created """
def __init__(self, name=None, links=None):
self.name = name
+
+ # list of link status
self.links = []
if links:
@@ -24,12 +32,7 @@ class Package:
:param links: One or list of urls or :class:`LinkStatus`
"""
- links = to_list(links)
- for link in links:
- if not isinstance(link, LinkStatus):
- link = LinkStatus(link, link, -1, DS.Queued)
-
- self.links.append(link)
+ self.links.extend(to_link_list(to_list(links)))
def addPackage(self, pack):
self.packs.append(pack)
@@ -128,13 +131,16 @@ class Crypter(Base):
for url_or_pack in result:
if isinstance(url_or_pack, Package): #package
ret.extend(url_or_pack.getAllURLs())
- else: # single url
- ret.append(url_or_pack)
- # eliminate duplicates
+ elif isinstance(url_or_pack, LinkStatus): #link
+ ret.append(url_or_pack.url)
+ else:
+ core.log.debug("Invalid decrypter result: " + url_or_pack)
+
return uniqify(ret)
+
+ __type__ = "crypter"
# TODO: pass user to crypter
- # TODO: crypter could not only know url, but also the name and size
def __init__(self, core, password=None):
Base.__init__(self, core)
@@ -196,7 +202,7 @@ class Crypter(Base):
"""Internal method to select decrypting method
:param urls: List of urls/content
- :return:
+ :return: (links, packages)
"""
cls = self.__class__
@@ -235,7 +241,7 @@ class Crypter(Base):
self.logWarning(_("Could not remove file '%s'") % f)
self.core.print_exc()
- return result
+ return to_link_list(result)
def getLocalContent(self, urls):
"""Load files from disk and separate to file content and url list
diff --git a/pyload/plugins/Hoster.py b/pyload/plugins/Hoster.py
index b59d11a9c..0ad07878a 100644
--- a/pyload/plugins/Hoster.py
+++ b/pyload/plugins/Hoster.py
@@ -47,6 +47,8 @@ class Hoster(Base):
"""
pass
+ __type__ = "hoster"
+
def __init__(self, pyfile):
# TODO: pyfile.owner, but it's not correct yet
Base.__init__(self, pyfile.m.core)
diff --git a/pyload/plugins/crypter/DebugCrypter.py b/pyload/plugins/crypter/DebugCrypter.py
new file mode 100644
index 000000000..a10d7c8e7
--- /dev/null
+++ b/pyload/plugins/crypter/DebugCrypter.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+
+from random import randint
+from time import sleep
+
+from pyload.plugins.Crypter import Crypter
+
+class DebugCrypter(Crypter):
+ """ Generates link used by debug hoster to test the decrypt mechanism """
+
+ __version__ = 0.1
+ __pattern__ = r"^debug_crypter=(\d+)$"
+
+
+ def decryptURL(self, url):
+
+ m = self.pattern.search(url)
+ n = int(m.group(1))
+
+ sleep(randint(3, n if n > 2 else 3))
+
+ return ["debug_hoster=%d" % i for i in range(n)]
+
+
+
+
+
+
+
diff --git a/pyload/plugins/hoster/DebugHoster.py b/pyload/plugins/hoster/DebugHoster.py
new file mode 100644
index 000000000..d168ad1c2
--- /dev/null
+++ b/pyload/plugins/hoster/DebugHoster.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+
+from time import sleep
+from random import randint
+
+from pyload.Api import LinkStatus, DownloadStatus as DS
+from pyload.plugins.Hoster import Hoster
+
+
+class DebugHoster(Hoster):
+ """ Generates link used by debug hoster to test the decrypt mechanism """
+
+ __version__ = 0.1
+ __pattern__ = r"^debug_hoster=\d*$"
+
+ @classmethod
+ def getInfo(cls, urls):
+ for url in urls:
+ yield LinkStatus(url, url + " - checked", randint(1024, 2048), DS.Online)
+ sleep(1)
+
+ def process(self, pyfile):
+ pass
+
+
+
+
+
+
+