Пример #1
0
        public override ItemList ProcessSeason(ShowItem si, string folder, int snum, bool forceRefresh)
        {
            if (TVSettings.Instance.FolderJpg)
            {
                // season folders JPGs

                ItemList TheActionList = new ItemList();
                FileInfo fi = FileHelper.FileInFolder(folder, defaultFileName);
                if (!doneFolderJPG.Contains(fi.FullName) && (!fi.Exists|| forceRefresh))
                // some folders may come up multiple times
                {

                    string bannerPath = "";

                    if (TVSettings.Instance.SeasonSpecificFolderJPG())
                    {
                        //We are getting a Series Level image
                        bannerPath = si.TheSeries().GetSeasonBannerPath(snum);
                    }
                    else
                    {
                        //We are getting a Show Level image
                        bannerPath = si.TheSeries().GetItem(TVSettings.Instance.ItemForFolderJpg());
                    }
                    if (!string.IsNullOrEmpty(bannerPath))
                        TheActionList.Add(new ActionDownload(si, null, fi, bannerPath,
                                                                  TVSettings.Instance.ShrinkLargeMede8erImages));
                    doneFolderJPG.Add(fi.FullName);
                }
                return TheActionList;
            }

            
            return base.ProcessSeason(si,folder,snum,forceRefresh);
        }
Пример #2
0
        private static void AppendShow(this StringBuilder sb, ShowItem si, Color backgroundColour)
        {
            if (si == null)
            {
                return;
            }

            SeriesInfo ser = si.TheSeries();
            string     horizontalBanner = CreateHorizontalBannerHtml(ser);
            string     poster           = CreatePosterHtml(ser);
            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            = StarRating(si.TheSeries().GetSiteRating());
            string     genreIcons       = string.Join(" ", si.TheSeries().GetGenres().Select(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" : "";
            string     runTimeHtml      = string.IsNullOrWhiteSpace(ser.GetRuntime()) ? string.Empty : $"<br/> {ser.GetRuntime()} min";
            string     actorLinks       = string.Join(", ", si.TheSeries().GetActors().Select(ActorLinkHtml));
            string     tvdbLink         = TheTVDB.Instance.WebsiteUrl(si.TvdbCode, -1, true);
            string     airsTime         = ParseAirsTime(ser);
            string     airsDay          = ser.GetAirsDay();
            string     dayTime          = $"{airsDay} {airsTime}";

            string tvLink   = string.IsNullOrWhiteSpace(ser.GetSeriesId()) ? string.Empty : "http://www.tv.com/show/" + ser.GetSeriesId() + "/summary.html";
            string imdbLink = string.IsNullOrWhiteSpace(ser.GetImdb()) ? string.Empty : "http://www.imdb.com/title/" + ser.GetImdb();

            string urlFilename    = HttpUtility.UrlEncode(si.GetBestFolderLocationToOpen());
            string explorerButton = CreateButton($"{UI.EXPLORE_PROXY}{urlFilename}", "<i class=\"far fa-folder-open\"></i>", "Open Containing Folder");

            sb.AppendLine($@"<div class=""card card-body"" style=""background-color:{backgroundColour.HexColour()}"">
                <div class=""text-center"">
	             {horizontalBanner}
                  <div class=""row"">
                   <div class=""col-md-4"">
                    {poster}
                   </div>
                   <div class=""col-md-8 d-flex flex-column"">
                    <div class=""row"">
                     <div class=""col-md-8""><h1>{ser.Name}</h1></div>
                     <div class=""col-md-4 text-right""><h6>{yearRange} ({si.TheSeries().GetStatus()})</h6><small class=""text-muted"">{episodeSummary} Episodes{runTimeHtml}</small></div>
                    </div>
                    <div><p class=""lead"">{ser.GetOverview()}</p></div>
			        <div><blockquote>{actorLinks}</blockquote></div> 
		            <div>
                     {explorerButton}
			         {CreateButton(tvdbLink, "TVDB.com", "View on TVDB")}
			         {CreateButton(imdbLink, "IMDB.com", "View on IMDB")}
			         {CreateButton(tvLink, "TV.com", "View on TV.com")}
			        </div>
		            <div class=""row align-items-bottom flex-grow-1"">
                     <div class=""col-md-4 align-self-end"">{stars}<br>{siteRating}{AddRatingCount(ser.GetSiteRatingVotes())}</div>
                     <div class=""col-md-4 align-self-end text-center"">{si.TheSeries().GetContentRating()}<br>{si.TheSeries().GetNetwork()}, {dayTime}</div>
                     <div class=""col-md-4 align-self-end text-right"">{genreIcons}<br>{string.Join(", ", si.TheSeries().GetGenres())}</div>
                    </div>
                   </div>
                  </div>
                 </div>");
        }
Пример #3
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            if (!TVSettings.Instance.FolderJpg)
            {
                return(null);
            }

            ItemList theActionList   = new ItemList();
            FileInfo fi              = FileHelper.FileInFolder(si.AutoAddFolderBase, DEFAULT_FILE_NAME);
            bool     fileDoesntExist = !doneFolderJpg.Contains(fi.FullName) && !fi.Exists;

            if (forceRefresh || fileDoesntExist)
            {
                string downloadPath;

                if (TVSettings.Instance.SeasonSpecificFolderJPG())
                {
                    //default to poster when we want season posters for the season specific folders;
                    downloadPath = si.TheSeries().GetSeriesPosterPath();
                }
                else
                {
                    downloadPath = si.TheSeries().GetImage(TVSettings.Instance.ItemForFolderJpg());
                }

                if (!string.IsNullOrEmpty(downloadPath))
                {
                    theActionList.Add(new ActionDownloadImage(si, null, fi, downloadPath, false));
                }
                doneFolderJpg.Add(fi.FullName);
            }
            return(theActionList);
        }
Пример #4
0
        public override ItemList ProcessSeason(ShowItem si, string folder, int snum, bool forceRefresh)
        {
            if (!TVSettings.Instance.FolderJpg)
            {
                return(null);
            }

            // season folders JPGs
            ItemList theActionList = new ItemList();
            FileInfo fi            = FileHelper.FileInFolder(folder, DEFAULT_FILE_NAME);

            if (!doneFolderJpg.Contains(fi.FullName) && (!fi.Exists || forceRefresh))
            // some folders may come up multiple times
            {
                string bannerPath;

                if (TVSettings.Instance.SeasonSpecificFolderJPG())
                {
                    //We are getting a Series Level image
                    bannerPath = si.TheSeries().GetSeasonBannerPath(snum);
                }
                else
                {
                    //We are getting a Show Level image
                    bannerPath = si.TheSeries().GetImage(TVSettings.Instance.ItemForFolderJpg());
                }
                if (!string.IsNullOrEmpty(bannerPath))
                {
                    theActionList.Add(new ActionDownloadImage(si, null, fi, bannerPath,
                                                              TVSettings.Instance.ShrinkLargeMede8erImages));
                }
                doneFolderJpg.Add(fi.FullName);
            }
            return(theActionList);
        }
Пример #5
0
        public static string GetSeasonImagesHtmlOverview([NotNull] this ShowItem si, [NotNull] Season s)
        {
            int    snum = s.SeasonNumber;
            string body = "";

            List <ProcessedEpisode> eis = si.SeasonEpisodes[snum];

            string seasText = Season.UIFullSeasonWord(snum);

            if (eis.Count > 0 && eis[0].SeasonId > 0)
            {
                seasText = " - <A HREF=\"" + TheTVDB.API.WebsiteSeasonUrl(s) + "\">" + seasText + "</a>";
            }
            else
            {
                seasText = " - " + seasText;
            }

            body += "<h1><A HREF=\"" + TheTVDB.API.WebsiteShowUrl(si) + "\">" + si.ShowName +
                    "</A>" + seasText + "</h1>";

            if (TVSettings.Instance.NeedToDownloadBannerFile())
            {
                body += ImageSection("Series Banner", 758, 140, si.TheSeries()?.GetSeasonWideBannerPath(snum));
                body += ImageSection("Series Poster", 350, 500, si.TheSeries()?.GetSeasonBannerPath(snum));
            }
            else
            {
                body +=
                    "<h2>Images are not being downloaded for this series. Please see Options -> Preferences -> Media Center to reconfigure.</h2>";
            }

            return(body);
        }
Пример #6
0
        public override ItemList ProcessSeason(ShowItem si, string folder, int snum, bool forceRefresh)
        {
            if (TVSettings.Instance.KODIImages)
            {
                ItemList theActionList = new ItemList();
                //If we have KODI New style images being downloaded then we want to check that 3 files exist
                //for the series:
                //http://wiki.xbmc.org/index.php?title=XBMC_v12_(Frodo)_FAQ#Local_images
                //poster
                //banner
                //fanart - we do not have the option in TVDB to get season specific fanart, so we'll leave that

                string filenamePrefix = "";

                if (si.InOneFolder())
                {   // We have multiple seasons in the same folder
                    // We need to do slightly more work to come up with the filenamePrefix

                    filenamePrefix = "season";

                    if (snum == 0)
                    {
                        filenamePrefix += "-specials";
                    }
                    else if (snum < 10)
                    {
                        filenamePrefix += "0" + snum;
                    }
                    else
                    {
                        filenamePrefix += snum;
                    }

                    filenamePrefix += "-";
                }
                FileInfo posterJpg = FileHelper.FileInFolder(folder, filenamePrefix + "poster.jpg");
                if (forceRefresh || !posterJpg.Exists)
                {
                    string path = si.TheSeries()?.GetSeasonBannerPath(snum);
                    if (!string.IsNullOrEmpty(path))
                    {
                        theActionList.Add(new ActionDownloadImage(si, null, posterJpg, path));
                    }
                }

                FileInfo bannerJpg = FileHelper.FileInFolder(folder, filenamePrefix + "banner.jpg");
                if (forceRefresh || !bannerJpg.Exists)
                {
                    string path = si.TheSeries()?.GetSeasonWideBannerPath(snum);
                    if (!string.IsNullOrEmpty(path))
                    {
                        theActionList.Add(new ActionDownloadImage(si, null, bannerJpg, path));
                    }
                }
                return(theActionList);
            }
            return(base.ProcessSeason(si, folder, snum, forceRefresh));
        }
Пример #7
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            //If we have XBMC New style images being downloaded then we want to check that 3 files exist
            //for the series:
            //http://wiki.xbmc.org/index.php?title=XBMC_v12_(Frodo)_FAQ#Local_images
            //poster
            //banner
            //fanart

            if (TVSettings.Instance.XBMCImages)
            {
                ItemList TheActionList = new ItemList();
                // base folder:
                if (!string.IsNullOrEmpty(si.AutoAdd_FolderBase) && (si.AllFolderLocations(false).Count > 0))
                {
                    FileInfo posterJPG = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "poster.jpg");
                    FileInfo bannerJPG = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "banner.jpg");
                    FileInfo fanartJPG = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "fanart.jpg");

                    if ((forceRefresh || (!posterJPG.Exists)) && (!donePosterJPG.Contains(si.AutoAdd_FolderBase)))
                    {
                        string path = si.TheSeries().GetItem("poster");
                        if (!string.IsNullOrEmpty(path))
                        {
                            TheActionList.Add(new ActionDownload(si, null, posterJPG, path, false));
                            donePosterJPG.Add(si.AutoAdd_FolderBase);
                        }
                    }

                    if ((forceRefresh || (!bannerJPG.Exists)) && (!doneBannerJPG.Contains(si.AutoAdd_FolderBase)))
                    {
                        string path = si.TheSeries().GetItem("banner");
                        if (!string.IsNullOrEmpty(path))
                        {
                            TheActionList.Add(new ActionDownload(si, null, bannerJPG, path, false));
                            doneBannerJPG.Add(si.AutoAdd_FolderBase);
                        }
                    }

                    if ((forceRefresh || (!fanartJPG.Exists)) && (!doneFanartJPG.Contains(si.AutoAdd_FolderBase)))
                    {
                        string path = si.TheSeries().GetItem("fanart");
                        if (!string.IsNullOrEmpty(path))
                        {
                            TheActionList.Add(new ActionDownload(si, null, fanartJPG, path));
                            doneFanartJPG.Add(si.AutoAdd_FolderBase);
                        }
                    }
                }
                return TheActionList;
            }

            return base.ProcessShow(si, forceRefresh);
        }
Пример #8
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            //If we have KODI New style images being downloaded then we want to check that 3 files exist
            //for the series:
            //http://wiki.xbmc.org/index.php?title=XBMC_v12_(Frodo)_FAQ#Local_images
            //poster
            //banner
            //fanart

            if (TVSettings.Instance.KODIImages)
            {
                ItemList TheActionList = new ItemList();
                // base folder:
                if (!string.IsNullOrEmpty(si.AutoAdd_FolderBase) && (si.AllFolderLocations(false).Count > 0))
                {
                    FileInfo posterJPG = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "poster.jpg");
                    FileInfo bannerJPG = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "banner.jpg");
                    FileInfo fanartJPG = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "fanart.jpg");

                    if ((forceRefresh || (!posterJPG.Exists)) && (!donePosterJPG.Contains(si.AutoAdd_FolderBase)))
                    {
                        string path = si.TheSeries().GetSeriesPosterPath();
                        if (!string.IsNullOrEmpty(path))
                        {
                            TheActionList.Add(new ActionDownload(si, null, posterJPG, path, false));
                            donePosterJPG.Add(si.AutoAdd_FolderBase);
                        }
                    }

                    if ((forceRefresh || (!bannerJPG.Exists)) && (!doneBannerJPG.Contains(si.AutoAdd_FolderBase)))
                    {
                        string path = si.TheSeries().GetSeriesWideBannerPath();
                        if (!string.IsNullOrEmpty(path))
                        {
                            TheActionList.Add(new ActionDownload(si, null, bannerJPG, path, false));
                            doneBannerJPG.Add(si.AutoAdd_FolderBase);
                        }
                    }

                    if ((forceRefresh || (!fanartJPG.Exists)) && (!doneFanartJPG.Contains(si.AutoAdd_FolderBase)))
                    {
                        string path = si.TheSeries().GetSeriesFanartPath();
                        if (!string.IsNullOrEmpty(path))
                        {
                            TheActionList.Add(new ActionDownload(si, null, fanartJPG, path));
                            doneFanartJPG.Add(si.AutoAdd_FolderBase);
                        }
                    }
                }
                return(TheActionList);
            }

            return(base.ProcessShow(si, forceRefresh));
        }
Пример #9
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            

            if (TVSettings.Instance.FolderJpg)
            {
                ItemList TheActionList = new ItemList();
                FileInfo fi = FileHelper.FileInFolder(si.AutoAdd_FolderBase, defaultFileName);
                bool fileDoesntExist = !doneFolderJPG.Contains(fi.FullName) && !fi.Exists;

                if (forceRefresh || fileDoesntExist)
                {
                    //default to poster when we want season posters for the season specific folders;
                    string itemToGet = (TVSettings.Instance.SeasonSpecificFolderJPG()) ? "poster" : TVSettings.Instance.ItemForFolderJpg();

                    string bannerPath = bannerPath = si.TheSeries().GetItem(itemToGet);

                    if (!string.IsNullOrEmpty(bannerPath))
                        TheActionList.Add(new ActionDownload(si, null, fi, bannerPath, false));
                    doneFolderJPG.Add(fi.FullName);
                }
                return TheActionList;

            }
            return null;
        }
Пример #10
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            // for each tv show, optionally write a tvshow.nfo file
            if (TVSettings.Instance.NFOs)
            {
                ItemList TheActionList = new ItemList();
                FileInfo tvshownfo = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "tvshow.nfo");

                bool needUpdate = !tvshownfo.Exists ||
                                  (si.TheSeries().Srv_LastUpdated > TimeZone.Epoch(tvshownfo.LastWriteTime)) ||
                    // was it written before we fixed the bug in <episodeguideurl> ?
                                  (tvshownfo.LastWriteTime.ToUniversalTime().CompareTo(new DateTime(2009, 9, 13, 7, 30, 0, 0, DateTimeKind.Utc)) < 0);

                bool alreadyOnTheList = DownloadXBMCMetaData.doneNFO.Contains(tvshownfo.FullName);

                if ((forceRefresh || needUpdate) && !alreadyOnTheList)
                {
                    TheActionList.Add(new ActionNFO(tvshownfo, si));
                    DownloadXBMCMetaData.doneNFO.Add(tvshownfo.FullName);
                }
                return TheActionList;

            }
            return base.ProcessShow(si, forceRefresh);
        }
Пример #11
0
        public override ItemList ProcessShow([NotNull] ShowItem si, bool forceRefresh)
        {
            DateTime?updateTime = si.TheSeries()?.LastAiredDate;

            if (!TVSettings.Instance.CorrectFileDates || !updateTime.HasValue)
            {
                return(null);
            }

            DateTime newUpdateTime = Helpers.GetMinWindowsTime(updateTime.Value);

            DirectoryInfo di = new DirectoryInfo(si.AutoAddFolderBase);

            try
            {
                if ((di.LastWriteTimeUtc != newUpdateTime) && (!doneFilesAndFolders.Contains(di.FullName)))
                {
                    doneFilesAndFolders.Add(di.FullName);
                    return(new ItemList()
                    {
                        new ActionDateTouch(di, si, newUpdateTime)
                    });
                }
            }
            catch (Exception)
            {
                doneFilesAndFolders.Add(di.FullName);
                return(new ItemList()
                {
                    new ActionDateTouch(di, si, newUpdateTime)
                });
            }
            return(null);
        }
Пример #12
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            if (TVSettings.Instance.Mede8erXML)
            {
                ItemList theActionList = new ItemList();

                FileInfo tvshowxml = FileHelper.FileInFolder(si.AutoAddFolderBase, "series.xml");

                SeriesInfo seriesInfo = si.TheSeries();
                bool       needUpdate = !tvshowxml.Exists ||
                                        seriesInfo is null ||
                                        seriesInfo.SrvLastUpdated > TimeZoneHelper.Epoch(tvshowxml.LastWriteTime);

                if ((forceRefresh || needUpdate) && !doneFiles.Contains(tvshowxml.FullName))
                {
                    doneFiles.Add(tvshowxml.FullName);
                    theActionList.Add(new ActionMede8erXML(tvshowxml, si));
                }

                //Updates requested by [email protected] on 18/4/2013
                FileInfo viewxml = FileHelper.FileInFolder(si.AutoAddFolderBase, "View.xml");
                if (!viewxml.Exists && !doneFiles.Contains(viewxml.FullName))
                {
                    doneFiles.Add(viewxml.FullName);
                    theActionList.Add(new ActionMede8erViewXML(viewxml, si));
                }

                return(theActionList);
            }

            return(base.ProcessShow(si, forceRefresh));
        }
Пример #13
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            if (TVSettings.Instance.Mede8erXML)
            {
                ItemList TheActionList = new ItemList();

                FileInfo tvshowxml = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "series.xml");

                bool needUpdate = !tvshowxml.Exists ||
                                  (si.TheSeries().Srv_LastUpdated > TimeZone.Epoch(tvshowxml.LastWriteTime));

                if (forceRefresh || needUpdate)
                {
                    TheActionList.Add(new ActionMede8erXML(tvshowxml, si));
                }

                //Updates requested by [email protected] on 18/4/2013
                FileInfo viewxml = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "view.xml");
                if (!viewxml.Exists)
                {
                    TheActionList.Add(new ActionMede8erViewXML(viewxml, si));
                }


                return(TheActionList);
            }

            return(base.ProcessShow(si, forceRefresh));
        }
Пример #14
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            if (TVSettings.Instance.FolderJpg)
            {
                ItemList TheActionList   = new ItemList();
                FileInfo fi              = FileHelper.FileInFolder(si.AutoAdd_FolderBase, defaultFileName);
                bool     fileDoesntExist = !doneFolderJPG.Contains(fi.FullName) && !fi.Exists;

                if (forceRefresh || fileDoesntExist)
                {
                    //default to poster when we want season posters for the season specific folders;
                    string itemToGet = (TVSettings.Instance.SeasonSpecificFolderJPG()) ? "poster" : TVSettings.Instance.ItemForFolderJpg();

                    string bannerPath = bannerPath = si.TheSeries().GetItem(itemToGet);

                    if (!string.IsNullOrEmpty(bannerPath))
                    {
                        TheActionList.Add(new ActionDownload(si, null, fi, bannerPath, false));
                    }
                    doneFolderJPG.Add(fi.FullName);
                }
                return(TheActionList);
            }
            return(null);
        }
Пример #15
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("&nbsp;", 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>");
        }
Пример #16
0
        private string GetTargetEpisodeName([NotNull] ShowItem show, [NotNull] Episode ep, bool urlEncode)
        {
            //note this is for an Episode and not a ProcessedEpisode
            string name = StyleString;

            string epname = ep.Name;

            name = name.ReplaceInsensitive("{ShowName}", show.ShowName);
            switch (show.Order)
            {
            case Season.SeasonType.dvd:
                name = name.ReplaceInsensitive("{Season}", ep.DvdSeasonNumber.ToString());
                name = name.ReplaceInsensitive("{Season:2}", ep.DvdSeasonNumber.ToString("00"));
                name = name.ReplaceInsensitive("{SeasonNumber}", show.GetSeasonIndex(ep.DvdSeasonNumber).ToString());
                name = name.ReplaceInsensitive("{SeasonNumber:2}", show.GetSeasonIndex(ep.DvdSeasonNumber).ToString("00"));
                name = name.ReplaceInsensitive("{Episode}", ep.DvdEpNum.ToString("00"));
                name = name.ReplaceInsensitive("{Episode2}", ep.DvdEpNum.ToString("00"));
                name = Regex.Replace(name, "{AllEpisodes}", ep.DvdEpNum.ToString("00")); break;

            case Season.SeasonType.aired:
                name = name.ReplaceInsensitive("{Season}", ep.AiredSeasonNumber.ToString());
                name = name.ReplaceInsensitive("{Season:2}", ep.AiredSeasonNumber.ToString("00"));
                name = name.ReplaceInsensitive("{SeasonNumber}", show.GetSeasonIndex(ep.AiredSeasonNumber).ToString());
                name = name.ReplaceInsensitive("{SeasonNumber:2}", show.GetSeasonIndex(ep.AiredSeasonNumber).ToString("00"));
                name = name.ReplaceInsensitive("{Episode}", ep.AiredEpNum.ToString("00"));
                name = name.ReplaceInsensitive("{Episode2}", ep.AiredEpNum.ToString("00"));
                name = Regex.Replace(name, "{AllEpisodes}", ep.AiredEpNum.ToString("00"));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            name = name.ReplaceInsensitive("{EpisodeName}", epname);
            name = name.ReplaceInsensitive("{Number}", "");
            name = name.ReplaceInsensitive("{Number:2}", "");
            name = name.ReplaceInsensitive("{Number:3}", "");
            name = name.ReplaceInsensitive("{Imdb}", ep.ImdbCode);

            SeriesInfo si = show.TheSeries();

            name = name.ReplaceInsensitive("{ShowImdb}", si?.Imdb ?? string.Empty);
            name = name.ReplaceInsensitive("{Year}", si?.MinYear.ToString() ?? string.Empty);

            Season selectedSeason = show.GetSeason(ep.GetSeasonNumber(show.Order));

            name = name.ReplaceInsensitive("{SeasonYear}", selectedSeason != null ? selectedSeason.MinYear().ToString() : string.Empty);

            name = ReplaceDates(urlEncode, name, ep.GetAirDateDt(show.GetTimeZone()));

            name = Regex.Replace(name, "([^\\\\])\\[.*?[^\\\\]\\]", "$1"); // remove optional parts

            name = name.Replace("\\[", "[");
            name = name.Replace("\\]", "]");

            return(name.Trim());
        }
Пример #17
0
        public Boolean filter(ShowItem show)
        {
            //Filter on show name
            Boolean isNameOK = (ShowName == null) || show.ShowName.Contains(ShowName, StringComparison.OrdinalIgnoreCase);

            //Filter on show status
            Boolean isStatusOK = (ShowStatus == null) || show.ShowStatus.Equals(ShowStatus);

            //Filter on show network
            Boolean isNetworkOK = (ShowNetwork == null) || (show.TheSeries() == null) || show.TheSeries().getNetwork().Equals(ShowNetwork);

            //Filter on show rating
            Boolean isRatingOK = (ShowRating == null) || (show.TheSeries() == null) || show.TheSeries().GetContentRating().Equals(ShowRating);

            //Filter on show genres
            Boolean areGenresIgnored = (Genres.Count == 0);

            Boolean doAnyGenresMatch = false; //assume false

            if (!areGenresIgnored)
            {
                if (show.Genres == null)
                {
                    doAnyGenresMatch = false;
                }
                else
                {
                    foreach (String showGenre in show.Genres)
                    {
                        foreach (String filterGenre in this.Genres)
                        {
                            if (showGenre == filterGenre)
                            {
                                doAnyGenresMatch = true;
                            }
                        }
                    }
                }
            }

            return(isNameOK && isStatusOK && isNetworkOK && isRatingOK && (areGenresIgnored || doAnyGenresMatch));
        }
Пример #18
0
        public bool Filter(ShowItem show)
        {
            //Filter on show name
            bool isNameOk = (ShowName == null) || show.ShowName.Contains(ShowName, StringComparison.OrdinalIgnoreCase);

            //Filter on show status
            bool isStatusOk = (ShowStatus == null) || show.ShowStatus.Equals(ShowStatus);

            //Filter on show network
            bool isNetworkOk = (ShowNetwork == null) || (show.TheSeries() == null) || show.TheSeries().GetNetwork().Equals(ShowNetwork);

            //Filter on show rating
            bool isRatingOk = (ShowRating == null) || (show.TheSeries() == null) || show.TheSeries().GetContentRating().Equals(ShowRating);

            //Filter on show genres
            bool areGenresIgnored = (Genres.Count == 0);
            bool doAnyGenresMatch = FindMatchingGenres(show);

            return(isNameOk && isStatusOk && isNetworkOk && isRatingOk && (areGenresIgnored || doAnyGenresMatch));
        }
Пример #19
0
        public static string GetShowImagesHtmlOverview(this ShowItem si)
        {
            SeriesInfo ser = si.TheSeries();

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

            body += ImageSection("Show Banner", 758, 140, ser.GetSeriesWideBannerPath());
            body += ImageSection("Show Poster", 350, 500, ser.GetSeriesPosterPath());
            body += ImageSection("Show Fanart", 960, 540, ser.GetSeriesFanartPath());
            return(body);
        }
Пример #20
0
        private string GetTargetEpisodeName([NotNull] ShowItem show, [NotNull] Episode ep, DateTimeZone tz, bool dvdOrder, bool urlEncode)
        {
            //note this is for an Episode and not a ProcessedEpisode
            string name = StyleString;

            string epname = ep.Name;

            name = name.ReplaceInsensitive("{ShowName}", show.ShowName);
            if (dvdOrder)
            {
                name = name.ReplaceInsensitive("{Season}", ep.DvdSeasonNumber.ToString());
                name = name.ReplaceInsensitive("{Season:2}", ep.DvdSeasonNumber.ToString("00"));
                name = name.ReplaceInsensitive("{SeasonNumber}", ep.DvdSeasonIndex.ToString());
                name = name.ReplaceInsensitive("{SeasonNumber:2}", ep.DvdSeasonIndex.ToString("00"));
                name = name.ReplaceInsensitive("{Episode}", ep.DvdEpNum.ToString("00"));
                name = name.ReplaceInsensitive("{Episode2}", ep.DvdEpNum.ToString("00"));
                name = Regex.Replace(name, "{AllEpisodes}", ep.DvdEpNum.ToString("00"));
            }
            else
            {
                name = name.ReplaceInsensitive("{Season}", ep.AiredSeasonNumber.ToString());
                name = name.ReplaceInsensitive("{Season:2}", ep.AiredSeasonNumber.ToString("00"));
                name = name.ReplaceInsensitive("{SeasonNumber}", ep.AiredSeasonIndex.ToString());
                name = name.ReplaceInsensitive("{SeasonNumber:2}", ep.AiredSeasonIndex.ToString("00"));
                name = name.ReplaceInsensitive("{Episode}", ep.AiredEpNum.ToString("00"));
                name = name.ReplaceInsensitive("{Episode2}", ep.AiredEpNum.ToString("00"));
                name = Regex.Replace(name, "{AllEpisodes}", ep.AiredEpNum.ToString("00"));
            }
            name = name.ReplaceInsensitive("{EpisodeName}", epname);
            name = name.ReplaceInsensitive("{Number}", "");
            name = name.ReplaceInsensitive("{Number:2}", "");
            name = name.ReplaceInsensitive("{Number:3}", "");
            name = name.ReplaceInsensitive("{Imdb}", ep.ImdbCode);

            SeriesInfo si = show.TheSeries();

            name = name.ReplaceInsensitive("{ShowImdb}", si?.Imdb ?? string.Empty);
            name = name.ReplaceInsensitive("{Year}", si?.MinYear.ToString() ?? string.Empty);

            Season selectedSeason = show.GetSeason(dvdOrder ? ep.DvdSeasonNumber : ep.AiredSeasonNumber);

            name = name.ReplaceInsensitive("{SeasonYear}", selectedSeason != null ? selectedSeason.MinYear().ToString() : string.Empty);

            name = ReplaceDates(urlEncode, name, ep.GetAirDateDt(tz));

            name = Regex.Replace(name, "([^\\\\])\\[.*?[^\\\\]\\]", "$1"); // remove optional parts

            name = name.Replace("\\[", "[");
            name = name.Replace("\\]", "]");

            return(name.Trim());
        }
Пример #21
0
        private static void WriteInfo(XmlWriter writer, ShowItem si, string whichItem, string elemName, string attribute, string attributeVal)
        {
            string t = si.TheSeries().GetItem(whichItem);

            if (!string.IsNullOrEmpty(t))
            {
                writer.WriteStartElement(elemName);
                if (!String.IsNullOrEmpty(attribute) && !String.IsNullOrEmpty(attributeVal))
                {
                    writer.WriteAttributeString(attribute, attributeVal);
                }
                writer.WriteValue(t);
                writer.WriteEndElement();
            }
        }
Пример #22
0
 public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
 {
     if (TVSettings.Instance.wdLiveTvMeta)
     {
         ItemList theActionList = new ItemList();
         FileInfo tvshowxml     = FileHelper.FileInFolder(si.AutoAddFolderBase, "series.xml");
         bool     needUpdate    = !tvshowxml.Exists ||
                                  (si.TheSeries().SrvLastUpdated > TimeZone.Epoch(tvshowxml.LastWriteTime));
         if ((forceRefresh || needUpdate) && (!doneFiles.Contains(tvshowxml.FullName)))
         {
             doneFiles.Add(tvshowxml.FullName);
             theActionList.Add(new ActionWdtvMeta(tvshowxml, si));
         }
         return(theActionList);
     }
     return(base.ProcessShow(si, forceRefresh));
 }
Пример #23
0
        public static string GetShowImagesHtmlOverview([NotNull] this ShowItem si)
        {
            string body =
                $"<h1><A HREF=\"{TheTVDB.API.WebsiteShowUrl(si)}\">{si.ShowName}</A> </h1>";

            SeriesInfo ser = si.TheSeries();

            if (ser is null)
            {
                return(body);
            }

            body += ImageSection("Show Banner", 758, 140, ser.GetSeriesWideBannerPath());
            body += ImageSection("Show Poster", 350, 500, ser.GetSeriesPosterPath());
            body += ImageSection("Show Fanart", 960, 540, ser.GetSeriesFanartPath());
            return(body);
        }
Пример #24
0
        public override ItemList ProcessSeason(ShowItem si, string folder, int snum, bool forceRefresh)
        {
            DateTime?newUpdateTime = si.TheSeries().Seasons[snum].LastAiredDate();

            if (TVSettings.Instance.CorrectFileDates && newUpdateTime.HasValue)
            {
                DirectoryInfo di = new DirectoryInfo(folder);
                if ((di.LastWriteTimeUtc != newUpdateTime.Value) && (!this.doneFilesAndFolders.Contains(di.FullName)))
                {
                    this.doneFilesAndFolders.Add(di.FullName);
                    return(new ItemList()
                    {
                        new ItemDateTouch(di, si, newUpdateTime.Value)
                    });
                }
            }
            return(null);
        }
Пример #25
0
        public static bool EpisodeNeeded([NotNull] ShowItem si, DirFilesCache dfc, int seasF, int epF,
                                         [NotNull] FileSystemInfo fi)
        {
            if (si is null)
            {
                throw new ArgumentNullException(nameof(si));
            }

            if (fi is null)
            {
                throw new ArgumentNullException(nameof(fi));
            }

            try
            {
                SeriesInfo s = si.TheSeries();
                if (s is null)
                {
                    //We have not downloaded the series, so have to assume that we need the episode/file
                    return(true);
                }

                Episode          ep  = s.GetEpisode(seasF, epF, si.DvdOrder);
                ProcessedEpisode pep = new ProcessedEpisode(ep, si);

                foreach (FileInfo testFileInfo in FindEpOnDisk(dfc, si, pep))
                {
                    //We will check that the file that is found is not the one we are testing
                    if (fi.FullName == testFileInfo.FullName)
                    {
                        continue;
                    }

                    //We have found another file that matches
                    return(false);
                }
            }
            catch (SeriesInfo.EpisodeNotFoundException)
            {
                //Ignore exception, we may need the file
                return(true);
            }
            return(true);
        }
Пример #26
0
        private static Action SetupDirectoryRemoval([NotNull] DirectoryInfo di, [NotNull] IReadOnlyList <ShowItem> matchingShows)
        {
            ShowItem si = matchingShows[0]; //Choose the first series

            FinderHelper.FindSeasEp(di, out int seasF, out int epF, si, out TVSettings.FilenameProcessorRE _);
            SeriesInfo s = si.TheSeries();

            if (s is null)
            {
                throw new ArgumentNullException(nameof(s));
            }

            ProcessedEpisode pep = si.GetEpisode(seasF, epF);

            LOGGER.Info(
                $"Removing {di.FullName} as it matches {matchingShows[0].ShowName} and no episodes are needed");

            return(new ActionDeleteDirectory(di, pep, TVSettings.Instance.Tidyup));
        }
Пример #27
0
        public override ItemList ProcessSeason(ShowItem si, string folder, int snum, bool forceRefresh)
        {
            if (TVSettings.Instance.SeriesJpg)
            {
                ItemList TheActionList = new ItemList();
                FileInfo fi = FileHelper.FileInFolder(folder, defaultFileName);
                if (forceRefresh ||(!doneJPG.Contains(fi.FullName) && !fi.Exists))
                {
                    string bannerPath = si.TheSeries().GetSeasonBannerPath(snum);
                    if (!string.IsNullOrEmpty(bannerPath))
                        TheActionList.Add(new ActionDownload(si, null, fi, bannerPath, TVSettings.Instance.ShrinkLargeMede8erImages));
                    doneJPG.Add(fi.FullName);
                }
                return TheActionList;
            }


            return base.ProcessSeason(si, folder, snum, forceRefresh);
        }
Пример #28
0
        public override ItemList ProcessSeason(ShowItem si, string folder, int snum, bool forceRefresh)
        {
            if (TVSettings.Instance.SeriesJpg)
            {
                ItemList TheActionList = new ItemList();
                FileInfo fi            = FileHelper.FileInFolder(folder, defaultFileName);
                if (forceRefresh || (!doneJPG.Contains(fi.FullName) && !fi.Exists))
                {
                    string bannerPath = si.TheSeries().GetSeasonBannerPath(snum);
                    if (!string.IsNullOrEmpty(bannerPath))
                    {
                        TheActionList.Add(new ActionDownload(si, null, fi, bannerPath, TVSettings.Instance.ShrinkLargeMede8erImages));
                    }
                    doneJPG.Add(fi.FullName);
                }
                return(TheActionList);
            }


            return(base.ProcessSeason(si, folder, snum, forceRefresh));
        }
Пример #29
0
        public override ItemList ProcessSeason(ShowItem si, string folder, int snum, bool forceRefresh)
        {
            if (!TVSettings.Instance.SeriesJpg)
            {
                return(null);
            }

            ItemList theActionList = new ItemList();
            FileInfo fi            = FileHelper.FileInFolder(folder, DEFAULT_FILE_NAME);

            if (forceRefresh || (!doneJpg.Contains(fi.FullName) && !fi.Exists))
            {
                string bannerPath = si.TheSeries().GetSeasonBannerPath(snum);
                if (!string.IsNullOrEmpty(bannerPath))
                {
                    theActionList.Add(new ActionDownloadImage(si, null, fi, bannerPath, TVSettings.Instance.ShrinkLargeMede8erImages));
                }
                doneJpg.Add(fi.FullName);
            }
            return(theActionList);
        }
Пример #30
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            //We only want to do something if the fanart option is enabled. If the XBMC option is enabled then let it do the work.
            if ((TVSettings.Instance.FanArtJpg) && !TVSettings.Instance.XBMCImages)
            {
                ItemList TheActionList = new ItemList();
                FileInfo fi = FileHelper.FileInFolder(si.AutoAdd_FolderBase, defaultFileName);

                bool doesntExist =  !fi.Exists;
                if ((forceRefresh ||doesntExist) &&(!doneFanartJPG.Contains(fi.FullName)))
                {
                    string bannerPath = si.TheSeries().GetItem("fanart");

                    if (!string.IsNullOrEmpty(bannerPath))
                        TheActionList.Add(new ActionDownload(si, null, fi, bannerPath, false));
                    doneFanartJPG.Add(fi.FullName);
                }
                return TheActionList;

            }
            return base.ProcessShow(si, forceRefresh);
        }
