Пример #1
0
        public override bool Equals(object obj)
        {
            YouTubeVideo video = obj as YouTubeVideo;

            if (video == null)
            {
                return(false);
            }
            return(video.Id == Id);
        }
Пример #2
0
        private static YouTubeVideo[] ParseVideoList(Stream videoListStream, out int totalResults)
        {
            totalResults = 0;
            ArrayList videos = new ArrayList();

            using (videoListStream)
            {
                XmlDocument document = new XmlDocument();

                XmlNamespaceManager mgr = new XmlNamespaceManager(document.NameTable);

                mgr.AddNamespace(
                    "atom", "http://www.w3.org/2005/Atom");

                mgr.AddNamespace(
                    "media", "http://search.yahoo.com/mrss/");

                mgr.AddNamespace(
                    "yt", "http://gdata.youtube.com/schemas/2007");

                mgr.AddNamespace(
                    "gd", "http://schemas.google.com/g/2005");

                mgr.AddNamespace(
                    "openSearch", "http://a9.com/-/spec/opensearchrss/1.0/");

                mgr.AddNamespace(
                    "app", "http://purl.org/atom/app#");

                document.Load(videoListStream);

                XmlNodeList nodes = document.SelectNodes("//atom:feed//atom:entry", mgr);

                XmlNode totalCount = document.SelectSingleNode("//atom:feed//openSearch:totalResults", mgr);
                if (totalCount != null)
                {
                    int.TryParse(totalCount.InnerText, out totalResults);
                }

                foreach (XmlNode node in nodes)
                {
                    YouTubeVideo ytVid = new YouTubeVideo();
                    ytVid.Load(node, mgr);
                    if (ytVid.IsPublished)
                    {
                        videos.Add(ytVid);
                    }
                }
            }

            return(videos.ToArray(typeof(YouTubeVideo)) as YouTubeVideo[]);
        }
        private static YouTubeVideo[] ParseVideoList(Stream videoListStream, out int totalResults)
        {
            totalResults = 0;
            ArrayList videos = new ArrayList();

            using (videoListStream)
            {

                XmlDocument document = new XmlDocument();

                XmlNamespaceManager mgr = new XmlNamespaceManager(document.NameTable);

                mgr.AddNamespace(
                "atom", "http://www.w3.org/2005/Atom");

                mgr.AddNamespace(
                "media", "http://search.yahoo.com/mrss/");

                mgr.AddNamespace(
                "yt", "http://gdata.youtube.com/schemas/2007");

                mgr.AddNamespace(
                "gd", "http://schemas.google.com/g/2005");

                mgr.AddNamespace(
                    "openSearch", "http://a9.com/-/spec/opensearchrss/1.0/");

                mgr.AddNamespace(
                    "app", "http://purl.org/atom/app#");

                document.Load(videoListStream);

                XmlNodeList nodes = document.SelectNodes("//atom:feed//atom:entry", mgr);

                XmlNode totalCount = document.SelectSingleNode("//atom:feed//openSearch:totalResults", mgr);
                if (totalCount != null)
                    int.TryParse(totalCount.InnerText, out totalResults);

                foreach (XmlNode node in nodes)
                {
                    YouTubeVideo ytVid = new YouTubeVideo();
                    ytVid.Load(node, mgr);
                    if (ytVid.IsPublished)
                        videos.Add(ytVid);
                }
            }

            return videos.ToArray(typeof(YouTubeVideo)) as YouTubeVideo[];
        }