No error is shown, but the list of album titles isn't either. Here's the code excerpt from the Python program. Content_directory_url = http://mediaserverlocationUniqueID/upnp.org-ContentDirectory-1/control. ObjectID contains the search criteria in for the SOAPAction #Browse command.
`headers = {
"Content-Type": "text/xml; charset=utf-8",
"SOAPAction": "urn:schemas-upnp-org:service:ContentDirectory:1#Browse"
}
ObjectID = "0$albums"
soap_payload = f"""
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1">
<ObjectID>{ObjectID}</ObjectID>
<BrowseFlag>BrowseDirectChildren</BrowseFlag>
<Filter>*</Filter>
<StartingIndex>0</StartingIndex>
<RequestedCount>0</RequestedCount>
<SortCriteria></SortCriteria>
</u:Browse>
</s:Body>
</s:Envelope>
"""
try:
response = requests.post(content_directory_url, headers=headers, data=soap_payload)
response.raise_for_status()
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
SystemExit
if response.status_code == 200:
print("Results")
print ("")
root = ET.fromstring(response.text)
for child in root.iter("*"):
print(child.tag, f"Child value:", child.text)
namespace = {"dlna": "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite",
"upnp": "urn:schemas-upnp-org:metadata-1-0/upnp/"}
Music_items should contain a list of albums based on the ObjectID search criteria but it returns no values.**
music_items = root.findall(".//dlna:container[dlna:class=object.item]", namespace)
for music_folder in music_items:
music_folder_name = music_folder.findall(".//dlna:title", namespace).text
print(f"Audio Name: {music_folder_name}")
else:
print("Error: Could not retrieve folders from DLNA server: ", response.status_code)`