Пример #31
0
        public bool Filter([NotNull] ShowItem show)
        {
            SeriesInfo seriesInfo = show.TheSeries();

            //Filter on show name
            bool isNameOk = (ShowName is null) || show.ShowName.Contains(ShowName, StringComparison.OrdinalIgnoreCase);

            //Filter on show status
            bool isStatusOk = (ShowStatus is null) || show.ShowStatus.Equals(ShowStatus);

            //Filter on show network
            bool isNetworkOk = (ShowNetwork is null) || seriesInfo is null || seriesInfo.Network.Equals(ShowNetwork);

            //Filter on show rating
            bool isRatingOk = ShowRating is null || seriesInfo is null || seriesInfo.ContentRating.Equals(ShowRating);

            //Filter on show genres
            bool areGenresIgnored = (Genres?.Count == 0);
            bool doAnyGenresMatch = FindMatchingGenres(show);

            return(isNameOk && isStatusOk && isNetworkOk && isRatingOk && (areGenresIgnored || doAnyGenresMatch));
        }
Пример #32
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            //We only want to do something if the fanart option is enabled. If the KODI option is enabled then let it do the work.
            if ((TVSettings.Instance.FanArtJpg) && !TVSettings.Instance.KODIImages)
            {
                ItemList theActionList = new ItemList();
                FileInfo fi            = FileHelper.FileInFolder(si.AutoAddFolderBase, DEFAULT_FILE_NAME);

                bool doesntExist = !fi.Exists;
                if ((forceRefresh || doesntExist) && (!DoneFanartJpg.Contains(fi.FullName)))
                {
                    string bannerPath = si.TheSeries().GetSeriesFanartPath();

                    if (!string.IsNullOrEmpty(bannerPath))
                    {
                        theActionList.Add(new ActionDownloadImage(si, null, fi, bannerPath, false));
                    }
                    DoneFanartJpg.Add(fi.FullName);
                }
                return(theActionList);
            }
            return(base.ProcessShow(si, forceRefresh));
        }
