summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-01-16 23:41:31 +0100
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-01-16 23:41:31 +0100
commit230147695a21b447273b7207f1370358600dc494 (patch)
treeb9579c84175a17d47e3af1359be347168ba4fe40 /module
parentworkaround premium4.me overcharging (diff)
downloadpyload-230147695a21b447273b7207f1370358600dc494.tar.xz
megashares.com premium
Diffstat (limited to 'module')
-rw-r--r--module/plugins/accounts/MegasharesCom.py42
-rw-r--r--module/plugins/hoster/MegasharesCom.py48
2 files changed, 70 insertions, 20 deletions
diff --git a/module/plugins/accounts/MegasharesCom.py b/module/plugins/accounts/MegasharesCom.py
new file mode 100644
index 000000000..91601fc95
--- /dev/null
+++ b/module/plugins/accounts/MegasharesCom.py
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+
+from module.plugins.Account import Account
+import re
+from time import mktime, strptime
+
+class MegasharesCom(Account):
+ __name__ = "MegasharesCom"
+ __version__ = "0.02"
+ __type__ = "account"
+ __description__ = """megashares.com account plugin"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ VALID_UNTIL_PATTERN = r'<p class="premium_info_box">Period Ends: (\w{3} \d{1,2}, \d{4})</p>'
+
+ def loadAccountInfo(self, user, req):
+ #self.relogin(user)
+ html = req.load("http://d01.megashares.com/myms.php", decode = True)
+
+ premium = False if '>Premium Upgrade<' in html else True
+
+ validuntil = trafficleft = -1
+ try:
+ timestr = re.search(self.VALID_UNTIL_PATTERN, html).group(1)
+ self.logDebug(timestr)
+ validuntil = mktime(strptime(timestr, "%b %d, %Y"))
+ except Exception, e:
+ self.logError(e)
+
+ return {"validuntil": validuntil, "trafficleft": -1, "premium": premium}
+
+ def login(self, user, data, req):
+ html = req.load('http://d01.megashares.com/myms_login.php', post = {
+ "httpref": "",
+ "myms_login": "Login",
+ "mymslogin_name": user,
+ "mymspassword": data['password']
+ }, decode = True)
+
+ if not '<span class="b ml">%s</span>' % user in html:
+ self.wrongPassword() \ No newline at end of file
diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py
index a1dd6e694..3fac633bc 100644
--- a/module/plugins/hoster/MegasharesCom.py
+++ b/module/plugins/hoster/MegasharesCom.py
@@ -19,20 +19,19 @@
import re
from time import time
from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
-from module.network.RequestFactory import getURL
class MegasharesCom(SimpleHoster):
__name__ = "MegasharesCom"
__type__ = "hoster"
__pattern__ = r"http://(\w+\.)?megashares.com/.*"
- __version__ = "0.13"
+ __version__ = "0.21"
__description__ = """megashares.com plugin - free only"""
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
FILE_NAME_PATTERN = '<h1 class="black xxl"[^>]*title="(?P<N>[^"]+)">'
FILE_SIZE_PATTERN = '<strong><span class="black">Filesize:</span></strong> (?P<S>[0-9.]+) (?P<U>[kKMG])i?B<br />'
- DOWNLOAD_URL_PATTERN = '<div id="show_download_button_2" style="display:none">\s*<a href="([^"]+)">'
+ DOWNLOAD_URL_PATTERN = '<div id="show_download_button_%d"[^>]*>\s*<a href="([^"]+)">'
PASSPORT_LEFT_PATTERN = 'Your Download Passport is: <[^>]*>(\w+).*\s*You have\s*<[^>]*>\s*([0-9.]+) ([kKMG]i?B)'
PASSPORT_RENEW_PATTERN = 'Your download passport will renew in\s*<strong>(\d+)</strong>:<strong>(\d+)</strong>:<strong>(\d+)</strong>'
REACTIVATE_NUM_PATTERN = r'<input[^>]*id="random_num" value="(\d+)" />'
@@ -41,15 +40,21 @@ class MegasharesCom(SimpleHoster):
NO_SLOTS_PATTERN = r'<dd class="red">All download slots for this link are currently filled'
FILE_OFFLINE_PATTERN = r'<dd class="red">(Invalid Link Request|Link has been deleted)'
- def process(self, pyfile):
- self.html = self.load(pyfile.url, decode=True)
+ def setup(self):
+ self.resumeDownload = True
+ self.multiDL = True if self.premium else False
+
+ def handlePremium(self):
+ self.handleDownload(True)
+
+ def handleFree(self):
+ self.html = self.load(self.pyfile.url, decode=True)
+
if self.NO_SLOTS_PATTERN in self.html:
self.retry(wait_time = 300)
+
self.getFileInfo()
- self.handleFree()
-
- def handleFree(self):
- if self.pyfile.size > 576716800: self.fail("This file is too large for free download")
+ #if self.pyfile.size > 576716800: self.fail("This file is too large for free download")
# Reactivate passport if needed
found = re.search(self.REACTIVATE_PASSPORT_PATTERN, self.html)
@@ -82,19 +87,22 @@ class MegasharesCom(SimpleHoster):
self.logInfo("Download passport: %s" % found.group(1))
data_left = float(found.group(2)) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[found.group(3)]
self.logInfo("Data left: %s %s (%d MB needed)" % (found.group(2), found.group(3), self.pyfile.size / 1048576))
- if self.pyfile.size > data_left:
+
+ if not data_left:
found = re.search(self.PASSPORT_RENEW_PATTERN, self.html)
- if not found: self.fail('Passport renew time not found')
- renew = found.group(1) + 60 * (found.group(2) + 60 * found.group(3))
- self.retry(renew, 3, "Unable to get passport")
-
- # Find download link
- found = re.search(self.DOWNLOAD_URL_PATTERN, self.html)
- if not found: self.fail('Download link not found')
+ renew = (found.group(1) + 60 * (found.group(2) + 60 * found.group(3))) if found else 600
+ self.retry(renew, 15, "Unable to get passport")
+
+ self.handleDownload(False)
+
+ def handleDownload(self, premium = False):
+ # Find download link;
+ found = re.search(self.DOWNLOAD_URL_PATTERN % (1 if premium else 2), self.html)
+ msg = '%s download URL' % ('Premium' if premium else 'Free')
+ if not found: self.parseError(msg)
+
download_url = found.group(1)
-
- # Download
- self.logDebug("Download URL: %s" % download_url)
+ self.logDebug("%s: %s" % (msg, download_url))
self.download(download_url)
getInfo = create_getInfo(MegasharesCom) \ No newline at end of file