def youtube(link):
 pattern = 'http://www\\.youtube\\.com\\/watch\\?v=([a-zA-Z0-9\\-\\_]+)'
 match = re.match(pattern, link)
 if (not match):
  pattern = 'http:\\/\\/youtu.be\\/([a-zA-Z0-9\\-\\_]+)'
  match = re.match(pattern, link)
 if (not match):
  return None
 return ('http://www.youtube.com/embed/%s' % match.group(1))

def youtube ( link ) : pattern = 'http://www\\.youtube\\.com\\/watch\\?v=([a-zA-Z0-9\\-\\_]+)' match = re . match ( pattern , link ) if ( not match ) : pattern = 'http:\\/\\/youtu.be\\/([a-zA-Z0-9\\-\\_]+)' match = re . match ( pattern , link ) if ( not match ) : return None return ( 'http://www.youtube.com/embed/%s' % match . group ( 1 ) )
youtube <query> -- returns the first youtube search result for <query> .