‘NoneType’ object has no attribute ‘group’

The error is in your line 11, your re.search is returning no results, ie None, and then you’re trying to call fmtre.group but fmtre is None, hence the AttributeError.

You could try:

def getVideoUrl(content):
    fmtre = re.search('(?<=fmt_url_map=).*', content)
    if fmtre is None:
        return None
    grps = fmtre.group(0).split('&amp;')
    vurls = urllib2.unquote(grps[0])
    videoUrl = None
    for vurl in vurls.split('|'):
        if vurl.find('itag=5') > 0:
            return vurl
    return None

Leave a Comment