All Projects → 5kyc0d3r → upnpy

5kyc0d3r / upnpy

Licence: MIT license
Lightweight UPnP client library for Python.

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to upnpy

Miniupnp
UPnP IGD implementation
Stars: ✭ 974 (+2017.39%)
Mutual labels:  upnp
Airconnect
Use AirPlay to stream to UPnP/Sonos & Chromecast devices
Stars: ✭ 2,349 (+5006.52%)
Mutual labels:  upnp
docker-airconnect
This is a dockerized version of AirConnect (https://github.com/philippe44/AirConnect) which bridges AirPlay with Sonos and the Google Cast protocol.
Stars: ✭ 24 (-47.83%)
Mutual labels:  upnp
Weupnp
A tiny UPnP (Universal Plug and Play) client library written in Java
Stars: ✭ 88 (+91.3%)
Mutual labels:  upnp
Droidupnp
DroidUPnP is an upnp control point application for android.
Stars: ✭ 122 (+165.22%)
Mutual labels:  upnp
Internet Hosting Tool
Enable Moonlight streaming from your PC over the Internet with no configuration required
Stars: ✭ 205 (+345.65%)
Mutual labels:  upnp
Gerbera
UPnP Media Server for 2021: Stream your digital media through your home network and consume it on all kinds of UPnP supporting devices 📱💻📺
Stars: ✭ 710 (+1443.48%)
Mutual labels:  upnp
Jupii
Play audio, video and images on UPnP/DLNA devices
Stars: ✭ 27 (-41.3%)
Mutual labels:  upnp
Killcast
Manipulate Chromecast Devices in your Network
Stars: ✭ 133 (+189.13%)
Mutual labels:  upnp
nano-dlna
A minimal UPnP/DLNA media streamer
Stars: ✭ 146 (+217.39%)
Mutual labels:  upnp
Universalmediaserver
A DLNA, UPnP and HTTP(S) Media Server.
Stars: ✭ 1,339 (+2810.87%)
Mutual labels:  upnp
Upnpclient
uPnP client library for Python 3.
Stars: ✭ 115 (+150%)
Mutual labels:  upnp
Rssdp
Really Simple Service Discovery Protocol - a 100% .Net implementation of the SSDP protocol for publishing custom/basic devices, and discovering all device types on a network.
Stars: ✭ 216 (+369.57%)
Mutual labels:  upnp
Technitiumlibrary
A library for .net based applications.
Stars: ✭ 53 (+15.22%)
Mutual labels:  upnp
UPnP Generic
A simple library that implements port mappings to router using UPnP SSDP for Arduino boards, running on nRF52, SAMD21/SAMD51, STM32F/L/H/G/WB/MP1, Teensy, RP2040-based boards, WT32_ETH01, Portenta_H7, etc. besides ESP8266/ESP32, using ESP WiFi, WiFiNINA, Ethernet W5x00, ESP8266/ESP32 AT-command WiFi, Portenta_H7 Murata WiFi or Vision-shield Ethe…
Stars: ✭ 14 (-69.57%)
Mutual labels:  upnp
Plainupnp
PlainUPnP is an upnp control point application for android.
Stars: ✭ 33 (-28.26%)
Mutual labels:  upnp
Smartthingspublic
SmartThings open-source DeviceTypeHandlers and SmartApps code
Stars: ✭ 2,201 (+4684.78%)
Mutual labels:  upnp
dslrbrowser-ios
DSLR Browser iOS app to discover and connect to your Wi-Fi and DLNA enabled (Canon) camera
Stars: ✭ 17 (-63.04%)
Mutual labels:  upnp
Beacon
A simple UPnP Assistant that is capable of opening arbitrary ports.
Stars: ✭ 34 (-26.09%)
Mutual labels:  upnp
Netdisco
🔎 Python library to scan local network for services and devices.
Stars: ✭ 240 (+421.74%)
Mutual labels:  upnp

UPnPy

Build Status PyPI - Python Version PyPI package version MIT License

Lightweight UPnP client library for Python.

Install

$ pip install upnpy

Examples

Get the external IP address of an Internet Gateway Device:

import upnpy

upnp = upnpy.UPnP()

# Discover UPnP devices on the network
# Returns a list of devices e.g.: [Device <Broadcom ADSL Router>]
devices = upnp.discover()

# Select the IGD
# alternatively you can select the device directly from the list
# device = devices[0]
device = upnp.get_igd()

# Get the services available for this device
# Returns a list of services available for the device
# e.g.: [<Service (WANPPPConnection) id="WANPPPConnection.1">, ...]
device.get_services()

# We can now access a specific service on the device by its ID
# The IDs for the services in this case contain illegal values so we can't access it by an attribute
# If the service ID didn't contain illegal values we could access it via an attribute like this:
# service = device.WANPPPConnection

# We will access it like a dictionary instead:
service = device['WANPPPConnection.1']

# Get the actions available for the service
# Returns a list of actions for the service:
#   [<Action name="SetConnectionType">,
#   <Action name="GetConnectionTypeInfo">,
#   <Action name="RequestConnection">,
#   <Action name="ForceTermination">,
#   <Action name="GetStatusInfo">,
#   <Action name="GetNATRSIPStatus">,
#   <Action name="GetGenericPortMappingEntry">,
#   <Action name="GetSpecificPortMappingEntry">,
#   <Action name="AddPortMapping">,
#   <Action name="DeletePortMapping">,
#   <Action name="GetExternalIPAddress">]
service.get_actions()

# Finally, get the external IP address
# Execute the action by its name
# Returns a dictionary: {'NewExternalIPAddress': 'xxx.xxx.xxx.xxx'}
service.GetExternalIPAddress()

Add a new port mapping to an Internet Gateway Device:

import upnpy

upnp = upnpy.UPnP()

# Discover UPnP devices on the network
# Returns a list of devices e.g.: [Device <Broadcom ADSL Router>]
devices = upnp.discover()

# Select the IGD
# alternatively you can select the device directly from the list
# device = devices[0]
device = upnp.get_igd()

# Get the services available for this device
# Returns a list of services available for the device
# e.g.: [<Service (WANPPPConnection) id="WANPPPConnection.1">, ...]
device.get_services()

# We can now access a specific service on the device by its ID
# The IDs for the services in this case contain illegal values so we can't access it by an attribute
# If the service ID didn't contain illegal values we could access it via an attribute like this:
# service = device.WANPPPConnection

# We will access it like a dictionary instead:
service = device['WANPPPConnection.1']

# Get the actions available for the service
# Returns a list of actions for the service:
#   [<Action name="SetConnectionType">,
#   <Action name="GetConnectionTypeInfo">,
#   <Action name="RequestConnection">,
#   <Action name="ForceTermination">,
#   <Action name="GetStatusInfo">,
#   <Action name="GetNATRSIPStatus">,
#   <Action name="GetGenericPortMappingEntry">,
#   <Action name="GetSpecificPortMappingEntry">,
#   <Action name="AddPortMapping">,
#   <Action name="DeletePortMapping">,
#   <Action name="GetExternalIPAddress">]
service.get_actions()

# The action we are looking for is the "AddPortMapping" action
# Lets see what arguments the action accepts
# Use the get_input_arguments() or get_output_arguments() method of the action
# for a list of input / output arguments.
# Example output of the get_input_arguments method for the "AddPortMapping" action
# Returns a dictionary:
# [
#     {
#         "name": "NewRemoteHost",
#         "data_type": "string",
#         "allowed_value_list": []
#     },
#     {
#         "name": "NewExternalPort",
#         "data_type": "ui2",
#         "allowed_value_list": []
#     },
#     {
#         "name": "NewProtocol",
#         "data_type": "string",
#         "allowed_value_list": [
#             "TCP",
#             "UDP"
#         ]
#     },
#     {
#         "name": "NewInternalPort",
#         "data_type": "ui2",
#         "allowed_value_list": []
#     },
#     {
#         "name": "NewInternalClient",
#         "data_type": "string",
#         "allowed_value_list": []
#     },
#     {
#         "name": "NewEnabled",
#         "data_type": "boolean",
#         "allowed_value_list": []
#     },
#     {
#         "name": "NewPortMappingDescription",
#         "data_type": "string",
#         "allowed_value_list": []
#     },
#     {
#         "name": "NewLeaseDuration",
#         "data_type": "ui4",
#         "allowed_value_list": []
#     }
# ]
service.AddPortMapping.get_input_arguments()

# Finally, add the new port mapping to the IGD
# This specific action returns an empty dict: {}
service.AddPortMapping(
    NewRemoteHost='',
    NewExternalPort=80,
    NewProtocol='TCP',
    NewInternalPort=8000,
    NewInternalClient='192.168.1.3',
    NewEnabled=1,
    NewPortMappingDescription='Test port mapping entry from UPnPy.',
    NewLeaseDuration=0
)

Documentation

Documentation is available at https://upnpy.readthedocs.io/en/latest/

License

This project is licensed under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].