/// <inheritdoc/> public override Video Clone(int server, bool isSpecial = false) { bool cloneMovie = false; bool hasSpecials = false; // check if Movie is on requested Server foreach (int serverList in this.Server) { if (serverList.Equals(server)) { cloneMovie = true; } } // check if Movie contains Specials, if isSpecial is requested if (isSpecial) { foreach (VideoFile videoFile in this.MediaFiles) { if (videoFile.Server.Equals(server) && videoFile.IsSpecial == isSpecial) { hasSpecials = true; } } } Movie movieClone = null; if (cloneMovie && hasSpecials == isSpecial) { movieClone = new Movie(this.Configuration); movieClone.Title = this.Title; movieClone.TitleSort = this.TitleSort; movieClone.TitleOriginal = this.TitleOriginal; movieClone.MediaGroup = this.MediaGroup; movieClone.Rating = this.Rating; movieClone.PublishingYear = this.PublishingYear; movieClone.PublishingDate = this.PublishingDate; movieClone.Content = this.Content; movieClone.RunTime = this.RunTime; movieClone.Images = this.Images; // if required, still to be cloned movieClone.MPAA = this.MPAA; movieClone.PlayCount = this.PlayCount; movieClone.PlayDate = this.PlayDate; movieClone.IMDbId = this.IMDbId; movieClone.Country = this.Country; movieClone.Genres = this.Genres; movieClone.Studios = this.Studios; movieClone.Directors = this.Directors; movieClone.Writers = this.Writers; movieClone.Actors = this.Actors; foreach (VideoFile videoFile in this.MediaFiles) { if (videoFile.Server.Equals(server) && videoFile.IsSpecial == isSpecial) { movieClone.MediaFiles.Add((VideoFile)videoFile.Clone()); } } movieClone.Filename = this.Filename; movieClone.AddServer(server); movieClone.VideoCodec = this.VideoCodec; movieClone.VideoDefinition = this.VideoDefinition; movieClone.VideoAspectRatio = this.VideoAspectRatio; movieClone.AudioStreams = this.AudioStreams; movieClone.SubTitles = this.SubTitles; movieClone.MediaLanguages = this.MediaLanguages; } return movieClone; }
/// <summary> /// reads the MovieCollectoz XML export into MediaCollection /// </summary> /// <remarks> /// requires user defined field:<br/> /// "XBMC Movie" - true if entry is to be interpreted as a movie<br/> /// "XBMC Series" - true if entry is to be interpreted as a series<br/> /// </remarks> /// <param name="eingabeXML">File that was used while export from MovieCollector - complete local path</param> public void ReadXML(string eingabeXML) { bool xMLMovieIsMovie = false; bool xMLMovieIsSeries = false; Video media = null; foreach (XmlNode xMLMovie in BaseClassExtention.XMLReadFile(eingabeXML, "movieinfo").XMLReadSubnode("movielist").XMLReadSubnodes("movie")) { #region evaluate Type and create media-object foreach (XmlNode xMLUserDefinedValue in xMLMovie.XMLReadSubnode("userdefinedvalues").XMLReadSubnodes("userdefinedvalue")) { if (xMLUserDefinedValue.XMLReadSubnode("userdefinedfield").XMLReadSubnode("label").XMLReadInnerText(string.Empty) == "XBMC Movie") { xMLMovieIsMovie = xMLUserDefinedValue.XMLReadSubnode("value").XMLReadInnerText(string.Empty) == "Yes" || xMLUserDefinedValue.XMLReadSubnode("value").XMLReadInnerText(string.Empty) == "Ja"; } if (xMLUserDefinedValue.XMLReadSubnode("userdefinedfield").XMLReadSubnode("label").XMLReadInnerText(string.Empty) == "XBMC Serie") { xMLMovieIsSeries = xMLUserDefinedValue.XMLReadSubnode("value").XMLReadInnerText(string.Empty) == "Yes" || xMLUserDefinedValue.XMLReadSubnode("value").XMLReadInnerText(string.Empty) == "Ja"; } } if (xMLMovieIsMovie) { if (!this.Configuration.KodiExportMovieAsSeries) { media = new Movie(this.Configuration); } else { xMLMovieIsMovie = false; xMLMovieIsSeries = true; } } if (xMLMovieIsSeries) { media = new Series(this.Configuration); } if (media == null) { continue; // TODO: ### write error log } #endregion #region Media (Movie & Series) media.Title = xMLMovie.XMLReadSubnode("title").XMLReadInnerText(string.Empty); media.Title = media.OverrideVideoStreamData(media.Title); media.PublishingYear = xMLMovie.XMLReadSubnode("releasedate").XMLReadSubnode("year").XMLReadSubnode("displayname").XMLReadInnerText(string.Empty); media.TitleSort = xMLMovie.XMLReadSubnode("titlesort").XMLReadInnerText(string.Empty); media.TitleOriginal = xMLMovie.XMLReadSubnode("originaltitle").XMLReadInnerText(string.Empty); media.MediaGroup = xMLMovie.XMLReadSubnode("series").XMLReadSubnode("displayname").XMLReadInnerText(media.Title); media.Rating = xMLMovie.XMLReadSubnode("imdbrating").XMLReadInnerText(string.Empty); media.Content = xMLMovie.XMLReadSubnode("plot").XMLReadInnerText(string.Empty); media.RunTime = xMLMovie.XMLReadSubnode("runtime").XMLReadInnerText(string.Empty); media.MPAA = xMLMovie.XMLReadSubnode("mpaarating").XMLReadSubnode("displayname").XMLReadInnerText(string.Empty); media.IMDbId = "tt" + xMLMovie.XMLReadSubnode("imdbnum").XMLReadInnerText(string.Empty); media.Country = xMLMovie.XMLReadSubnode("country").XMLReadSubnode("displayname").XMLReadInnerText(string.Empty); media.ReadImages(xMLMovie); media.ReadGenre(xMLMovie); media.ReadStudio(xMLMovie); media.ReadCrew(xMLMovie); media.ReadCast(xMLMovie); media.ReadStreamData(xMLMovie); #endregion #region Movie if (xMLMovieIsMovie) { ((Movie)media).VideoIndex = 1; ((Movie)media).ReadMediaFiles(xMLMovie); media.PublishingDate = xMLMovie.XMLReadSubnode("releasedate").XMLReadSubnode("date").XMLReadInnerText(media.PublishingYear); media.PlayCount = (xMLMovie.XMLReadSubnode("seenit").XMLReadInnerText(string.Empty) == "Yes" || xMLMovie.XMLReadSubnode("seenit").XMLReadInnerText(string.Empty) == "Ja") ? "1" : "0"; media.PlayDate = xMLMovie.XMLReadSubnode("viewingdate").XMLReadSubnode("date").XMLReadInnerText(string.Empty); if (media.HasSpecials() && media.MediaGroup == string.Empty) { media.MediaGroup = media.Title; } this.MovieCollection.Add((Movie)media); } #endregion #region Series if (xMLMovieIsSeries) { // releasedate and number episodes in series media.PublishingDate = xMLMovie.XMLReadSubnode("releasedate").XMLReadSubnode("date").XMLReadInnerText(media.PublishingYear); ((Series)media).NumberOfTotalEpisodes = (int)int.Parse(xMLMovie.XMLReadSubnode("chapters").XMLReadInnerText(string.Empty)); int videoIndex = 0; // episodes foreach (XmlNode xMLSeriesDisc in xMLMovie.XMLReadSubnode("discs").XMLReadSubnodes("disc")) { Episode seriesDiscEpisode = new Episode(this.Configuration); seriesDiscEpisode.Series = (Series)media; seriesDiscEpisode.ExtractSeriesData((Series)media); seriesDiscEpisode.OverrideSeason(seriesDiscEpisode.OverrideVideoStreamData(xMLSeriesDisc.XMLReadSubnode("title").XMLReadInnerText(string.Empty)), false); foreach (XmlNode xMLEpisode in xMLSeriesDisc.XMLReadSubnode("episodes").XMLReadSubnodes("episode")) { Episode episode = new Episode(this.Configuration); videoIndex++; episode.VideoIndex = videoIndex; // reset Episode-Attributes to Disc-Attributes episode.ExtractSeriesData(seriesDiscEpisode); // read Episode-Details episode.Series = (Series)media; episode.Title = episode.OverrideSeason(episode.OverrideVideoStreamData(xMLEpisode.XMLReadSubnode("title").XMLReadInnerText(string.Empty)), true); episode.TitleSort = episode.Title; episode.TitleOriginal = episode.Title; episode.MediaGroup = episode.Series.MediaGroup; episode.Content = xMLEpisode.XMLReadSubnode("plot").XMLReadInnerText(string.Empty); if (!episode.IsSpecial && episode.Content == string.Empty) { episode.Content = episode.Series.Content; } episode.RunTime = xMLEpisode.XMLReadSubnode("runtimeminutes").XMLReadInnerText(string.Empty); episode.PublishingDate = xMLEpisode.XMLReadSubnode("firstairdate").XMLReadSubnode("date").XMLReadInnerText(episode.Series.PublishingDate); episode.PlayCount = xMLEpisode.XMLReadSubnode("seenit").XMLReadInnerText(string.Empty) == "Yes" || xMLEpisode.XMLReadSubnode("seenit").XMLReadInnerText(string.Empty) == "Ja" ? "1" : "0"; episode.PlayDate = xMLEpisode.XMLReadSubnode("viewingdate").XMLReadSubnode("date").XMLReadInnerText(string.Empty); episode.Genres = episode.Series.Genres; episode.Studios = episode.Series.Studios; episode.AudioStreams = episode.Series.AudioStreams; episode.SubTitles = episode.Series.SubTitles; episode.ReadCrew(xMLEpisode); episode.ReadCast(xMLEpisode); episode.ReadMediaFiles(xMLEpisode); episode.ReadImages(xMLEpisode); ((Series)media).Episodes.Add(episode); } } // add SubTitles on series-level ((Series)media).ReadMediaFiles(xMLMovie); this.SeriesCollection.Add((Series)media); } #endregion #region Media (Movie & Series) media.SetFilename(); #endregion } this.GroupByMediaGroup(); }
/// <inheritdoc/> public override Media Clone() { Movie movieClone = new Movie(this.Configuration); movieClone.Title = this.Title; movieClone.TitleSort = this.TitleSort; movieClone.TitleOriginal = this.TitleOriginal; movieClone.MediaGroup = this.MediaGroup; movieClone.Rating = this.Rating; movieClone.PublishingYear = this.PublishingYear; movieClone.PublishingDate = this.PublishingDate; movieClone.Content = this.Content; movieClone.RunTime = this.RunTime; movieClone.Images = this.Images; // if required, still to be cloned movieClone.MPAA = this.MPAA; movieClone.PlayCount = this.PlayCount; movieClone.PlayDate = this.PlayDate; movieClone.IMDbId = this.IMDbId; movieClone.Country = this.Country; movieClone.Genres = this.Genres; movieClone.Directors = this.Directors; movieClone.Studios = this.Studios; movieClone.Writers = this.Writers; movieClone.Actors = this.Actors; foreach (VideoFile videoFile in this.MediaFiles) { movieClone.MediaFiles.Add((VideoFile)videoFile.Clone()); } movieClone.Filename = this.Filename; movieClone.Server = this.Server; movieClone.VideoCodec = this.VideoCodec; movieClone.VideoDefinition = this.VideoDefinition; movieClone.VideoAspectRatio = this.VideoAspectRatio; movieClone.AudioStreams = this.AudioStreams; movieClone.SubTitles = this.SubTitles; movieClone.MediaLanguages = this.MediaLanguages; return (Movie)movieClone; }