diff --git a/resolv/__init__.py b/resolv/__init__.py index a65ec0b..6c0ac33 100644 --- a/resolv/__init__.py +++ b/resolv/__init__.py @@ -14,6 +14,8 @@ def resolve(url): return filebox.resolve(url) elif re.match("https?:\/\/(www\.)?pastebin\.com\/[a-zA-Z0-9]+", url) is not None: return pastebin.resolve(url) + elif re.match("https?:\/\/(www\.)?mediafire\.com\/\?[a-z0-9]+", url) is not None: + return mediafire.resolve(url) else: return {} diff --git a/resolv/resolvers/__init__.py b/resolv/resolvers/__init__.py index cda6834..b514ffd 100644 --- a/resolv/resolvers/__init__.py +++ b/resolv/resolvers/__init__.py @@ -5,3 +5,4 @@ from onechannel import * from youtube import * from filebox import * from pastebin import * +from mediafire import * diff --git a/resolv/resolvers/mediafire.py b/resolv/resolvers/mediafire.py new file mode 100644 index 0000000..0b5456d --- /dev/null +++ b/resolv/resolvers/mediafire.py @@ -0,0 +1,22 @@ +import re, urllib2 +from resolv.shared import ResolverError, unescape + +def resolve(url): + try: + contents = urllib2.urlopen(url).read() + except: + raise ResolverError("Could not retrieve the specified URL.") + + matches = re.search('kNO = "([^"]+)";', contents) + + if matches is None: + raise ResolverError("No download was found on the given URL; the server for this file may be in maintenance mode, or the given URL may not be valid. It is also possible that you have been blocked - CAPTCHA support is not yet present.") + + file_url = matches.group(1) + + try: + file_title = unescape(re.search('([^<]+)<\/title>', contents).group(1)) + except: + raise ResolverError("Could not find the download title.") + + return { 'title': file_title, 'files': { 'file': file_url } }