lanplaypy


Namelanplaypy JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/LeGeRyChEeSe/lanplaypy
SummaryLAN-PLAY API Python
upload_time2023-05-09 07:02:41
maintainer
docs_urlNone
authorKilian Douarinou
requires_python>=3.9
licenseMIT
keywords lan-play api python graphql
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align='center'>LanPlay API</h1>
<p align="center">
<img src="https://github.com/LeGeRyChEeSe/lanplaypy/blob/main/images/lanplay.png?raw=true" align="center" height=205 alt="lanplaypy" />
</p>
<p align="center">
<img src='https://visitor-badge.laobi.icu/badge?page_id=LeGeRyChEeSe.lanplaypy', alt='Visitors'/>
<a href="https://github.com/LeGeRyChEeSe/lanplaypy/stargazers">
<img src="https://img.shields.io/github/stars/LeGeRyChEeSe/lanplaypy" alt="Stars"/>
</a>
<a href="https://github.com/LeGeRyChEeSe/lanplaypy/issues">
<img src="https://img.shields.io/github/issues/LeGeRyChEeSe/lanplaypy" alt="Issues"/>
</a>

<p align="center">
This is the unofficial API for <a href="http://www.lan-play.com">LanPlay</a>.<br>
It's made for getting servers, rooms, games and players easily from LanPlay API.<br>
It was designed to make life easier for developers with LanPlay. It’s a more direct and simple interface with the API.
<p align="center">