Пример #33
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            //We only want to do something if the fanart option is enabled. If the XBMC option is enabled then let it do the work.
            if ((TVSettings.Instance.FanArtJpg) && !TVSettings.Instance.XBMCImages)
            {
                ItemList TheActionList = new ItemList();
                FileInfo fi            = FileHelper.FileInFolder(si.AutoAdd_FolderBase, defaultFileName);

                bool doesntExist = !fi.Exists;
                if ((forceRefresh || doesntExist) && (!doneFanartJPG.Contains(fi.FullName)))
                {
                    string bannerPath = si.TheSeries().GetItem("fanart");

                    if (!string.IsNullOrEmpty(bannerPath))
                    {
                        TheActionList.Add(new ActionDownload(si, null, fi, bannerPath, false));
                    }
                    doneFanartJPG.Add(fi.FullName);
                }
                return(TheActionList);
            }
            return(base.ProcessShow(si, forceRefresh));
        }
Пример #34
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            DateTime?newUpdateTime = si.TheSeries().LastAiredDate();

            if (TVSettings.Instance.CorrectFileDates && newUpdateTime.HasValue)
            {
                //Any series before 1980 will get 1980 as the timestamp
                if (newUpdateTime.Value.CompareTo(Helpers.WindowsStartDateTime) < 0)
                {
                    newUpdateTime = Helpers.WindowsStartDateTime;
                }

                DirectoryInfo di = new DirectoryInfo(si.AutoAddFolderBase);
                if ((di.LastWriteTimeUtc != newUpdateTime.Value) && (!doneFilesAndFolders.Contains(di.FullName)))
                {
                    doneFilesAndFolders.Add(di.FullName);
                    return(new ItemList()
                    {
                        new ActionDateTouch(di, si, newUpdateTime.Value)
                    });
                }
            }
            return(null);
        }
