From 0b3dc1d0243d1c8db633f2ba439ae51ffdc5f3a3 Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Fri, 16 Nov 2012 22:13:18 +0100 Subject: Contributed plugins - closed #722,#723 --- module/plugins/hoster/FileshareInUa.py | 78 ++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 module/plugins/hoster/FileshareInUa.py (limited to 'module/plugins/hoster/FileshareInUa.py') diff --git a/module/plugins/hoster/FileshareInUa.py b/module/plugins/hoster/FileshareInUa.py new file mode 100644 index 000000000..9700b2d0a --- /dev/null +++ b/module/plugins/hoster/FileshareInUa.py @@ -0,0 +1,78 @@ +from urllib import urlencode +import re +from module.plugins.Hoster import Hoster +from module.network.RequestFactory import getURL +from module.utils import parseFileSize + +class FileshareInUa(Hoster): + __name__ = "FileshareInUa" + __type__ = "hoster" + __pattern__ = r"http://(?:\w*\.)*?fileshare.in.ua/[A-Za-z0-9]+" + __version__ = "0.01" + __description__ = """fileshare.in.ua hoster plugin""" + __author_name__ = ("fwannmacher") + __author_mail__ = ("felipe@warhammerproject.com") + + HOSTER_NAME = "fileshare.in.ua" + PATTERN_FILENAME = r'

(.*?)

' + PATTERN_FILESIZE = r'(.*?)' + PATTERN_OFFLINE = "This file doesn't exist, or has been removed." + + def setup(self): + self.resumeDownload = True + self.multiDL = True + + def process(self, pyfile): + self.pyfile = pyfile + self.html = self.load(pyfile.url, decode=True) + + if not self._checkOnline(): + self.offline() + + self.pyfile.name = self._getName() + + self.link = self._getLink() + + if not self.link.startswith('http://'): + self.link = "http://fileshare.in.ua" + self.link + + self.download(self.link) + + def _checkOnline(self): + if re.search(self.PATTERN_OFFLINE, self.html): + return False + else: + return True + + def _getName(self): + name = re.search(self.PATTERN_FILENAME, self.html) + if name is None: + self.fail("%s: Plugin broken." % self.__name__) + + return name.group(1) + + def _getLink(self): + return re.search("", self.html).group(1) + +def getInfo(urls): + result = [] + + for url in urls: + html = getURL(url) + + if re.search(FileshareInUa.PATTERN_OFFLINE, html): + result.append((url, 0, 1, url)) + else: + name = re.search(FileshareInUa.PATTERN_FILENAME, html) + + if name is None: + result.append((url, 0, 1, url)) + continue + + name = name.group(1) + size = re.search(FileshareInUa.PATTERN_FILESIZE, html) + size = parseFileSize(size.group(1)) + + result.append((name, size, 3, url)) + + yield result -- cgit v1.2.3