From 0d199b30c4245bcb8e32e416820ba2e6d01635ae Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Fri, 7 Oct 2011 13:47:08 +0200 Subject: add megashares.com plugin (#262) --- module/plugins/hoster/MediafireCom.py | 19 +++-- module/plugins/hoster/MegasharesCom.py | 136 +++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+), 7 deletions(-) create mode 100644 module/plugins/hoster/MegasharesCom.py (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py index 8a39d364e..0bc0e504f 100644 --- a/module/plugins/hoster/MediafireCom.py +++ b/module/plugins/hoster/MediafireCom.py @@ -35,8 +35,8 @@ def getInfo(urls): found = re.search(MediafireCom.FILE_SIZE_PATTERN, html) if found is not None: - size, units = found.groups() - size = float(size) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[units] + size, units = found.group(1), found.group(2).replace('k','K') + size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] found = re.search(MediafireCom.FILE_NAME_PATTERN, html) if found is not None: @@ -53,9 +53,10 @@ class MediafireCom(Hoster): __name__ = "MediafireCom" __type__ = "hoster" __pattern__ = r"http://(?:\w*\.)*mediafire\.com/.*" - __version__ = "0.4" + __version__ = "0.5" __description__ = """Mediafire.com plugin - free only""" __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") PAGE1_FUNCTION_PATTERN = r"function %s\(qk,pk1\)\{if[^']*'loadingicon'\);[^;]*; (.*?)eval" PAGE1_KEY_PATTERN = ";break;}\s*(\w+='';\w+=unescape.*?)eval\(" @@ -71,7 +72,7 @@ class MediafireCom(Hoster): FINAL_LINK_PATTERN = r'parent.document.getElementById\(\'(\w{32})\'\).*(http://[^"]+)" \+(\w+)\+ "([^"]+)">' FILE_NAME_PATTERN = r'' - FILE_SIZE_PATTERN = r'
\(([0-9.]+) (kB|MB|GB)\)
' + FILE_SIZE_PATTERN = r'
\(([0-9.]+) (kB|KB|MB|GB)\)
' FILE_OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File. ' def setup(self): @@ -79,16 +80,20 @@ class MediafireCom(Hoster): def process(self, pyfile): self.html = self.load(pyfile.url) + self.getFileInfo(pyfile) + self.handleFree() + def getFileInfo(self, pyfile): + if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline() + found = re.search(self.FILE_NAME_PATTERN, self.html) if not found: self.fail("Parse error (file name)") pyfile.name = found.group(1) found = re.search(self.FILE_SIZE_PATTERN, self.html) if found: - pyfile.size = float(found.group(1)) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[found.group(2)] - - self.handleFree() + size, units = found.group(1), found.group(2).replace('k','K') + pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] def handleFree(self): found = re.search(self.RECAPTCHA_PATTERN, self.html) diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py new file mode 100644 index 000000000..0a326c268 --- /dev/null +++ b/module/plugins/hoster/MegasharesCom.py @@ -0,0 +1,136 @@ +# -*- coding: utf-8 -*- +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see . + + @author: zoidberg +""" + +import re +from time import time +from module.plugins.Hoster import Hoster +from module.network.RequestFactory import getURL + +def getInfo(urls): + result = [] + + for url in urls: + html = getURL(url, decode=True) + if re.search(MegasharesCom.FILE_OFFLINE_PATTERN, html): + # File offline + result.append((url, 0, 1, url)) + else: + # Get file info + name, size = url, 0 + + found = re.search(MegasharesCom.FILE_SIZE_PATTERN, html) + if found is not None: + size, units = found.groups() + size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] + + found = re.search(MegasharesCom.FILE_NAME_PATTERN, html) + if found is not None: + name = found.group(1) + + if found or size > 0: + result.append((name, size, 2, url)) + yield result + + +class MegasharesCom(Hoster): + __name__ = "MegasharesCom" + __type__ = "hoster" + __pattern__ = r"http://(\w+\.)?megashares.com/.*" + __version__ = "0.1" + __description__ = """megashares.com plugin - free only""" + __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") + + FILE_NAME_PATTERN = '

]*title="([^"]+)">' + FILE_SIZE_PATTERN = 'Filesize: ([0-9.]+) (KB|MB|GB)
' + DOWNLOAD_URL_PATTERN = '