Package: lanplaypy
LanPlay APIThis is the unofficial API forLanPlay.It's made for getting servers, rooms, games and players easily from LanPlay API.It was designed to make life easier for developers with LanPlay. It’s a more direct and simple interface with the API.Table of ContentsInstallationGet API KeyScript ExampleContributingLicenseInstallationpipinstalllanplaypyGet API KeyTo use the LanPlay package you will need a specific, non-transferable API key that can be retrieved fromLanPlay.Please follow these steps :Open a Web Browser and go tohttp://www.lan-play.comOpen a Console Mode (Ctrl + Shift + Cshould work, or Google is your friend to find how to access the Console Mode 🫠)Go toNetworktab and refresh the current pageSearch a line namedgetMonitorsand click on itOpen thePayloadtabCopy theapi_keyvalue and paste it into theLanPlay('LAN_PLAY_API_KEY')definition below (replace 'LAN_PLAY_API_KEY' with theapi_keyvalue)Script ExampleBefore doing anything be sure to get yourapi_keyfromGet API KeysectionHere is an example of a simple script using LanPlay API that gets server infos refreshed every 1 secondimportasyncioimportlanplayimporttimeimportosasyncdefmain(time_to_refresh:int=1):# time_to_refresh let you update the informations of the server every 1 seconds# You can change this variable from execution in loop.run_until_complete(main()) at the end of this script with some other values# For example to update the infos of the server every 0.5 seconds or 500ms, you can use await main(0.5)lan=lanplay.LanPlay('LAN_PLAY_API_KEY')# Create an instance of the LanPlay class with LAN_PLAY_API_KEY# It's the main variable where all data will be storedprint('List of all LanPlay servers available : ',lan.servers)# Useful when you don't know wich LanPlay server to choose...awaitlan.setServer('joinsg.net:11453')# Initialize the server with any LanPlay server you want# Here is an example with the joinsg.net:11453 server# Replace with 'http:/joinsg.net:11453/' will works too# You can now access all data from 'lan' variablewhileTrue:os.system('clear')# Clear the console to get a clean UI with updated server's infos# See below some useful examplesforroominlan.rooms:# Display games info of a roomprint(room.advertise_data)print(f'Room{lan.rooms.index(room)+1}:')print('Host Player : ',room.host_player)print('Unique Nintendo Host Player Name : ',room.host_player_nintendo_name)# Unique Nintendo host player nameifroom.game:print('Game : ',room.game.name)# Or 'room.game' will also displays the name of the gameprint('Icon URL of the Game : ',room.game.icon_url)# Useful when you want a cool picture of the current game playedprint('Game Size : ',room.game.size)# To see if you've enough space to download this game on your Switch...print('Publisher of the Game : ',room.game.publisher)# Get the publisher of the actual played gameprint('Max Players number in the room : ',room.node_count_max)# Max Players allowed to play in a roomprint('Actual number of Players in the room: ',room.node_count)# Actual number of Players playing in a roomforplayerinroom.players:# Display players infos of a roomprint(f'Player{room.players.index(player)+1}: ',player)# Or 'player.player_name' will also displays the name of the playerprint('Players Online : ',lan.server_info.online)# Displays the current number of Online players in the serverprint('Players Idle : ',lan.server_info.idle)# Displays the current number of Idle players in the serverawaitlan.refreshServer()# Function that refresh all infos of the server, rooms, games and players to stay up-to-datetime.sleep(time_to_refresh)# Wait 'time_to_refresh' seconds (1 second in this example) before continue the looploop=asyncio.get_event_loop()loop.run_until_complete(main())loop.close()Or you can also use it in CLI as well with the same syntax.ContributingAny contributions you make aregreatly appreciated.Fork the ProjectCreate your Feature Branch (git checkout -b feature/NewFeature)Commit your Changes (git commit -m 'Add some NewFeature')Push to the Branch (git push origin feature/NewFeature)Open a Pull RequestThanks to everycontributorswho have contributed in this project.LicenseDistributed under the MIT License. SeeLICENSEfor more information.Author/Maintainer:Garoh| Discord: GarohRL#4449
1.1.0 (2023-05-09)Security FixesImprove security and data integrity assurance in general.New FeaturesChanged how to access the attributes of a class instance. (Transparent to the user.)Bug FixesFixed codec decoding. Please use 'utf-8' or 'utf-16' in Room(encoding='utf-X').ImprovementsOptimize class access and remove some useless data accesses for the user. It's a more clean coding environment now.DocumentationUpdate the example script with more code explanation and more user-friendly UI.Clarify the steps to get the api_key value from LanPlay website. Update some other infos.MIT LicenseCopyright (c) [2023][Kilian Douarinou]Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.