diff options
author | zoidberg10 <zoidberg@mujmail.cz> | 2011-11-13 00:47:02 +0100 |
---|---|---|
committer | zoidberg10 <zoidberg@mujmail.cz> | 2011-11-13 00:47:02 +0100 |
commit | e3a62f8a2e9dcb4212f6fa8e1a94f832ad66d35a (patch) | |
tree | 121b107759d11e11890267355119ecf47e3e7fba /module/plugins/hoster/UploadkingCom.py | |
parent | Merged in nick_de/pyload (pull request #5) (diff) | |
download | pyload-e3a62f8a2e9dcb4212f6fa8e1a94f832ad66d35a.tar.xz |
Move getFileInfo to SimpleHoster.py; update Mediafire
Diffstat (limited to 'module/plugins/hoster/UploadkingCom.py')
-rw-r--r-- | module/plugins/hoster/UploadkingCom.py | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/module/plugins/hoster/UploadkingCom.py b/module/plugins/hoster/UploadkingCom.py index d29a06e48..a706e95bc 100644 --- a/module/plugins/hoster/UploadkingCom.py +++ b/module/plugins/hoster/UploadkingCom.py @@ -17,60 +17,34 @@ """ import re -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(UploadkingCom.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - # Get file info - name, size = url, 0 - - found = re.search(UploadkingCom.FILE_INFO_PATTERN, html) - if found is not None: - name, size, units = found.groups() - size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - result.append((name, size, 2, url)) + file_info = parseFileInfo(UploadkingCom, url, getURL(url, decode=False)) + result.append(file_info) + yield result -class UploadkingCom(Hoster): +class UploadkingCom(SimpleHoster): __name__ = "UploadkingCom" __type__ = "hoster" __pattern__ = r"http://(?:www\.)?uploadking\.com/\w{10}" - __version__ = "0.1" + __version__ = "0.12" __description__ = """UploadKing.com plugin - free only""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") - FILE_INFO_PATTERN = r'<font style="font-size:\d*px;">File(?:name)?:\s*<(?:b|/font><font[^>]*)>([^<]+)(?:</b>)?</div></TD></TR><TR><TD[^>]*><font style="font-size:\d*px;">(?:Files|S)ize:\s*<(?:b|/font><font[^>]*)>([0-9.]+) (KB|MB|GB)</(?:b|font)>' + FILE_INFO_PATTERN = r'<font style="font-size:\d*px;">File(?:name)?:\s*<(?:b|/font><font[^>]*)>([^<]+)(?:</b>)?</div></TD></TR><TR><TD[^>]*><font style="font-size:\d*px;">(?:Files|S)ize:\s*<(?:b|/font><font[^>]*)>([0-9.]+) ([kKMG]i?B)</(?:b|font)>' FILE_OFFLINE_PATTERN = r'<center><font[^>]*>Unfortunately, this file is unavailable</font></center>' FILE_URL_PATTERN = r'id="dlbutton"><a href="([^"]+)"' - def setup(self): - self.multiDL = False - - def process(self, pyfile): - self.html = self.load(pyfile.url, decode = True) - self.getFileInfo(pyfile) - self.handleFree(pyfile) - - def getFileInfo(self, pyfile): - if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline() - - found = re.search(self.FILE_INFO_PATTERN, self.html) - if not found: self.fail("Parse error (file info)") - pyfile.name, size, units = found.groups() - pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units] - - def handleFree(self, pyfile): + def handleFree(self): found = re.search(self.FILE_URL_PATTERN, self.html) - if not found: self.fail("Captcha key not found") + if not found: self.fail("Download URL not found") url = found.group(1) - + self.logDebug("DOWNLOAD URL: " + url) self.download(url)
\ No newline at end of file |