def linkedin(url): """ Extract the long URL of the lnkd.in shortened URLs. """ up = urlparse(url) new_url = "http://www.linkedin.com/slink?code=" + up.path[1:] response = read_headers(new_url) response.url = url return response
def twotuus(url): """ Extracts the destination URL of a 2tu.us shortened URL. """ # 2tu.us for some reason disallows standard User-Agents, you get a 403 # status code when using the default Firefox Agent. kwargs = {"User-Agent": ""} response = read_headers(url, **kwargs) return response
def cutst(url): """ Extracts the destination URL of cut.st and it's former domain 5v5.net. """ up = urlparse(url) new_url = "{0}://cut.st/url_redirector.php?url={1}".format(up.scheme, up.path[1:]) response = read_headers(new_url) response.url = url return response
def ptitlien(url): """ Extract the destination URL of pitlien.com shortened URLs. """ new_url = url up = urlparse(new_url) new_url = "{0}://www.{1}{2}".format(up.scheme, up.netloc, up.path) response = read_headers(new_url) response.url = url return response
def hurlws(url): """ Extracts the destination URL of a hurl.ws shortened URL. """ # hurl.ws URLs require the 'www.' part if "www." not in url: up = urlparse(url) url = "{0}://www.{1}{2}".format(up.scheme, up.netloc, up.path) response = read_headers(url) response.url = url return response
def supsus(url): """ Extracts the destination of sups.us or socialups.com shortened URLs. """ up = urlparse(url) new_url = url if "socialups" not in up.netloc or "www." not in up.netloc: new_url = "http://www.socialups.com{0}".format(up.path) response = read_headers(new_url) response.url = url return response
def sockroll(url): """ Extracts the sockroll.com shortened destination URL. """ new_url = url up = urlparse(new_url) if "www." not in up.netloc: new_url = "{0}://www.sockroll.com{1}".format(up.scheme, up.path) response = read_headers(new_url) response.url = url return response
def owlli(url): """ Extract the destination URL of owl.li shortened links. """ # the owl.li domain redirects to their new service located at ow.ly up = urlparse(url) new_url = "{0}://{1}{2}".format(up.scheme, up.netloc.replace("l.li", ".ly"), up.path) response = read_headers(new_url) response.url = url return response
def tumblr(url): """ Extracts the destination URL of a shortened tumblr.co or tumblr.com URL. """ # tumblr.co/short_url -> www.tumblr.com/short_url -> destination original_url = url up = urlparse(url) if up.netloc == "tmblr.co" or "www." not in up.netloc: url = ("{0}://www.tumblr.com{1}".format(up.scheme, up.path)) response = read_headers(url) response.url = original_url return response
def livemixtapes(url): """ Extracts the destination of a livemixtap.es shortened URL. """ # http://livemixtap.es/ -> http://www.livemixtapes.com/r/jac -> destination up = urlparse(url) if "/r/" in up.path and "www." not in up.netloc: new_url = "http://www.{0}{1}".format(up.netloc, up.path) elif "/r/" in up.path: new_url = url else: new_url = "http://www.livemixtapes.com/r{0}".format(up.path) response = read_headers(new_url) response.url = url return response
def xeeurl(url): """ Extracts the destination URL of a shortened xeeurl.com URL. """ if not url.endswith("/"): url += "/" response = read_headers(url) return response