import requests


def get_best_variant(variants):
    """
    Returns the best variant for a video
    :param variants: Array with video variants
    :return: A URL with the best variant
    """
    bitrate = 0
    url = ""
    for v in variants:
        if ("bitrate" not in v and bitrate == 0) or ("bitrate" in v and v["bitrate"] > bitrate):
            bitrate = v["bitrate"] if "bitrate" in v else 0
            url = v["url"]
    if len(url) > 0:
        r = requests.get(url, stream=True)
        if r.status_code < 400:
            return r.raw
    return None