当前位置: 首页>>代码示例>>C#>>正文


C# XmlDocument.SafeGetString方法代码示例

本文整理汇总了C#中System.Xml.XmlDocument.SafeGetString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocument.SafeGetString方法的具体用法?C# XmlDocument.SafeGetString怎么用?C# XmlDocument.SafeGetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlDocument的用法示例。


在下文中一共展示了XmlDocument.SafeGetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: loadXML

        private void loadXML(string filename)
        {
            this.HasXML = true;
            this.xmlName = filename;
            doc = new XmlDocument();
            try
            {
                doc.Load(filename);
            } catch(XmlException e) {
                MessageBox.Show(e.Message, "Error in XML: "+filename);
            }

            this.CustomRating = doc.SafeGetString("Title/CustomRating");
            this.Overview = doc.SafeGetString("Title/Description");

        }
开发者ID:bartonnen,项目名称:MediaBrowser.Classic,代码行数:16,代码来源:LibraryFolder.cs

示例2: Fetch

        public override void Fetch()
        {
            var folder = Item as Folder;

            // fake stuff like itunes trailers may have no path
            if (string.IsNullOrEmpty(Item.Path)) { return; }

            string mfile = XmlLocation();
            //Logger.ReportInfo("Looking for XML file: " + mfile);
            string location = Path.GetDirectoryName(mfile);
            if (File.Exists(mfile))
            {

                Logger.ReportInfo("Found XML file: " + mfile);
                DateTime modTime = new FileInfo(mfile).LastWriteTimeUtc;
                lastWriteTime = modTime;
                folderFile = mfile;
                XmlDocument doc = new XmlDocument();
                doc.Load(mfile);

                string s = doc.SafeGetString("Title/LocalTitle");
                if ((s == null) || (s == ""))
                    s = doc.SafeGetString("Title/OriginalTitle");
                folder.Name = s;
                folder.SortName = doc.SafeGetString("Title/SortTitle");

                folder.Overview = doc.SafeGetString("Title/Description");
                if (folder.Overview != null)
                    folder.Overview = folder.Overview.Replace("\n\n", "\n");

                string front = doc.SafeGetString("Title/Covers/Front");
                if ((front != null) && (front.Length > 0))
                {
                    front = Path.Combine(location, front);
                    if (File.Exists(front))
                        Item.PrimaryImagePath = front;
                }

                //using this for logos now
                //string back = doc.SafeGetString("Title/Covers/Back");
                //if ((back != null) && (back.Length > 0))
                //{
                //    back = Path.Combine(location, back);
                //    if (File.Exists(back))
                //        Item.SecondaryImagePath = back;
                //}

                //Folder level security data
                if (folder.CustomRating == null)
                    folder.CustomRating = doc.SafeGetString("Title/CustomRating");

                if (folder.CustomPIN == null)
                    folder.CustomPIN = doc.SafeGetString("Title/CustomPIN");

                //
            }
        }
开发者ID:xantilas,项目名称:videobrowser,代码行数:57,代码来源:FolderProviderFromXml.cs

示例3: Fetch

        public override void Fetch()
        {
            Episode episode = Episode;
            Debug.Assert(episode != null);

            // store the location so we do not fetch again
            metadataFile = XmlLocation;
            // no data, do nothing
            if (metadataFile == null) return;

            metadataFileDate = new FileInfo(metadataFile).LastWriteTimeUtc;

            string metadataFolder = Path.GetDirectoryName(metadataFile);

            XmlDocument metadataDoc = new XmlDocument();
            metadataDoc.Load(metadataFile);

            var p = metadataDoc.SafeGetString("Item/filename");
            if (p != null && p.Length > 0) {
                string image = System.IO.Path.Combine(metadataFolder, System.IO.Path.GetFileName(p));
                if (File.Exists(image))
                    Item.PrimaryImagePath = image;
            }

            episode.Overview = metadataDoc.SafeGetString("Item/Overview");
            episode.EpisodeNumber = metadataDoc.SafeGetString("Item/EpisodeNumber");
            episode.Name = episode.EpisodeNumber + " - " + metadataDoc.SafeGetString("Item/EpisodeName");
            episode.SeasonNumber = metadataDoc.SafeGetString("Item/SeasonNumber");
            episode.ImdbRating = metadataDoc.SafeGetSingle("Item/Rating", (float)-1, 10);
            episode.FirstAired = metadataDoc.SafeGetString("Item/FirstAired");

            string writers = metadataDoc.SafeGetString("Item/Writer");
            if (writers != null)
                episode.Writers = new List<string>(writers.Trim('|').Split('|'));

            string directors = metadataDoc.SafeGetString("Item/Director");
            if (directors != null)
                episode.Directors = new List<string>(directors.Trim('|').Split('|'));

            var actors = ActorListFromString(metadataDoc.SafeGetString("Item/GuestStars"));
            if (actors != null) {
                if (episode.Actors == null)
                    episode.Actors = new List<Actor>();
                episode.Actors = actors;
            }
        }
开发者ID:purplecow,项目名称:Media-Browser,代码行数:46,代码来源:LocalEpisodeProvider.cs