Пример #35
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            // for each tv show, optionally write a tvshow.nfo file
            if (TVSettings.Instance.NFOShows)
            {
                ItemList theActionList = new ItemList();
                FileInfo tvshownfo     = FileHelper.FileInFolder(si.AutoAddFolderBase, "tvshow.nfo");

                SeriesInfo seriesInfo = si.TheSeries();
                bool       needUpdate = !tvshownfo.Exists ||
                                        seriesInfo is null ||
                                        seriesInfo.SrvLastUpdated > TimeZoneHelper.Epoch(tvshownfo.LastWriteTime);

                bool alreadyOnTheList = DoneNfo.Contains(tvshownfo.FullName);

                if ((forceRefresh || needUpdate) && !alreadyOnTheList)
                {
                    theActionList.Add(new ActionNfo(tvshownfo, si));
                    DoneNfo.Add(tvshownfo.FullName);
                }
                return(theActionList);
            }
            return(base.ProcessShow(si, forceRefresh));
        }
Пример #36
0
        public override ItemList ProcessShow(ShowItem si, bool forceRefresh)
        {
            // for each tv show, optionally write a tvshow.nfo file
            if (TVSettings.Instance.NFOShows)
            {
                ItemList TheActionList = new ItemList();
                FileInfo tvshownfo     = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "tvshow.nfo");

                bool needUpdate = !tvshownfo.Exists ||
                                  (si.TheSeries().Srv_LastUpdated > TimeZone.Epoch(tvshownfo.LastWriteTime)) ||
                                  // was it written before we fixed the bug in <episodeguideurl> ?
                                  (tvshownfo.LastWriteTime.ToUniversalTime().CompareTo(new DateTime(2009, 9, 13, 7, 30, 0, 0, DateTimeKind.Utc)) < 0);

                bool alreadyOnTheList = DownloadKODIMetaData.doneNFO.Contains(tvshownfo.FullName);

                if ((forceRefresh || needUpdate) && !alreadyOnTheList)
                {
                    TheActionList.Add(new ActionNFO(tvshownfo, si));
                    DownloadKODIMetaData.doneNFO.Add(tvshownfo.FullName);
                }
                return(TheActionList);
            }
            return(base.ProcessShow(si, forceRefresh));
        }
Пример #37
0
        public override ItemList ProcessShow(ShowItem si,bool forceRefresh)
        {
            if (TVSettings.Instance.Mede8erXML)
            {
                ItemList TheActionList = new ItemList();

                FileInfo tvshowxml = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "series.xml");

                bool needUpdate = !tvshowxml.Exists ||
                                  (si.TheSeries().Srv_LastUpdated > TimeZone.Epoch(tvshowxml.LastWriteTime));

                if (forceRefresh || needUpdate)
                    TheActionList.Add(new ActionMede8erXML(tvshowxml, si));

                //Updates requested by [email protected] on 18/4/2013
                FileInfo viewxml = FileHelper.FileInFolder(si.AutoAdd_FolderBase, "view.xml");
                if (!viewxml.Exists) TheActionList.Add(new ActionMede8erViewXML(viewxml,si));


                return TheActionList;
            }

            return base.ProcessShow(si, forceRefresh);
        }
Пример #38
0
 private static void WriteInfo(XmlWriter writer, ShowItem si, string whichItem, string elemName, string attribute, string attributeVal)
 {
     string t = si.TheSeries().GetItem(whichItem);
     if (!string.IsNullOrEmpty(t))
     {
         writer.WriteStartElement(elemName);
         if (!String.IsNullOrEmpty(attribute) && !String.IsNullOrEmpty(attributeVal))
         {
             writer.WriteAttributeString(attribute, attributeVal);
         }
         writer.WriteValue(t);
         writer.WriteEndElement();
     }
 }
