summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/XFileSharing.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-19 04:48:07 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-10-19 04:48:07 +0200
commitffd38f027ed103f7b39ec78c6af0d182774950a4 (patch)
treee6d88b064a38bb44932674f32ac602efc786468b /module/plugins/hoster/XFileSharing.py
parentMerge pull request #2054 from GammaC0de/patch-1 (diff)
downloadpyload-ffd38f027ed103f7b39ec78c6af0d182774950a4.tar.xz
Spare fixes
Diffstat (limited to 'module/plugins/hoster/XFileSharing.py')
-rw-r--r--module/plugins/hoster/XFileSharing.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/module/plugins/hoster/XFileSharing.py b/module/plugins/hoster/XFileSharing.py
new file mode 100644
index 000000000..89b58bb7f
--- /dev/null
+++ b/module/plugins/hoster/XFileSharing.py
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+
+import re
+
+from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo
+
+
+class XFileSharing(XFSHoster):
+ __name__ = "XFileSharing"
+ __type__ = "hoster"
+ __version__ = "0.57"
+ __status__ = "testing"
+
+ __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*(?P<DOMAIN>(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)'
+ __config__ = [("activated", "bool", "Activated", True)]
+
+ __description__ = """XFileSharing dummy hoster plugin for hook"""
+ __license__ = "GPLv3"
+ __authors__ = [("Walter Purcaro", "vuolter@gmail.com")]
+
+
+ URL_REPLACEMENTS = [("/embed-", "/")]
+
+
+ def _log(self, level, plugintype, pluginname, messages):
+ messages = (self.PLUGIN_NAME,) + messages
+ return self.plugin._log(level, plugintype, pluginname, messages)
+
+
+ def init(self):
+ self.__pattern__ = self.pyload.pluginManager.hosterPlugins[self.classname]['pattern']
+
+ self.PLUGIN_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group("DOMAIN").lower()
+ self.PLUGIN_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+|-)', self.PLUGIN_DOMAIN) if part != '.')
+
+
+ def _setup(self):
+ account_name = self.classname if not self.account or self.account.PLUGIN_DOMAIN is None else self.PLUGIN_NAME
+ self.chunk_limit = 1
+ self.multiDL = True
+
+ if self.account:
+ self.req = self.pyload.requestFactory.getRequest(accountname, self.account.user)
+ self.premium = self.account.premium
+ self.resume_download = self.premium
+ else:
+ self.req = self.pyload.requestFactory.getRequest(account_name)
+ self.premium = False
+ self.resume_download = False
+
+
+ def load_account(self):
+ if self.req:
+ self.req.close()
+
+ if not self.account:
+ self.account = self.pyload.accountManager.getAccountPlugin(self.PLUGIN_NAME)
+
+ if not self.account:
+ self.account = self.pyload.accountManager.getAccountPlugin(self.classname)
+
+ if self.account:
+ if not self.account.PLUGIN_DOMAIN:
+ self.account.PLUGIN_DOMAIN = self.PLUGIN_DOMAIN
+
+ if not self.account.user: #@TODO: Move to `Account` in 0.4.10
+ self.account.user = self.account.select()[0]
+
+ if not self.account.logged:
+ self.account = False
+
+
+getInfo = create_getInfo(XFileSharing)