def channelfromname(user):
 cached = userdata_cached(user)
 if cached:
  (user, channel_id) = cached
 else:
  qs = {'part': 'id,snippet', 'maxResults': 1, 'q': user, 'type': 'channel'}
  try:
   userinfo = pafy.call_gdata('search', qs)['items']
   if (len(userinfo) > 0):
    snippet = userinfo[0].get('snippet', {})
    channel_id = snippet.get('channelId', user)
    username = snippet.get('title', user)
    user = cache_userdata(user, username, channel_id)[0]
   else:
    g.message = 'User {} not found.'.format(((c.y + user) + c.w))
    return
  except pafy.GdataError as e:
   g.message = 'Could not retrieve information for user {}\n{}'.format(((c.y + user) + c.w), e)
   util.dbg('Error during channel request for user {}:\n{}'.format(user, e))
   return
 return (user, channel_id)

def channelfromname ( user ) : cached = userdata_cached ( user ) if cached : ( user , channel_id ) = cached else : qs = { 'part' : 'id,snippet' , 'maxResults' : 1 , 'q' : user , 'type' : 'channel' } try : userinfo = pafy . call_gdata ( 'search' , qs ) [ 'items' ] if ( len ( userinfo ) > 0 ) : snippet = userinfo [ 0 ] . get ( 'snippet' , { } ) channel_id = snippet . get ( 'channelId' , user ) username = snippet . get ( 'title' , user ) user = cache_userdata ( user , username , channel_id ) [ 0 ] else : g . message = 'User {} not found.' . format ( ( ( c . y + user ) + c . w ) ) return except pafy . GdataError as e : g . message = 'Could not retrieve information for user {}\n{}' . format ( ( ( c . y + user ) + c . w ) , e ) util . dbg ( 'Error during channel request for user {}:\n{}' . format ( user , e ) ) return return ( user , channel_id )
query channel id from username .