"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
dlna: cds: don't specify childCount at all when unknown
Dan Walters7e2568a3125b
diff --git a/cmd/serve/dlna/cds.go b/cmd/serve/dlna/cds.goindex 5a30455a1..1fa1cfe9f 100644--- a/cmd/serve/dlna/cds.go+++ b/cmd/serve/dlna/cds.go@@ -16,8 +16,8 @@ import ("github.com/anacrolix/dms/dlna""github.com/anacrolix/dms/upnp"- "github.com/anacrolix/dms/upnpav""github.com/pkg/errors"+ "github.com/rclone/rclone/cmd/serve/dlna/upnpav""github.com/rclone/rclone/fs""github.com/rclone/rclone/vfs")@@ -77,16 +77,10 @@ func (cds *contentDirectoryService) cdsObjectToUpnpavObject(cdsObject object, fi}if fileInfo.IsDir() {- children, err := cds.readContainer(cdsObject, host)- if err != nil {- return nil, err- }-obj.Class = "object.container.storageFolder"obj.Title = fileInfo.Name()return upnpav.Container{- Object: obj,- ChildCount: len(children),+ Object: obj,}, nil}diff --git a/cmd/serve/dlna/dlna_test.go b/cmd/serve/dlna/dlna_test.goindex cca76d877..eaeab4091 100644--- a/cmd/serve/dlna/dlna_test.go+++ b/cmd/serve/dlna/dlna_test.go@@ -122,8 +122,8 @@ func TestContentDirectoryBrowseMetadata(t *testing.T) {// expect a <container> elementrequire.Contains(t, string(body), html.EscapeString("<container "))require.NotContains(t, string(body), html.EscapeString("<item "))- // with a non-zero childCount- require.Regexp(t, " childCount="[1-9]", string(body))+ // if there is a childCount, it better not be zero+ require.NotContains(t, string(body), html.EscapeString(" childCount=\"0\""))}// Check that the X_MS_MediaReceiverRegistrar is faked out properly.diff --git a/cmd/serve/dlna/upnpav/upnpav.go b/cmd/serve/dlna/upnpav/upnpav.gonew file mode 100644index 000000000..5ac5e17b7--- /dev/null+++ b/cmd/serve/dlna/upnpav/upnpav.go@@ -0,0 +1,63 @@+package upnpav++import (+ "encoding/xml"+ "time"+)++const (+ // NoSuchObjectErrorCode : The specified ObjectID is invalid.+ NoSuchObjectErrorCode = 701+)++// Resource description+type Resource struct {+ XMLName xml.Name `xml:"res"`+ ProtocolInfo string `xml:"protocolInfo,attr"`+ URL string `xml:",chardata"`+ Size uint64 `xml:"size,attr,omitempty"`+ Bitrate uint `xml:"bitrate,attr,omitempty"`+ Duration string `xml:"duration,attr,omitempty"`+ Resolution string `xml:"resolution,attr,omitempty"`+}++// Container description+type Container struct {+ Object+ XMLName xml.Name `xml:"container"`+ ChildCount *int `xml:"childCount,attr"`+}++// Item description+type Item struct {+ Object+ XMLName xml.Name `xml:"item"`+ Res []Resource+ InnerXML string `xml:",innerxml"`+}++// Object description+type Object struct {+ ID string `xml:"id,attr"`+ ParentID string `xml:"parentID,attr"`+ Restricted int `xml:"restricted,attr"` // indicates whether the object is modifiable+ Class string `xml:"upnp:class"`+ Icon string `xml:"upnp:icon,omitempty"`+ Title string `xml:"dc:title"`+ Date Timestamp `xml:"dc:date"`+ Artist string `xml:"upnp:artist,omitempty"`+ Album string `xml:"upnp:album,omitempty"`+ Genre string `xml:"upnp:genre,omitempty"`+ AlbumArtURI string `xml:"upnp:albumArtURI,omitempty"`+ Searchable int `xml:"searchable,attr"`+}++// Timestamp wraps time.Time for formatting purposes+type Timestamp struct {+ time.Time+}++// MarshalXML formats the Timestamp per DIDL-Lite spec+func (t Timestamp) MarshalXML(e *xml.Encoder, start xml.StartElement) error {+ return e.EncodeElement(t.Format("2006-01-02"), start)+}