From e3a62f8a2e9dcb4212f6fa8e1a94f832ad66d35a Mon Sep 17 00:00:00 2001 From: zoidberg10 Date: Sun, 13 Nov 2011 00:47:02 +0100 Subject: Move getFileInfo to SimpleHoster.py; update Mediafire --- module/plugins/hoster/MegasharesCom.py | 63 +++++++++------------------------- 1 file changed, 17 insertions(+), 46 deletions(-) (limited to 'module/plugins/hoster/MegasharesCom.py') diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index 0a326c268..3c17eb979 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -18,40 +18,23 @@ import re from time import time -from module.plugins.Hoster import Hoster +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo 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)) + file_info = parseFileInfo(MegasharesCom, url, getURL(url, decode=True)) + result.append(file_info) + yield result - -class MegasharesCom(Hoster): +class MegasharesCom(SimpleHoster): __name__ = "MegasharesCom" __type__ = "hoster" __pattern__ = r"http://(\w+\.)?megashares.com/.*" - __version__ = "0.1" + __version__ = "0.12" __description__ = """megashares.com plugin - free only""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") @@ -59,35 +42,23 @@ class MegasharesCom(Hoster): FILE_NAME_PATTERN = '

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