diff options
author | zoidberg10 <zoidberg@mujmail.cz> | 2011-12-12 18:22:27 +0100 |
---|---|---|
committer | zoidberg10 <zoidberg@mujmail.cz> | 2011-12-12 18:22:27 +0100 |
commit | f999accf64045a348cf06ee4ffce74c80762c1e9 (patch) | |
tree | 252be3bbe3c173dd9f67709a8afd7c35c5384e5c /module/plugins/crypter/MediafireComFolder.py | |
parent | closed #449 (diff) | |
download | pyload-f999accf64045a348cf06ee4ffce74c80762c1e9.tar.xz |
improve mediafire plugin
Diffstat (limited to 'module/plugins/crypter/MediafireComFolder.py')
-rw-r--r-- | module/plugins/crypter/MediafireComFolder.py | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/module/plugins/crypter/MediafireComFolder.py b/module/plugins/crypter/MediafireComFolder.py index 49a72ca76..1056a3947 100644 --- a/module/plugins/crypter/MediafireComFolder.py +++ b/module/plugins/crypter/MediafireComFolder.py @@ -2,13 +2,14 @@ import re from module.plugins.Crypter import Crypter +from module.plugins.hoster.MediafireCom import checkHTMLHeader from module.common.json_layer import json_loads class MediafireComFolder(Crypter): __name__ = "MediafireComFolder" __type__ = "crypter" __pattern__ = r"http://(\w*\.)*mediafire\.com/(folder/|\?).*" - __version__ = "0.10" + __version__ = "0.12" __description__ = """Mediafire.com Folder Plugin""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") @@ -18,25 +19,39 @@ class MediafireComFolder(Crypter): def decrypt(self, pyfile): new_links = [] - - html = self.load(pyfile.url) - found = re.search(self.FILE_URL_PATTERN, html) - if found: - new_links.append("http://www.mediafire.com/download.php?" + found.group(1)) - else: - found = re.search(self.FOLDER_KEY_PATTERN, html) - if not found: self.fail('Parse error: Folder Key') - folder_key = found.group(1) - self.logDebug("FOLDER KEY: %s" % folder_key) + + url, result = checkHTMLHeader(pyfile.url) + self.logDebug('Location (%d): %s' % (result, url)) - json_resp = json_loads(self.load("http://www.mediafire.com/api/folder/get_info.php?folder_key=%s&response_format=json&version=1" % folder_key)) - #self.logInfo(json_resp) - if json_resp['response']['result'] == "Success": - for link in json_resp['response']['folder_info']['files']: - new_links.append("http://www.mediafire.com/download.php?%s" % link['quickkey']) + if result == 0: + # load and parse html + html = self.load(pyfile.url) + found = re.search(self.FILE_URL_PATTERN, html) + if found: + # file page + new_links.append("http://www.mediafire.com/file/%s" % found.group(1)) else: - self.fail(json_resp['response']['message']) - + # folder page + found = re.search(self.FOLDER_KEY_PATTERN, html) + if found: + folder_key = found.group(1) + self.logDebug("FOLDER KEY: %s" % folder_key) + + json_resp = json_loads(self.load("http://www.mediafire.com/api/folder/get_info.php?folder_key=%s&response_format=json&version=1" % folder_key)) + #self.logInfo(json_resp) + if json_resp['response']['result'] == "Success": + for link in json_resp['response']['folder_info']['files']: + new_links.append("http://www.mediafire.com/file/%s" % link['quickkey']) + else: + self.fail(json_resp['response']['message']) + else: + fileID = re.search(self.__pattern__, pyfile.url) + new_links.append("ttp://www.mediafire.com/file/%s" % fileID) + elif result == 1: + self.offline() + else: + new_links.append(url) + if new_links: self.core.files.addLinks(new_links, self.pyfile.package().id) else: |