示例4: Fetch

        public override void Fetch()
        {
            var movie = Item as IMovie;
            Debug.Assert(movie != null);

            string mfile = XmlLocation();
            string location = Path.GetDirectoryName(mfile);
            if (File.Exists(mfile))
            {

                DateTime modTime = new FileInfo(mfile).LastWriteTimeUtc;
                lastWriteTime = modTime;
                myMovieFile = mfile;
                XmlDocument doc = new XmlDocument();
                doc.Load(mfile);

                string s = doc.SafeGetString("Title/LocalTitle");
                if ((s == null) || (s == ""))
                    s = doc.SafeGetString("Title/OriginalTitle");
                movie.Name = s;
                movie.SortName = doc.SafeGetString("Title/SortTitle");

                movie.Overview = doc.SafeGetString("Title/Description");
                if (movie.Overview != null)
                    movie.Overview = movie.Overview.Replace("\n\n", "\n");

                movie.TagLine = doc.SafeGetString("Title/TagLine");
                movie.Plot = doc.SafeGetString("Title/Plot");

                //if added date is in xml override the file/folder date - this isn't gonna work cuz it's already filled in...
                DateTime added = DateTime.MinValue;
                DateTime.TryParse(doc.SafeGetString("Title/Added"), out added);
                if (added > DateTime.MinValue) movie.DateCreated = added;


                string front = doc.SafeGetString("Title/Covers/Front");
                if ((front != null) && (front.Length > 0))
                {
                    front = Path.Combine(location, front);
                    if (File.Exists(front))
                        Item.PrimaryImagePath = front;
                }

                if (string.IsNullOrEmpty(movie.DisplayMediaType))
                {
                    movie.DisplayMediaType = doc.SafeGetString("Title/Type", "");
                    switch (movie.DisplayMediaType.ToLower())
                    {
                        case "blu-ray":
                            movie.DisplayMediaType = MediaType.BluRay.ToString();
                            break;
                        case "dvd":
                            movie.DisplayMediaType = MediaType.DVD.ToString();
                            break;
                        case "hd dvd":
                            movie.DisplayMediaType = MediaType.HDDVD.ToString();
                            break;
                        case "":
                            movie.DisplayMediaType = null;
                            break;
                    }
                }
                if (movie.ProductionYear == null)
                {
                    int y = doc.SafeGetInt32("Title/ProductionYear", 0);
                    if (y > 1850)
                        movie.ProductionYear = y;
                }
                if (movie.ImdbRating == null)
                {
                    float i = doc.SafeGetSingle("Title/IMDBrating", (float)-1, (float)10);
                    if (i >= 0)
                        movie.ImdbRating = i;
                }
                if (movie.ImdbID == null)
                {
                    if (!string.IsNullOrEmpty(doc.SafeGetString("Title/IMDB")))
                    {
                        movie.ImdbID = doc.SafeGetString("Title/IMDB");
                    }
                    else
                    {
                        movie.ImdbID = doc.SafeGetString("Title/IMDbId");
                    }
                }
                if (movie.TmdbID == null)
                {
                    movie.TmdbID = doc.SafeGetString("Title/TMDbId");
                }

                foreach (XmlNode node in doc.SelectNodes("Title/Persons/Person[Type='Actor']"))
                {
                    try
                    {
                        if (movie.Actors == null)
                            movie.Actors = new List<Actor>();

                        var name = node.SelectSingleNode("Name").InnerText;
                        var role = node.SafeGetString("Role", "");
                        var actor = new Actor() { Name = name, Role = role };
//.........这里部分代码省略.........
开发者ID:bartonnen,项目名称:MediaBrowser.Classic,代码行数:101,代码来源:MovieProviderFromXml.cs

示例5: GetSeriesDetails

        public Item GetSeriesDetails(Item item)
        {
            DataProviderId dp = item.ProvidersId.Find(p => p.Name == this.Name);
            if (dp == null) return null;
            if (!LoadSeriesDetails(dp.Id))
                return null;
            Item series = new Item();
            series.ProvidersId = new List<DataProviderId> { dp };

            XmlDocument doc = new XmlDocument();
            doc.Load(Path.Combine(Path.Combine(XmlPath, dp.Id), lang + ".xml"));
            if (doc == null) return null;

            series.Title = series.SeriesName = doc.SafeGetString("//SeriesName");
            series.Overview = doc.SafeGetString("//Overview");
            series.Rating = doc.SafeGetSingle("//Rating", 0, 10);
            series.RunningTime = doc.SafeGetInt32("//Runtime");
            series.MPAARating = doc.SafeGetString("//ContentRating");

            string g = doc.SafeGetString("//Genre");
            if (g != null)
            {
                string[] genres = g.Trim('|').Split('|');
                if (g.Length > 0)
                {
                    series.Genres = new List<string>();
                    series.Genres.AddRange(genres);
                }
            }

            XmlDocument actorsDoc = new XmlDocument();
            actorsDoc.Load(Path.Combine(Path.Combine(XmlPath, dp.Id), "actors.xml"));
            if (actorsDoc != null)
            {
                series.Actors = new List<Actor>();
                foreach (XmlNode actorNode in actorsDoc.SelectNodes("//Actor"))
                {
                    string name = actorNode.SafeGetString("Name");
                    if (!string.IsNullOrEmpty(name))
                    {
                        Actor actor = new Actor();
                        actor.Name = name;
                        actor.Role = actorNode.SafeGetString("Role");
                        actor.ImagePath = BannerUrl + actorNode.SafeGetString("Image");
                        if (series.Actors == null) series.Actors = new List<Actor>();
                        series.Actors.Add(actor);
                    }
                }
            }
            else
            {
                string actors = doc.SafeGetString("//Actors");
                if (actors != null)
                {
                    string[] a = actors.Trim('|').Split('|');
                    if (a.Length > 0)
                    {
                        series.Actors = new List<Actor>();
                        series.Actors.AddRange(
                            a.Select(actor => new Actor { Name = actor }));
                    }
                }
            }

            XmlDocument banners = new XmlDocument();
            banners.Load(Path.Combine(Path.Combine(XmlPath, dp.Id), "banners.xml"));
            if (banners != null)
            {
                series.BackdropImagePaths = new List<Poster>();
                series.ImagesPaths = new List<Poster>();
                series.BannersPaths = new List<Poster>();
                foreach (XmlNode node in banners.SelectNodes("//Banner"))
                {
                    if (node.SafeGetString("BannerType") == "poster")
                    {
                        Poster poster = new Poster();
                        string path = node.SafeGetString("BannerPath");
                        string thumb = node.SafeGetString("ThumbnailPath");
                        if (!string.IsNullOrEmpty(thumb))
                            poster.Thumb = BannerUrl + thumb;
                        poster.Image = BannerUrl + path;

                        if (!string.IsNullOrEmpty(path))
                            series.ImagesPaths.Add(poster);
                    }
                    else if (node.SafeGetString("BannerType") == "fanart")
                    {
                        Poster poster = new Poster();
                        poster.Checked = false;
                        string path = node.SafeGetString("BannerPath");
                        string thumb = node.SafeGetString("ThumbnailPath");
                        string size = node.SafeGetString("BannerType2");
                        if (size.Contains("x"))
                        {
                            poster.width = size.Substring(0, size.IndexOf("x"));
                            poster.height = size.Substring(size.IndexOf("x") + 1);
                        }
                        if (!string.IsNullOrEmpty(thumb))
                            poster.Thumb = BannerUrl + thumb;
                        poster.Image = BannerUrl + path;
//.........这里部分代码省略.........
开发者ID:arthurwayne,项目名称:metavideoeditor,代码行数:101,代码来源:Plugin.cs

示例6: Run

        /// <summary>
        /// Runs the specified progress.
        /// </summary>
        /// <param name="progress">The progress.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
        {
            if (!_config.Configuration.EnableInternetProviders)
            {
                progress.Report(100);
                return;
            }

            var path = RemoteSeriesProvider.GetSeriesDataPath(_config.CommonApplicationPaths);

            var timestampFile = Path.Combine(path, "time.txt");

            var timestampFileInfo = new FileInfo(timestampFile);

            // Don't check for tvdb updates anymore frequently than 24 hours
            if (timestampFileInfo.Exists && (DateTime.UtcNow - timestampFileInfo.LastWriteTimeUtc).TotalDays < 1)
            {
                return;
            }

            // Find out the last time we queried tvdb for updates
            var lastUpdateTime = timestampFileInfo.Exists ? File.ReadAllText(timestampFile, Encoding.UTF8) : string.Empty;

            string newUpdateTime;

            var existingDirectories = Directory.EnumerateDirectories(path).Select(Path.GetFileName).ToList();

            // If this is our first time, update all series
            if (string.IsNullOrEmpty(lastUpdateTime))
            {
                // First get tvdb server time
                using (var stream = await _httpClient.Get(new HttpRequestOptions
                {
                    Url = ServerTimeUrl,
                    CancellationToken = cancellationToken,
                    EnableHttpCompression = true,
                    ResourcePool = RemoteSeriesProvider.Current.TvDbResourcePool

                }).ConfigureAwait(false))
                {
                    var doc = new XmlDocument();

                    doc.Load(stream);

                    newUpdateTime = doc.SafeGetString("//Time");
                }

                await UpdateSeries(existingDirectories, path, progress, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                var seriesToUpdate = await GetSeriesIdsToUpdate(existingDirectories, lastUpdateTime, cancellationToken).ConfigureAwait(false);

                newUpdateTime = seriesToUpdate.Item2;

                await UpdateSeries(seriesToUpdate.Item1, path, progress, cancellationToken).ConfigureAwait(false);
            }

            File.WriteAllText(timestampFile, newUpdateTime, Encoding.UTF8);
            progress.Report(100);
        }
开发者ID:snap608,项目名称:MediaBrowser,代码行数:67,代码来源:TvdbPrescanTask.cs

示例7: GetSeriesIdsToUpdate

        /// <summary>
        /// Gets the series ids to update.
        /// </summary>
        /// <param name="existingSeriesIds">The existing series ids.</param>
        /// <param name="lastUpdateTime">The last update time.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{IEnumerable{System.String}}.</returns>
        private async Task<Tuple<IEnumerable<string>, string>> GetSeriesIdsToUpdate(IEnumerable<string> existingSeriesIds, string lastUpdateTime, CancellationToken cancellationToken)
        {
            // First get last time
            using (var stream = await _httpClient.Get(new HttpRequestOptions
            {
                Url = string.Format(UpdatesUrl, lastUpdateTime),
                CancellationToken = cancellationToken,
                EnableHttpCompression = true,
                ResourcePool = RemoteSeriesProvider.Current.TvDbResourcePool

            }).ConfigureAwait(false))
            {
                var doc = new XmlDocument();

                doc.Load(stream);

                var newUpdateTime = doc.SafeGetString("//Time");

                var seriesNodes = doc.SelectNodes("//Series");

                var seriesList = seriesNodes == null ? new string[] { } :
                    seriesNodes.Cast<XmlNode>()
                    .Select(i => i.InnerText)
                    .Where(i => !string.IsNullOrWhiteSpace(i) && existingSeriesIds.Contains(i, StringComparer.OrdinalIgnoreCase));

                return new Tuple<IEnumerable<string>, string>(seriesList, newUpdateTime);
            }
        }
开发者ID:snap608,项目名称:MediaBrowser,代码行数:35,代码来源:TvdbPrescanTask.cs

示例8: FetchEpisodeData

        /// <summary>
        /// Fetches the episode data.
        /// </summary>
        /// <param name="seriesXml">The series XML.</param>
        /// <param name="episode">The episode.</param>
        /// <param name="seriesId">The series id.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{System.Boolean}.</returns>
        private async Task<ProviderRefreshStatus> FetchEpisodeData(XmlDocument seriesXml, Episode episode, string seriesId, CancellationToken cancellationToken)
        {
            var status = ProviderRefreshStatus.Success;

            if (episode.IndexNumber == null)
            {
                return status;
            }

            var seasonNumber = episode.ParentIndexNumber ?? TVUtils.GetSeasonNumberFromEpisodeFile(episode.Path);

            if (seasonNumber == null)
            {
                return status;
            }

            var usingAbsoluteData = false;

            var episodeNode = seriesXml.SelectSingleNode("//Episode[EpisodeNumber='" + episode.IndexNumber.Value + "'][SeasonNumber='" + seasonNumber.Value + "']");

            if (episodeNode == null)
            {
                if (seasonNumber.Value == 1)
                {
                    episodeNode = seriesXml.SelectSingleNode("//Episode[absolute_number='" + episode.IndexNumber.Value + "']");
                    usingAbsoluteData = true;
                }
            }

            // If still null, nothing we can do
            if (episodeNode == null)
            {
                return status;
            }
            IEnumerable<XmlDocument> extraEpisodesNode = new XmlDocument[] { };

            if (episode.IndexNumberEnd.HasValue)
            {
                var seriesXDocument = XDocument.Load(new XmlNodeReader(seriesXml));
                if (usingAbsoluteData)
                {
                    extraEpisodesNode =
                        seriesXDocument.Descendants("Episode")
                                       .Where(
                                           x =>
                                           int.Parse(x.Element("absolute_number").Value) > episode.IndexNumber &&
                                           int.Parse(x.Element("absolute_number").Value) <= episode.IndexNumberEnd.Value).OrderBy(x => x.Element("absolute_number").Value).Select(x => x.ToXmlDocument());
                }
                else
                {
                    var all =
                        seriesXDocument.Descendants("Episode").Where(x => int.Parse(x.Element("SeasonNumber").Value) == seasonNumber.Value);

                    var xElements = all.Where(x => int.Parse(x.Element("EpisodeNumber").Value) > episode.IndexNumber && int.Parse(x.Element("EpisodeNumber").Value) <= episode.IndexNumberEnd.Value);
                    extraEpisodesNode = xElements.OrderBy(x => x.Element("EpisodeNumber").Value).Select(x => x.ToXmlDocument());
                }

            }
            var doc = new XmlDocument();
            doc.LoadXml(episodeNode.OuterXml);

            if (!episode.HasImage(ImageType.Primary))
            {
                var p = doc.SafeGetString("//filename");
                if (p != null)
                {
                    try
                    {
                        var url = TVUtils.BannerUrl + p;

                        await _providerManager.SaveImage(episode, url, RemoteSeriesProvider.Current.TvDbResourcePool, ImageType.Primary, null, cancellationToken)
                          .ConfigureAwait(false);
                    }
                    catch (HttpException)
                    {
                        status = ProviderRefreshStatus.CompletedWithErrors;
                    }
                }
            }
            if (!episode.LockedFields.Contains(MetadataFields.Overview))
            {
                var extraOverview = extraEpisodesNode.Aggregate("", (current, xmlDocument) => current + ("\r\n\r\n" + xmlDocument.SafeGetString("//Overview")));
                episode.Overview = doc.SafeGetString("//Overview") + extraOverview;
            }
            if (usingAbsoluteData)
                episode.IndexNumber = doc.SafeGetInt32("//absolute_number", -1);
            if (episode.IndexNumber < 0)
                episode.IndexNumber = doc.SafeGetInt32("//EpisodeNumber");
            if (!episode.LockedFields.Contains(MetadataFields.Name))
            {
                var extraNames = extraEpisodesNode.Aggregate("", (current, xmlDocument) => current + (", " + xmlDocument.SafeGetString("//EpisodeName")));
                episode.Name = doc.SafeGetString("//EpisodeName") + extraNames;
//.........这里部分代码省略.........
开发者ID:Kampari,项目名称:MediaBrowser,代码行数:101,代码来源:RemoteEpisodeProvider.cs

示例9: ProcessDocument

        protected virtual void ProcessDocument(XmlDocument doc, bool ignoreImages)
        {
            Movie movie = Item as Movie;
            if (doc != null)
            {
                // This is problematic for foreign films we want to keep the alt title.
                //if (store.Name == null)
                //    store.Name = doc.SafeGetString("//movie/title");

                movie.Name = doc.SafeGetString("//movie/name");

                movie.Overview = doc.SafeGetString("//movie/overview");
                if (movie.Overview != null)
                    movie.Overview = movie.Overview.Replace("\n\n", "\n");

                movie.TagLine = doc.SafeGetString("//movie/tagline");
                movie.ImdbID = doc.SafeGetString("//movie/imdb_id");

                movie.ImdbRating = doc.SafeGetSingle("//movie/rating", -1, 10);

                string release = doc.SafeGetString("//movie/released");
                if (!string.IsNullOrEmpty(release))
                    movie.ProductionYear = Int32.Parse(release.Substring(0, 4));

                movie.RunningTime = doc.SafeGetInt32("//movie/runtime");
                if (movie.MediaInfo != null && movie.MediaInfo.RunTime > 0) movie.RunningTime = movie.MediaInfo.RunTime;

                movie.MpaaRating = doc.SafeGetString("//movie/certification");

                movie.Studios = null;
                foreach (XmlNode n in doc.SelectNodes("//studios/studio"))
                {
                    if (movie.Studios == null)
                        movie.Studios = new List<string>();
                    string name = n.SafeGetString("@name");
                    if (!string.IsNullOrEmpty(name))
                        movie.Studios.Add(name);
                }

                movie.Directors = null;
                foreach (XmlNode n in doc.SelectNodes("//cast/person[@job='Director']"))
                {
                    if (movie.Directors == null)
                        movie.Directors = new List<string>();
                    string name = n.SafeGetString("@name");
                    if (!string.IsNullOrEmpty(name))
                        movie.Directors.Add(name);
                }

                movie.Writers = null;
                foreach (XmlNode n in doc.SelectNodes("//cast/person[@job='Author']"))
                {
                    if (movie.Writers == null)
                        movie.Writers = new List<string>();
                    string name = n.SafeGetString("@name");
                    if (!string.IsNullOrEmpty(name))
                        movie.Writers.Add(name);
                }

                movie.Actors = null;
                foreach (XmlNode n in doc.SelectNodes("//cast/person[@job='Actor']"))
                {
                    if (movie.Actors == null)
                        movie.Actors = new List<Actor>();
                    string name = n.SafeGetString("@name");
                    string role = n.SafeGetString("@character");
                    if (!string.IsNullOrEmpty(name))
                        movie.Actors.Add(new Actor { Name = name, Role = role });
                }

                XmlNodeList nodes = doc.SelectNodes("//movie/categories/category[@type='genre']/@name");
                List<string> genres = new List<string>();
                foreach (XmlNode node in nodes)
                {
                    string n = MapGenre(node.InnerText);
                    if ((!string.IsNullOrEmpty(n)) && (!genres.Contains(n)))
                        genres.Add(n);
                }
                movie.Genres = genres;

                if (!ignoreImages)
                {
                    string img = doc.SafeGetString("//movie/images/image[@type='poster' and @size='" + Kernel.Instance.ConfigData.FetchedPosterSize + "']/@url");
                    if (img == null)
                    {
                        img = doc.SafeGetString("//movie/images/image[@type='poster' and @size='original']/@url"); //couldn't find preferred size
                    }
                    if (img != null)
                    {
                        if (Kernel.Instance.ConfigData.SaveLocalMeta)
                        {
                            //download and save locally
                            RemoteImage cover = new RemoteImage() { Path = img };
                            string ext = Path.GetExtension(img).ToLower();
                            string fn = (Path.Combine(Item.Path,"folder" + ext));
                            try
                            {
                                Kernel.IgnoreFileSystemMods = true;
                                cover.DownloadImage().Save(fn, ext == ".png" ? System.Drawing.Imaging.ImageFormat.Png : System.Drawing.Imaging.ImageFormat.Jpeg);
                                Kernel.IgnoreFileSystemMods = false;
//.........这里部分代码省略.........
开发者ID:xantilas,项目名称:ghalager-videobrowser-20120129,代码行数:101,代码来源:MovieDbProvider.cs

示例10: Fetch

        public override void Fetch()
        {
            var movie = Item as Movie;
             Debug.Assert(movie != null);

            string mfile = XmlLocation();
            string location = Path.GetDirectoryName(mfile);
            if (File.Exists(mfile))
            {

                DateTime modTime = new FileInfo(mfile).LastWriteTimeUtc;
                lastWriteTime = modTime;
                myMovieFile = mfile;
                XmlDocument doc = new XmlDocument();
                doc.Load(mfile);

                string s = doc.SafeGetString("Title/LocalTitle");
                if ((s == null) || (s == ""))
                    s = doc.SafeGetString("Title/OriginalTitle");
                movie.Name = s;
                movie.SortName = doc.SafeGetString("Title/SortTitle");

                movie.Overview = doc.SafeGetString("Title/Description");
                if (movie.Overview != null)
                    movie.Overview = movie.Overview.Replace("\n\n", "\n");

                string front = doc.SafeGetString("Title/Covers/Front");
                if ((front != null) && (front.Length > 0))
                {
                    front = Path.Combine(location, front);
                    if (File.Exists(front))
                        Item.PrimaryImagePath = front;
                }

                string back = doc.SafeGetString("Title/Covers/Back");
                if ((back != null) && (back.Length > 0))
                {
                    back = Path.Combine(location, back);
                    if (File.Exists(back))
                        Item.SecondaryImagePath = back;
                }

                if (movie.RunningTime == null)
                {
                    int rt = doc.SafeGetInt32("Title/RunningTime",0);
                    if (rt > 0)
                        movie.RunningTime = rt;
                }
                if (movie.ProductionYear == null)
                {
                    int y = doc.SafeGetInt32("Title/ProductionYear",0);
                    if (y > 1900)
                        movie.ProductionYear = y;
                }
                if (movie.ImdbRating == null)
                {
                    float i = doc.SafeGetSingle("Title/IMDBrating", (float)-1, (float)10);
                    if (i >= 0)
                        movie.ImdbRating = i;
                }

                foreach (XmlNode node in doc.SelectNodes("Title/Persons/Person[Type='Actor']"))
                {
                    try
                    {
                        if (movie.Actors == null)
                            movie.Actors = new List<Actor>();
                        movie.Actors.Add(new Actor { Name = node.SelectSingleNode("Name").InnerText, Role = node.SelectSingleNode("Role").InnerText });
                    }
                    catch
                    {
                        // fall through i dont care, one less actor
                    }
                }

                foreach (XmlNode node in doc.SelectNodes("Title/Persons/Person[Type='Director']"))
                {
                    try
                    {
                        if (movie.Directors == null)
                            movie.Directors = new List<string>();
                        movie.Directors.Add(node.SelectSingleNode("Name").InnerText);
                    }
                    catch
                    {
                        // fall through i dont care, one less director
                    }
                }

                foreach (XmlNode node in doc.SelectNodes("Title/Genres/Genre"))
                {
                    try
                    {
                        if (movie.Genres == null)
                            movie.Genres = new List<string>();
                        movie.Genres.Add(node.InnerText);
                    }
                    catch
                    {
                        // fall through i dont care, one less genre
//.........这里部分代码省略.........
开发者ID:purplecow,项目名称:Media-Browser,代码行数:101,代码来源:MovieProviderFromXml.cs

示例11: FetchMainInfo

        /// <summary>
        /// Fetches the main info.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <param name="doc">The doc.</param>
        private void FetchMainInfo(Series series, XmlDocument doc)
        {
            if (!series.LockedFields.Contains(MetadataFields.Name))
            {
                series.Name = doc.SafeGetString("//SeriesName");
            }
            if (!series.LockedFields.Contains(MetadataFields.Overview))
            {
                series.Overview = doc.SafeGetString("//Overview");
            }
            series.CommunityRating = doc.SafeGetSingle("//Rating", 0, 10);
            series.AirDays = TVUtils.GetAirDays(doc.SafeGetString("//Airs_DayOfWeek"));
            series.AirTime = doc.SafeGetString("//Airs_Time");
            SeriesStatus seriesStatus;
            if(Enum.TryParse(doc.SafeGetString("//Status"), true, out seriesStatus))
                series.Status = seriesStatus;
            series.PremiereDate = doc.SafeGetDateTime("//FirstAired");
            if (series.PremiereDate.HasValue)
                series.ProductionYear = series.PremiereDate.Value.Year;

            series.RunTimeTicks = TimeSpan.FromMinutes(doc.SafeGetInt32("//Runtime")).Ticks;

            if (!series.LockedFields.Contains(MetadataFields.Studios))
            {
                string s = doc.SafeGetString("//Network");

                if (!string.IsNullOrWhiteSpace(s))
                {
                    series.Studios.Clear();

                    foreach (var studio in s.Trim().Split('|'))
                    {
                        series.AddStudio(studio);
                    }
                }
            }
            series.OfficialRating = doc.SafeGetString("//ContentRating");
            if (!series.LockedFields.Contains(MetadataFields.Genres))
            {
                string g = doc.SafeGetString("//Genre");

                if (g != null)
                {
                    string[] genres = g.Trim('|').Split('|');
                    if (g.Length > 0)
                    {
                        series.Genres.Clear();

                        foreach (var genre in genres)
                        {
                            series.AddGenre(genre);
                        }
                    }
                }
            }
            if (series.Status == SeriesStatus.Ended) {
                
                var document = XDocument.Load(new XmlNodeReader(doc));
                var dates = document.Descendants("Episode").Where(x => {
                                                                      var seasonNumber = x.Element("SeasonNumber");
                                                                      var firstAired = x.Element("FirstAired");
                                                                      return firstAired != null && seasonNumber != null && (!string.IsNullOrEmpty(seasonNumber.Value) && seasonNumber.Value != "0") && !string.IsNullOrEmpty(firstAired.Value);
                                                                  }).Select(x => {
                                                                                DateTime? date = null;
                                                                                DateTime tempDate;
                                                                                var firstAired = x.Element("FirstAired");
                                                                                if (firstAired != null && DateTime.TryParse(firstAired.Value, out tempDate)) 
                                                                                {
                                                                                    date = tempDate;
                                                                                }
                                                                                return date;
                                                                            }).ToList();
                if(dates.Any(x=>x.HasValue))
                    series.EndDate = dates.Where(x => x.HasValue).Max();
            }
        }
开发者ID:squibber46,项目名称:MediaBrowser,代码行数:81,代码来源:RemoteSeriesProvider.cs

示例12: FetchEpisodeData

        /// <summary>
        /// Fetches the episode data.
        /// </summary>
        /// <param name="seriesXml">The series XML.</param>
        /// <param name="episode">The episode.</param>
        /// <param name="seriesId">The series id.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{System.Boolean}.</returns>
        private async Task<ProviderRefreshStatus> FetchEpisodeData(XmlDocument seriesXml, Episode episode, string seriesId, CancellationToken cancellationToken)
        {
            var status = ProviderRefreshStatus.Success;

            if (episode.IndexNumber == null)
            {
                return status;
            }

            var seasonNumber = episode.ParentIndexNumber ?? TVUtils.GetSeasonNumberFromEpisodeFile(episode.Path);

            if (seasonNumber == null)
            {
                return status;
            }

            var usingAbsoluteData = false;

            var episodeNode = seriesXml.SelectSingleNode("//Episode[EpisodeNumber='" + episode.IndexNumber.Value + "'][SeasonNumber='" + seasonNumber.Value + "']");

            if (episodeNode == null)
            {
                if (seasonNumber.Value == 1)
                {
                    episodeNode = seriesXml.SelectSingleNode("//Episode[absolute_number='" + episode.IndexNumber.Value + "']");
                    usingAbsoluteData = true;
                }
            }

            // If still null, nothing we can do
            if (episodeNode == null)
            {
                return status;
            }

            var doc = new XmlDocument();
            doc.LoadXml(episodeNode.OuterXml);

            if (!episode.HasImage(ImageType.Primary))
            {
                var p = doc.SafeGetString("//filename");
                if (p != null)
                {
                    if (!Directory.Exists(episode.MetaLocation)) Directory.CreateDirectory(episode.MetaLocation);

                    try
                    {
                        episode.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(episode, TVUtils.BannerUrl + p, Path.GetFileName(p), ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken);
                    }
                    catch (HttpException)
                    {
                        status = ProviderRefreshStatus.CompletedWithErrors;
                    }
                }
            }

            episode.Overview = doc.SafeGetString("//Overview");
            if (usingAbsoluteData)
                episode.IndexNumber = doc.SafeGetInt32("//absolute_number", -1);
            if (episode.IndexNumber < 0)
                episode.IndexNumber = doc.SafeGetInt32("//EpisodeNumber");

            episode.Name = doc.SafeGetString("//EpisodeName");
            episode.CommunityRating = doc.SafeGetSingle("//Rating", -1, 10);
            var firstAired = doc.SafeGetString("//FirstAired");
            DateTime airDate;
            if (DateTime.TryParse(firstAired, out airDate) && airDate.Year > 1850)
            {
                episode.PremiereDate = airDate.ToUniversalTime();
                episode.ProductionYear = airDate.Year;
            }

            episode.People.Clear();

            var actors = doc.SafeGetString("//GuestStars");
            if (actors != null)
            {
                foreach (var person in actors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
                    .Where(i => !string.IsNullOrWhiteSpace(i))
                    .Select(str => new PersonInfo { Type = PersonType.GuestStar, Name = str }))
                {
                    episode.AddPerson(person);
                }
            }


            var directors = doc.SafeGetString("//Director");
            if (directors != null)
            {
                foreach (var person in directors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
                    .Where(i => !string.IsNullOrWhiteSpace(i))
                    .Select(str => new PersonInfo { Type = PersonType.Director, Name = str }))
//.........这里部分代码省略.........
开发者ID:snap608,项目名称:MediaBrowser,代码行数:101,代码来源:RemoteEpisodeProvider.cs

示例13: FetchXmlMovie

        private static void FetchXmlMovie(Item movie)
        {
            string mfile = Path.Combine(location, videofilename + ".nfo");

            if (File.Exists(mfile))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(mfile);

                movie.Title = doc.SafeGetString("movie/title");
                movie.OriginalTitle = doc.SafeGetString("movie/originaltitle");
                movie.SortTitle = doc.SafeGetString("movie/sorttitle");
                DateTime added;
                DateTime.TryParse(doc.SafeGetString("movie/added"), out added);
                if (added != null) movie.DateAdded = added;

                int? y = doc.SafeGetInt32("movie/year", 0);
                if (y.IsValidYear()) movie.Year = y;

                int? rt = doc.SafeGetInt32("movie/runtime", 0);
                if (rt.IsValidRunningTime())  movie.RunningTime = rt;

                movie.Rating = doc.SafeGetSingle("movie/rating", (float)-1, (float)10);
                movie.MPAARating = doc.SafeGetString("movie/mpaa");
                movie.Overview = doc.SafeGetString("movie/plot");
                movie.Mediatype = doc.SafeGetString("movie/type");
                movie.AspectRatio = doc.SafeGetString("movie/aspectratio");

                foreach (XmlNode node in doc.SelectNodes("movie/actor"))
                {
                    if (movie.Actors == null)
                        movie.Actors = new List<Actor>();
                    Actor actor = new Actor();
                    actor.Name = node.SafeGetString("name");
                    actor.Role = node.SafeGetString("role");
                    actor.ImagePath = node.SafeGetString("thumb");
                    if (string.IsNullOrEmpty(actor.ImagePath) && Directory.Exists(PluginOptions.Instance.ActorsThumbPath))
                    {
                        string actorImage = Path.Combine(PluginOptions.Instance.ActorsThumbPath, actor.Name + ".tbn");
                        if (File.Exists(actorImage))
                            actor.ImagePath = actorImage;
                    }
                    movie.Actors.Add(actor);
                }

                foreach (XmlNode node in doc.SelectNodes("movie/director"))
                {
                    if (movie.Crew == null) movie.Crew = new List<CrewMember>();
                    movie.Crew.Add(new CrewMember { Name = node.InnerText, Activity = "Director" });
                }

                foreach (XmlNode node in doc.SelectNodes("movie/genre"))
                {
                    if (movie.Genres == null) movie.Genres = new List<string>();
                    movie.Genres.Add(node.InnerText);
                }

                foreach (XmlNode node in doc.SelectNodes("movie/studio"))
                {
                    if (movie.Studios == null) movie.Studios = new List<string>();
                    movie.Studios.Add(node.InnerText);
                }

                foreach (XmlNode node in doc.SelectNodes("movie/country"))
                {
                    if (movie.Countries == null) movie.Countries = new List<string>();
                    movie.Countries.Add(node.InnerText);
                }

                foreach (XmlNode node in doc.SelectNodes("movie/tagline"))
                {
                    if (movie.TagLines == null) movie.TagLines = new List<string>();
                    movie.TagLines.Add(node.InnerText);
                }

                foreach (XmlNode node in doc.SelectNodes("movie/trailer"))
                {
                    if (movie.TrailerFiles == null) movie.TrailerFiles = new List<string>();
                    movie.TrailerFiles.Add(node.InnerText);
                }

                foreach (XmlNode node in doc.SelectNodes("movie/thumb"))
                {
                    if (movie.ImagesPaths == null) movie.ImagesPaths = new List<Poster>();
                    movie.ImagesPaths.AddDistinctPoster(new Poster { Image = node.InnerText });
                }

                foreach (XmlNode node in doc.SelectNodes("movie/fanart/thumb"))
                {
                    if (movie.BackdropImagePaths == null) movie.BackdropImagePaths = new List<Poster>();
                    movie.BackdropImagePaths.AddDistinctPoster(new Poster { Image = node.InnerText });
                }

            }
        }
开发者ID:arthurwayne,项目名称:metavideoeditor,代码行数:95,代码来源:plugin.cs

示例14: FetchSeries

        private static void FetchSeries(Item series)
        {
            string mfile = Path.Combine(location, "tvshow.nfo");

            if (File.Exists(mfile))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(mfile);

                series.SeriesName = series.Title = doc.SafeGetString("tvshow/title");
                series.Rating = doc.SafeGetSingle("tvshow/rating", (float)-1, (float)10);

                string id = doc.SafeGetString("tvshow/id");
                if (!string.IsNullOrEmpty(id))
                {
                    series.ProvidersId = new List<DataProviderId>();
                    series.ProvidersId.Add(new DataProviderId { Id = id, Name = "TheTVDB", Url = "http://thetvdb.com/?tab=series&id=" + id });
                }

                series.Overview = doc.SafeGetString("tvshow/overview");

                foreach (XmlNode node in doc.SelectNodes("tvshow/actor"))
                {
                    if (series.Actors == null)
                        series.Actors = new List<Actor>();
                    Actor actor = new Actor();
                    actor.Name = node.SafeGetString("name");
                    actor.Role = node.SafeGetString("role");
                    actor.ImagePath = node.SafeGetString("thumb");
                    if (string.IsNullOrEmpty(actor.ImagePath) && Directory.Exists(PluginOptions.Instance.ActorsThumbPath))
                    {
                        string actorImage = Path.Combine(PluginOptions.Instance.ActorsThumbPath, actor.Name + ".tbn");
                        if (File.Exists(actorImage))
                            actor.ImagePath = actorImage;
                    }
                    series.Actors.Add(actor);
                }

                foreach (XmlNode node in doc.SelectNodes("tvshow/genre"))
                {
                    if (series.Genres == null) series.Genres = new List<string>();
                    series.Genres.Add(node.InnerText);
                }

                series.MPAARating = doc.SafeGetString("mpaa");

                int? rt = doc.SafeGetInt32("tvshow/runtime", 0);
                if (rt.IsValidRunningTime()) series.RunningTime = rt;

                series.Rating = doc.SafeGetSingle("tvshow/rating", (float)-1, (float)10);

                foreach (XmlNode node in doc.SelectNodes("tvshow/studio"))
                {
                    if (series.Studios == null) series.Studios = new List<string>();
                    series.Studios.Add(node.InnerText);
                }

                foreach (XmlNode node in doc.SelectNodes("tvshow/tagline"))
                {
                    if (series.TagLines == null) series.TagLines = new List<string>();
                    series.TagLines.Add(node.InnerText);
                }

                foreach (XmlNode node in doc.SelectNodes("tvshow/thumb"))
                {
                    if (series.BannersPaths == null) series.BannersPaths = new List<Poster>();
                    series.BannersPaths.AddDistinctPoster(new Poster { Image = node.InnerText });
                }
            }
        }
开发者ID:arthurwayne,项目名称:metavideoeditor,代码行数:70,代码来源:plugin.cs

示例15: FetchEpisode

        private static void FetchEpisode(Item episode)
        {
            var mfile = Path.Combine(location, videofilename + ".nfo");
            if (File.Exists(mfile))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(mfile);

                episode.Overview = doc.SafeGetString("episodedetails/plot");
                episode.EpisodeNumber = doc.SafeGetString("episodedetails/episode");
                episode.Title = doc.SafeGetString("episodedetails/title");
                episode.SeasonNumber = doc.SafeGetString("episodedetails/season");
                episode.Rating = doc.SafeGetSingle("episodedetails/rating", (float)-1, 10);

                foreach (XmlNode node in doc.SelectNodes("episodedetails/actor"))
                {
                    if (episode.Actors == null)
                        episode.Actors = new List<Actor>();
                    Actor actor = new Actor();
                    actor.Name = node.SafeGetString("name");
                    actor.Role = node.SafeGetString("role");
                    actor.ImagePath = node.SafeGetString("thumb");
                    if (string.IsNullOrEmpty(actor.ImagePath) && Directory.Exists(PluginOptions.Instance.ActorsThumbPath))
                    {
                        string actorImage = Path.Combine(PluginOptions.Instance.ActorsThumbPath, actor.Name + ".tbn");
                        if (File.Exists(actorImage))
                            actor.ImagePath = actorImage;
                    }
                    episode.Actors.Add(actor);
                }

                foreach (XmlNode node in doc.SelectNodes("episodedetails/director"))
                {
                    if (episode.Crew == null) episode.Crew = new List<CrewMember>();
                    episode.Crew.Add(new CrewMember { Name = node.InnerText, Activity = "Director" });
                }

                foreach (XmlNode node in doc.SelectNodes("episodedetails/credit"))
                {
                    if (episode.Crew == null) episode.Crew = new List<CrewMember>();
                    episode.Crew.Add(new CrewMember { Name = node.InnerText, Activity = "Writer" });
                }
            }
        }
开发者ID:arthurwayne,项目名称:metavideoeditor,代码行数:44,代码来源:plugin.cs


注:本文中的System.Xml.XmlDocument.SafeGetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。