Пример #39
0
        public override ItemList ProcessSeason(ShowItem si, string folder, int snum, bool forceRefresh)
        {
            if (TVSettings.Instance.XBMCImages)
            {
                ItemList TheActionList = new ItemList();
                if (TVSettings.Instance.DownloadFrodoImages())
                {
                    //If we have XBMC New style images being downloaded then we want to check that 3 files exist
                    //for the series:
                    //http://wiki.xbmc.org/index.php?title=XBMC_v12_(Frodo)_FAQ#Local_images
                    //poster
                    //banner
                    //fanart - we do not have the option in TVDB to get season specific fanart, so we'll leave that

                    string filenamePrefix = "";

                    if (!si.AutoAdd_FolderPerSeason)
                    {   // We have multiple seasons in the same folder
                        // We need to do slightly more work to come up with the filenamePrefix

                        filenamePrefix = "season";

                        if (snum == 0) filenamePrefix += "-specials";
                        else if (snum < 10) filenamePrefix += "0" + snum;
                        else filenamePrefix += snum;

                        filenamePrefix += "-";

                    }

                    FileInfo posterJPG = FileHelper.FileInFolder(folder, filenamePrefix + "poster.jpg");
                    if (forceRefresh || !posterJPG.Exists)
                    {
                        string path = si.TheSeries().GetSeasonBannerPath(snum);
                        if (!string.IsNullOrEmpty(path))
                            TheActionList.Add(new ActionDownload(si, null, posterJPG, path));
                    }

                    FileInfo bannerJPG = FileHelper.FileInFolder(folder, filenamePrefix + "banner.jpg");
                    if (forceRefresh || !bannerJPG.Exists)
                    {
                        string path = si.TheSeries().GetSeasonWideBannerPath(snum);
                        if (!string.IsNullOrEmpty(path))
                            TheActionList.Add(new ActionDownload(si, null, bannerJPG, path));
                    }
                }
                if (TVSettings.Instance.DownloadEdenImages())
                {
                    string filenamePrefix = "season";

                    if (snum == 0) filenamePrefix += "-specials";
                    else if (snum < 10) filenamePrefix += "0" + snum;
                    else filenamePrefix += snum;

                    FileInfo posterTBN = FileHelper.FileInFolder(si.AutoAdd_FolderBase, filenamePrefix + ".tbn");
                    if (forceRefresh || !posterTBN.Exists)
                    {
                        string path = si.TheSeries().GetSeasonBannerPath(snum);
                        if (!string.IsNullOrEmpty(path))
                            TheActionList.Add(new ActionDownload(si, null, posterTBN, path));
                    }
                }
                return TheActionList;
            }

            return base.ProcessSeason(si, folder, snum, forceRefresh);
        }
Пример #40
0
        public AddEditShow(ShowItem si)
        {
            this.mSI = si;
            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.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();
        }
Пример #41
0
        public void TVShowNFOCheck(ShowItem si)
        {
            // check there is a TVShow.nfo file in the root folder for the show
            if (string.IsNullOrEmpty(si.AutoAdd_FolderBase)) // no base folder defined
                return;

            if (si.AllFolderLocations(this.Settings).Count == 0) // no seasons enabled
                return;

            FileInfo tvshownfo = Helpers.FileInFolder(si.AutoAdd_FolderBase, "tvshow.nfo");

            bool needUpdate = !tvshownfo.Exists || (si.TheSeries().Srv_LastUpdated > TimeZone.Epoch(tvshownfo.LastWriteTime));
            // was it written before we fixed the bug in <episodeguideurl> ?
            needUpdate = needUpdate || (tvshownfo.LastWriteTime.ToUniversalTime().CompareTo(new DateTime(2009, 9, 13, 7, 30, 0, 0, DateTimeKind.Utc)) < 0);
            if (needUpdate)
                this.TheActionList.Add(new ActionNFO(tvshownfo, si));
        }
Пример #42
0
        public bool LoadXMLSettings(FileInfo from)
        {
            if (from == null)
                return true;

            try
            {
                XmlReaderSettings settings = new XmlReaderSettings
                {
                    IgnoreComments = true,
                    IgnoreWhitespace = true
                };

                if (!from.Exists)
                {
                    //LoadErr = from->Name + " : File does not exist";
                    //return false;
                    return true; // that's ok
                }

                XmlReader reader = XmlReader.Create(from.FullName, settings);

                reader.Read();
                if (reader.Name != "xml")
                {
                    this.LoadErr = from.Name + " : Not a valid XML file";
                    return false;
                }

                reader.Read();

                if (reader.Name != "TVRename")
                {
                    this.LoadErr = from.Name + " : Not a TVRename settings file";
                    return false;
                }

                if (reader.GetAttribute("Version") != "2.1")
                {
                    this.LoadErr = from.Name + " : Incompatible version";
                    return false;
                }

                reader.Read(); // move forward one

                while (!reader.EOF)
                {
                    if (reader.Name == "TVRename" && !reader.IsStartElement())
                        break; // end of it all

                    if (reader.Name == "Settings")
                    {
                        this.Settings = new TVSettings(reader.ReadSubtree());
                        reader.Read();
                    }
                    else if (reader.Name == "MyShows")
                    {
                        XmlReader r2 = reader.ReadSubtree();
                        r2.Read();
                        r2.Read();
                        while (!r2.EOF)
                        {
                            if ((r2.Name == "MyShows") && (!r2.IsStartElement()))
                                break;
                            if (r2.Name == "ShowItem")
                            {
                                ShowItem si = new ShowItem(this.mTVDB, r2.ReadSubtree(), this.Settings);

                                if (si.UseCustomShowName) // see if custom show name is actually the real show name
                                {
                                    SeriesInfo ser = si.TheSeries();
                                    if ((ser != null) && (si.CustomShowName == ser.Name))
                                    {
                                        // then, turn it off
                                        si.CustomShowName = "";
                                        si.UseCustomShowName = false;
                                    }
                                }
                                ShowItems.Add(si);

                                r2.Read();
                            }
                            else
                                r2.ReadOuterXml();
                        }
                        reader.Read();
                    }
                    else if (reader.Name == "MonitorFolders")
                        this.MonitorFolders = ReadStringsFromXml(reader, "MonitorFolders", "Folder");
                    else if (reader.Name == "IgnoreFolders")
                        this.IgnoreFolders = ReadStringsFromXml(reader, "IgnoreFolders", "Folder");
                    else if (reader.Name == "FinderSearchFolders")
                        this.SearchFolders = ReadStringsFromXml(reader, "FinderSearchFolders", "Folder");
                    else if (reader.Name == "IgnoreItems")
                    {
                        XmlReader r2 = reader.ReadSubtree();
                        r2.Read();
                        r2.Read();
                        while (r2.Name == "Ignore")
                            this.Ignore.Add(new IgnoreItem(r2));
                        reader.Read();
                    }
                    else
                        reader.ReadOuterXml();
                }

                reader.Close();
                reader = null;
            }
            catch (Exception e)
            {
                this.LoadErr = from.Name + " : " + e.Message;
                return false;
            }

            try
            {
                mStats = TVRenameStats.Load();
            }
            catch (Exception)
            {
                // not worried if stats loading fails
            }
            return true;
        }