Esempio n. 1
0
        /// <summary>
        /// Do series replace.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        /// <param name="value">
        /// The value.
        /// </param>
        /// <returns>
        /// The do series replace.
        /// </returns>
        public string DoSeriesReplace(Series series, string value)
        {
            string firstEpisodeFileNamePath = series.GetFirstEpisode();
            string firstEpisodePath = Path.GetDirectoryName(firstEpisodeFileNamePath);
            string firstEpisodeFileNameNoExt = Path.GetFileNameWithoutExtension(firstEpisodeFileNamePath);

            string seriesName = FileSystemCharChange.To(series.SeriesName);

            value = value.Replace("<firstEpisodePath>", firstEpisodePath);
            value = value.Replace("<seriesName>", seriesName);
            value = value.Replace(
                "<firstEpisodeOfSeason>", firstEpisodePath + Path.DirectorySeparatorChar + firstEpisodeFileNameNoExt);

            return value;
        }
Esempio n. 2
0
 /// <summary>
 /// The rename series.
 /// </summary>
 /// <param name="series">
 /// The series.
 /// </param>
 public static void RenameSeries(Series series)
 {
     foreach (var season in series.Seasons)
     {
         foreach (Episode episode in season.Value.Episodes)
         {
             if (!string.IsNullOrEmpty(episode.FilePath.PathAndFilename))
             {
                 RenameEpisode(episode);
             }
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Checks if the series needs updating, and if so returns an updated series.
        /// </summary>
        /// <param name="seriesId">The series id.</param>
        /// <param name="seriesLanguage">The series language.</param>
        /// <param name="lastUpdated">The last updated value</param>
        /// <returns>
        /// Updated series object, or NULL value if no update was found.
        /// </returns>
        public Series CheckForUpdate(uint? seriesId, string seriesLanguage, string lastUpdated)
        {
            var seriesXml = this.GetSeriesDetails(seriesId.ToString(), seriesLanguage, true);
            var newSeries = new Series();

            newSeries.PopulateFullDetails(seriesXml);

            return lastUpdated != newSeries.Lastupdated ? newSeries : null;
        }
Esempio n. 4
0
        /// <summary>
        /// Load Series
        /// </summary>
        /// <param name="series">The series.</param>
        /// <returns>
        /// Process succeeded.
        /// </returns>
        public static bool LoadSeries(Series series)
        {
            try
            {
                if (Get.InOutCollection.IoType == NFOType.YAMJ)
                {
                    yamj.LoadSeries(series);
                }
                else if (Get.InOutCollection.IoType == NFOType.XBMC)
                {
                    xbmc.LoadSeries(series);
                }

                return true;
            }
            catch (Exception exception)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "LoadSeries", exception.Message);
                return false;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the series NFO.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <returns>
        /// Series NFO path
        /// </returns>
        public string GetSeriesNFO(Series series)
        {
            string firstEpisode = series.GetFirstEpisode();

            string path = Path.GetDirectoryName(firstEpisode);
            string fileName = Path.GetFileNameWithoutExtension(firstEpisode);

            string checkPath = path + Path.DirectorySeparatorChar + fileName + ".nfo";

            if (File.Exists(checkPath))
            {
                return checkPath;
            }

            return string.Empty;
        }
Esempio n. 6
0
        /// <summary>
        /// Generates the series output.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <returns>
        /// Generates a XML output
        /// </returns>
        public string GenerateSeriesOutput(Series series)
        {
            using (var stringWriter = new StringWriterWithEncoding(Encoding.UTF8))
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, this.GetSettings()))
                {
                    this.XmlWriterStart(xmlWriter);

                    xmlWriter.WriteStartElement("tvshow");

                    // Id
                    XWrite.WriteEnclosedElement(xmlWriter, "id", series.SeriesID);

                    // Title
                    XWrite.WriteEnclosedElement(xmlWriter, "title", series.SeriesName);

                    // Rating
                    XWrite.WriteEnclosedElement(xmlWriter, "rating", series.Rating);

                    // Plot
                    XWrite.WriteEnclosedElement(xmlWriter, "plot", series.Overview);

                    // Certification
                    XWrite.WriteEnclosedElement(xmlWriter, "certification", series.ContentRating);

                    // Genre
                    foreach (string genre in series.Genre)
                    {
                        XWrite.WriteEnclosedElement(xmlWriter, "genre", genre);
                    }

                    // Premiered
                    if (series.FirstAired != null)
                    {
                        XWrite.WriteEnclosedElement(
                            xmlWriter, "premiered", series.FirstAired.Value.ToString("yyyy-MM-dd"));
                    }

                    // Company
                    XWrite.WriteEnclosedElement(xmlWriter, "company", series.Network);

                    // Country
                    XWrite.WriteEnclosedElement(xmlWriter, "country", series.Country);

                    // Actor
                    foreach (PersonModel actor in series.Actors)
                    {
                        string role = actor.Role;
                        if (Get.InOutCollection.CleanActorRoles)
                        {
                            role = Regex.Replace(actor.Role, @"\(as.*?\)", string.Empty).Trim();
                        }

                        xmlWriter.WriteStartElement("actor");
                        XWrite.WriteEnclosedElement(xmlWriter, "name", actor.Name);
                        XWrite.WriteEnclosedElement(xmlWriter, "role", role);
                        XWrite.WriteEnclosedElement(xmlWriter, "thumb", actor.ImageUrl);
                        xmlWriter.WriteEndElement();
                    }

                    xmlWriter.WriteEndElement();
                }

                return stringWriter.ToString();
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Gets the series fanart.
 /// </summary>
 /// <param name="series">The series.</param>
 /// <returns>
 /// Series Fanart path
 /// </returns>
 public string GetSeriesFanart(Series series)
 {
     return this.GetSeriesImage(series, "Set_{0}_1.fanart.jpg");
 }
Esempio n. 8
0
        /// <summary>
        /// The update season.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        /// <param name="newSeason">
        /// The new season.
        /// </param>
        public static void UpdateSeason(Series series, Season newSeason, int? episodeNumber = null, bool force = false)
        {
            InternalApps.Logs.Log.WriteToLog(
                        LogSeverity.Debug,
                        0,
                        "Factories > TvDBFactory > UpdateSeason",
                        string.Format(
                            "Called with episodeNumber {0} ({1}). Forced: {2}",
                            episodeNumber.GetValueOrDefault(0), series.SeriesName, force ? "true" : "false"
                        )
            );

            if (!series.Seasons.ContainsKey(newSeason.SeasonNumber))
            {
                series.Seasons.Add(newSeason.SeasonNumber, newSeason);
                return;
            }

            Season season = series.Seasons[newSeason.SeasonNumber];

            if (!season.IsLocked)
            {
                if (string.IsNullOrEmpty(season.BannerPath) && string.IsNullOrEmpty(season.BannerUrl))
                {
                    season.BannerUrl = newSeason.BannerUrl;
                }

                if (string.IsNullOrEmpty(season.FanartPath) && string.IsNullOrEmpty(season.FanartUrl))
                {
                    season.FanartPath = newSeason.FanartUrl;
                }

                if (string.IsNullOrEmpty(season.PosterPath) && string.IsNullOrEmpty(season.PosterUrl))
                {
                    season.PosterPath = newSeason.PosterUrl;
                }
            }
            
            foreach (Episode episode in newSeason.Episodes)
            {
                if (episodeNumber == null)
                {
                    UpdateEpisode(season, episode, force);
                }
                else if (episode.EpisodeNumber == episodeNumber)
                {
                    UpdateEpisode(season, episode, true);
                }
            }
        }
Esempio n. 9
0
        public static void RestoreHiddenSeries(Series series)
        {
            TvDBFactory.masterSeriesNameList.Add(
                new MasterSeriesListModel
                    {
                        BannerPath = series.SeriesBannerPath,
                        Locked = false,
                        SeriesGuid = series.Guid,
                        SeriesName = series.SeriesName
                    });

            TvDBFactory.tvDatabase.Add(series.SeriesName, series);

            TvDBFactory.HiddenTvDatabase.Remove(series);

            TvDBFactory.InvokeTvDbChanged(new EventArgs());

            DatabaseIOFactory.DatabaseDirty = true;
        }
Esempio n. 10
0
        /// <summary>
        /// Gets the series NFO.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <returns>
        /// Series NFO path
        /// </returns>
        public string GetSeriesNFO(Series series)
        {
            string seriesPath = series.GetSeriesPath();

            if (string.IsNullOrEmpty(seriesPath))
            {
                return string.Empty;
            }

            string checkPath = seriesPath + Path.DirectorySeparatorChar + "tvshow.nfo";

            if (File.Exists(checkPath))
            {
                return checkPath;
            }

            return string.Empty;
        }
Esempio n. 11
0
        /// <summary>
        /// Gets the series poster.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <returns>
        /// Series poster path
        /// </returns>
        public string GetSeriesPoster(Series series)
        {
            string seriesPath = series.GetSeriesPath();

            if (string.IsNullOrEmpty(seriesPath))
            {
                return string.Empty;
            }

            string checkPath = seriesPath + Path.DirectorySeparatorChar + "season-all.tbn";

            if (File.Exists(checkPath))
            {
                return checkPath;
            }

            return string.Empty;
        }
Esempio n. 12
0
        /// <summary>
        /// Gets the series banner.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <returns>
        /// Series Banner path
        /// </returns>
        public string GetSeriesBanner(Series series)
        {
            string seriesPath = series.GetSeriesPath();

            if (string.IsNullOrEmpty(seriesPath))
            {
                return string.Empty;
            }

            string checkPath = seriesPath + Path.DirectorySeparatorChar + "folder.jpg";

            if (File.Exists(checkPath))
            {
                return checkPath;
            }

            return string.Empty;
        }
Esempio n. 13
0
        /// <summary>
        /// Generates the series output.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <returns>
        /// Generates a XML output
        /// </returns>
        public string GenerateSeriesOutput(Series series)
        {
            // http://wiki.xbmc.org/index.php?title=Import_-_Export_Library#TV_Shows
            using (var stringWriter = new StringWriterWithEncoding(Encoding.UTF8))
            {
                using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, this.GetSettings()))
                {
                    this.XmlWriterStart(xmlWriter);

                    xmlWriter.WriteStartElement("tvshow");

                    // Id
                    XWrite.WriteEnclosedElement(xmlWriter, "id", series.SeriesID);

                    // Title
                    XWrite.WriteEnclosedElement(xmlWriter, "title", series.SeriesName);

                    // Rating
                    XWrite.WriteEnclosedElement(xmlWriter, "rating", series.Rating);

                    // Certification
                    XWrite.WriteEnclosedElement(xmlWriter, "mpaa", series.ContentRating);

                    // Votes
                    //XWrite.WriteEnclosedElement(xmlWriter, "votes", series.Votes);

                    // Plot
                    XWrite.WriteEnclosedElement(xmlWriter, "plot", series.Overview);

                    // Runtime
                    XWrite.WriteEnclosedElement(xmlWriter, "runtime", series.Runtime);

                    // Tagline
                    //XWrite.WriteEnclosedElement(xmlWriter, "tagline", series.Tagline);

                    // Thumb

                    // Fanart

                    // Episodeguide
                    xmlWriter.WriteStartElement("episodeguide");
                    //XWrite.WriteEnclosedElement(xmlWriter, "url", series.EpisodeGuideUrl); // Cache attribute supported: <url cache="73388.xml">http://www.thetvdb.com/api/1D62F2F90030C444/series/73388/all/en.zip</url>
                    xmlWriter.WriteEndElement();

                    // Genre
                    foreach (string genre in series.Genre)
                    {
                        XWrite.WriteEnclosedElement(xmlWriter, "genre", genre);
                    }

                    // Director
                    //XWrite.WriteEnclosedElement(xmlWriter, "director", series.Director);

                    // Premiered
                    if (series.FirstAired != null)
                    {
                        XWrite.WriteEnclosedElement(
                            xmlWriter, "premiered", series.FirstAired.Value.ToString("yyyy-MM-dd"));
                    }

                    // Status
                    XWrite.WriteEnclosedElement(xmlWriter, "aired", series.Status);

                    // Aired
                    XWrite.WriteEnclosedElement(xmlWriter, "aired", series.FirstAired);

                    // Studio
                    XWrite.WriteEnclosedElement(xmlWriter, "studio", series.Network);

                    // Trailer
                    //XWrite.WriteEnclosedElement(xmlWriter, "trailer", series.Trailer);

                    // Actor
                    foreach (PersonModel actor in series.Actors)
                    {
                        string role = actor.Role;
                        if (Get.InOutCollection.CleanActorRoles)
                        {
                            role = Regex.Replace(actor.Role, @"\(as.*?\)", string.Empty).Trim();
                        }

                        xmlWriter.WriteStartElement("actor");
                        XWrite.WriteEnclosedElement(xmlWriter, "name", actor.Name);
                        XWrite.WriteEnclosedElement(xmlWriter, "role", role);
                        XWrite.WriteEnclosedElement(xmlWriter, "thumb", actor.ImageUrl);
                        xmlWriter.WriteEndElement();
                    }

                    // Unused in XBMC?
                    // Country
                    //XWrite.WriteEnclosedElement(xmlWriter, "country", series.Country);



                    xmlWriter.WriteEndElement();
                }

                return stringWriter.ToString();
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Loads the series.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        /// <returns>
        /// Loaded succeeded
        /// </returns>
        public bool LoadSeries(Series series)
        {
            string seriesName = series.GetSeriesNameOnDisk();
            string seriesPath = series.GetSeriesPath();

            if (string.IsNullOrEmpty(seriesName) || string.IsNullOrEmpty(seriesPath))
            {
                return false;
            }

            string nfo = Find.FindNFO(seriesName, seriesPath);

            if (string.IsNullOrEmpty(nfo))
            {
                return false;
            }

            XmlDocument doc = XRead.OpenPath(nfo);

            series.SeriesID = XRead.GetUInt(doc, "id");
            series.SeriesName = XRead.GetString(doc, "title");
            series.Rating = XRead.GetDouble(doc, "rating");
            series.ContentRating = XRead.GetString(doc, "mpaa");
            //series.Votes = XRead.GetInt(doc, "votes");
            series.Overview = XRead.GetString(doc, "plot");
            series.Runtime = XRead.GetInt(doc, "runtime");
            //series.Tagline = XRead.GetString(doc, "tagline");
            // Thumb
            // Fanart
            //series.EpisodeGuide = XRead.GetString(doc, "url"); // url is located in episodeguide tags
            series.Genre = XRead.GetStrings(doc, "genre").ToBindingList();
            //series.Director = XRead.GetString(doc, "director");
            series.FirstAired = XRead.GetDateTime(doc, "premiered", "yyyy-MM-dd");
            series.Status = XRead.GetString(doc, "status");
            //series.Aired = XRead.GetString(doc, "aired");
            series.Network = XRead.GetString(doc, "studio");
            //series.Trailer = XRead.GetString(doc, "trailer");

            if (doc.GetElementsByTagName("actor").Count > 0)
            {
                series.Actors = new BindingList<PersonModel>();

                foreach (XmlNode actor in doc.GetElementsByTagName("actor"))
                {
                    string xmlActor = actor.InnerXml;

                    XmlDocument docActor = XRead.OpenXml("<x>" + xmlActor + "</x>");

                    string name = XRead.GetString(docActor, "name");
                    string role = XRead.GetString(docActor, "role");
                    string imageurl = XRead.GetString(docActor, "thumb");

                    var personModel = new PersonModel(name, role, imageurl);

                    series.Actors.Add(personModel);
                }
            }

            return true;
        }
Esempio n. 15
0
        public string GetSeriesImage(Series series, string stringFormat)
        {
            string firstEpisode = series.GetFirstEpisode();

            if (string.IsNullOrEmpty(firstEpisode))
            {
                return string.Empty;
            }

            var path = Path.GetDirectoryName(firstEpisode);
            var fileName = series.SeriesName.Trim();

            return this.GetImageWithParse(path, fileName, stringFormat);
        }
Esempio n. 16
0
 /// <summary>
 /// The add custom series.
 /// </summary>
 /// <param name="series">
 /// The series.
 /// </param>
 public static void AddCustomSeries(Series series)
 {
     tvDatabase.Add(series.SeriesName, series);
     GenerateMasterSeriesList();
     InvokeMasterSeriesNameListChanged(new EventArgs());
 }
Esempio n. 17
0
        /// <summary>
        /// Saves the series.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <param name="type">The SeriesIOType type.</param>
        public void SaveSeries(Series series, SeriesIOType type)
        {
            string path = series.GetSeriesPath();
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            string nfoTemplate;
            string posterTemplate;
            string fanartTemplate;
            string bannerTemplate;

            string firstEpisodePath = series.GetFirstEpisode();

            if (Get.InOutCollection.RenameTV)
            {
                TvRenamerFactory.RenameSeries(series);
            }

            if (MovieNaming.IsBluRay(firstEpisodePath))
            {
                nfoTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeriesNfoTemplate;
                posterTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeriesPosterTemplate;
                fanartTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeriesFanartTemplate;
                bannerTemplate = Get.InOutCollection.CurrentTvSaveSettings.BluraySeriesBannerTemplate;
            }
            else if (MovieNaming.IsDVD(firstEpisodePath))
            {
                nfoTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeriesNfoTemplate;
                posterTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeriesPosterTemplate;
                fanartTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeriesFanartTemplate;
                bannerTemplate = Get.InOutCollection.CurrentTvSaveSettings.DVDSeriesBannerTemplate;
            }
            else
            {
                nfoTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeriesNfoTemplate;
                posterTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeriesPosterTemplate;
                fanartTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeriesFanartTemplate;
                bannerTemplate = Get.InOutCollection.CurrentTvSaveSettings.SeriesBannerTemplate;
            }

            if (type == SeriesIOType.All || type == SeriesIOType.Nfo)
            {
                // Nfo
                string nfoPathTo = GeneratePath.TvSeries(series, nfoTemplate, string.Empty);

                this.WriteNFO(this.GenerateSeriesOutput(series), nfoPathTo);
                series.ChangedText = false;
            }

            // Poster
            if (type == SeriesIOType.All || type == SeriesIOType.Images || type == SeriesIOType.Poster)
            {
                if (!string.IsNullOrEmpty(series.PosterUrl) || !string.IsNullOrEmpty(series.PosterPath))
                {
                    string posterPathFrom;

                    if (!string.IsNullOrEmpty(series.PosterPath) && File.Exists(series.PosterPath))
                    {
                        posterPathFrom = series.PosterPath;
                    }
                    else
                    {
                        posterPathFrom = this.TvPathImageGet(series.PosterUrl);
                    }

                    string posterPathTo = GeneratePath.TvSeries(series, posterTemplate, posterPathFrom);

                    this.CopyFile(posterPathFrom, posterPathTo);
                    series.ChangedPoster = false;
                }
            }

            // Fanart
            if (type == SeriesIOType.All || type == SeriesIOType.Images || type == SeriesIOType.Fanart)
            {
                if (!string.IsNullOrEmpty(series.FanartUrl) || !string.IsNullOrEmpty(series.FanartPath))
                {
                    string fanartPathFrom;

                    if (!string.IsNullOrEmpty(series.FanartPath) && File.Exists(series.FanartPath))
                    {
                        fanartPathFrom = series.FanartPath;
                    }
                    else
                    {
                        fanartPathFrom = this.TvPathImageGet(series.FanartUrl);
                    }

                    string fanartPathTo = GeneratePath.TvSeries(series, fanartTemplate, fanartPathFrom);

                    this.CopyFile(fanartPathFrom, fanartPathTo);
                    series.ChangedFanart = false;
                }
            }

            // Banner
            if (type == SeriesIOType.All || type == SeriesIOType.Images || type == SeriesIOType.Banner)
            {
                if (!string.IsNullOrEmpty(series.SeriesBannerUrl) || !string.IsNullOrEmpty(series.SeriesBannerPath))
                {
                    string bannerPathFrom;

                    if (!string.IsNullOrEmpty(series.SeriesBannerPath) && File.Exists(series.SeriesBannerPath))
                    {
                        bannerPathFrom = series.SeriesBannerPath;
                    }
                    else
                    {
                        bannerPathFrom = this.TvPathImageGet(series.SeriesBannerUrl);
                    }

                    string bannerPathTo = GeneratePath.TvSeries(series, bannerTemplate, bannerPathFrom);

                    this.CopyFile(bannerPathFrom, bannerPathTo);
                    series.ChangedBanner = false;
                }
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Gets the series poster.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <returns>
        /// Series poster path
        /// </returns>
        public string GetSeriesPoster(Series series)
        {
            string firstEpisode = series.GetFirstEpisode();

            if (string.IsNullOrEmpty(firstEpisode))
            {
                return string.Empty;
            }

            string path = Path.GetDirectoryName(firstEpisode);
            string seriesName = string.Format("Set_{0}_1", series.SeriesName.Trim());

            string checkPath = path + Path.DirectorySeparatorChar + seriesName + ".jpg";

            if (File.Exists(checkPath))
            {
                return checkPath;
            }

            return string.Empty;
        }
Esempio n. 19
0
 /// <summary>
 /// Gets the series banner.
 /// </summary>
 /// <param name="series">The series.</param>
 /// <returns>
 /// Series Banner path
 /// </returns>
 public string GetSeriesBanner(Series series)
 {
     return this.GetSeriesImage(series, "Set_{0}_1.banner.jpg");
 }
Esempio n. 20
0
        /// <summary>
        /// Loads the series.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        /// <returns>
        /// Loaded succeeded
        /// </returns>
        public bool LoadSeries(Series series)
        {
            string seriesName = series.GetSeriesNameOnDisk();
            string seriesPath = series.GetSeriesPath();

            if (string.IsNullOrEmpty(seriesName) || string.IsNullOrEmpty(seriesPath))
            {
                return false;
            }

            string nfo = Find.FindNFO(seriesName, seriesPath);

            if (string.IsNullOrEmpty(nfo))
            {
                return false;
            }

            XmlDocument doc = XRead.OpenPath(nfo);

            series.SeriesName = XRead.GetString(doc, "title");
            series.SeriesID = XRead.GetUInt(doc, "id");
            series.Rating = XRead.GetDouble(doc, "rating");
            series.Overview = XRead.GetString(doc, "plot");
            series.ContentRating = XRead.GetString(doc, "certification");
            series.Genre = XRead.GetStrings(doc, "genre").ToBindingList();
            series.FirstAired = XRead.GetDateTime(doc, "premiered", "yyyy-MM-dd");
            series.Network = XRead.GetString(doc, "country");

            if (doc.GetElementsByTagName("actor").Count > 0)
            {
                series.Actors = new BindingList<PersonModel>();

                foreach (XmlNode actor in doc.GetElementsByTagName("actor"))
                {
                    string xmlActor = actor.InnerXml;

                    XmlDocument docActor = XRead.OpenXml("<x>" + xmlActor + "</x>");

                    string name = XRead.GetString(docActor, "name");
                    string role = XRead.GetString(docActor, "role");
                    string imageurl = XRead.GetString(docActor, "thumb");

                    var personModel = new PersonModel(name, role, imageurl);

                    series.Actors.Add(personModel);
                }
            }

            return true;
        }
Esempio n. 21
0
 /// <summary>
 /// Gets the series poster.
 /// </summary>
 /// <param name="series">The series.</param>
 /// <returns>
 /// Series poster path
 /// </returns>
 public string GetSeriesPoster(Series series)
 {
     return this.GetSeriesImage(series, "Set_{0}_1.jpg");
 }
Esempio n. 22
0
        /// <summary>
        /// The update season.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        /// <param name="newSeason">
        /// The new season.
        /// </param>
        public static void UpdateSeason(Series series, Season newSeason)
        {
            if (!series.Seasons.ContainsKey(newSeason.SeasonNumber))
            {
                series.Seasons.Add(newSeason.SeasonNumber, newSeason);
                return;
            }

            Season season = series.Seasons[newSeason.SeasonNumber];

            if (!season.IsLocked)
            {
                if (string.IsNullOrEmpty(season.BannerPath) && string.IsNullOrEmpty(season.BannerUrl))
                {
                    season.BannerUrl = newSeason.BannerUrl;
                }

                if (string.IsNullOrEmpty(season.FanartPath) && string.IsNullOrEmpty(season.FanartUrl))
                {
                    season.BannerUrl = newSeason.FanartUrl;
                }

                if (string.IsNullOrEmpty(season.PosterPath) && string.IsNullOrEmpty(season.PosterUrl))
                {
                    season.BannerUrl = newSeason.PosterUrl;
                }
            }

            foreach (Episode episode in season.Episodes)
            {
                UpdateEpisode(season, episode);
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Loads the series.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        /// <returns>
        /// Loaded succeeded
        /// </returns>
        public bool LoadSeries(Series series)
        {
            string seriesName = series.SeriesName;
            string seriesPath = series.GetSeriesPath();

            if (!string.IsNullOrEmpty(seriesName) || !string.IsNullOrEmpty(seriesPath))
            {

                var seriesNameHex = "Set_"
                                    +
                                    FileSystemCharChange.To(
                                        seriesName,
                                        FileSystemCharChange.ConvertArea.Tv,
                                        FileSystemCharChange.ConvertType.Hex) + "_1";

                var seriesNameChar = "Set_"
                                     +
                                     FileSystemCharChange.To(
                                         seriesName,
                                         FileSystemCharChange.ConvertArea.Tv,
                                         FileSystemCharChange.ConvertType.Char) + "_1";

                string nfo = Find.FindNFO("Set_" + seriesName + "_1", seriesPath);

                if (string.IsNullOrEmpty(nfo))
                {
                    nfo = Find.FindNFO(seriesNameHex, seriesPath);

                    if (string.IsNullOrEmpty(nfo))
                    {
                        nfo = Find.FindNFO(seriesNameChar, seriesPath);

                        if (!string.IsNullOrEmpty(nfo))
                        {
                            XmlDocument doc = XRead.OpenPath(nfo);

                            series.SeriesName = XRead.GetString(doc, "title");
                            series.SeriesID = XRead.GetUInt(doc, "id");
                            series.Rating = XRead.GetDouble(doc, "rating");
                            series.Overview = XRead.GetString(doc, "plot");
                            series.ContentRating = XRead.GetString(doc, "certification");
                            series.Genre = XRead.GetStrings(doc, "genre").ToBindingList();
                            series.FirstAired = XRead.GetDateTime(doc, "premiered", "yyyy-MM-dd");
                            series.Network = XRead.GetString(doc, "country");

                            if (doc.GetElementsByTagName("actor").Count > 0)
                            {
                                series.Actors = new BindingList<PersonModel>();

                                foreach (XmlNode actor in doc.GetElementsByTagName("actor"))
                                {
                                    string xmlActor = actor.InnerXml;

                                    XmlDocument docActor = XRead.OpenXml("<x>" + xmlActor + "</x>");

                                    string name = XRead.GetString(docActor, "name");
                                    string role = XRead.GetString(docActor, "role");
                                    string imageurl = XRead.GetString(docActor, "thumb");

                                    var personModel = new PersonModel(name, imageurl, role);

                                    series.Actors.Add(personModel);
                                }
                            }
                        }
                    }
                }
            }

            foreach (var season in series.Seasons)
            {
                foreach (var episode in season.Value.Episodes)
                {
                    if (File.Exists(episode.FilePath.PathAndFilename))
                    {
                        var nfoPath = Path.Combine(
                            episode.FilePath.FolderPath, episode.FilePath.FilenameWithOutExt + ".nfo");

                        if (File.Exists(nfoPath))
                        {
                            var doc = XRead.OpenPath(nfoPath);

                            episode.SeasonNumber = XRead.GetInt(doc, "season");
                            episode.EpisodeNumber = XRead.GetInt(doc, "episode");
                            episode.EpisodeName = XRead.GetString(doc, "title");
                            episode.Overview = XRead.GetString(doc, "plot");
                            episode.FirstAired = XRead.GetDateTime(doc, "aired");
                        }
                    }
                }
            }

            return true;
        }
Esempio n. 24
0
        /// <summary>
        /// The process series to background.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        private static void ProcessSeriesToBackground(Series series)
        {
            var current = GenerateOutput.AccessCurrentIOHandler() as IoInterface;

            if (current == null)
            {
                return;
            }

            string posterPath = current.GetSeriesPoster(series);
            string fanartPath = current.GetSeriesFanart(series);
            string bannerPath = current.GetSeriesBanner(series);

            if (!string.IsNullOrEmpty(posterPath))
            {
                series.PosterPath = posterPath;
            }

            if (!string.IsNullOrEmpty(fanartPath))
            {
                series.FanartPath = fanartPath;
            }

            if (!string.IsNullOrEmpty(bannerPath))
            {
                series.SeriesBannerPath = bannerPath;
            }
        }
Esempio n. 25
0
        private void Set(Series series, List<string> toRemove, Dictionary<string, ScanSeries> toAdd, string key, ScanSeries value)
        {
            try
            {
                if (!TvDBFactory.TvDatabase.ContainsKey(series.SeriesName))
                {
                    TvDBFactory.TvDatabase.Add(series.SeriesName, series); // add series to db
                }

                var m = (from show in ImportTvFactory.SeriesNameList where show.SeriesName == key select show).Single();

                m.WaitingForScan = false;
                m.ScanComplete = true;

                var changedValue = value;
                toRemove.Add(key);

                if (!string.IsNullOrEmpty(series.SeriesName) && !toAdd.ContainsKey(series.SeriesName))
                {
                    toAdd.Add(series.SeriesName, changedValue);
                }
                else if (toAdd.ContainsKey(series.SeriesName))
                {
                    foreach (var season in changedValue.Seasons)
                    {
                        if (!toAdd[series.SeriesName].Seasons.ContainsKey(season.Key))
                        {
                            toAdd[series.SeriesName].Seasons.Add(season.Key, season.Value);
                        }
                        else
                        {
                            foreach (var episode in season.Value.Episodes)
                            {
                                toAdd[series.SeriesName].Seasons[season.Key].Episodes.Add(episode.Key, episode.Value);
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "FrmImportTv > Set", exception.Message);
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Get total episodes.
        /// </summary>
        /// <param name="series">
        /// The series.
        /// </param>
        /// <param name="missingOnly">
        /// The missing only.
        /// </param>
        /// <returns>
        /// Total episodes.
        /// </returns>
        public static int GetTotalEpisodes(Series series, bool missingOnly = false)
        {
            int count = 0;

            foreach (var season in series.Seasons)
            {
                if (missingOnly == false)
                {
                    count += season.Value.Episodes.Count;
                }
                else
                {
                    count +=
                        season.Value.Episodes.Count(episode => string.IsNullOrEmpty(episode.FilePath.FileNameAndPath));
                }
            }

            return count;
        }
Esempio n. 27
0
        /// <summary>
        /// Saves the specific series.
        /// </summary>
        /// <param name="series">The series.</param>
        /// <param name="type">The SeriesIOType type.</param>
        /// <returns>Process succeeded</returns>
        public static bool SaveSpecificSeries(Series series, SeriesIOType type = SeriesIOType.All)
        {
            try
            {
                if (Get.InOutCollection.IoType == NFOType.YAMJ)
                {
                    yamj.SaveSeries(series, type);
                }
                else if (Get.InOutCollection.IoType == NFOType.XBMC)
                {
                    xbmc.SaveSeries(series, type);
                }
            }
            catch (Exception exception)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "SaveSpecificSeries", exception.Message);
                return false;
            }

            return true;
        }
Esempio n. 28
0
        /// <summary>
        /// Initializes static members of the <see cref="TvDBFactory"/> class. 
        /// </summary>
        static TvDBFactory()
        {
            tvDatabase = new SortedList<string, Series>();

            CurrentSeries = new Series();
            CurrentSeason = new Season();
            CurrentEpisode = new Episode();

            galleryGroup = new GalleryItemGroup();

            masterSeriesNameList = new BindingList<MasterSeriesListModel>();

            currentSelectedSeries = new List<Series>();
            currentSelectedSeason = new List<Season>();
            currentSelectedEpisode = new List<Episode>();
        }
Esempio n. 29
0
        /// <summary>
        /// Populate series search details into object.
        /// </summary>
        /// <param name="seriesSearchDetails">The series Search Details.</param>
        /// <returns>
        /// The series object.
        /// </returns>
        public Series OpenNewSeries(SearchDetails seriesSearchDetails)
        {
            SeriesXml rawData = this.GetSeriesDetails(seriesSearchDetails.SeriesID, seriesSearchDetails.Language);

            var details = new Series();
            details.PopulateFullDetails(rawData);

            if (!string.IsNullOrEmpty(details.SeriesBannerUrl))
            {
                string url = "http://cache.thetvdb.com/banners/_cache/" + details.SeriesBannerUrl;

                string imagePath = Downloader.ProcessDownload(url, DownloadType.Binary, Section.Tv);

                details.SmallBanner = ImageHandler.LoadImage(imagePath);
            }

            return details;
        }
Esempio n. 30
0
        public static string TvSeries(Series series, string replace, string fromFile, string altFirstEpisode = null)
        {
            if (series == null)
            {
                series = new Series();
                series.SeriesName = "Test series";
                series.Seasons.Add(1, new Season());
                series.Seasons[1].Episodes.Add(new Episode{FilePath = new MediaModel{PathAndFilename = @"c:\testshow\season 1\test show.s01e01.avi"}});
            }

            string firstEpisodeFullPath;
            string seriesName;

            if (altFirstEpisode != null)
            {
                if (altFirstEpisode == string.Empty)
                {
                    return string.Empty;
                }

                if (MovieNaming.IsDVD(altFirstEpisode))
                {
                    firstEpisodeFullPath = MovieNaming.GetDvdPath(altFirstEpisode) + MovieNaming.GetDvdName(altFirstEpisode);
                }
                else if (MovieNaming.IsBluRay(altFirstEpisode))
                {
                    firstEpisodeFullPath = MovieNaming.GetBluRayPath(altFirstEpisode) + MovieNaming.GetBluRayName(altFirstEpisode);
                }
                else
                {
                    firstEpisodeFullPath = altFirstEpisode;

                }

                seriesName = Regex.Match(
                    Path.GetFileNameWithoutExtension(firstEpisodeFullPath),
                    "(?<seriesName>.*?)" + Settings.ConstSettings.DefaultRegex.Tv,
                    RegexOptions.IgnoreCase).Groups["seriesName"].Value.Trim();
            }
            else
            {
                firstEpisodeFullPath = series.GetFirstEpisode();

                seriesName = Tools.Restructure.FileSystemCharChange.To(series.SeriesName, FileSystemCharChange.ConvertArea.Tv);
            }

            string firstEpisodePath;

            if (MovieNaming.IsDVD(firstEpisodeFullPath))
            {
                firstEpisodePath = MovieNaming.GetDvdPath(firstEpisodeFullPath);
            }
            else if (MovieNaming.IsBluRay(firstEpisodeFullPath))
            {
                firstEpisodePath = MovieNaming.GetBluRayPath(firstEpisodeFullPath);
            }
            else
            {
                firstEpisodePath = Path.GetDirectoryName(firstEpisodeFullPath);
            }

            replace = replace.Replace(Settings.Get.InOutCollection.TvSeriesName, seriesName);
            replace = replace.Replace(Settings.Get.InOutCollection.TvFirstEpisodePathOfSeries, firstEpisodePath);
            replace = replace.Replace(Settings.Get.InOutCollection.TvSeriesPath, series.GetSeriesPath());

            return replace + Path.GetExtension(fromFile);
        }