Advertisement
dalgeek

Download Unity Connection recorded names

Feb 18th, 2025 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.00 KB | Software | 0 0
  1. import requests
  2. from urllib3 import disable_warnings
  3. from urllib3.exceptions import InsecureRequestWarning
  4. import xmltodict
  5.  
  6. """Warning: this script has not been tested in production.
  7. It has no throttling or error checking. Don't complain to me
  8. if you tank your production server.
  9.  
  10. This will download all user voicename files to the current
  11. directory with the name "alias.wav"
  12.  
  13. Update the uxcnhost, cupiuser, and cupipass to match your environment.
  14. """
  15. disable_warnings(InsecureRequestWarning)
  16.  
  17. ucxnhost = ""
  18. cupiuser = ''
  19. cupipass = ''
  20.  
  21. def vmrest_get(ucxnhost: str, uri: str, username:str, password:str, filename: str = None):
  22.    
  23.     url = f"https://{ucxnhost}/{uri}"
  24.     basic_auth = requests.auth.HTTPBasicAuth(username, password)
  25.     response = requests.get(url, auth=basic_auth, verify=False)
  26.    
  27.     if response.status_code == 404:
  28.         return None
  29.     elif response.status_code == 200:
  30.         if filename:
  31.             with open(filename, 'wb') as f_output:
  32.                 f_output.write(response.content)
  33.                 return True
  34.         else:
  35.             response_dict = xmltodict.parse(response.content)
  36.             return response_dict
  37.  
  38. # Can use a query to limit the users returned if needed
  39. allusers = vmrest_get(ucxnhost, "/vmrest/users?query=(alias startswith a)", cupiuser, cupipass)
  40. #allusers = vmrest_get(ucxnhost, "/vmrest/users", cupiuser, cupipass)
  41. for user in allusers['Users']['User']:
  42.     user_uri = user['URI']
  43.     user_info = vmrest_get(ucxnhost, user_uri, cupiuser, cupipass)
  44.     #print (user_info)
  45.     user_alias = user_info['User']['Alias']
  46.     if "VoiceNameURI" in user_info['User']:
  47.         user_voicename_uri = user_info['User']['VoiceNameURI']
  48.         print (f"Alias: {user_alias}\tVoiceNameURI: {user_voicename_uri}")
  49.         user_voicename_file = f"{user_alias}.wav"
  50.         download = vmrest_get(ucxnhost, user_voicename_uri, cupiuser, cupipass, filename=user_voicename_file)
  51.     else:
  52.         print (f"Alias: {user_alias}\tVoiceNameURI: NULL")
  53.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement