github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/cmd/serve/dlna/upnpav/upnpav.go (about) 1 package upnpav 2 3 import ( 4 "encoding/xml" 5 "time" 6 ) 7 8 const ( 9 // NoSuchObjectErrorCode : The specified ObjectID is invalid. 10 NoSuchObjectErrorCode = 701 11 ) 12 13 // Resource description 14 type Resource struct { 15 XMLName xml.Name `xml:"res"` 16 ProtocolInfo string `xml:"protocolInfo,attr"` 17 URL string `xml:",chardata"` 18 Size uint64 `xml:"size,attr,omitempty"` 19 Bitrate uint `xml:"bitrate,attr,omitempty"` 20 Duration string `xml:"duration,attr,omitempty"` 21 Resolution string `xml:"resolution,attr,omitempty"` 22 } 23 24 // Container description 25 type Container struct { 26 Object 27 XMLName xml.Name `xml:"container"` 28 ChildCount *int `xml:"childCount,attr"` 29 } 30 31 // Item description 32 type Item struct { 33 Object 34 XMLName xml.Name `xml:"item"` 35 Res []Resource 36 InnerXML string `xml:",innerxml"` 37 } 38 39 // Object description 40 type Object struct { 41 ID string `xml:"id,attr"` 42 ParentID string `xml:"parentID,attr"` 43 Restricted int `xml:"restricted,attr"` // indicates whether the object is modifiable 44 Class string `xml:"upnp:class"` 45 Icon string `xml:"upnp:icon,omitempty"` 46 Title string `xml:"dc:title"` 47 Date Timestamp `xml:"dc:date"` 48 Artist string `xml:"upnp:artist,omitempty"` 49 Album string `xml:"upnp:album,omitempty"` 50 Genre string `xml:"upnp:genre,omitempty"` 51 AlbumArtURI string `xml:"upnp:albumArtURI,omitempty"` 52 Searchable int `xml:"searchable,attr"` 53 } 54 55 // Timestamp wraps time.Time for formatting purposes 56 type Timestamp struct { 57 time.Time 58 } 59 60 // MarshalXML formats the Timestamp per DIDL-Lite spec 61 func (t Timestamp) MarshalXML(e *xml.Encoder, start xml.StartElement) error { 62 return e.EncodeElement(t.Format("2006-01-02"), start) 63 }