# Table of Contents
- [Installation](#installation)
- [Get API Key](#get-api-key)
- [Script Example](#script-example)
- [Contributing](#contributing)
- [License](#license)

## Installation

```python
pip install lanplaypy
```

## Get API Key
To use the LanPlay package you will need a specific, non-transferable API key that can be retrieved from <a href="http://www.lan-play.com">LanPlay</a>.<br>
Please follow these steps :

1. Open a Web Browser and go to http://www.lan-play.com
2. Open a Console Mode (<b>Ctrl + Shift + C</b> should work, or Google is your friend to find how to access the Console Mode 🫠)
3. Go to <b>Network</b> tab and refresh the current page
4. Search a line named <b>getMonitors</b> and click on it
5. Open the <b>Payload</b> tab
6. Copy the <b>api_key</b> value and paste it into the <b>LanPlay('LAN_PLAY_API_KEY')</b> definition below (replace 'LAN_PLAY_API_KEY' with the <b>api_key</b> value)


## Script Example
### Before doing anything be sure to get your <b>api_key</b> from [Get API Key](#get-api-key) section
Here is an example of a simple script using LanPlay API that gets server infos refreshed every 1 second

```python
import asyncio
import lanplay
import time
import os


async def main(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 stored

    print('List of all LanPlay servers available : ', lan.servers)
    # Useful when you don't know wich LanPlay server to choose...

    await lan.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' variable

    while True:
        os.system('clear')
        # Clear the console to get a clean UI with updated server's infos

        # See below some useful examples

        for room in lan.rooms:
            # Display games info of a room

            print(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 name

            if room.game:
                print('Game : ', room.game.name)
                # Or 'room.game' will also displays the name of the game

                print('Icon URL of the Game : ', room.game.icon_url)
                # Useful when you want a cool picture of the current game played

                print('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 game

            print('Max Players number in the room : ', room.node_count_max)
            # Max Players allowed to play in a room

            print('Actual number of Players in the room: ', room.node_count)
            # Actual number of Players playing in a room

            for player in room.players:
                # Display players infos of a room

                print(f'Player {room.players.index(player) + 1} : ', player)
                # Or 'player.player_name' will also displays the name of the player

        print('Players Online : ', lan.server_info.online)
        # Displays the current number of Online players in the server

        print('Players Idle : ', lan.server_info.idle)
        # Displays the current number of Idle players in the server

        await lan.refreshServer()
        # Function that refresh all infos of the server, rooms, games and players to stay up-to-date

        time.sleep(time_to_refresh)
        # Wait 'time_to_refresh' seconds (1 second in this example) before continue the loop

loop = 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.

## Contributing

Any contributions you make are **greatly appreciated**.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/NewFeature`)
3. Commit your Changes (`git commit -m 'Add some NewFeature'`)
4. Push to the Branch (`git push origin feature/NewFeature`)
5. Open a Pull Request


*Thanks to every [contributors](https://github.com/LeGeRyChEeSe/lanplaypy/graphs/contributors) who have contributed in this project.*

## License

Distributed under the MIT License. See [LICENSE](https://github.com/LeGeRyChEeSe/lanplaypy/blob/main/LICENSE) for more information.

----

Author/Maintainer: [Garoh](https://github.com/LeGeRyChEeSe/) | Discord: GarohRL#4449
1.1.0 (2023-05-09)
==================

Security Fixes
--------------
- Improve security and data integrity assurance in general.

New Features
------------
- Changed how to access the attributes of a class instance. (Transparent to the user.)

Bug Fixes
---------
- Fixed codec decoding. Please use 'utf-8' or 'utf-16' in Room(encoding='utf-X').

Improvements
------------
- Optimize class access and remove some useless data accesses for the user. It's a more clean coding environment now.

Documentation
-------------
- Update 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 License

Copyright (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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/LeGeRyChEeSe/lanplaypy",
    "name": "lanplaypy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "LAN-PLAY API Python GraphQL",
    "author": "Kilian Douarinou",
    "author_email": "kilian.douarinou41@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/44/32/d760264048e284e67ea048a154e3e5cbe7b3ac6bacfdf2cbbb1de343170d/lanplaypy-1.1.0.tar.gz",
    "platform": null,
    "description": "<h1 align='center'>LanPlay API</h1>\n<p align=\"center\">\n<img src=\"https://github.com/LeGeRyChEeSe/lanplaypy/blob/main/images/lanplay.png?raw=true\" align=\"center\" height=205 alt=\"lanplaypy\" />\n</p>\n<p align=\"center\">\n<img src='https://visitor-badge.laobi.icu/badge?page_id=LeGeRyChEeSe.lanplaypy', alt='Visitors'/>\n<a href=\"https://github.com/LeGeRyChEeSe/lanplaypy/stargazers\">\n<img src=\"https://img.shields.io/github/stars/LeGeRyChEeSe/lanplaypy\" alt=\"Stars\"/>\n</a>\n<a href=\"https://github.com/LeGeRyChEeSe/lanplaypy/issues\">\n<img src=\"https://img.shields.io/github/issues/LeGeRyChEeSe/lanplaypy\" alt=\"Issues\"/>\n</a>\n\n<p align=\"center\">\nThis is the unofficial API for <a href=\"http://www.lan-play.com\">LanPlay</a>.<br>\nIt's made for getting servers, rooms, games and players easily from LanPlay API.<br>\nIt was designed to make life easier for developers with LanPlay. It\u2019s a more direct and simple interface with the API.\n<p align=\"center\">\n\n# Table of Contents\n- [Installation](#installation)\n- [Get API Key](#get-api-key)\n- [Script Example](#script-example)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n\n```python\npip install lanplaypy\n```\n\n## Get API Key\nTo use the LanPlay package you will need a specific, non-transferable API key that can be retrieved from <a href=\"http://www.lan-play.com\">LanPlay</a>.<br>\nPlease follow these steps :\n\n1. Open a Web Browser and go to http://www.lan-play.com\n2. Open a Console Mode (<b>Ctrl + Shift + C</b> should work, or Google is your friend to find how to access the Console Mode \ud83e\udee0)\n3. Go to <b>Network</b> tab and refresh the current page\n4. Search a line named <b>getMonitors</b> and click on it\n5. Open the <b>Payload</b> tab\n6. Copy the <b>api_key</b> value and paste it into the <b>LanPlay('LAN_PLAY_API_KEY')</b> definition below (replace 'LAN_PLAY_API_KEY' with the <b>api_key</b> value)\n\n\n## Script Example\n### Before doing anything be sure to get your <b>api_key</b> from [Get API Key](#get-api-key) section\nHere is an example of a simple script using LanPlay API that gets server infos refreshed every 1 second\n\n```python\nimport asyncio\nimport lanplay\nimport time\nimport os\n\n\nasync def main(time_to_refresh: int = 1):\n    # time_to_refresh let you update the informations of the server every 1 seconds\n    # You can change this variable from execution in loop.run_until_complete(main()) at the end of this script with some other values\n    # For example to update the infos of the server every 0.5 seconds or 500ms, you can use await main(0.5)\n\n    lan = lanplay.LanPlay('LAN_PLAY_API_KEY')\n    # Create an instance of the LanPlay class with LAN_PLAY_API_KEY\n    # It's the main variable where all data will be stored\n\n    print('List of all LanPlay servers available : ', lan.servers)\n    # Useful when you don't know wich LanPlay server to choose...\n\n    await lan.setServer('joinsg.net:11453')\n    # Initialize the server with any LanPlay server you want\n    # Here is an example with the joinsg.net:11453 server\n    # Replace with 'http:/joinsg.net:11453/' will works too\n\n    # You can now access all data from 'lan' variable\n\n    while True:\n        os.system('clear')\n        # Clear the console to get a clean UI with updated server's infos\n\n        # See below some useful examples\n\n        for room in lan.rooms:\n            # Display games info of a room\n\n            print(room.advertise_data)\n            print(f'Room {lan.rooms.index(room) + 1} :')\n            print('Host Player : ', room.host_player)\n            print('Unique Nintendo Host Player Name : ',\n                  room.host_player_nintendo_name)\n            # Unique Nintendo host player name\n\n            if room.game:\n                print('Game : ', room.game.name)\n                # Or 'room.game' will also displays the name of the game\n\n                print('Icon URL of the Game : ', room.game.icon_url)\n                # Useful when you want a cool picture of the current game played\n\n                print('Game Size : ', room.game.size)\n                # To see if you've enough space to download this game on your Switch...\n\n                print('Publisher of the Game : ', room.game.publisher)\n                # Get the publisher of the actual played game\n\n            print('Max Players number in the room : ', room.node_count_max)\n            # Max Players allowed to play in a room\n\n            print('Actual number of Players in the room: ', room.node_count)\n            # Actual number of Players playing in a room\n\n            for player in room.players:\n                # Display players infos of a room\n\n                print(f'Player {room.players.index(player) + 1} : ', player)\n                # Or 'player.player_name' will also displays the name of the player\n\n        print('Players Online : ', lan.server_info.online)\n        # Displays the current number of Online players in the server\n\n        print('Players Idle : ', lan.server_info.idle)\n        # Displays the current number of Idle players in the server\n\n        await lan.refreshServer()\n        # Function that refresh all infos of the server, rooms, games and players to stay up-to-date\n\n        time.sleep(time_to_refresh)\n        # Wait 'time_to_refresh' seconds (1 second in this example) before continue the loop\n\nloop = asyncio.get_event_loop()\nloop.run_until_complete(main())\nloop.close()\n```\n\n- Or you can also use it in CLI as well with the same syntax.\n\n## Contributing\n\nAny contributions you make are **greatly appreciated**.\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/NewFeature`)\n3. Commit your Changes (`git commit -m 'Add some NewFeature'`)\n4. Push to the Branch (`git push origin feature/NewFeature`)\n5. Open a Pull Request\n\n\n*Thanks to every [contributors](https://github.com/LeGeRyChEeSe/lanplaypy/graphs/contributors) who have contributed in this project.*\n\n## License\n\nDistributed under the MIT License. See [LICENSE](https://github.com/LeGeRyChEeSe/lanplaypy/blob/main/LICENSE) for more information.\n\n----\n\nAuthor/Maintainer: [Garoh](https://github.com/LeGeRyChEeSe/) | Discord: GarohRL#4449\n1.1.0 (2023-05-09)\n==================\n\nSecurity Fixes\n--------------\n- Improve security and data integrity assurance in general.\n\nNew Features\n------------\n- Changed how to access the attributes of a class instance. (Transparent to the user.)\n\nBug Fixes\n---------\n- Fixed codec decoding. Please use 'utf-8' or 'utf-16' in Room(encoding='utf-X').\n\nImprovements\n------------\n- Optimize class access and remove some useless data accesses for the user. It's a more clean coding environment now.\n\nDocumentation\n-------------\n- Update the example script with more code explanation and more user-friendly UI.\n\n- Clarify the steps to get the api_key value from LanPlay website. Update some other infos.\n\n\n\nMIT License\n\nCopyright (c) [2023][Kilian Douarinou]\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "LAN-PLAY API Python",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/LeGeRyChEeSe/lanplaypy"
    },
    "split_keywords": [
        "lan-play",
        "api",
        "python",
        "graphql"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4432d760264048e284e67ea048a154e3e5cbe7b3ac6bacfdf2cbbb1de343170d",
                "md5": "f2a6679d5828c4f9939db3e6d453c714",
                "sha256": "7a19d8fe33ed91a2389eed263ff9a9636c364058eb11b367a9f6e46d45e883a0"
            },
            "downloads": -1,
            "filename": "lanplaypy-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f2a6679d5828c4f9939db3e6d453c714",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 11542,
            "upload_time": "2023-05-09T07:02:41",
            "upload_time_iso_8601": "2023-05-09T07:02:41.773389Z",
            "url": "https://files.pythonhosted.org/packages/44/32/d760264048e284e67ea048a154e3e5cbe7b3ac6bacfdf2cbbb1de343170d/lanplaypy-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-09 07:02:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "LeGeRyChEeSe",
    "github_project": "lanplaypy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "lanplaypy"
}
        
Elapsed time: 0.07133s