def extract_id(url):
 if (not isinstance(url, basestring)):
  return
 m = re.search(u'((?:nm|tt)[\\d]{7})', url)
 if m:
  return m.group(1)

def extract_id ( url ) : if ( not isinstance ( url , basestring ) ) : return m = re . search ( u'((?:nm|tt)[\\d]{7})' , url ) if m : return m . group ( 1 )
return imdb id of the given url .