Exemplo n.º 1
0
        private void ParseContainers(XDocument document, DIDLLiteObject didlobj)
        {
            XNamespace didlite = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/";
            XNamespace dc      = "http://purl.org/dc/elements/1.1/";
            XNamespace upnp    = "urn:schemas-upnp-org:metadata-1-0/upnp/";

            var xcontainers = document.Root.Elements(didlite + "container").ToList();

            foreach (var xcontainer in xcontainers)
            {
                MediaContainer mcontainer = new MediaContainer();

                //Parse components
                ParseUPnPComponent(xcontainer, mcontainer);

                //searchable and restricted
                mcontainer.Searchable = GetAttribute <bool>("searchable", xcontainer, true);
                mcontainer.Restricted = GetAttribute <bool>("restricted", xcontainer, true);

                //dc purl objects
                mcontainer.Title       = GetChildValue <string>(dc + "title", xcontainer, "Unkown");
                mcontainer.Creator     = GetChildValue <string>(dc + "creator", xcontainer, "Unknown");
                mcontainer.Description = GetChildValue <string>(dc + "description", xcontainer, "Unknown");

                //upnp objects
                mcontainer.Genre       = GetChildValue <string>(upnp + "genre", xcontainer, "Unkown");
                mcontainer.AlbumArtURI = GetChildValue <string>(upnp + "albumArtURI", xcontainer, "");

                //add to list
                didlobj.Items.Add(mcontainer);
            }
        }
Exemplo n.º 2
0
        private void ParseItems(XDocument document, DIDLLiteObject didlobj)
        {
            XNamespace didlite = "urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/";
            XNamespace dc      = "http://purl.org/dc/elements/1.1/";
            XNamespace upnp    = "urn:schemas-upnp-org:metadata-1-0/upnp/";

            var xitems = document.Root.Elements(didlite + "item").ToList();

            foreach (var xitem in xitems)
            {
                MediaItem mitem = new MediaItem();

                //Parse components
                ParseUPnPComponent(xitem, mitem);

                //searchable and restricted
                mitem.Restricted = GetAttribute <bool>("restricted", xitem, true);

                //dc purl objects
                mitem.Title = GetChildValue <string>(dc + "title", xitem, "Unkown");

                //upnp objects
                //mcontainer.Genre = GetChildValue<string>(upnp + "genre", xcontainer, "Unkown");
                mitem.AlbumArtURI = GetChildValue <string>(upnp + "albumArtURI", xitem, "");
                mitem.Artist      = GetChildValue <string>(upnp + "artist", xitem, "Unknown");
                mitem.Album       = GetChildValue <string>(upnp + "album", xitem, "Unknown");

                //Parse resources
                ParseItemResources(xitem, mitem);

                //add to list
                didlobj.Items.Add(mitem);
            }
        }
Exemplo n.º 3
0
        public DIDLLiteObject ParseDIDL(string xml)
        {
            xml = xml.Replace("&", "&amp;");

            XDocument      document = XDocument.Parse(xml);
            DIDLLiteObject didl     = new DIDLLiteObject();

            //Parse containers
            ParseContainers(document, didl);

            //Parse Item
            ParseItems(document, didl);


            return(didl);
        }