def is_youtube_video(link):
    content = urllib2.unquote(link).decode('utf8')
    # shortened YT url
    result = re.search('http://youtu.be', content, flags=re.IGNORECASE)
    if result is None:
        result = re.search('www.youtube.com', content, flags=re.IGNORECASE)
        if result is None:
            return False
        else:
            video_prefix = "watch?v="
    else:
        video_prefix = "youtu.be/"

    try:
        logging.info(content)
        id_pos = content.index(video_prefix) + len(video_prefix)
        video_id = content[id_pos:]
        try:
            param_pos = video_id.index("&")
            video_id_trimed = video_id[:param_pos]
        except ValueError:
            video_id_trimed = video_id
    except ValueError:
        logging.info('badly formed video url')
        return False

    return video_id_trimed
Test that the panel only inserts content after generate_stats and
dataset/ETHPy150Open GoogleDeveloperExperts/experts-app-backend/services/update_gplus.py/is_youtube_video--crossover with--dataset/ETHPy150Open django-debug-toolbar/django-debug-toolbar/tests/panels/test_profiling.py/ProfilingPanelTestCase.test_insert_content