summaryrefslogtreecommitdiffstats
path: root/module/plugins/MultiHoster.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-06-09 18:10:22 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-06-09 18:10:23 +0200
commit16af85004c84d0d6c626b4f8424ce9647669a0c1 (patch)
tree025d479862d376dbc17e934f4ed20031c8cd97d1 /module/plugins/MultiHoster.py
parentadapted to jshint config (diff)
downloadpyload-16af85004c84d0d6c626b4f8424ce9647669a0c1.tar.xz
moved everything from module to pyload
Diffstat (limited to 'module/plugins/MultiHoster.py')
-rw-r--r--module/plugins/MultiHoster.py73
1 files changed, 0 insertions, 73 deletions
diff --git a/module/plugins/MultiHoster.py b/module/plugins/MultiHoster.py
deleted file mode 100644
index 1936478b4..000000000
--- a/module/plugins/MultiHoster.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from time import time
-
-from module.utils import remove_chars
-
-from Account import Account
-
-def normalize(domain):
- """ Normalize domain/plugin name, so they are comparable """
- return remove_chars(domain.strip().lower(), "-.")
-
-#noinspection PyUnresolvedReferences
-class MultiHoster(Account):
- """
- Base class for MultiHoster services.
- This is also an Account instance so you should see :class:`Account` and overwrite necessary methods.
- Multihoster becomes only active when an Account was entered and the MultiHoster addon was activated.
- You need to overwrite `loadHosterList` and a corresponding :class:`Hoster` plugin with the same name should
- be available to make your service working.
- """
-
- #: List of hoster names that will be replaced so pyLoad will recognize them: (orig_name, pyload_name)
- replacements = [("freakshare.net", "freakshare.com")]
-
- #: Load new hoster list every x seconds
- hoster_timeout = 300
-
- def __init__(self, *args, **kwargs):
-
- # Hoster list
- self.hoster = []
- # Timestamp
- self.ts = 0
-
- Account.__init__(self, *args, **kwargs)
-
- def loadHosterList(self, req):
- """Load list of supported hoster
-
- :return: List of domain names
- """
- raise NotImplementedError
-
-
- def isHosterUsuable(self, domain):
- """ Determine before downloading if hoster should be used.
-
- :param domain: domain name
- :return: True to let the MultiHoster download, False to fallback to default plugin
- """
- return True
-
- def getHosterList(self, force=False):
- if self.ts + self.hoster_timeout < time() or force:
- req = self.getAccountRequest()
- try:
- self.hoster = self.loadHosterList(req)
- except Exception, e:
- self.logError(e)
- return []
- finally:
- req.close()
-
- for rep in self.replacements:
- if rep[0] in self.hoster:
- self.hoster.remove(rep[0])
- if rep[1] not in self.hoster:
- self.hoster.append(rep[1])
-
- self.ts = time()
-
- return self.hoster \ No newline at end of file