def json_user_library():
  if 'gs_session' in session:
    if gs.authenticated_find(session['gs_session']):
      library_result = gs.get_user_library_songs(session['gs_session'])
    else:
      #User not authenticated. Need to authenticate.
      pass
  else:
    #User has no session.
    pass
  return json.dumps(library_result)
def test_authenticate(sID):
  r = gs.authenticate(sID, 'asdfprou', os.environ.get('GS_USER_PW'))
  print r
  r = gs.get_user_library_songs(sID)
  print r
  if r:
    print 'got songs'
  else:
    print 'no songs'
  r = gs.add_user_favorite_song(sID, '33123639')
  r = gs.add_user_favorite_song(sID, '33332120')
  r = gs.remove_user_favorite_songs(sID, ['33332120', '33123639'])
  r = gs.get_user_playlists(sID)
  r = gs.logout(sID)
def json_authenticate():
  if request.method == 'GET':
    username = request.args.get('username')
    password = request.args.get('password')
    auth_result = ''
    library_result = ''
    if 'gs_session' in session:
      if username and password:
        auth_result = gs.authenticate(session['gs_session'], username, password)
        library_result = gs.get_user_library_songs(session['gs_session'])
      else:
        auth_result = False
    else:
      #User no session.
      auth_result = False

    return json.dumps(library_result)