Repository: rclone/rclone (language: go)

Issue:
DLNA Browse+BrowseMetadata not to spec, angers pedantic client.

#### The associated forum post URL from `https://forum.rclone.org`

Irrelevant.

#### What is the problem you are having with rclone?

Rclone DLNA server doesn't conform to [spec](https://upnp.org/specs/av/UPnP-av-ContentDirectory-v1-Service.pdf) when replying to a Browse request. Section 2.7.4.2. _Argument Descriptions_ says it should include `NumberReturned` and `TotalMatches`.

[Current rclone code](https://github.com/rclone/rclone/blob/3f3e4b055e322ed6b8c8686cc20948244d884c21/cmd/serve/dlna/cds.go#L291) only returns `Result`.

This was discovered using the [DLNA Digital Media Integration](https://www.home-assistant.io/integrations/dlna_dms) in Home Assistant.

This results in a failure to browse and inability to go further. Granted, the client could be more tolerant. But the fix seems trivial and would probably benefit everyone.

![image](https://github.com/rclone/rclone/assets/28158/cff1fe0a-4cca-4c45-be9c-2ded3442d5b3)

#### What is your rclone version (output from `rclone version`)

rclone v1.66.0
- os/version: arch 24.0.1 (64 bit)
- os/kernel: 6.7.12-1-MANJARO (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.22.1
- go/linking: dynamic
- go/tags: none

#### Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

See above.

#### Which cloud storage system are you using? (e.g. Google Drive)

None

#### The command you were trying to run (e.g. `rclone copy /tmp remote:tmp`)

`rclone serve dlna --addr 0.0.0.0:8090 -vv /home/arnaud/[...]`

#### A log from the command with the `-vv` flag (e.g. output from `rclone -vv copy /tmp remote:tmp`)

```
[...Startup...]
2024/06/01 16:15:11 INFO  : /ctl: 192.168.1.173:51490 POST 200 "urn:schemas-upnp-org:service:ContentDirectory:1#Browse"
```

#### How to use GitHub

* Please use the 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to show that you are affected by the same issue.
* Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
* Subscribe to receive notifications on status change and new comments.



Discussion / hints:

Fix patch:
diff --git a/cmd/serve/dlna/cds.go b/cmd/serve/dlna/cds.go
index 59572f9265932..be8fdc9c94ba6 100644
--- a/cmd/serve/dlna/cds.go
+++ b/cmd/serve/dlna/cds.go
@@ -289,7 +289,10 @@ func (cds *contentDirectoryService) Handle(action string, argsXML []byte, r *htt
 				return nil, err
 			}
 			return map[string]string{
-				"Result": didlLite(string(result)),
+				"TotalMatches":   "1",
+				"NumberReturned": "1",
+				"Result":         didlLite(string(result)),
+				"UpdateID":       cds.updateIDString(),
 			}, nil
 		default:
 			return nil, upnp.Errorf(upnp.ArgumentValueInvalidErrorCode, "unhandled browse flag: %v", browse.BrowseFlag)


Test patch: