def main(): # Initialise vrcpy wrapper client and login with username + password client = vrcpy.Client() client.login("username", "password") # Close client session, invalidate auth cookie client.logout()
def twofactorauth(): # Initialise vrcpy wrapper client client = vrcpy.Client() # Login with username + password, then verify 2-factor-auth code # Can be done in 1 line via: # client.login2fa("username", "password", code="123456", verify=True) client.login2fa("username", "password") client.verify2fa("123456") # Close client session, invalidate auth cookie client.logout()
def main(): # Initialise vrcpy wrapper client and login with username + password client = vrcpy.Client() client.login("username", "password") # Get avatar via id a = client.fetch_avatar("avtr_fa5303c6-78d1-451c-a678-faf3eadb5c50") author = a.author() # Get author of the avatar print("Avatar '" + a.name + "' was made by " + author.displayName) ## This should print "Avatar 'Etoigne' was made by Katfish" # Close client session, invalidate auth cookie client.logout()
def login(json_file): # Creates a valid session with the VRChat API login_info = None with open(json_file, 'r') as login_info_file: login_info = json.load(login_info_file) if login_info is None: raise Exception( "Something went wrong while trying to retrieve your login credentials" ) client = vrcpy.Client() client.login2fa(login_info["username"], login_info["password"]) code = input("Please enter your 2FA token: ") client.verify2fa(code) return client
# Example of using vrcpy without builtin event loop import vrcpy import asyncio loop = asyncio.get_event_loop() client = vrcpy.Client(loop=loop) async def main(): await client.login(username="******", password="******", mfa="123456") # If you want to do your own io eventloop, you'd probably # want to set it up here. We are going to use a very simple one # to get friends in-game every minute try: while True: me = await client.fetch_me() for friend in me.online_friends: friend = await client.fetch_user(friend) print(friend.display_name + " is now in-game!") await asyncio.sleep(60) print("-" * 25) except KeyboardInterrupt: await client.logout()
def main(): client = vrcpy.Client() log_file = open("VRChat_Avatar_Collector.log", mode='a+', encoding='utf-8', errors='ignore', buffering=1) def end(): client.logout() log_file.close() exit() def log(text): log = datetime.now().strftime("%m/%d/%y - %H:%M:%S") con = datetime.now().strftime("%H:%M:%S") #console doesn't need day log_file.write("[" + log + "] " + text + '\n') print("[" + con + "] " + text) def create_dirs(): if not os.path.exists(DIR): log("No directory named " + config["avatarFolder"] + ", making one") os.mkdir(DIR) else: log("Using existing avatar directory '" + config["avatarFolder"] + "'") try: config = json.load(open('config.json')) captureCount = int( config["captureCount"] ) #default 16 enough to collect all your current favorites in one go captureFrequency = int( config["captureFrequency"] ) #default 60 seconds to meet vrchat api guidelines except Exception as e: log("Error opening config.json") log(str(e)) end() DIR = os.path.join(os.getcwd(), config["avatarFolder"]) client.login(config["username"], config["password"]) b = client.fetch_me() log("Logged in as " + b.displayName) def avtr_grab(): b = client.fetch_me() #refresh user object avtr_name = b.currentAvatar.name avtr_id = b.currentAvatar.id img = b.currentAvatar.thumbnailImageUrl #sometimes gets api.vrchat.cloud img link instead of cloudfront thumbnail png log("-" * 24) log("Name: " + avtr_name) log("ID: " + avtr_id) log("Img: " + img) outputFile = os.path.join(DIR, avtr_id + ".png") log(outputFile) if not os.path.exists(outputFile): r = requests.get( img, allow_redirects=True, stream=True, headers={'User-Agent': ""} ) #stopped by cf if useragent is missing, fine if empty, https://i.gifer.com/72nt.gif r.raw.decode_content = True with open(outputFile, 'wb') as f: shutil.copyfileobj(r.raw, f) log("Got: " + avtr_name + ":" + avtr_id) else: log("Avatar " + avtr_name + ":" + avtr_id + " has already been downloaded") log("Skipping") create_dirs() for x in range(0, captureCount): avtr_grab() time.sleep(captureFrequency) end()
def _assign(self, obj): pass class LimitedUser(vrcpy.user.LimitedUser): def _assign(self, obj): pass class User(vrcpy.user.User): def _assign(self, obj): pass class CurrentUser(vrcpy.user.CurrentUser): def _assign(self, obj): pass client = vrcpy.Client() loop = asyncio.get_event_loop() def test(vrc_py, vrc_sdk): print(f"Starting tests for {vrc_py.__class__}") for attr in vrc_sdk: b = False for req in vrc_py.required: if attr == vrc_py.required[req]["dict_key"]: b = True break for opt in vrc_py.optional: if attr == vrc_py.optional[opt]["dict_key"]: b = True