You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB
Python

import re, sys
from resolvers import *
from HTMLParser import HTMLParser
# Fix encoding to deal with UTF-8 page contents
reload(sys)
sys.setdefaultencoding("UTF-8")
# Main functions
def resolve(url):
if re.match("https?:\/\/(www\.)?putlocker\.com", url) is not None:
return putlocker.resolve(url)
elif re.match("https?:\/\/(www\.)?sockshare\.com", url) is not None:
return sockshare.resolve(url)
elif re.match("https?:\/\/(www\.)?1channel\.ch\/external\.php", url) is not None:
return onechannel.resolve(url)
elif re.match("https?:\/\/(www\.)?youtube\.com\/watch\?", url) is not None:
return youtube.resolve(url)
elif re.match("https?:\/\/(www\.)?filebox\.com\/[a-zA-Z0-9]+", url) is not None:
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 {}
def recurse(url):
previous_result = {}
while True:
result = resolve(url)
if result == {}:
return previous_result
elif 'url' not in result:
return result
url = result['url']
previous_result = result
# Exception classes
class ResolverError(Exception):
def __init__(self, value):
self.val = value
def __str__(self):
return repr(self.val)
# Utility functions
def unescape(s):
return HTMLParser.unescape.__func__(HTMLParser, s)