Beispiel #1
0
        private static string CreateHtml([NotNull] ShowItem si)
        {
            SeriesInfo series = si.TheSeries();

            if (series is null)
            {
                return(string.Empty);
            }

            string posterUrl      = TheTVDB.GetImageURL(series.GetImage(TVSettings.FolderJpgIsType.Poster));
            string yearRange      = ShowHtmlHelper.YearRange(series);
            string episodeSummary = series.AiredSeasons.Sum(pair => pair.Value.Episodes.Count).ToString();
            string stars          = ShowHtmlHelper.StarRating(series.SiteRating / 2);
            string genreIcons     = string.Join(" ", series.Genres().Select(ShowHtmlHelper.GenreIconHtml));
            string siteRating     = series.SiteRating > 0 ? series.SiteRating + "/10" : "";

            return($@"<div class=""card card-body"">
            <div class=""row"">
            <div class=""col-md-4"">
                <img class=""show-poster rounded w-100"" src=""{posterUrl}"" alt=""{si.ShowName} Show Poster""></div>
            <div class=""col-md-8 d-flex flex-column"">
                <div class=""row"">
                    <div class=""col-md-8""><h1>{si.ShowName}</h1></div>
                    <div class=""col-md-4 text-right""><h6>{yearRange} ({series.Status})</h6><small class=""text-muted"">{episodeSummary} Episodes</small></div>
                </div>
            <div><blockquote>{series.Overview}</blockquote></div>
            <div><blockquote>{string.Join(", ", series.GetActorNames())}</blockquote></div>
            <div class=""row align-items-bottom flex-grow-1"">
                <div class=""col-md-4 align-self-end"">{stars}<br>{siteRating}</div>
                <div class=""col-md-4 align-self-end text-center"">{series.ContentRating}<br>{series.Network}</div>
                <div class=""col-md-4 align-self-end text-right"">{genreIcons}<br>{string.Join(", ", series.Genres())}</div>
            </div>
            </div></div></div>");
        }
Beispiel #2
0
        private static string CreateHtml(ShowItem si)
        {
            string posterUrl      = TheTVDB.GetImageURL(si.TheSeries().GetImage(TVSettings.FolderJpgIsType.Poster));
            int    minYear        = si.TheSeries().MinYear();
            int    maxYear        = si.TheSeries().MaxYear();
            string yearRange      = (minYear == maxYear) ? minYear.ToString() : minYear + "-" + maxYear;
            string episodeSummary = si.TheSeries().AiredSeasons.Sum(pair => pair.Value.Episodes.Count).ToString();
            string stars          = ShowHtmlHelper.StarRating(si.TheSeries().GetSiteRating());
            string genreIcons     = string.Join("&nbsp;", si.TheSeries().GetGenres().Select(ShowHtmlHelper.GenreIconHtml));
            bool   ratingIsNumber = float.TryParse(si.TheSeries().GetSiteRating(), NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.CreateSpecificCulture("en-US"), out float rating);
            string siteRating     = ratingIsNumber && rating > 0 ? rating + "/10" : "";

            return($@"<div class=""card card-body"">
            <div class=""row"">
            <div class=""col-md-4"">
                <img class=""show-poster rounded w-100"" src=""{posterUrl}"" alt=""{si.ShowName} Show Poster""></div>
            <div class=""col-md-8 d-flex flex-column"">
                <div class=""row"">
                    <div class=""col-md-8""><h1>{si.ShowName}</h1></div>
                    <div class=""col-md-4 text-right""><h6>{yearRange} ({si.TheSeries().GetStatus()})</h6><small class=""text-muted"">{episodeSummary} Episodes</small></div>
                </div>
            <div><blockquote>{si.TheSeries().GetOverview()}</blockquote></div>
            <div><blockquote>{string.Join(", ", si.TheSeries().GetActorNames())}</blockquote></div>
            <div class=""row align-items-bottom flex-grow-1"">
                <div class=""col-md-4 align-self-end"">{stars}<br>{siteRating}</div>
                <div class=""col-md-4 align-self-end text-center"">{si.TheSeries().GetContentRating()}<br>{si.TheSeries().GetNetwork()}</div>
                <div class=""col-md-4 align-self-end text-right"">{genreIcons}<br>{string.Join(", ", si.TheSeries().GetGenres())}</div>
            </div>
            </div></div></div>");
        }
Beispiel #3
0
        private static void ConvertSeriesTimeZones([NotNull] TVDoc doc, TheTVDB tvdb)
        {
            //this is just to convert timezones in the TheTVDB into the TVDOC where they should be:
            //it should only do anything the first time it is run and then be entirely benign
            //can be removed after 1/1/19

            foreach (ShowItem si in doc.Library.GetShowItems())
            {
                string newTimeZone = tvdb.GetSeries(si.TvdbCode)?.TempTimeZone;

                if (string.IsNullOrWhiteSpace(newTimeZone))
                {
                    continue;
                }

                if (newTimeZone == TimeZoneHelper.DefaultTimeZone())
                {
                    continue;
                }

                if (si.ShowTimeZone != TimeZoneHelper.DefaultTimeZone())
                {
                    continue;
                }

                si.ShowTimeZone = newTimeZone;
                doc.SetDirty();
                Logger.Info("Copied timezone:{0} onto series {1}", newTimeZone, si.ShowName);
            }
        }
Beispiel #4
0
 public void SetDefaults(TheTVDB db)
 {
     this.TVDB = db;
     this.ManualFolderLocations = new Dictionary <int, List <string> >();
     this.IgnoreSeasons         = new List <int>();
     this.UseCustomShowName     = false;
     this.CustomShowName        = "";
     this.UseSequentialMatch    = false;
     this.SeasonRules           = new Dictionary <int, List <ShowRule> >();
     this.SeasonEpisodes        = new Dictionary <int, List <ProcessedEpisode> >();
     this.ShowNextAirdate       = true;
     this.TVDBCode = -1;
     //                WhichSeasons = gcnew List<int>;
     //                NamingStyle = (int)NStyle.DefaultStyle();
     this.AutoAddNewSeasons        = true;
     this.PadSeasonToTwoDigits     = false;
     this.AutoAdd_FolderBase       = "";
     this.AutoAdd_FolderPerSeason  = true;
     this.AutoAdd_SeasonFolderName = "Season ";
     this.DoRename       = true;
     this.DoMissingCheck = true;
     this.CountSpecials  = false;
     this.DVDOrder       = false;
     CustomSearchURL     = "";
     ForceCheckNoAirdate = false;
     ForceCheckFuture    = false;
 }
Beispiel #5
0
                                         }; // TODO: move into settings, and allow user to edit these

        #endregion Fields

        #region Constructors

        public TVDoc(FileInfo settingsFile, TheTVDB tvdb, CommandLineArgs args)
        {
            this.mTVDB = tvdb;
            this.Args = args;

            this.Ignore = new List<IgnoreItem>();

            this.Workers = null;
            this.WorkerSemaphore = null;

            this.mStats = new TVRenameStats();
            this.mDirty = false;
            this.TheActionList = new ItemList();

            this.Settings = new TVSettings();

            this.MonitorFolders = new List<String>();
            this.IgnoreFolders = new List<String>();
            this.SearchFolders = new List<String>();

            ShowItems = new List<ShowItem>();
            this.AddItems = new FolderMonitorEntryList();

            this.DownloadDone = true;
            this.DownloadOK = true;

            this.ActionCancel = false;
            this.ScanProgDlg = null;

            this.LoadOK = ((settingsFile == null) || this.LoadXMLSettings(settingsFile)) && this.mTVDB.LoadOK;

            UpdateTVDBLanguage();

            //    StartServer();
        }
Beispiel #6
0
        public FolderMonitorEdit(TheTVDB db, FolderMonitorEntry hint)
        {
            this.InitializeComponent();

            this.mTCCF                        = new TheTVDBCodeFinder("", db);
            this.mTCCF.Dock                   = DockStyle.Fill;
            this.mTCCF.SelectionChanged      += this.CodeChanged;
            this.mTCCF.lvMatches.DoubleClick += this.MatchDoubleClick;


            this.pnlCF.SuspendLayout();
            this.pnlCF.Controls.Add(this.mTCCF);
            this.pnlCF.ResumeLayout();

            if (hint.CodeKnown)
            {
                this.mTCCF.SetHint(hint.TVDBCode.ToString());
            }
            else
            {
                string s = hint.Folder;
                int    p = s.LastIndexOf(System.IO.Path.DirectorySeparatorChar);
                this.mTCCF.SetHint(s.Substring(p + 1));
            }
            this.Code = -1;
        }
Beispiel #7
0
        private void FillLanguageList()
        {
            TheTVDB db = this.mDoc.GetTVDB(true, "Preferences-FLL");

            this.cbLanguages.BeginUpdate();
            this.cbLanguages.Items.Clear();

            String pref = "";

            foreach (var kvp in db.LanguageList)
            {
                String name = kvp.Value;
                this.cbLanguages.Items.Add(name);

                if (EnterPreferredLanguage == kvp.Key)
                {
                    pref = kvp.Value;
                }
            }
            this.cbLanguages.EndUpdate();
            this.cbLanguages.Text    = pref;
            this.cbLanguages.Enabled = true;

            db.Unlock("Preferences-FLL");
        }
Beispiel #8
0
 private static string CreatePosterHtml(SeriesInfo ser)
 {
     if ((!string.IsNullOrEmpty(ser.GetSeriesPosterPath())) &&
         (!string.IsNullOrEmpty(TheTVDB.GetImageURL(ser.GetSeriesPosterPath()))))
     {
         return($"<img class=\"show-poster rounded w-100\" src=\"{TheTVDB.GetImageURL(ser.GetSeriesPosterPath())}\" alt=\"{ser.Name} Show Poster\">");
     }
     return(string.Empty);
 }
Beispiel #9
0
        private static string CreateHorizontalBannerHtml([NotNull] SeriesInfo ser)
        {
            if ((!string.IsNullOrEmpty(ser.GetSeriesWideBannerPath())) &&
                (!string.IsNullOrEmpty(TheTVDB.GetImageURL(ser.GetSeriesWideBannerPath()))))
            {
                return($"<img class=\"rounded\" src=\"{TheTVDB.GetImageURL(ser.GetSeriesWideBannerPath())}\"><br/>&nbsp;");
            }

            return(string.Empty);
        }
Beispiel #10
0
        private static string CreateHorizontalBannerHtml([NotNull] this Season s)
        {
            if ((!string.IsNullOrEmpty(s.GetWideBannerPath())) &&
                (!string.IsNullOrEmpty(TheTVDB.GetImageURL(s.GetWideBannerPath()))))
            {
                return($"<img class=\"rounded w-100\" src=\"{TheTVDB.GetImageURL(s.GetWideBannerPath())}\"><br/>");
            }

            return(string.Empty);
        }
Beispiel #11
0
        private static string ImageSection(string title, int width, int height, [CanBeNull] string bannerPath)
        {
            if (string.IsNullOrEmpty(bannerPath))
            {
                return("");
            }

            string url = TheTVDB.GetImageURL(bannerPath);

            return(string.IsNullOrEmpty(url) ? "" : $"<h2>{title}</h2><img width={width} height={height} src=\"{url}\"><br/>");
        }
Beispiel #12
0
        private void BuildData()
        {
            // find actors that have been in more than one thing
            // Dictionary<String^, List<String> ^> ^whoInWhat = gcnew Dictionary<String^, List<String> ^>;
            TheTVDB db = this.mDoc.GetTVDB(true, "Actors");

            this.TheData = new DataArr(db.GetSeriesDict().Count);
            foreach (System.Collections.Generic.KeyValuePair <int, SeriesInfo> ser in db.GetSeriesDict())
            {
                SeriesInfo si     = ser.Value;
                string     actors = si.GetItem("Actors");
                if (!string.IsNullOrEmpty(actors))
                {
                    foreach (string act in actors.Split('|'))
                    {
                        string aa = act.Trim();
                        if (!string.IsNullOrEmpty(aa))
                        {
                            this.TheData.Set(si.Name, aa, true);
                        }
                    }
                }

                if (this.cbGuestStars.Checked)
                {
                    foreach (System.Collections.Generic.KeyValuePair <int, Season> kvp in si.Seasons)
                    {
                        foreach (Episode ep in kvp.Value.Episodes)
                        {
                            string guest = ep.GetItem("GuestStars");

                            if (!string.IsNullOrEmpty(guest))
                            {
                                foreach (string g in guest.Split('|'))
                                {
                                    string aa = g.Trim();
                                    if (!string.IsNullOrEmpty(aa))
                                    {
                                        this.TheData.Set(si.Name, aa, false);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            db.Unlock("Actors");
            this.TheData.RemoveEmpties();
        }
Beispiel #13
0
        public TheTVDBCodeFinder(string initialHint, TheTVDB db)
        {
            this.mInternal = false;
            this.mTVDB = db;

            this.InitializeComponent();

            this.txtFindThis.Text = initialHint;

            if (string.IsNullOrEmpty(initialHint))
            {
                ListViewItem lvi = new ListViewItem("");
                lvi.SubItems.Add("Enter the show's name, and click \"Search\"");
                this.lvMatches.Items.Add(lvi);
            }
        }
Beispiel #14
0
        public TheTVDBCodeFinder(string initialHint, TheTVDB db)
        {
            this.mInternal = false;
            this.mTVDB     = db;

            this.InitializeComponent();

            this.txtFindThis.Text = initialHint;

            if (string.IsNullOrEmpty(initialHint))
            {
                ListViewItem lvi = new ListViewItem("");
                lvi.SubItems.Add("Enter the show's name, and click \"Search\"");
                this.lvMatches.Items.Add(lvi);
            }
        }
Beispiel #15
0
        private static string ScreenShotHtml(this ProcessedEpisode ei)
        {
            if (!TVSettings.Instance.ShowEpisodePictures)
            {
                return(string.Empty);
            }
            if (TVSettings.Instance.HideMyShowsSpoilers && ei.HowLong() != "Aired")
            {
                return(string.Empty);
            }
            if (string.IsNullOrEmpty(ei.Filename))
            {
                return(string.Empty);
            }
            if (string.IsNullOrWhiteSpace(TheTVDB.GetImageURL(ei.Filename)))
            {
                return(string.Empty);
            }

            return($"<img class=\"rounded w-100\" src=\"{TheTVDB.GetImageURL(ei.Filename)}\" alt=\"{ei.Name} Screenshot\">");
        }
Beispiel #16
0
        private void LoadLanguage()
        {
            TheTVDB db      = this.mDoc.GetTVDB(true, "Preferences-LoadLanguages");
            bool    aborted = false;

            try
            {
                if (!db.Connected)
                {
                    db.Connect();
                }
            }
            catch (ThreadAbortException)
            {
                aborted = true;
            }
            db.Unlock("Preferences-LoadLanguages");
            if (!aborted)
            {
                this.BeginInvoke(LoadLanguageDone);
            }
        }
Beispiel #17
0
        public FolderMonitorEdit(TheTVDB db, FolderMonitorEntry hint)
        {
            this.InitializeComponent();

            this.mTCCF = new TheTVDBCodeFinder("", db);
            this.mTCCF.Dock = DockStyle.Fill;
            this.mTCCF.SelectionChanged += this.CodeChanged;
            this.mTCCF.lvMatches.DoubleClick += this.MatchDoubleClick;

            this.pnlCF.SuspendLayout();
            this.pnlCF.Controls.Add(this.mTCCF);
            this.pnlCF.ResumeLayout();

            if (hint.CodeKnown)
                this.mTCCF.SetHint(hint.TVDBCode.ToString());
            else
            {
                string s = hint.Folder;
                int p = s.LastIndexOf(System.IO.Path.DirectorySeparatorChar);
                this.mTCCF.SetHint(s.Substring(p+1));
            }
            this.Code = -1;
        }
Beispiel #18
0
        private ShowSummaryData AddShowDetails(ShowItem si)
        {
            TheTVDB db = TheTVDB.Instance;

            db.GetLock("ShowSummary");
            SeriesInfo ser = db.GetSeries(si.TVDBCode);

            ShowSummaryData showSummary = new ShowSummaryData
            {
                ShowName = si.ShowName,
                ShowItem = si
            };

            if (ser != null)
            {
                foreach (int snum in si.DVDOrder? ser.DVDSeasons.Keys: ser.AiredSeasons.Keys)
                {
                    ShowSummaryData.ShowSummarySeasonData seasonData = getSeasonDetails(si, ser, snum);
                    showSummary.AddSeason(seasonData);
                }
            }
            db.Unlock("ShowSummary");
            return(showSummary);
        }
Beispiel #19
0
        public ShowItem(TheTVDB db, XmlReader reader, TVSettings settings)
        {
            this.SetDefaults(db);

            reader.Read();
            if (reader.Name != "ShowItem")
                return; // bail out

            reader.Read();
            while (!reader.EOF)
            {
                if ((reader.Name == "ShowItem") && !reader.IsStartElement())
                    break; // all done

                if (reader.Name == "ShowName")
                {
                    this.CustomShowName = reader.ReadElementContentAsString();
                    this.UseCustomShowName = true;
                }
                if (reader.Name == "UseCustomShowName")
                    this.UseCustomShowName = reader.ReadElementContentAsBoolean();
                if (reader.Name == "CustomShowName")
                    this.CustomShowName = reader.ReadElementContentAsString();
                else if (reader.Name == "TVDBID")
                    this.TVDBCode = reader.ReadElementContentAsInt();
                else if (reader.Name == "CountSpecials")
                    this.CountSpecials = reader.ReadElementContentAsBoolean();
                else if (reader.Name == "ShowNextAirdate")
                    this.ShowNextAirdate = reader.ReadElementContentAsBoolean();
                else if (reader.Name == "AutoAddNewSeasons")
                    this.AutoAddNewSeasons = reader.ReadElementContentAsBoolean();
                else if (reader.Name == "FolderBase")
                    this.AutoAdd_FolderBase = reader.ReadElementContentAsString();
                else if (reader.Name == "FolderPerSeason")
                    this.AutoAdd_FolderPerSeason = reader.ReadElementContentAsBoolean();
                else if (reader.Name == "SeasonFolderName")
                    this.AutoAdd_SeasonFolderName = reader.ReadElementContentAsString();
                else if (reader.Name == "DoRename")
                    this.DoRename = reader.ReadElementContentAsBoolean();
                else if (reader.Name == "DoMissingCheck")
                    this.DoMissingCheck = reader.ReadElementContentAsBoolean();
                else if (reader.Name == "DVDOrder")
                    this.DVDOrder = reader.ReadElementContentAsBoolean();
                else if (reader.Name == "CustomSearchURL")
                    this.CustomSearchURL = reader.ReadElementContentAsString();
                else if (reader.Name == "ForceCheckAll") // removed 2.2.0b2
                    this.ForceCheckNoAirdate = this.ForceCheckFuture = reader.ReadElementContentAsBoolean();
                else if (reader.Name == "ForceCheckFuture")
                    this.ForceCheckFuture = reader.ReadElementContentAsBoolean();
                else if (reader.Name == "ForceCheckNoAirdate")
                    this.ForceCheckNoAirdate = reader.ReadElementContentAsBoolean();
                else if (reader.Name == "PadSeasonToTwoDigits")
                    this.PadSeasonToTwoDigits = reader.ReadElementContentAsBoolean();
                else if (reader.Name == "UseSequentialMatch")
                    this.UseSequentialMatch = reader.ReadElementContentAsBoolean();
                else if (reader.Name == "IgnoreSeasons")
                {
                    if (!reader.IsEmptyElement)
                    {
                        reader.Read();
                        while (reader.Name != "IgnoreSeasons")
                        {
                            if (reader.Name == "Ignore")
                                this.IgnoreSeasons.Add(reader.ReadElementContentAsInt());
                            else
                                reader.ReadOuterXml();
                        }
                    }
                    reader.Read();
                }
                else if (reader.Name == "AliasNames")
                {
                    if (!reader.IsEmptyElement)
                    {
                        reader.Read();
                        while (reader.Name != "AliasNames")
                        {
                            if (reader.Name == "Alias")
                                this.AliasNames.Add(reader.ReadElementContentAsString());
                            else
                                reader.ReadOuterXml();
                        }
                    }
                    reader.Read();
                }
                else if (reader.Name == "Rules")
                {
                    if (!reader.IsEmptyElement)
                    {
                        int snum = int.Parse(reader.GetAttribute("SeasonNumber"));
                        this.SeasonRules[snum] = new List<ShowRule>();
                        reader.Read();
                        while (reader.Name != "Rules")
                        {
                            if (reader.Name == "Rule")
                            {
                                this.SeasonRules[snum].Add(new ShowRule(reader.ReadSubtree()));
                                reader.Read();
                            }
                        }
                    }
                    reader.Read();
                }
                else if (reader.Name == "SeasonFolders")
                {
                    if (!reader.IsEmptyElement)
                    {
                        int snum = int.Parse(reader.GetAttribute("SeasonNumber"));
                        this.ManualFolderLocations[snum] = new List<String>();
                        reader.Read();
                        while (reader.Name != "SeasonFolders")
                        {
                            if ((reader.Name == "Folder") && reader.IsStartElement())
                            {
                                string ff = reader.GetAttribute("Location");
                                if (this.AutoFolderNameForSeason(snum, settings) != ff)
                                    this.ManualFolderLocations[snum].Add(ff);
                            }
                            reader.Read();
                        }
                    }
                    reader.Read();
                }

                else
                    reader.ReadOuterXml();
            } // while
        }
Beispiel #20
0
 public ShowItem(TheTVDB db, int tvDBCode)
 {
     this.SetDefaults(db);
     this.TVDBCode = tvDBCode;
 }
Beispiel #21
0
 public ShowItem(TheTVDB db)
 {
     this.SetDefaults(db);
 }
Beispiel #22
0
        public static string GetSeasonHtmlOverviewOffline([NotNull] this ShowItem si, [NotNull] Season s)
        {
            SeriesInfo ser  = s.TheSeries;
            int        snum = s.SeasonNumber;
            string     body = "";

            if (!string.IsNullOrEmpty(ser.GetSeriesWideBannerPath()) &&
                !string.IsNullOrEmpty(TheTVDB.GetImageURL(ser.GetSeriesWideBannerPath())))
            {
                body += "<img width=758 height=140 src=\"" + TheTVDB.GetImageURL(ser.GetSeriesWideBannerPath()) +
                        "\"><br/>";
            }

            List <ProcessedEpisode> eis = si.SeasonEpisodes.ContainsKey(snum) ?
                                          si.SeasonEpisodes[snum] :
                                          ShowItem.ProcessedListFromEpisodes(s.Episodes.Values, si);

            string seasText = SeasonName(si, snum);

            if ((eis.Count > 0) && (eis[0].SeasonId > 0))
            {
                seasText = " - <A HREF=\"" + TheTVDB.Instance.WebsiteUrl(ser.TvdbCode, eis[0].SeasonId, false) + "\">" +
                           seasText + "</a>";
            }
            else
            {
                seasText = " - " + seasText;
            }

            body += "<h1><A HREF=\"" + TheTVDB.Instance.WebsiteUrl(si.TvdbCode, -1, true) + "\">" + si.ShowName +
                    "</A>" + seasText + "</h1>";

            DirFilesCache dfc = new DirFilesCache();

            foreach (ProcessedEpisode ei in eis)
            {
                string epl = ei.NumsAsString();

                string episodeUrl = TheTVDB.Instance.WebsiteUrl(ei.SeriesId, ei.SeasonId, ei.EpisodeId);

                body += "<A href=\"" + episodeUrl + "\" name=\"ep" + epl + "\">"; // anchor
                if (si.DvdOrder && snum == 0)
                {
                    body += "<b>" + ei.Name + "</b>";
                }
                else
                {
                    body += "<b>" + HttpUtility.HtmlEncode(CustomEpisodeName.NameForNoExt(ei, CustomEpisodeName.OldNStyle(6))) +
                            "</b>";
                }

                body += "</A>"; // anchor
                if (si.UseSequentialMatch && (ei.OverallNumber != -1))
                {
                    body += " (#" + ei.OverallNumber + ")";
                }

                List <FileInfo> fl = dfc.FindEpOnDisk(ei);
                if (fl.Count > 0)
                {
                    foreach (FileInfo fi in fl)
                    {
                        string urlFilename = HttpUtility.UrlEncode(fi.FullName);
                        body += $" <A HREF=\"watch://{urlFilename}\" class=\"search\">Watch</A>";
                        body += $" <A HREF=\"explore://{urlFilename}\" class=\"search\">Show in Explorer</A>";
                    }
                }
                else
                {
                    body += " <A HREF=\"" + TVSettings.Instance.BTSearchURL(ei) + "\" class=\"search\">Search</A>";
                }

                DateTime?dt = ei.GetAirDateDt(true);
                if ((dt != null) && (dt.Value.CompareTo(DateTime.MaxValue) != 0))
                {
                    body += "<p>" + dt.Value.ToShortDateString() + " (" + ei.HowLong() + ")";
                }

                body += "<p><p>";

                if ((TVSettings.Instance.ShowEpisodePictures) ||
                    (TVSettings.Instance.HideMyShowsSpoilers && ei.HowLong() != "Aired"))
                {
                    body += "<table><tr>";
                    body += "<td width=100% valign=top>" + GetOverview(ei) + "</td><td width=300 height=225>";
                    // 300x168 / 300x225
                    if (!string.IsNullOrEmpty(ei.Filename))
                    {
                        body += "<img src=" + TheTVDB.GetImageURL(ei.Filename) + ">";
                    }

                    body += "</td></tr></table>";
                }
                else
                {
                    body += GetOverview(ei);
                }

                body += "<p><hr><p>";
            } // for each episode in this season

            return(body);
        }
Beispiel #23
0
        public static string GetShowHtmlOverviewOffline([NotNull] this ShowItem si)
        {
            string     body = "";
            SeriesInfo ser  = si.TheSeries();

            if ((!string.IsNullOrEmpty(ser?.GetSeriesWideBannerPath())) &&
                (!string.IsNullOrEmpty(TheTVDB.GetImageURL(ser.GetSeriesWideBannerPath()))))
            {
                body += "<img width=758 height=140 src=\"" + TheTVDB.GetImageURL(ser.GetSeriesWideBannerPath()) +
                        "\"><br/>";
            }

            body += $"<h1><A HREF=\"{TheTVDB.Instance.WebsiteUrl(si.TvdbCode, -1, true)}\">{si.ShowName}</A> </h1>";

            body += "<h2>Overview</h2>" + ser?.Overview; //get overview in either format

            bool first = true;

            foreach (Actor aa in si.Actors.Where(aa => !string.IsNullOrEmpty(aa.ActorName)))
            {
                body += first ? "<h2>Actors</h2>" : ", ";

                body += "<A HREF=\"http://www.imdb.com/find?s=nm&q=" + aa.ActorName + "\">" + aa.ActorName + $"</a> as {aa.ActorRole}";
                first = false;
            }

            string airsTime = ser?.AirsTime.PrettyPrint();
            string airsDay  = ser?.AirsDay;

            if ((!string.IsNullOrEmpty(airsTime)) && (!string.IsNullOrEmpty(airsDay)))
            {
                body += "<h2>Airs</h2> " + airsTime + " " + airsDay;
                string net = ser.Network;
                if (!string.IsNullOrEmpty(net))
                {
                    body += ", " + net;
                }
            }

            string yearRange = YearRange(ser);

            string siteRating = ser?.SiteRating > 0 ? ser.SiteRating + "/10" : string.Empty;
            string tvdbLink   = TheTVDB.Instance.WebsiteUrl(si.TvdbCode, -1, true);

            string tableHtml = string.Empty;

            tableHtml += GetOverviewPart("thetvdb.com", $"<A HREF=\"{tvdbLink}\">Visit</a>");
            tableHtml += GetOverviewPart("imdb.com", "<A HREF=\"http://www.imdb.com/title/" + ser?.Imdb + "\">Visit</a>");
            tableHtml += GetOverviewPart("tv.com", "<A HREF=\"http://www.tv.com/show/" + ser?.SeriesId + "/summary.html\">Visit</a>");
            tableHtml += GetOverviewPart("Runtime", ser?.Runtime);
            tableHtml += GetOverviewPart("Aliases", string.Join(", ", si.AliasNames));
            tableHtml += GetOverviewPart("Genres", string.Join(", ", si.Genres));
            tableHtml += GetOverviewPart("Rating", ser?.ContentRating);
            tableHtml += GetOverviewPart("User Rating", $"{siteRating}{AddRatingCount(ser?.SiteRatingVotes??0)}");
            tableHtml += GetOverviewPart("Active From", yearRange);
            tableHtml += GetOverviewPart("Status", ser?.Status);

            if (!string.IsNullOrWhiteSpace(tableHtml))
            {
                body += "<h2>Information<table border=0>" + tableHtml + "</table>";
            }

            return(body);
        }
Beispiel #24
0
        public bool Go(ref bool pause, TVRenameStats stats)
        {
            XmlWriterSettings settings = new XmlWriterSettings
            {
                Indent = true,
                NewLineOnAttributes = true
            };
            // "try" and silently fail.  eg. when file is use by other...
            XmlWriter writer;

            try
            {
                //                XmlWriter writer = XmlWriter.Create(this.Where.FullName, settings);
                writer = XmlWriter.Create(this.Where.FullName, settings);
                if (writer == null)
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                this.Done = true;
                return(true);
            }

            if (this.Episode != null) // specific episode
            {
                // See: http://xbmc.org/wiki/?title=Import_-_Export_Library#TV_Episodes
                writer.WriteStartElement("episodedetails");

                XMLHelper.WriteElementToXML(writer, "title", this.Episode.Name);
                XMLHelper.WriteElementToXML(writer, "rating", this.Episode.EpisodeRating);
                XMLHelper.WriteElementToXML(writer, "season", this.Episode.SeasonNumber);
                XMLHelper.WriteElementToXML(writer, "episode", this.Episode.EpNum);
                XMLHelper.WriteElementToXML(writer, "plot", this.Episode.Overview);

                writer.WriteStartElement("aired");
                if (this.Episode.FirstAired != null)
                {
                    writer.WriteValue(this.Episode.FirstAired.Value.ToString("yyyy-MM-dd"));
                }
                writer.WriteEndElement();

                if (this.Episode.SI != null)
                {
                    WriteInfo(writer, this.Episode.SI, "ContentRating", "mpaa");
                }

                //Director(s)
                if (!String.IsNullOrEmpty(this.Episode.EpisodeDirector))
                {
                    string EpDirector = this.Episode.EpisodeDirector;
                    if (!string.IsNullOrEmpty(EpDirector))
                    {
                        foreach (string Daa in EpDirector.Split('|'))
                        {
                            if (string.IsNullOrEmpty(Daa))
                            {
                                continue;
                            }

                            XMLHelper.WriteElementToXML(writer, "director", Daa);
                        }
                    }
                }

                //Writers(s)
                if (!String.IsNullOrEmpty(this.Episode.Writer))
                {
                    string EpWriter = this.Episode.Writer;
                    if (!string.IsNullOrEmpty(EpWriter))
                    {
                        XMLHelper.WriteElementToXML(writer, "credits", EpWriter);
                    }
                }

                // Guest Stars...
                if (!String.IsNullOrEmpty(this.Episode.EpisodeGuestStars))
                {
                    string RecurringActors = "";

                    if (this.Episode.SI != null)
                    {
                        RecurringActors = this.Episode.SI.TheSeries().GetItem("Actors");
                    }

                    string GuestActors = this.Episode.EpisodeGuestStars;
                    if (!string.IsNullOrEmpty(GuestActors))
                    {
                        foreach (string Gaa in GuestActors.Split('|'))
                        {
                            if (string.IsNullOrEmpty(Gaa))
                            {
                                continue;
                            }

                            // Skip if the guest actor is also in the overal recurring list
                            if (!string.IsNullOrEmpty(RecurringActors) && RecurringActors.Contains(Gaa))
                            {
                                continue;
                            }

                            writer.WriteStartElement("actor");
                            XMLHelper.WriteElementToXML(writer, "name", Gaa);
                            writer.WriteEndElement(); // actor
                        }
                    }
                }

                // actors...
                if (this.Episode.SI != null)
                {
                    string actors = this.Episode.SI.TheSeries().GetItem("Actors");
                    if (!string.IsNullOrEmpty(actors))
                    {
                        foreach (string aa in actors.Split('|'))
                        {
                            if (string.IsNullOrEmpty(aa))
                            {
                                continue;
                            }

                            writer.WriteStartElement("actor");
                            XMLHelper.WriteElementToXML(writer, "name", aa);
                            writer.WriteEndElement(); // actor
                        }
                    }
                }

                writer.WriteEndElement(); // episodedetails
            }
            else if (this.SI != null)     // show overview (tvshow.nfo)
            {
                // http://www.xbmc.org/wiki/?title=Import_-_Export_Library#TV_Shows

                writer.WriteStartElement("tvshow");

                XMLHelper.WriteElementToXML(writer, "title", this.SI.ShowName);

                XMLHelper.WriteElementToXML(writer, "episodeguideurl", TheTVDB.BuildURL(true, true, this.SI.TVDBCode, TheTVDB.Instance.RequestLanguage));

                WriteInfo(writer, this.SI, "Overview", "plot");

                string genre = this.SI.TheSeries().GetItem("Genre");
                if (!string.IsNullOrEmpty(genre))
                {
                    genre = genre.Trim('|');
                    genre = genre.Replace("|", " / ");
                    XMLHelper.WriteElementToXML(writer, "genre", genre);
                }

                WriteInfo(writer, this.SI, "FirstAired", "premiered");
                WriteInfo(writer, this.SI, "Year", "year");
                WriteInfo(writer, this.SI, "Rating", "rating");
                WriteInfo(writer, this.SI, "Status", "status");

                // actors...
                string actors = this.SI.TheSeries().GetItem("Actors");
                if (!string.IsNullOrEmpty(actors))
                {
                    foreach (string aa in actors.Split('|'))
                    {
                        if (string.IsNullOrEmpty(aa))
                        {
                            continue;
                        }

                        writer.WriteStartElement("actor");
                        XMLHelper.WriteElementToXML(writer, "name", aa);
                        writer.WriteEndElement(); // actor
                    }
                }

                WriteInfo(writer, this.SI, "ContentRating", "mpaa");
                WriteInfo(writer, this.SI, "IMDB_ID", "id", "moviedb", "imdb");

                XMLHelper.WriteElementToXML(writer, "tvdbid", this.SI.TheSeries().TVDBCode);

                string rt = this.SI.TheSeries().GetItem("Runtime");
                if (!string.IsNullOrEmpty(rt))
                {
                    XMLHelper.WriteElementToXML(writer, "runtime", rt + " minutes");
                }

                writer.WriteEndElement(); // tvshow
            }

            try
            {
                writer.Close();
            }
            catch (Exception e)
            {
                this.ErrorText = e.Message;
                this.Error     = true;
                this.Done      = true;
                return(false);
            }

            this.Done = true;
            return(true);
        }
Beispiel #25
0
        private bool WriteEpisodeMetaDataFile()
        {
            // "try" and silently fail.  eg. when file is use by other...
            try
            {
                XmlWriterSettings settings = new XmlWriterSettings
                {
                    Indent = true,
                    NewLineOnAttributes = true,
                };

                using (XmlWriter writer = XmlWriter.Create(Where.FullName, settings))
                {
                    writer.WriteStartElement("details");
                    writer.WriteElement("title", TVSettings.Instance.NamingStyle.NameFor(Episode));
                    writer.WriteElement("mpaa", Episode.TheSeries.ContentRating);

                    if (Episode.FirstAired.HasValue)
                    {
                        writer.WriteElement("year", Episode.FirstAired.Value.ToString("yyyy-MM-dd"));
                        writer.WriteElement("firstaired",
                                            Episode.FirstAired.Value.ToString("yyyy-MM-dd"));
                    }

                    writer.WriteElement("runtime", Episode.TheSeries.Runtime, true);
                    writer.WriteElement("rating", Episode.EpisodeRating);
                    writer.WriteElement("studio", Episode.TheSeries.Network);
                    writer.WriteElement("plot", Episode.TheSeries.Overview);
                    writer.WriteElement("overview", Episode.Overview);
                    foreach (string director in Episode.Directors)
                    {
                        writer.WriteElement("directors", director);
                    }

                    foreach (string epwriter in Episode.Writers)
                    {
                        writer.WriteElement("writers", epwriter);
                    }

                    foreach (string genre in Episode.TheSeries.Genres())
                    {
                        writer.WriteElement("genre", genre);
                    }

                    // actors...
                    foreach (Actor aa in Episode.TheSeries.GetActors())
                    {
                        if (string.IsNullOrEmpty(aa.ActorName))
                        {
                            continue;
                        }

                        writer.WriteStartElement("actor");
                        writer.WriteElement("name", aa.ActorName);
                        writer.WriteElement("role", aa.ActorRole);
                        writer.WriteEndElement(); // actor
                    }

                    // guest stars...
                    foreach (string guest in Episode.GuestStars)
                    {
                        writer.WriteElement("guest", guest);
                    }

                    writer.WriteElement("thumbnail", TheTVDB.GetImageURL(Episode.Filename));
                    writer.WriteElement("banner", TheTVDB.GetImageURL(Episode.AppropriateSeason.GetWideBannerPath()));
                    writer.WriteElement("backdrop", TheTVDB.GetImageURL(Episode.TheSeries.GetSeriesFanartPath()));
                    writer.WriteEndElement(); // details
                }
                Done = true;
                return(true);
            }
            catch (Exception e)
            {
                ErrorText = e.Message;
                Error     = true;
                Done      = true;
                return(false);
            }
        }
Beispiel #26
0
        public override bool Go(ref bool pause, TVRenameStats stats)
        {
            XmlWriterSettings settings = new XmlWriterSettings
            {
                Indent = true,
                NewLineOnAttributes = true,

                //Multipart NFO files are not actually valid XML as they have multiple episodeDetails elements
                ConformanceLevel = ConformanceLevel.Fragment
            };

            try
            {
                // "try" and silently fail.  eg. when file is use by other...
                using (XmlWriter writer = XmlWriter.Create(Where.FullName, settings))
                {
                    if (Episode != null) // specific episode
                    {
                        if (Episode.Type == ProcessedEpisode.ProcessedEpisodeType.merged)
                        {
                            foreach (Episode ep in Episode.SourceEpisodes)
                            {
                                WriteEpisodeDetailsFor(ep, writer, true, Episode.Show.DvdOrder);
                            }
                        }
                        else
                        {
                            WriteEpisodeDetailsFor(Episode, writer, false, Episode.Show.DvdOrder);
                        }
                    }
                    else if (SelectedShow != null) // show overview (tvshow.nfo)
                    {
                        // http://www.xbmc.org/wiki/?title=Import_-_Export_Library#TV_Shows
                        writer.WriteStartElement("tvshow");

                        XmlHelper.WriteElementToXml(writer, "title", SelectedShow.ShowName);

                        XmlHelper.WriteElementToXml(writer, "episodeguideurl",
                                                    TheTVDB.BuildUrl(SelectedShow.TvdbCode, SelectedShow.UseCustomLanguage? SelectedShow.PreferredLanguage.Abbreviation:TVSettings.Instance.PreferredLanguageCode));

                        XmlHelper.WriteElementToXml(writer, "plot", SelectedShow.TheSeries().GetOverview());

                        string genre = string.Join(" / ", SelectedShow.TheSeries().GetGenres());
                        if (!string.IsNullOrEmpty(genre))
                        {
                            XmlHelper.WriteElementToXml(writer, "genre", genre);
                        }

                        XmlHelper.WriteElementToXml(writer, "premiered", SelectedShow.TheSeries().GetFirstAired());
                        XmlHelper.WriteElementToXml(writer, "year", SelectedShow.TheSeries().GetYear());
                        XmlHelper.WriteElementToXml(writer, "rating", SelectedShow.TheSeries().GetContentRating());
                        XmlHelper.WriteElementToXml(writer, "status", SelectedShow.TheSeries().GetStatus());

                        // actors...
                        foreach (Actor aa in SelectedShow.TheSeries().GetActors())
                        {
                            if (string.IsNullOrEmpty(aa.ActorName))
                            {
                                continue;
                            }

                            writer.WriteStartElement("actor");
                            XmlHelper.WriteElementToXml(writer, "name", aa.ActorName);
                            XmlHelper.WriteElementToXml(writer, "role", aa.ActorRole);
                            XmlHelper.WriteElementToXml(writer, "order", aa.ActorSortOrder);
                            XmlHelper.WriteElementToXml(writer, "thumb", aa.ActorImage);
                            writer.WriteEndElement(); // actor
                        }

                        XmlHelper.WriteElementToXml(writer, "mpaa", SelectedShow.TheSeries().GetContentRating());
                        XmlHelper.WriteInfo(writer, "id", "moviedb", "imdb", SelectedShow.TheSeries().GetImdb());

                        XmlHelper.WriteElementToXml(writer, "tvdbid", SelectedShow.TheSeries().TvdbCode);

                        string rt = SelectedShow.TheSeries().GetRuntime();
                        if (!string.IsNullOrEmpty(rt))
                        {
                            XmlHelper.WriteElementToXml(writer, "runtime", rt + " minutes");
                        }
                        writer.WriteEndElement(); // tvshow
                    }
                }
            }
            catch (Exception e)
            {
                ErrorText = e.Message;
                Error     = true;
                Done      = true;
                return(false);
            }
            Done = true;
            return(true);
        }
Beispiel #27
0
        public override bool Go(ref bool pause, TVRenameStats stats)
        {
            XmlWriterSettings settings = new XmlWriterSettings
            {
                Indent = true,
                NewLineOnAttributes = true,

                //Multipart NFO files are not actually valid XML as they have multiple episodeDetails elements
                ConformanceLevel = ConformanceLevel.Fragment
            };

            try
            {
                // "try" and silently fail.  eg. when file is use by other...
                using (XmlWriter writer = XmlWriter.Create(this.Where.FullName, settings))
                {
                    if (this.Episode != null) // specific episode
                    {
                        if (this.Episode.type == ProcessedEpisode.ProcessedEpisodeType.merged)
                        {
                            foreach (Episode ep in this.Episode.sourceEpisodes)
                            {
                                WriteEpisodeDetailsFor(ep, writer, true, this.Episode.SI.DVDOrder);
                            }
                        }
                        else
                        {
                            WriteEpisodeDetailsFor(this.Episode, writer, false, this.Episode.SI.DVDOrder);
                        }
                    }
                    else if (this.SI != null) // show overview (tvshow.nfo)
                    {
                        // http://www.xbmc.org/wiki/?title=Import_-_Export_Library#TV_Shows
                        writer.WriteStartElement("tvshow");

                        XMLHelper.WriteElementToXML(writer, "title", this.SI.ShowName);

                        XMLHelper.WriteElementToXML(writer, "episodeguideurl",
                                                    TheTVDB.BuildURL(this.SI.TVDBCode, TheTVDB.Instance.RequestLanguage));

                        XMLHelper.WriteElementToXML(writer, "plot", this.SI.TheSeries().GetOverview());

                        string genre = String.Join(" / ", this.SI.TheSeries().GetGenres());
                        if (!string.IsNullOrEmpty(genre))
                        {
                            XMLHelper.WriteElementToXML(writer, "genre", genre);
                        }

                        XMLHelper.WriteElementToXML(writer, "premiered", this.SI.TheSeries().GetFirstAired());
                        XMLHelper.WriteElementToXML(writer, "year", this.SI.TheSeries().GetYear());
                        XMLHelper.WriteElementToXML(writer, "rating", this.SI.TheSeries().GetContentRating());
                        XMLHelper.WriteElementToXML(writer, "status", this.SI.TheSeries().getStatus());

                        // actors...
                        foreach (string aa in this.SI.TheSeries().GetActors())
                        {
                            if (string.IsNullOrEmpty(aa))
                            {
                                continue;
                            }

                            writer.WriteStartElement("actor");
                            XMLHelper.WriteElementToXML(writer, "name", aa);
                            writer.WriteEndElement(); // actor
                        }

                        XMLHelper.WriteElementToXML(writer, "mpaa", this.SI.TheSeries().GetContentRating());
                        XMLHelper.WriteInfo(writer, "id", "moviedb", "imdb", this.SI.TheSeries().GetIMDB());

                        XMLHelper.WriteElementToXML(writer, "tvdbid", this.SI.TheSeries().TVDBCode);

                        string rt = this.SI.TheSeries().GetRuntime();
                        if (!string.IsNullOrEmpty(rt))
                        {
                            XMLHelper.WriteElementToXML(writer, "runtime", rt + " minutes");
                        }
                        writer.WriteEndElement(); // tvshow
                    }
                }
            }
            catch (Exception e)
            {
                this.ErrorText = e.Message;
                this.Error     = true;
                this.Done      = true;
                return(false);
            }
            this.Done = true;
            return(true);
        }
Beispiel #28
0
        public AddEditShow(ShowItem si, TheTVDB db)
        {
            this.mSI   = si;
            this.mTVDB = db;
            this.InitializeComponent();

            this.cbTimeZone.BeginUpdate();
            this.cbTimeZone.Items.Clear();

            foreach (string s in TimeZone.ZoneNames())
            {
                this.cbTimeZone.Items.Add(s);
            }

            this.cbTimeZone.EndUpdate();

            this.mTCCF      = new TheTVDBCodeFinder(si.TVDBCode != -1 ? si.TVDBCode.ToString() : "", this.mTVDB);
            this.mTCCF.Dock = DockStyle.Fill;
            //mTCCF->SelectionChanged += gcnew System::EventHandler(this, &AddEditShow::lvMatches_ItemSelectionChanged);

            this.pnlCF.SuspendLayout();
            this.pnlCF.Controls.Add(this.mTCCF);
            this.pnlCF.ResumeLayout();

            this.chkCustomShowName.Checked = si.UseCustomShowName;
            if (this.chkCustomShowName.Checked)
            {
                this.txtCustomShowName.Text = si.CustomShowName;
            }
            this.chkCustomShowName_CheckedChanged(null, null);

            this.cbSequentialMatching.Checked = si.UseSequentialMatch;
            this.chkShowNextAirdate.Checked   = si.ShowNextAirdate;
            this.chkSpecialsCount.Checked     = si.CountSpecials;
            this.chkFolderPerSeason.Checked   = si.AutoAdd_FolderPerSeason;
            this.txtSeasonFolderName.Text     = si.AutoAdd_SeasonFolderName;
            this.txtBaseFolder.Text           = si.AutoAdd_FolderBase;
            this.chkAutoFolders.Checked       = si.AutoAddNewSeasons;
            this.chkFolderPerSeason_CheckedChanged(null, null);

            this.cbDoRenaming.Checked     = si.DoRename;
            this.cbDoMissingCheck.Checked = si.DoMissingCheck;
            this.cbDoMissingCheck_CheckedChanged(null, null);

            this.chkPadTwoDigits.Checked = si.PadSeasonToTwoDigits;

            this.ShowTimeZone = ((si == null) || (si.TheSeries() == null))
                                    ? TimeZone.DefaultTimeZone()
                                    : si.TheSeries().ShowTimeZone;

            this.cbTimeZone.Text            = this.ShowTimeZone;
            this.chkDVDOrder.Checked        = si.DVDOrder;
            this.cbIncludeFuture.Checked    = si.ForceCheckFuture;
            this.cbIncludeNoAirdate.Checked = si.ForceCheckNoAirdate;

            bool first = true;

            si.IgnoreSeasons.Sort();
            foreach (int i in si.IgnoreSeasons)
            {
                if (!first)
                {
                    this.txtIgnoreSeasons.Text += " ";
                }
                this.txtIgnoreSeasons.Text += i.ToString();
                first = false;
            }

            foreach (System.Collections.Generic.KeyValuePair <int, List <string> > kvp in si.ManualFolderLocations)
            {
                foreach (string s in kvp.Value)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = kvp.Key.ToString();
                    lvi.SubItems.Add(s);

                    this.lvSeasonFolders.Items.Add(lvi);
                }
            }
            this.lvSeasonFolders.Sort();

            this.txtSeasonNumber_TextChanged(null, null);
            this.txtFolder_TextChanged(null, null);

            this.ActiveControl = mTCCF; // set initial focus to the code entry/show finder control

            foreach (string aliasName in this.mSI.AliasNames)
            {
                lbShowAlias.Items.Add(aliasName);
            }

            StringBuilder tl = new StringBuilder();

            foreach (string s in CustomName.Tags)
            {
                tl.AppendLine(s);
            }
            this.txtTagList.Text = tl.ToString();

            cbUseCustomSearch.Checked = !String.IsNullOrEmpty(si.CustomSearchURL);
            txtSearchURL.Text         = si.CustomSearchURL ?? "";
            EnableDisableCustomSearch();
        }
Beispiel #29
0
        public AddEditShow(ShowItem si, TheTVDB db)
        {
            this.mSI = si;
            this.mTVDB = db;
            this.InitializeComponent();

            this.cbTimeZone.BeginUpdate();
            this.cbTimeZone.Items.Clear();

            foreach (string s in TimeZone.ZoneNames())
                this.cbTimeZone.Items.Add(s);

            this.cbTimeZone.EndUpdate();

            this.mTCCF = new TheTVDBCodeFinder(si.TVDBCode != -1 ? si.TVDBCode.ToString() : "", this.mTVDB);
            this.mTCCF.Dock = DockStyle.Fill;
            //mTCCF->SelectionChanged += gcnew System::EventHandler(this, &AddEditShow::lvMatches_ItemSelectionChanged);

            this.pnlCF.SuspendLayout();
            this.pnlCF.Controls.Add(this.mTCCF);
            this.pnlCF.ResumeLayout();

            this.chkCustomShowName.Checked = si.UseCustomShowName;
            if (this.chkCustomShowName.Checked)
                this.txtCustomShowName.Text = si.CustomShowName;
            this.chkCustomShowName_CheckedChanged(null, null);

            this.cbSequentialMatching.Checked = si.UseSequentialMatch;
            this.chkShowNextAirdate.Checked = si.ShowNextAirdate;
            this.chkSpecialsCount.Checked = si.CountSpecials;
            this.chkFolderPerSeason.Checked = si.AutoAdd_FolderPerSeason;
            this.txtSeasonFolderName.Text = si.AutoAdd_SeasonFolderName;
            this.txtBaseFolder.Text = si.AutoAdd_FolderBase;
            this.chkAutoFolders.Checked = si.AutoAddNewSeasons;
            this.chkFolderPerSeason_CheckedChanged(null, null);

            this.cbDoRenaming.Checked = si.DoRename;
            this.cbDoMissingCheck.Checked = si.DoMissingCheck;
            this.cbDoMissingCheck_CheckedChanged(null, null);

            this.chkPadTwoDigits.Checked = si.PadSeasonToTwoDigits;

            this.ShowTimeZone = ((si == null) || (si.TheSeries() == null))
                                    ? TimeZone.DefaultTimeZone()
                                    : si.TheSeries().ShowTimeZone;

            this.cbTimeZone.Text = this.ShowTimeZone;
            this.chkDVDOrder.Checked = si.DVDOrder;
            this.cbIncludeFuture.Checked = si.ForceCheckFuture;
            this.cbIncludeNoAirdate.Checked = si.ForceCheckNoAirdate;

            bool first = true;
            si.IgnoreSeasons.Sort();
            foreach (int i in si.IgnoreSeasons)
            {
                if (!first)
                    this.txtIgnoreSeasons.Text += " ";
                this.txtIgnoreSeasons.Text += i.ToString();
                first = false;
            }

            foreach (System.Collections.Generic.KeyValuePair<int, List<string>> kvp in si.ManualFolderLocations)
            {
                foreach (string s in kvp.Value)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = kvp.Key.ToString();
                    lvi.SubItems.Add(s);

                    this.lvSeasonFolders.Items.Add(lvi);
                }
            }
            this.lvSeasonFolders.Sort();

            this.txtSeasonNumber_TextChanged(null, null);
            this.txtFolder_TextChanged(null, null);

            this.ActiveControl = mTCCF; // set initial focus to the code entry/show finder control

            foreach (string aliasName in this.mSI.AliasNames)
            {
                lbShowAlias.Items.Add(aliasName);
            }

            StringBuilder tl = new StringBuilder();

            foreach (string s in CustomName.Tags)
            {
                tl.AppendLine(s);
            }
            this.txtTagList.Text = tl.ToString();

            cbUseCustomSearch.Checked = !String.IsNullOrEmpty(si.CustomSearchURL);
            txtSearchURL.Text = si.CustomSearchURL ?? "";
            EnableDisableCustomSearch();
        }
Beispiel #30
0
        private void OKButton_Click(object sender, System.EventArgs e)
        {
            if (!TVSettings.OKExtensionsString(this.txtVideoExtensions.Text))
            {
                MessageBox.Show("Extensions list must be separated by semicolons, and each extension must start with a dot.", "Preferences", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.tabControl1.SelectedIndex = 1;
                this.txtVideoExtensions.Focus();
                return;
            }
            if (!TVSettings.OKExtensionsString(this.txtOtherExtensions.Text))
            {
                MessageBox.Show("Extensions list must be separated by semicolons, and each extension must start with a dot.", "Preferences", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.tabControl1.SelectedIndex = 1;
                this.txtOtherExtensions.Focus();
                return;
            }
            TVSettings S = this.mDoc.Settings;

            S.Replacements.Clear();
            for (int i = 1; i < this.ReplacementsGrid.RowsCount; i++)
            {
                string from = (string)(this.ReplacementsGrid[i, 0].Value);
                string to   = (string)(this.ReplacementsGrid[i, 1].Value);
                bool   ins  = (bool)(this.ReplacementsGrid[i, 2].Value);
                if (!string.IsNullOrEmpty(from))
                {
                    S.Replacements.Add(new Replacement(from, to, ins));
                }
            }

            S.ExportWTWRSS        = this.cbWTWRSS.Checked;
            S.ExportWTWRSSTo      = this.txtWTWRSS.Text;
            S.ExportWTWXML        = this.cbWTWXML.Checked;
            S.ExportWTWXMLTo      = this.txtWTWXML.Text;
            S.ExportMissingXML    = this.cbMissingXML.Checked;
            S.ExportMissingXMLTo  = this.txtMissingXML.Text;
            S.ExportMissingCSV    = this.cbMissingCSV.Checked;
            S.ExportMissingCSVTo  = this.txtMissingCSV.Text;
            S.ExportRenamingXML   = this.cbRenamingXML.Checked;
            S.ExportRenamingXMLTo = this.txtRenamingXML.Text;
            S.ExportFOXML         = this.cbFOXML.Checked;
            S.ExportFOXMLTo       = this.txtFOXML.Text;

            S.WTWRecentDays           = Convert.ToInt32(this.txtWTWDays.Text);
            S.StartupTab              = this.cbStartupTab.SelectedIndex;
            S.NotificationAreaIcon    = this.cbNotificationIcon.Checked;
            S.VideoExtensionsString   = this.txtVideoExtensions.Text;
            S.OtherExtensionsString   = this.txtOtherExtensions.Text;
            S.ExportRSSMaxDays        = Convert.ToInt32(this.txtExportRSSMaxDays.Text);
            S.ExportRSSMaxShows       = Convert.ToInt32(this.txtExportRSSMaxShows.Text);
            S.ExportRSSDaysPast       = Convert.ToInt32(this.txtExportRSSDaysPast.Text);
            S.KeepTogether            = this.cbKeepTogether.Checked;
            S.LeadingZeroOnSeason     = this.cbLeadingZero.Checked;
            S.ShowInTaskbar           = this.chkShowInTaskbar.Checked;
            S.RenameTxtToSub          = this.cbTxtToSub.Checked;
            S.ShowEpisodePictures     = this.cbShowEpisodePictures.Checked;
            S.AutoSelectShowInMyShows = this.cbAutoSelInMyShows.Checked;
            S.SpecialsFolderName      = this.txtSpecialsFolderName.Text;

            S.ForceLowercaseFilenames = this.cbForceLower.Checked;
            S.IgnoreSamples           = this.cbIgnoreSamples.Checked;

            S.uTorrentPath  = this.txtRSSuTorrentPath.Text;
            S.ResumeDatPath = this.txtUTResumeDatPath.Text;
            S.SABHostPort   = this.txtSABHostPort.Text;
            S.SABAPIKey     = this.txtSABAPIKey.Text;
            S.CheckSABnzbd  = this.cbCheckSABnzbd.Checked;

            S.SearchRSS             = this.cbSearchRSS.Checked;
            S.EpImgs                = this.cbEpImgs.Checked;
            S.NFOs                  = this.cbNFOs.Checked;
            S.pyTivoMeta            = this.cbMeta.Checked;
            S.pyTivoMetaSubFolder   = this.cbMetaSubfolder.Checked;
            S.FolderJpg             = this.cbFolderJpg.Checked;
            S.RenameCheck           = this.cbRenameCheck.Checked;
            S.MissingCheck          = this.cbMissing.Checked;
            S.SearchLocally         = this.cbSearchLocally.Checked;
            S.LeaveOriginals        = this.cbLeaveOriginals.Checked;
            S.CheckuTorrent         = this.cbCheckuTorrent.Checked;
            S.LookForDateInFilename = this.cbLookForAirdate.Checked;
            S.MonitorFolders        = this.cbMonitorFolder.Checked;

            if (this.rbFolderFanArt.Checked)
            {
                S.FolderJpgIs = TVSettings.FolderJpgIsType.FanArt;
            }
            else if (this.rbFolderBanner.Checked)
            {
                S.FolderJpgIs = TVSettings.FolderJpgIsType.Banner;
            }
            else
            {
                S.FolderJpgIs = TVSettings.FolderJpgIsType.Poster;
            }


            TheTVDB db = this.mDoc.GetTVDB(true, "Preferences-OK");

            foreach (var kvp in db.LanguageList)
            {
                if (kvp.Value == cbLanguages.Text)
                {
                    S.PreferredLanguage = kvp.Key;
                    break;
                }
            }
            if (rbWTWScan.Checked)
            {
                S.WTWDoubleClick = TVSettings.WTWDoubleClickAction.Scan;
            }
            else
            {
                S.WTWDoubleClick = TVSettings.WTWDoubleClickAction.Search;
            }

            db.SaveCache();
            db.Unlock("Preferences-OK");

            try
            {
                S.SampleFileMaxSizeMB = int.Parse(this.txtMaxSampleSize.Text);
            }
            catch
            {
                S.SampleFileMaxSizeMB = 50;
            }

            try
            {
                S.ParallelDownloads = int.Parse(this.txtParallelDownloads.Text);
            }
            catch
            {
                S.ParallelDownloads = 4;
            }

            if (S.ParallelDownloads < 1)
            {
                S.ParallelDownloads = 1;
            }
            else if (S.ParallelDownloads > 8)
            {
                S.ParallelDownloads = 8;
            }

            // RSS URLs
            S.RSSURLs.Clear();
            for (int i = 1; i < this.RSSGrid.RowsCount; i++)
            {
                string url = (string)(this.RSSGrid[i, 0].Value);
                if (!string.IsNullOrEmpty(url))
                {
                    S.RSSURLs.Add(url);
                }
            }

            S.ShowStatusColors = new ShowStatusColoringTypeList();
            foreach (ListViewItem item in lvwDefinedColors.Items)
            {
                if (item.SubItems.Count > 1 && !string.IsNullOrEmpty(item.SubItems[1].Text) && item.Tag != null && item.Tag is ShowStatusColoringType)
                {
                    S.ShowStatusColors.Add(item.Tag as ShowStatusColoringType, System.Drawing.ColorTranslator.FromHtml(item.SubItems[1].Text));
                }
            }

            this.mDoc.SetDirty();
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        private static void AppendEpisode([NotNull] this StringBuilder sb, [NotNull] ProcessedEpisode ep, [CanBeNull] IReadOnlyCollection <FileInfo> fl, Color backgroundColour)
        {
            string stars          = StarRating(ep.EpisodeRating);
            string episodeUrl     = TheTVDB.WebsiteUrl(ep.SeriesId, ep.SeasonId, ep.EpisodeId);
            bool   ratingIsNumber = float.TryParse(ep.EpisodeRating, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.CreateSpecificCulture("en-US"), out float rating);
            string siteRating     = ratingIsNumber && rating > 0
                ? rating + "/10" + AddRatingCount(ep.SiteRatingCount ?? 0)
                : "";

            string imdbLink       = string.IsNullOrWhiteSpace(ep.ImdbCode) ? string.Empty : "http://www.imdb.com/title/" + ep.ImdbCode;
            string productionCode = string.IsNullOrWhiteSpace(ep.ProductionCode)
                ? string.Empty
                : "Production Code <br/>" + ep.ProductionCode;

            string episodeDescriptor = CustomEpisodeName.NameForNoExt(ep, CustomEpisodeName.OldNStyle(6)); // may need to include (si.DVDOrder && snum == 0)? ep.Name:
            string writersHtml       = string.IsNullOrWhiteSpace(ep.Writer) ? string.Empty : "<b>Writers:</b> " + string.Join(", ", ep.Writers);
            string directorsHtml     = string.IsNullOrWhiteSpace(ep.EpisodeDirector) ? string.Empty : "<b>Directors:</b> " + string.Join(", ", ep.Directors);
            string guestHtml         = string.IsNullOrWhiteSpace(ep.EpisodeGuestStars) ? string.Empty : "<b>Guest Stars:</b> " + string.Join(", ", ep.GuestStars);
            string possibleBreak1    = string.IsNullOrWhiteSpace(writersHtml) || string.IsNullOrWhiteSpace(directorsHtml)
                ? string.Empty
                : "<br />";
            string possibleBreak2 = string.IsNullOrWhiteSpace(writersHtml) && string.IsNullOrWhiteSpace(directorsHtml) || string.IsNullOrWhiteSpace(guestHtml)
                ? string.Empty
                : "<br />";

            string searchButton = (fl is null || fl.Count == 0) && ep.HasAired()
                ? CreateButton(TVSettings.Instance.BTSearchURL(ep), "<i class=\"fas fa-search\"></i>", "Search for Torrent...")
                : string.Empty;

            string viewButton     = string.Empty;
            string explorerButton = string.Empty;

            if (fl != null)
            {
                foreach (string urlFilename in fl.Select(fi => Uri.EscapeDataString(fi.FullName)))
                {
                    viewButton     += CreateButton($"{UI.WATCH_PROXY}{urlFilename}", "<i class=\"far fa-eye\"></i>", "Watch Now");
                    explorerButton += CreateButton($"{UI.EXPLORE_PROXY}{urlFilename}", "<i class=\"far fa-folder-open\"></i>", "Open Containing Folder");
                }
            }

            string tvdbButton = CreateButton(episodeUrl, "TVDB.com", "View on TVDB");
            string imdbButton = CreateButton(imdbLink, "IMDB.com", "View on IMDB");
            string tvButton   = CreateButton(ep.ShowUrl, "TV.com", "View on TV.com");

            sb.AppendLine($@"
                <div class=""card card-body"" style=""background-color:{backgroundColour.HexColour()}"">
                 <div class=""row"">
                  <div class=""col-md-5"">{ep.ScreenShotHtml()}</div>
                   <div class=""col-md-7 d-flex flex-column"">
                    <div class=""row"">
                     <div class=""col-md-8""><h2>{episodeDescriptor}</h2></div>
                     <div class=""col-md-4 text-right"">{ep.DateDetailsHtml()}</div>
                    </div>
				   <div>
                    <blockquote>
                     {writersHtml}{possibleBreak1}
                     {directorsHtml}{possibleBreak2}
                     {guestHtml}
                    </blockquote>
                   </div>
                   <div><p class=""lead"">{ep.HiddenOverview()}</p></div>
                   <div>
                    {searchButton}
                    {viewButton}
                    {explorerButton}
                    {tvdbButton}
                    {imdbButton}
                    {tvButton}
                   </div>
		           <div class=""row align-items-bottom flex-grow-1"">
                    <div class=""col-md-6 align-self-end"">{stars}<br>{siteRating}</div>
                    <div class=""col-md-6 align-self-end text-right"">{productionCode}</div>
                   </div>
                  </div>
                 </div>
                </div>");
        }
Beispiel #32
0
 public void SetDefaults(TheTVDB db)
 {
     this.TVDB = db;
     this.ManualFolderLocations = new Dictionary<int, List<string>>();
     this.IgnoreSeasons = new List<int>();
     this.UseCustomShowName = false;
     this.CustomShowName = "";
     this.UseSequentialMatch = false;
     this.SeasonRules = new Dictionary<int, List<ShowRule>>();
     this.SeasonEpisodes = new Dictionary<int, List<ProcessedEpisode>>();
     this.ShowNextAirdate = true;
     this.TVDBCode = -1;
     //                WhichSeasons = gcnew List<int>;
     //                NamingStyle = (int)NStyle.DefaultStyle();
     this.AutoAddNewSeasons = true;
     this.PadSeasonToTwoDigits = false;
     this.AutoAdd_FolderBase = "";
     this.AutoAdd_FolderPerSeason = true;
     this.AutoAdd_SeasonFolderName = "Season ";
     this.DoRename = true;
     this.DoMissingCheck = true;
     this.CountSpecials = false;
     this.DVDOrder = false;
     CustomSearchURL = "";
     ForceCheckNoAirdate = false;
     ForceCheckFuture = false;
 }
Beispiel #33
0
        private void WriteSeriesXmlFile([NotNull] XmlWriter writer)
        {
            SeriesInfo series = SelectedShow.TheSeries();

            // https://kodi.wiki/view/NFO_files/TV_shows
            writer.WriteStartElement("tvshow");

            writer.WriteElement("title", SelectedShow.ShowName);
            writer.WriteElement("originaltitle", series?.Name);
            writer.WriteElement("studio", series?.Network);
            float?showRating = series?.SiteRating;

            if (showRating.HasValue)
            {
                writer.WriteStartElement("ratings");

                writer.WriteStartElement("rating");
                writer.WriteAttributeString("name", "tvdb");
                writer.WriteAttributeString("max", "10");
                writer.WriteAttributeString("default", "true");

                writer.WriteElement("value", showRating.Value);
                writer.WriteElement("votes", series.SiteRatingVotes, true);

                writer.WriteEndElement(); //rating

                writer.WriteEndElement(); //ratings
            }

            string lang = TVSettings.Instance.PreferredLanguageCode;

            if (SelectedShow.UseCustomLanguage && SelectedShow.PreferredLanguage != null)
            {
                lang = SelectedShow.PreferredLanguage.Abbreviation;
            }

            //https://forum.kodi.tv/showthread.php?tid=323588
            //says that we need a format like this:
            //<episodeguide><url post="yes" cache="auth.json">https://api.thetvdb.com/login?{&quot;apikey&quot;:&quot;((API-KEY))&quot;,&quot;id&quot;:((ID))}|Content-Type=application/json</url></episodeguide>

            writer.WriteStartElement("episodeguide");
            writer.WriteStartElement("url");
            writer.WriteAttributeString("post", "yes");
            writer.WriteAttributeString("cache", "auth.json");
            writer.WriteRaw(TheTVDB.BuildUrl(SelectedShow.TvdbCode, lang));
            writer.WriteEndElement(); //url
            writer.WriteEndElement(); //episodeguide

            if (!(series is null))
            {
                writer.WriteElement("id", series.TvdbCode);
                writer.WriteElement("runtime", series.Runtime, true);
                writer.WriteElement("mpaa", series.ContentRating, true);

                writer.WriteStartElement("uniqueid");
                writer.WriteAttributeString("type", "tvdb");
                writer.WriteAttributeString("default", "true");
                writer.WriteValue(series.TvdbCode);
                writer.WriteEndElement();

                writer.WriteStartElement("uniqueid");
                writer.WriteAttributeString("type", "imdb");
                writer.WriteAttributeString("default", "false");
                writer.WriteValue(series.Imdb);
                writer.WriteEndElement();

                writer.WriteElement("plot", series.Overview);

                writer.WriteElement("premiered", series.FirstAired);
                writer.WriteElement("year", series.Year);
                writer.WriteElement("status", series.Status);
            }

            writer.WriteStringsToXml("genre", SelectedShow.Genres);

            // actors...
            foreach (Actor aa in SelectedShow.Actors.Where(aa => !string.IsNullOrEmpty(aa.ActorName)))
            {
                writer.WriteStartElement("actor");
                writer.WriteElement("name", aa.ActorName);
                writer.WriteElement("role", aa.ActorRole);
                writer.WriteElement("order", aa.ActorSortOrder);
                writer.WriteElement("thumb", TheTVDB.GetImageURL(aa.ActorImage), true);
                writer.WriteEndElement(); // actor
            }

            writer.WriteEndElement(); // tvshow
        }
Beispiel #34
0
        private static void WriteEpisodeDetailsFor([NotNull] Episode episode, [CanBeNull] ShowItem show, [NotNull] XmlWriter writer, bool multi, bool dvdOrder)
        {
            // See: http://xbmc.org/wiki/?title=Import_-_Export_Library#TV_Episodes
            writer.WriteStartElement("episodedetails");

            writer.WriteElement("title", episode.Name);
            writer.WriteElement("originaltitle", show?.ShowName);
            writer.WriteElement("showtitle", show?.ShowName);

            writer.WriteElement("id", episode.EpisodeId);

            writer.WriteStartElement("uniqueid");
            writer.WriteAttributeString("type", "tvdb");
            writer.WriteAttributeString("default", "true");
            writer.WriteValue(episode.EpisodeId);
            writer.WriteEndElement();

            if (!string.IsNullOrEmpty(episode.ImdbCode))
            {
                writer.WriteStartElement("uniqueid");
                writer.WriteAttributeString("type", "imdb");
                writer.WriteAttributeString("default", "false");
                writer.WriteValue(episode.ImdbCode);
                writer.WriteEndElement();
            }

            string showRating = episode.EpisodeRating;

            if (showRating != null)
            {
                writer.WriteStartElement("ratings");

                writer.WriteStartElement("rating");
                writer.WriteAttributeString("name", "tvdb");
                writer.WriteAttributeString("max", "10");
                writer.WriteAttributeString("default", "true");

                writer.WriteElement("value", showRating);
                writer.WriteElement("votes", episode.SiteRatingCount ?? 0, true);

                writer.WriteEndElement(); //rating

                writer.WriteEndElement(); //ratings
            }

            if (dvdOrder)
            {
                writer.WriteElement("season", episode.DvdSeasonNumber);
                writer.WriteElement("episode", episode.DvdEpNum);
            }
            else
            {
                writer.WriteElement("season", episode.AiredSeasonNumber);
                writer.WriteElement("episode", episode.AiredEpNum);
            }

            writer.WriteElement("plot", episode.Overview);
            writer.WriteElement("studio", episode.TheSeries?.Network);

            writer.WriteStartElement("aired");
            if (episode.FirstAired != null)
            {
                writer.WriteValue(episode.FirstAired.Value.ToString("yyyy-MM-dd"));
            }

            writer.WriteEndElement();

            writer.WriteElement("mpaa", show?.TheSeries()?.ContentRating, true);

            //Director(s)
            string epDirector = episode.EpisodeDirector;

            if (!string.IsNullOrEmpty(epDirector))
            {
                foreach (string daa in epDirector.Split('|'))
                {
                    writer.WriteElement("director", daa, true);
                }
            }

            //Writers(s)
            string epWriter = episode.Writer;

            if (!string.IsNullOrEmpty(epWriter))
            {
                foreach (string txtWriter in epWriter.Split('|'))
                {
                    writer.WriteElement("credits", txtWriter, true);
                }
            }

            // Guest Stars...
            if (!string.IsNullOrEmpty(episode.EpisodeGuestStars))
            {
                string recurringActors = "";

                if (show != null)
                {
                    recurringActors = string.Join("|", show.TheSeries()?.GetActorNames() ?? new List <string>());
                }

                string guestActors = episode.EpisodeGuestStars;
                if (!string.IsNullOrEmpty(guestActors))
                {
                    foreach (string gaa in guestActors.Split('|')
                             .Where(gaa => !string.IsNullOrEmpty(gaa))
                             .Where(gaa => string.IsNullOrEmpty(recurringActors) || !recurringActors.Contains(gaa)))
                    {
                        writer.WriteStartElement("actor");
                        writer.WriteElement("name", gaa);
                        writer.WriteEndElement(); // actor
                    }
                }
            }

            // actors...
            if (show != null)
            {
                foreach (Actor aa in (show.TheSeries()?.GetActors() ?? new List <Actor>())
                         .Where(aa => !string.IsNullOrEmpty(aa.ActorName)))
                {
                    writer.WriteStartElement("actor");
                    writer.WriteElement("name", aa.ActorName);
                    writer.WriteElement("role", aa.ActorRole);
                    writer.WriteElement("order", aa.ActorSortOrder);
                    writer.WriteElement("thumb", TheTVDB.GetImageURL(aa.ActorImage), true);
                    writer.WriteEndElement(); // actor
                }
            }

            if (multi)
            {
                writer.WriteStartElement("resume");
                //we have to put 0 as we don't know where the multipart episode starts/ends
                writer.WriteElement("position", 0);
                writer.WriteElement("total", 0);
                writer.WriteEndElement(); // resume

                //For now we only put art in for multipart episodes. Kodi finds the art appropriately
                //without our help for the others

                if (show != null)
                {
                    string filename =
                        TVSettings.Instance.FilenameFriendly(
                            TVSettings.Instance.NamingStyle.GetTargetEpisodeName(show, episode, show.GetTimeZone(),
                                                                                 show.DvdOrder));

                    string thumbFilename = filename + ".jpg";
                    writer.WriteElement("thumb", thumbFilename);
                    //Should be able to do this using the local filename, but only seems to work if you provide a URL
                    //XMLHelper.WriteElementToXML(writer, "thumb", TheTVDB.Instance.GetTVDBDownloadURL(episode.GetFilename()))
                }
            }
            writer.WriteEndElement(); // episodedetails
        }
Beispiel #35
0
        public override bool Go(TVRenameStats stats)
        {
            XmlWriterSettings settings = new XmlWriterSettings
            {
                Indent              = true,
                IndentChars         = "    ",
                Encoding            = Encoding.UTF8,
                NewLineChars        = "\r\n",
                NewLineOnAttributes = true,

                //Multipart NFO files are not actually valid XML as they have multiple episodeDetails elements
                ConformanceLevel = ConformanceLevel.Fragment
            };

            try
            {
                // "try" and silently fail.  eg. when file is use by other...
                using (XmlWriter writer = XmlWriter.Create(Where.FullName, settings))
                {
                    if (Episode != null) // specific episode
                    {
                        if (Episode.Type == ProcessedEpisode.ProcessedEpisodeType.merged)
                        {
                            foreach (Episode ep in Episode.SourceEpisodes)
                            {
                                ShowItem si = Episode.Show ?? SelectedShow;
                                WriteEpisodeDetailsFor(ep, si, writer, true, si.DvdOrder);
                            }
                        }
                        else
                        {
                            ShowItem si = Episode.Show ?? SelectedShow;
                            WriteEpisodeDetailsFor(Episode, si, writer, false, si.DvdOrder);
                        }
                    }
                    else if (SelectedShow != null) // show overview (tvshow.nfo)
                    {
                        SeriesInfo series = SelectedShow.TheSeries();

                        // https://kodi.wiki/view/NFO_files/TV_shows
                        writer.WriteStartElement("tvshow");

                        writer.WriteElement("title", SelectedShow.ShowName);
                        writer.WriteElement("originaltitle", series?.Name);
                        writer.WriteElement("studio", series?.Network);
                        float?showRating = series?.SiteRating;
                        if (showRating.HasValue)
                        {
                            writer.WriteStartElement("ratings");

                            writer.WriteStartElement("rating");
                            writer.WriteAttributeString("name", "tvdb");
                            writer.WriteAttributeString("max", "10");
                            writer.WriteAttributeString("default", "true");

                            writer.WriteElement("value", showRating.Value);
                            writer.WriteElement("votes", series.SiteRatingVotes, true);

                            writer.WriteEndElement(); //rating

                            writer.WriteEndElement(); //ratings
                        }

                        string lang = TVSettings.Instance.PreferredLanguageCode;
                        if (SelectedShow.UseCustomLanguage && SelectedShow.PreferredLanguage != null)
                        {
                            lang = SelectedShow.PreferredLanguage.Abbreviation;
                        }

                        writer.WriteElement("episodeguideurl",
                                            TheTVDB.BuildUrl(SelectedShow.TvdbCode, lang));

                        if (!(series is null))
                        {
                            writer.WriteElement("id", series.SeriesId);
                            writer.WriteElement("runtime", series.Runtime, true);
                            writer.WriteElement("mpaa", series.ContentRating, true);

                            writer.WriteStartElement("uniqueid");
                            writer.WriteAttributeString("type", "tvdb");
                            writer.WriteAttributeString("default", "true");
                            writer.WriteValue(series.TvdbCode);
                            writer.WriteEndElement();

                            writer.WriteStartElement("uniqueid");
                            writer.WriteAttributeString("type", "imdb");
                            writer.WriteAttributeString("default", "false");
                            writer.WriteValue(series.Imdb);
                            writer.WriteEndElement();

                            writer.WriteElement("plot", series.Overview);

                            writer.WriteElement("premiered", series.FirstAired);
                            writer.WriteElement("year", series.Year);
                            writer.WriteElement("status", series.Status);
                        }

                        writer.WriteStringsToXml("genre", SelectedShow.Genres);

                        // actors...
                        foreach (Actor aa in SelectedShow.Actors.Where(aa => !string.IsNullOrEmpty(aa.ActorName)))
                        {
                            writer.WriteStartElement("actor");
                            writer.WriteElement("name", aa.ActorName);
                            writer.WriteElement("role", aa.ActorRole);
                            writer.WriteElement("order", aa.ActorSortOrder);
                            writer.WriteElement("thumb", aa.ActorImage);
                            writer.WriteEndElement(); // actor
                        }

                        writer.WriteEndElement(); // tvshow
                    }
                }
            }
            catch (Exception e)
            {
                ErrorText = e.Message;
                LastError = e;
                Error     = true;
                Done      = true;
                return(false);
            }
            Done = true;
            return(true);
        }
Beispiel #36
0
 public ShowItem(TheTVDB db, int tvDBCode)
 {
     this.SetDefaults(db);
     this.TVDBCode = tvDBCode;
 }
Beispiel #37
0
    private static int Main(string[] args)
    {
        // Enabling Windows XP visual effects before any controls are created
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        
        // Sort out the command line arguments
        CommandLineArgs clargs = new CommandLineArgs(args);

        // see if we're already running
        bool createdNew = false;
        System.Threading.Mutex mutex = new System.Threading.Mutex(true, "TVRenameMutex", out createdNew);

        if (!createdNew)
        {
            // we're already running

            // tell the already running copy to come to the foreground
            IpcClientChannel clientChannel = new IpcClientChannel();
            ChannelServices.RegisterChannel(clientChannel, true);

            RemotingConfiguration.RegisterWellKnownClientType(typeof (IPCMethods), "ipc://TVRenameChannel/IPCMethods");

            IPCMethods ipc = new IPCMethods();

            // if we were already running, and no command line arguments, then bring application to the foreground
            // and we're done.
            if (args.Length == 0)
            {
                ipc.BringToForeground();
                return 0;
            }

            // Send command-line arguments to already running TVRename via IPC

            CommandLineArgs.MissingFolderBehaviour before = ipc.MissingBehaviour;
            bool renameBefore = ipc.RenameBehaviour;

            if (clargs.RenameCheck == false)
             {
              // Temporarily override behaviour for missing folders
              ipc.RenameBehaviour = false;
            }

            if (clargs.MissingFolder != CommandLineArgs.MissingFolderBehaviour.Ask)
            {
                // Temporarily override behaviour for missing folders
                ipc.MissingBehaviour = clargs.MissingFolder;
            }

            // TODO: Unify command line handling between here and in UI.cs (ProcessArgs).  Just send in clargs via IPC?

            if (clargs.Scan || clargs.DoAll) // doall implies scan
                ipc.Scan();

            if (clargs.DoAll)
                ipc.DoAll();

            if (clargs.Quit)
            {
                ipc.Quit();
                return 0;
            }

            ipc.RenameBehaviour = renameBefore;
            ipc.MissingBehaviour = before;

        return 0;
        }

#if !DEBUG
		try
		{
#endif

        // Starting TVRename...

        // Check arguments for forced recover
        bool ok = true;
        string recoverText = "";

        if (clargs.ForceRecover)
        {
            ok = false; // force recover dialog
            recoverText = "Recover manually requested.";
        }

        // Load settings files
        TVDoc doc = null;
        try
        {
            if (!string.IsNullOrEmpty(clargs.UserFilePath))
                PathManager.SetUserDefinedBasePath(clargs.UserFilePath);
        }
        catch (System.Exception ex)
        {
            MessageBox.Show("Error while setting the User-Defined File Path:" + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            Environment.Exit(1);
        }

        FileInfo tvdbFile = PathManager.TVDBFile;
        FileInfo settingsFile = PathManager.TVDocSettingsFile;

        do // loop until no problems loading settings & tvdb cache files
        {
            if (!ok) // something went wrong last time around, ask the user what to do
            {
                RecoverXML rec = new RecoverXML(recoverText);
                if (rec.ShowDialog() == DialogResult.OK)
                {
                    tvdbFile = rec.DBFile;
                    settingsFile = rec.SettingsFile;
                }
                else
                    return 1;
            }

            // try loading using current settings files, and set up the main
            // classes
            TheTVDB tvdb = new TheTVDB(tvdbFile, PathManager.TVDBFile, clargs);
            doc = new TVDoc(settingsFile, tvdb, clargs);

            if (!ok)
                doc.SetDirty();

            ok = doc.LoadOK;

            if (!ok)
            {
                recoverText = "";
                if (!doc.LoadOK && !String.IsNullOrEmpty(doc.LoadErr))
                    recoverText += doc.LoadErr;
                if (!tvdb.LoadOK && !String.IsNullOrEmpty(tvdb.LoadErr))
                    recoverText += "\r\n" + tvdb.LoadErr;
            }
        } while (!ok);

        // Show user interface
        UI theUI = new UI(doc);
        Application.Run(theUI);
        GC.KeepAlive(mutex);

#if !DEBUG
		}
		catch (Exception e)
		{
		  ShowException se = new ShowException(e);
		  se.ShowDialog();
		}
#endif

        return 0;
    }
Beispiel #38
0
 public ShowItem(TheTVDB db)
 {
     this.SetDefaults(db);
 }
Beispiel #39
0
        public ShowItem(TheTVDB db, XmlReader reader, TVSettings settings)
        {
            this.SetDefaults(db);

            reader.Read();
            if (reader.Name != "ShowItem")
            {
                return; // bail out
            }
            reader.Read();
            while (!reader.EOF)
            {
                if ((reader.Name == "ShowItem") && !reader.IsStartElement())
                {
                    break; // all done
                }
                if (reader.Name == "ShowName")
                {
                    this.CustomShowName    = reader.ReadElementContentAsString();
                    this.UseCustomShowName = true;
                }
                if (reader.Name == "UseCustomShowName")
                {
                    this.UseCustomShowName = reader.ReadElementContentAsBoolean();
                }
                if (reader.Name == "CustomShowName")
                {
                    this.CustomShowName = reader.ReadElementContentAsString();
                }
                else if (reader.Name == "TVDBID")
                {
                    this.TVDBCode = reader.ReadElementContentAsInt();
                }
                else if (reader.Name == "CountSpecials")
                {
                    this.CountSpecials = reader.ReadElementContentAsBoolean();
                }
                else if (reader.Name == "ShowNextAirdate")
                {
                    this.ShowNextAirdate = reader.ReadElementContentAsBoolean();
                }
                else if (reader.Name == "AutoAddNewSeasons")
                {
                    this.AutoAddNewSeasons = reader.ReadElementContentAsBoolean();
                }
                else if (reader.Name == "FolderBase")
                {
                    this.AutoAdd_FolderBase = reader.ReadElementContentAsString();
                }
                else if (reader.Name == "FolderPerSeason")
                {
                    this.AutoAdd_FolderPerSeason = reader.ReadElementContentAsBoolean();
                }
                else if (reader.Name == "SeasonFolderName")
                {
                    this.AutoAdd_SeasonFolderName = reader.ReadElementContentAsString();
                }
                else if (reader.Name == "DoRename")
                {
                    this.DoRename = reader.ReadElementContentAsBoolean();
                }
                else if (reader.Name == "DoMissingCheck")
                {
                    this.DoMissingCheck = reader.ReadElementContentAsBoolean();
                }
                else if (reader.Name == "DVDOrder")
                {
                    this.DVDOrder = reader.ReadElementContentAsBoolean();
                }
                else if (reader.Name == "CustomSearchURL")
                {
                    this.CustomSearchURL = reader.ReadElementContentAsString();
                }
                else if (reader.Name == "ForceCheckAll") // removed 2.2.0b2
                {
                    this.ForceCheckNoAirdate = this.ForceCheckFuture = reader.ReadElementContentAsBoolean();
                }
                else if (reader.Name == "ForceCheckFuture")
                {
                    this.ForceCheckFuture = reader.ReadElementContentAsBoolean();
                }
                else if (reader.Name == "ForceCheckNoAirdate")
                {
                    this.ForceCheckNoAirdate = reader.ReadElementContentAsBoolean();
                }
                else if (reader.Name == "PadSeasonToTwoDigits")
                {
                    this.PadSeasonToTwoDigits = reader.ReadElementContentAsBoolean();
                }
                else if (reader.Name == "UseSequentialMatch")
                {
                    this.UseSequentialMatch = reader.ReadElementContentAsBoolean();
                }
                else if (reader.Name == "IgnoreSeasons")
                {
                    if (!reader.IsEmptyElement)
                    {
                        reader.Read();
                        while (reader.Name != "IgnoreSeasons")
                        {
                            if (reader.Name == "Ignore")
                            {
                                this.IgnoreSeasons.Add(reader.ReadElementContentAsInt());
                            }
                            else
                            {
                                reader.ReadOuterXml();
                            }
                        }
                    }
                    reader.Read();
                }
                else if (reader.Name == "AliasNames")
                {
                    if (!reader.IsEmptyElement)
                    {
                        reader.Read();
                        while (reader.Name != "AliasNames")
                        {
                            if (reader.Name == "Alias")
                            {
                                this.AliasNames.Add(reader.ReadElementContentAsString());
                            }
                            else
                            {
                                reader.ReadOuterXml();
                            }
                        }
                    }
                    reader.Read();
                }
                else if (reader.Name == "Rules")
                {
                    if (!reader.IsEmptyElement)
                    {
                        int snum = int.Parse(reader.GetAttribute("SeasonNumber"));
                        this.SeasonRules[snum] = new List <ShowRule>();
                        reader.Read();
                        while (reader.Name != "Rules")
                        {
                            if (reader.Name == "Rule")
                            {
                                this.SeasonRules[snum].Add(new ShowRule(reader.ReadSubtree()));
                                reader.Read();
                            }
                        }
                    }
                    reader.Read();
                }
                else if (reader.Name == "SeasonFolders")
                {
                    if (!reader.IsEmptyElement)
                    {
                        int snum = int.Parse(reader.GetAttribute("SeasonNumber"));
                        this.ManualFolderLocations[snum] = new List <String>();
                        reader.Read();
                        while (reader.Name != "SeasonFolders")
                        {
                            if ((reader.Name == "Folder") && reader.IsStartElement())
                            {
                                string ff = reader.GetAttribute("Location");
                                if (this.AutoFolderNameForSeason(snum, settings) != ff)
                                {
                                    this.ManualFolderLocations[snum].Add(ff);
                                }
                            }
                            reader.Read();
                        }
                    }
                    reader.Read();
                }

                else
                {
                    reader.ReadOuterXml();
                }
            } // while
        }