summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/hooks/SkipRev.py6
-rw-r--r--module/plugins/hoster/MediafireCom.py122
2 files changed, 33 insertions, 95 deletions
diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py
index a543ef71c..034d2b803 100644
--- a/module/plugins/hooks/SkipRev.py
+++ b/module/plugins/hooks/SkipRev.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
+import re
+
from types import MethodType
from urllib import unquote
from urlparse import urlparse
@@ -18,7 +20,7 @@ def _setup(self):
class SkipRev(Hook):
__name__ = "SkipRev"
__type__ = "hook"
- __version__ = "0.27"
+ __version__ = "0.28"
__config__ = [("mode" , "Auto;Manual", "Choose rev files to keep for package", "Auto"),
("tokeep", "int" , "Custom number of files to keep" , 0 )]
@@ -35,7 +37,7 @@ class SkipRev(Hook):
def _name(self, pyfile):
if hasattr(pyfile.pluginmodule, "getInfo"): #@NOTE: getInfo is deprecated in 0.4.10
- return getattr(pyfile.pluginmodule, "getInfo")([pyfile.url]).next()[0]
+ return pyfile.pluginmodule.getInfo([pyfile.url]).next()[0]
else:
self.logWarning("Unable to grab file name")
return urlparse(unquote(pyfile.url)).path.split('/')[-1]
diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py
index bc81c8202..54df531bd 100644
--- a/module/plugins/hoster/MediafireCom.py
+++ b/module/plugins/hoster/MediafireCom.py
@@ -3,126 +3,62 @@
import re
from module.plugins.internal.CaptchaService import SolveMedia
-from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
-from module.network.RequestFactory import getURL
-
-
-def replace_eval(js_expr):
- return js_expr.replace(r'eval("', '').replace(r"\'", r"'").replace(r'\"', r'"')
-
-
-def checkHTMLHeader(url):
- try:
- for _i in xrange(3):
- header = getURL(url, just_header=True)
-
- for line in header.splitlines():
- line = line.lower()
-
- if 'location' in line:
- url = line.split(':', 1)[1].strip()
- if 'error.php?errno=320' in url:
- return url, 1
-
- if not url.startswith('http://'):
- url = 'http://www.mediafire.com' + url
-
- break
-
- elif 'content-disposition' in line:
- return url, 2
- else:
- break
- except Exception:
- return url, 3
- else:
- return url, 0
-
-
-def getInfo(urls):
- for url in urls:
- location, status = checkHTMLHeader(url)
-
- if status:
- file_info = (url, 0, status, url)
- else:
- file_info = parseFileInfo(MediafireCom, url, getURL(url, decode=True))
-
- yield file_info
+from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
class MediafireCom(SimpleHoster):
__name__ = "MediafireCom"
__type__ = "hoster"
- __version__ = "0.84"
+ __version__ = "0.85"
- __pattern__ = r'http://(?:www\.)?mediafire\.com/(file/|(view/?|download\.php)?\?)(\w{11}|\w{15})($|/)'
+ __pattern__ = r'https?://(?:www\.)?mediafire\.com/(file/|view/\??|download(\.php\?|/))\w+'
__description__ = """Mediafire.com hoster plugin"""
__license__ = "GPLv3"
__authors__ = [("zoidberg", "zoidberg@mujmail.cz"),
- ("stickell", "l.stickell@yahoo.it")]
+ ("stickell", "l.stickell@yahoo.it"),
+ ("Walter Purcaro", "vuolter@gmail.com")]
+
+ NAME_PATTERN = r'<META NAME="description" CONTENT="(?P<N>.+?)"/>'
+ SIZE_PATTERN = r'<li>File size: <span>(?P<S>[\d.,]+) (?P<U>[\w^_]+)'
+ INFO_PATTERN = r'oFileSharePopup\.ald\(\'.*?\',\'(?P<N>.+?)\',\'(?P<S>[\d.,]+)\s*(?P<U>[\w^_]+)\',\'\',\'(?P<H>.+?)\'\)'
+ OFFLINE_PATTERN = r'class="error_msg_title"'
- NAME_PATTERN = r'<META NAME="description" CONTENT="(?P<N>[^"]+)"/>'
- INFO_PATTERN = r'oFileSharePopup\.ald\(\'(?P<ID>[^\']*)\',\'(?P<N>[^\']*)\',\'(?P<S>[^\']*)\',\'\',\'(?P<H>[^\']*)\'\)'
- OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File. </div>'
+ LINK_FREE_PATTERN = r'kNO = "(.+?)"'
PASSWORD_PATTERN = r'<form name="form_password"'
def setup(self):
- self.multiDL = False
-
-
- def process(self, pyfile):
- pyfile.url = re.sub(r'/view/?\?', '/?', pyfile.url)
+ self.resumeDownload = True
+ self.multiDL = True
- self.link, result = checkHTMLHeader(pyfile.url)
- self.logDebug("Location (%d): %s" % (result, self.link))
- if result == 0:
- self.html = self.load(self.link, decode=True)
- self.checkCaptcha()
- self.multiDL = True
- self.check_data = self.getFileInfo()
-
- if self.account:
- self.handlePremium(pyfile)
- else:
- self.handleFree(pyfile)
- elif result == 1:
- self.offline()
- else:
- self.multiDL = True
- self.download(self.link, disposition=True)
+ def handleFree(self, pyfile):
+ solvemedia = SolveMedia(self)
+ captcha_key = solvemedia.detect_key()
+ if captcha_key:
+ response, challenge = solvemedia.challenge(captcha_key)
+ self.html = self.load(pyfile.url,
+ post={'adcopy_challenge': challenge,
+ 'adcopy_response' : response},
+ decode=True)
- def handleFree(self, pyfile):
if self.PASSWORD_PATTERN in self.html:
password = self.getPassword()
- if password:
- self.logInfo(_("Password protected link, trying ") + password)
- self.html = self.load(self.link, post={"downloadp": password})
+ if not password:
+ self.fail(_("No password found"))
+ else:
+ self.logInfo(_("Password protected link, trying: ") + password)
+ self.html = self.load(self.link, post={'downloadp': password})
if self.PASSWORD_PATTERN in self.html:
self.fail(_("Incorrect password"))
- else:
- self.fail(_("No password found"))
-
- m = re.search(r'kNO = r"(http://.*?)";', self.html)
- if m is None:
- self.error(_("No download URL"))
- download_url = m.group(1)
- self.download(download_url)
+ return super(MediafireCom, self).handleFree(pyfile)
- def checkCaptcha(self):
- solvemedia = SolveMedia(self)
- response, challenge = solvemedia.challenge()
- self.html = self.load(self.link,
- post={'adcopy_challenge': challenge,
- 'adcopy_response' : response},
- decode=True)
+getInfo = create_getInfo(MediafireCom)