def tetl(url): """ Extracts the destination URL of the te.tl shortened link. """ up = urlparse(url) new_url = "{0}://www.{1}{2}".format(up.scheme, up.netloc, up.path) response = make_request(new_url) response = get_long_url(url, response) return response
def surlhu(url): """ Filters the destination URL of the passed surl.hu shortened URL. """ up = urlparse(url) preview_url = "http://surl.hu/s.php/{0}".format(up.path[1:]) response = make_request(preview_url) response = get_long_url(url, response) return response
def tinypl(url): """ Extracts the destination URL of a tiny.pl shortened URL. """ if url.endswith("!") or url.endswith("/"): url = url[:-1] up = urlparse(url) new_url = "{0}://{1}/co.php?d={2}".format(up.scheme, up.netloc, up.path[1:]) response = get_long_url(url, make_request(new_url)) return response
def minume(url): """ Custom routine for minu.me shortened URLs. """ # add the special char which switches to the preview function if url.endswith("/"): new_url = url + "p" else: new_url = url + "/p" # Make the request and reset the url response = get_long_url(url, make_request(new_url)) return response
def xavcc(url): """ Extracts the destination URL of xav.cc shortened URLs. """ # xav.cc returns with 403 status codes when you use your browser to click a # shortened link, not quite sure whats going on with their website but default # user agents are declined by their service. response = make_request(url, headers={"User-Agent": "I'm a tiny spider :]"}) if response.status_code in (301, 302): response = meta_redirect(url) else: response = get_long_url(url, response) return response
def smrl(url): """ Extracts the destination of a smrl.tk shortened URL (or one of it's domains). """ # smrl.tk and it's domains make use of iframes to show where the destination # points to. We have to set the passed URL, with the additional /info path, # as the referer parameter and make a GET request to srv.smrls.net if url.endswith("/"): url = url[:-1] up = urlparse(url) referer = "{0}://{1}{2}/info".format(up.scheme, up.netloc, up.path) headers = {"Referer": referer} response = make_request("http://srv.smrls.net/", headers=headers) response.group_marker = "__smrl__" response = get_long_url(url, response) return response
def zumlink(url): """ Extracts the destination URL or URLs from the zumlink.com shortened URL. """ # Zumlink.com's URL shortener supports both shortening one single link and # multiple links, this method is able to extract both types of shortened links. response = make_request(url, allow_redir=False) if not response.success: return response elif "location" in response.headers: response.long_url = response.headers["location"] elif response.source: response = get_long_url(url, response) else: response.error_msg = "Failed to extract the destination URL o_O" response.success = False return response
def zapitnu(url): """ Extracts the long URL of zapit.nu shortened links. """ if url.endswith("+"): url = url[:-1] response = get_long_url(url, make_request("{0}+".format(url))) return response