def check_youku_video(o, url, host = None, path = None, query = None): matched, website_id, video_id, format, search, queue, report_hit = True, 'youku', None, '', True, True, True if not (host and path and query): fragments = urlparse.urlsplit(url) [host, path, query] = [fragments[1], fragments[2], fragments[3]] if is_valid_ip(host) and VALIDATE_YOUKU_VIDEO_REGEX.search(path): try: video_id = urllib.quote(path.strip('/').split('/')[-1]) except Exception, e: pass
def check_xhamster_video(o, url, host = None, path = None, query = None): matched, website_id, video_id, format, search, queue, report_hit = True, 'xhamster', None, '', True, True, True if not (host and path and query): fragments = urlparse.urlsplit(url) [host, path, query] = [fragments[1], fragments[2], fragments[3]] if VALIDATE_XHAMSTER_DOMAIN_REGEX.search(host) and VALIDATE_XHAMSTER_VIDEO_REGEX3.search(path): pass elif is_valid_ip(host) and VALIDATE_XHAMSTER_VIDEO_REGEX1.search(path): queue = False elif host.find('.xhcdn.com') > -1 and VALIDATE_XHAMSTER_VIDEO_REGEX2.search(path): search = False else: matched = False if matched: try: video_id = urllib.quote(urllib.unquote(path).strip('/').split('/')[-1]) except Exception, e: pass