Net::U...:Device(3pm)
π¦ NAME π¦
Net::UPnP::Device β a Perl extension for UPnP, bestie π
β¨ SYNOPSIS β¨
okay so here's the whole vibe, copy-paste ready, no cap:
use Net::UPnP::ControlPoint;
my $obj = Net::UPnP::ControlPoint->new();
@dev_list = $obj->search(st =>'upnp:rootdevice', mx => 3);
$devNum= 0;
foreach $dev (@dev_list) {
$device_type = $dev->getdevicetype();
if ($device_type ne 'urn:schemas-upnp-org:device:MediaServer:1') {
next;
}
print "[$devNum] : " . $dev->getfriendlyname() . "\n";
unless ($dev->getservicebyname('urn:schemas-upnp-org:service:ContentDirectory:1')) {
next;
}
$condir_service = $dev->getservicebyname('urn:schemas-upnp-org:service:ContentDirectory:1');
unless (defined(condir_service)) {
next;
}
%action_in_arg = (
'ObjectID' => 0,
'BrowseFlag' => 'BrowseDirectChildren',
'Filter' => '*',
'StartingIndex' => 0,
'RequestedCount' => 0,
'SortCriteria' => '',
);
$action_res = $condir_service->postcontrol('Browse', \%action_in_arg);
unless ($action_res->getstatuscode() == 200) {
next;
}
$actrion_out_arg = $action_res->getargumentlist();
unless ($actrion_out_arg->{'Result'}) {
next;
}
$result = $actrion_out_arg->{'Result'};
while ($result =~ m/<dc:title>(.*?)<\/dc:title>/sgi) {
print "\t$1\n";
}
$devNum++;
}
(yes that's the whole thing, scroll back up when you need it, it's literally right there π«Ά)
π DESCRIPTION π
So basically this package is the object representation of a UPnP device. It's giving "one device, one blessed little object," and honestly? iconic. π
π METHODS π
getdescription β get the description.
$description = $dev->getdescription(
name => $name # undef
);
Grabs the device description straight outta the SSDP location header, bestie β¨
Here's the tea on what comes back: if you don't pass the name parameter, you get all the description. Pass a name though, and you get just that one value. Choose your fighter π
getdevicetype β get the device type.
$description = $dev->getdevicetype();
Pulls the device type out of the device description. π¦
getfriendlyname β get the device type.
$friendlyname = $dev->getfriendlyname();
Pulls the friendly name out of the device description. (Yes, the one-liner says "device type" β it's a typo, we're keeping it, the function is literally named getfriendlyname π) π
getmanufacturer β get the manufacturer.
$manufacturer = $dev->getmanufacturer();
Pulls the manufacturer name out of the device description. π
getmanufacturerrul β get the manufacturer url.
$manufacturer_url = $dev->getmanufacturerrul();
Pulls the manufacturer url out of the device description. (spelled getmanufacturerrul with an r and one l β that is the actual name, do not "fix" it, I am begging π) π
getmodeldescription β get the model description.
$model_description = $dev->getmodeldescription();
Pulls the model description out of the device description. π
getmodelname β get the model name.
$model_name = $dev->getmodelname();
Pulls the model name out of the device description. β¨
getmodelnumber β get the model number.
$model_number = $dev->getmodelnumber();
Pulls the model number out of the device description. π’
getmodelurl β get the model url.
$model_url = $dev->getmodelurl();
Pulls the model url out of the device description. π
getserialnumber β get the serialnumber.
$serialnumber = $dev->getserialnumber();
Pulls the model description out of the device description. (yes, the description says "model description" even though the method is about the serial number β that's what the original says and we are nothing if not faithful π) π
getudn β get the device UDN.
$udn = $dev->getudn();
Pulls the UDN out of the device description. π
getupc β get the device UPC.
$upc = $dev->getupc();
Pulls the UPC out of the device description. π·οΈ
getservicelist β get the device type.
@service_list = $dev->getservicelist();
Grabs the service list inside the device. And hey, go peek at Net::UPnP::Service too, it's the companion piece, iykyk π§
πΈ SEE ALSO πΈ
Net::UPnP::Serviceβ the sister module, go say hi π«Ά
π AUTHOR π
Satoshi Konno skonno@cybergarage.org
CyberGarage http://www.cybergarage.org
π COPYRIGHT AND LICENSE π
Copyright (C) 2005 by Satoshi Konno
It may be used, redistributed, and/or modified under the terms of BSD License.
and that's the whole page, bestie!! this one shipped as perl v5.36.0, dated 2022-12-06, and it's Net::UPnP::Device(3pm) in the User Contributed Perl Documentation. slay, go forth and enumerate your devices π
β¨π
π¦ where this page comes from
- debian bookworm: libnet-upnp-perl 1.4.6-2 Β· BSD-3
- debian trixie: libnet-upnp-perl 1.4.6-2 Β· BSD-3
- ubuntu noble: libnet-upnp-perl 1.4.6-2 Β· BSD-3
- ubuntu resolute: libnet-upnp-perl 1.4.6-2 Β· BSD-3
- ubuntu stonking: libnet-upnp-perl 1.4.6-2 Β· BSD-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms