Package: toyhouse
Toyhouse Data[work in progress] A Toyhouse service to retrieve data about your (and other people's) OCs, as well as your (and other people's) profiles.This is very much a niche project (lol) but I'm hoping it'll serve some use to anyone curious!PrerequisitesPython3RequestsBeautifulSoup4InstallationYou can now usepipto install this project! Simply run:pip install toyhouseThis project can be foundhere, albeit slightly out of date.[!IMPORTANT]
I cannot guarantee that this service works on profiles with extreme custom CSS, legacy layouts or profile warnings! If you want to use this, please manually visithttps://toyhou.se/~account/displayand turn off all three settings under 'Profile Browsing'. In the meantime, I will be attempting to fix that.UsageStart by importing the module, then instantiating either the Session or GuestSession class to start the session. With the former, you are required to authenticate (actually log in) usingauth()It is highly recommended to log in with a Session in order to access logged-in user only/authorise-only profiles and content.file_pathhere is an optional argument - it dictates a folder in which relevant images are saved.For instance, if you want to save a user's profile picture in your Documents folder, you would addC:/Users/<yourusername>/Documents, and the profile picture would then be downloaded in the subfolder/<thatuser>/. If left blank, the subfolder will be placed in the directory where this code is currently running.importtoyhousesession=toyhouse.Session("<username>","<password>","file_path")session.auth()# alternativelysession=toyhouse.GuestSession("<file_path>")FunctionsSessionsession=toyhouse.Session("<username>","<password>")session.auth()Starts a new logged-in Session using the credentials above, letting you access information on the Toyhouse website.session=toyhouse.GuestSession()Starts a new Guest Session. No authentication is required.Useruser_info=toyhouse.User(session,"<username>")Creates a new User object, letting you retrieve information about whatever user is listed there.charsuser_info.chars# Returns[('Althea',12391***,'https://toyhou.se/12391***.althea','https://toyhou.se/<username>/characters/<folder:folderid>?page=<page>')]Outputs alist of tuplescontaining everycharacter from that useraccessible to the authorised session, in the form(<char_name>, <char_id>, <char_url>, <char_loc>).statsuser_info.stats# Returns{'Time Registered':'22 Mar 2019, **:**:** am','Last Logged In':'25 Oct 2023, **:**:** am','Invited By':'***','Character Count':'***','Images Count':'***','Literatures Count':'***','Words Count':'***','Forum Posts Count':'***','Subscribed To...':'*** users','Subscribed To By...':'*** users','Authorizing...':'***','Authorized By...':'***'}Outputs the specified user's publicly viewablestatistics(if the user is not self, else it outputs all statistics regardless of hidden status) as adictionary.loguser_info.log# Returns[{'date':'6 Nov 2020, **:**:** pm','name_from':'my_old_username','name_to':'my_new_username'},{'date':'19 Apr 2020, **:**:** am','name_from':'my_oldest_username','name_to':'my_old_username'}]Outputs the specified user'susername change historyas alist of dictionaries, with most recent name change first.picuser_info.pic(download=True)# Returns<username>profilepicturehasbeensavedat<path>user_info.pic()# Returnshttps://f2.toyhou.se/file/f2-toyhou-se/users/<username>Retrieves the specified user'sprofile picture, and ifdownload=True,downloads the imageat the file path mentioned underUsage. Ifdownload=False, it returns the URL at which you can access the profile picture.designsuser_info.designsOutputs alist of tuplesin format(<char_name>, <char_id>, <char_url>, <char_loc>)for all characters that the user is credited as a designer of. This format is the same aschars()except with<char_locreturning the URL + page number that the character is on.favsuser_info.favsOutputs alist of tuplesin format(<char_name>, <char_id>, <char_url>, <char_loc>)for allcharacters that the user has favourited.
This format is identical to the above, with the addition of also showing what favourites folder the character has been sorted into in<char_loc>Characterchar_info=toyhouse.Character(session,characterid)This creates a new Character object, letting you retrieve information about the character profile which corresponds to that ID.statschar_info.stats# Returns{'Created':'31 Dec 2018, **:**:** am','Creator':'********','Favorites':'57'}Outputs the publicly viewablestatisticsof the character, including its creation date, creator and favourites amount as a bare minimum (can also include trade listing and designer) as adictionary.logchar_info.log# Returns[('20 May 2022, **:**:** pm','current_owner'),('20 Jan 2021, **:**:** pm','previous_owner'),('22 Sep 2020, **:**:** pm','previous_previous_owner')]Outputs the previousownership logof the character as alist of tuplesin form(<transfer date>, <recipient of transfer>), starting with the most recent transfer (so the current owner) first.favschar_info.favs# Returns['i_favourited_this_character','i_did_too','i_did_as_well']Outputs alistof all accounts that have thecharacter favourited.To-Do ListRetrieve character stats (favourites/favourite amount- comments/comment amount -ownership log)Add Guest SessionFind a profile which has multiple designers listedAdd the character's name into character statistics, since that's kind of importantRetrieve other users' favourite characters, ID, and folders/subfolders/page they are located on.Test on profiles with custom CSSAdd better ways to catch errors (e.glogin credentials incorrect)