From 16af85004c84d0d6c626b4f8424ce9647669a0c1 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 9 Jun 2013 18:10:22 +0200 Subject: moved everything from module to pyload --- pyload/plugins/hoster/FilesMailRu.py | 99 ++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 pyload/plugins/hoster/FilesMailRu.py (limited to 'pyload/plugins/hoster/FilesMailRu.py') diff --git a/pyload/plugins/hoster/FilesMailRu.py b/pyload/plugins/hoster/FilesMailRu.py new file mode 100644 index 000000000..ee4ea4953 --- /dev/null +++ b/pyload/plugins/hoster/FilesMailRu.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from module.plugins.Hoster import Hoster, chunks +from module.network.RequestFactory import getURL + +def getInfo(urls): + result = [] + for chunk in chunks(urls, 10): + for url in chunk: + src = getURL(url) + if r'
' in src: + result.append((url, 0, 1, url)) + elif r'Page cannot be displayed' in src: + result.append((url, 0, 1, url)) + else: + try: + url_pattern = '(.+?)' + file_name = re.search(url_pattern, src).group(0).split(', event)">')[1].split('')[0] + result.append((file_name, 0, 2, url)) + except: + pass + + + # status 1=OFFLINE, 2=OK, 3=UNKNOWN + # result.append((#name,#size,#status,#url)) + yield result + +class FilesMailRu(Hoster): + __name__ = "FilesMailRu" + __type__ = "hoster" + __pattern__ = r"http://files\.mail\.ru/.*" + __version__ = "0.3" + __description__ = """Files.Mail.Ru One-Klick Hoster""" + __author_name__ = ("oZiRiz") + __author_mail__ = ("ich@oziriz.de") + + + def setup(self): + if not self.account: + self.multiDL = False + self.chunkLimit = 1 + + def process(self, pyfile): + self.html = self.load(pyfile.url) + self.url_pattern = '(.+?)' + + #marks the file as "offline" when the pattern was found on the html-page''' + if r'
' in self.html: + self.offline() + + elif r'Page cannot be displayed' in self.html: + self.offline() + + #the filename that will be showed in the list (e.g. test.part1.rar)''' + pyfile.name = self.getFileName() + + #prepare and download''' + if not self.account: + self.prepare() + self.download(self.getFileUrl()) + self.myPostProcess() + else: + self.download(self.getFileUrl()) + self.myPostProcess() + + def prepare(self): + '''You have to wait some seconds. Otherwise you will get a 40Byte HTML Page instead of the file you expected''' + self.setWait(10) + self.wait() + return True + + def getFileUrl(self): + '''gives you the URL to the file. Extracted from the Files.mail.ru HTML-page stored in self.html''' + file_url = re.search(self.url_pattern, self.html).group(0).split('')[1].split('')[0] + return file_name + + def myPostProcess(self): + # searches the file for HTMl-Code. Sometimes the Redirect + # doesn't work (maybe a curl Problem) and you get only a small + # HTML file and the Download is marked as "finished" + # then the download will be restarted. It's only bad for these + # who want download a HTML-File (it's one in a million ;-) ) + # + # The maximum UploadSize allowed on files.mail.ru at the moment is 100MB + # so i set it to check every download because sometimes there are downloads + # that contain the HTML-Text and 60MB ZEROs after that in a xyzfile.part1.rar file + # (Loading 100MB in to ram is not an option) + check = self.checkDownload({"html": "