Пример #1
0
        private static string GetBestFolderLocationToOpen(this ShowItem si, Season s)
        {
            Dictionary <int, List <string> > afl = si.AllFolderLocations();

            int[] keys = new int[afl.Count];
            afl.Keys.CopyTo(keys, 0);

            if (afl.ContainsKey(s.SeasonNumber))
            {
                foreach (string folder in afl[s.SeasonNumber])
                {
                    if (Directory.Exists(folder))
                    {
                        return(folder);
                    }
                }
            }

            if (!string.IsNullOrEmpty(si.AutoAddFolderBase) && Directory.Exists(si.AutoAddFolderBase))
            {
                return(si.AutoAddFolderBase);
            }

            return(string.Empty);
        }
Пример #2
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));
        }
Пример #3
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);
        }
Пример #4
0
        private static string GetBestFolderLocationToOpen(this ShowItem si)
        {
            if (!string.IsNullOrEmpty(si.AutoAddFolderBase) && Directory.Exists(si.AutoAddFolderBase))
            {
                return(si.AutoAddFolderBase);
            }

            Dictionary <int, List <string> > afl = si.AllFolderLocations();

            foreach (KeyValuePair <int, List <string> > season in afl)
            {
                foreach (string folder in season.Value)
                {
                    if (!string.IsNullOrWhiteSpace(folder) && Directory.Exists(folder))
                    {
                        return(folder);
                    }
                }
            }
            return(string.Empty);
        }
Пример #5
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));
        }
Пример #6
0
        public List<System.IO.FileInfo> FindEpOnDisk(ShowItem si, Episode epi)
        {
            List<System.IO.FileInfo> ret = new List<System.IO.FileInfo>();

            int seasWanted = epi.TheSeason.SeasonNumber;
            int epWanted = epi.EpNum;

            int snum = epi.TheSeason.SeasonNumber;

            if (!si.AllFolderLocations(this.Settings).ContainsKey(snum))
                return ret;

            foreach (string folder in si.AllFolderLocations(this.Settings)[snum])
            {
                DirectoryInfo di;
                try
                {
                    di = new DirectoryInfo(folder);
                }
                catch
                {
                    return ret;
                }
                if (!di.Exists)
                    return ret;

                FileInfo[] files = di.GetFiles();
                foreach (FileInfo fiTemp in files)
                {
                    int seasFound;
                    int epFound;

                    if (!this.Settings.UsefulExtension(fiTemp.Extension, false))
                        continue; // move on

                    if (this.FindSeasEp(fiTemp, out seasFound, out epFound, si))
                    {
                        if (seasFound == -1)
                            seasFound = seasWanted;
                        if ((seasFound == seasWanted) && (epFound == epWanted))
                            ret.Add(fiTemp);
                    }
                }
            }

            return ret;
        }
Пример #7
0
        public List<FileInfo> FindEpOnDisk(DirFilesCache dfc, ShowItem si, Episode epi)
        {
            if (dfc == null)
                dfc = new DirFilesCache();
            List<FileInfo> ret = new List<FileInfo>();

            int seasWanted = epi.TheSeason.SeasonNumber;
            int epWanted = epi.EpNum;

            int snum = epi.TheSeason.SeasonNumber;

            if (!si.AllFolderLocations().ContainsKey(snum))
                return ret;

            foreach (string folder in si.AllFolderLocations()[snum])
            {
                FileInfo[] files = dfc.Get(folder);
                if (files == null)
                    continue;

                foreach (FileInfo fiTemp in files)
                {
                    int seasFound;
                    int epFound;

                    if (!TVSettings.Instance.UsefulExtension(fiTemp.Extension, false))
                        continue; // move on

                    if (FindSeasEp(fiTemp, out seasFound, out epFound, si))
                    {
                        if (seasFound == -1)
                            seasFound = seasWanted;
                        if ((seasFound == seasWanted) && (epFound == epWanted))
                            ret.Add(fiTemp);
                    }
                }
            }

            return ret;
        }
Пример #8
0
        public void ForceUpdateImages(ShowItem si)
        {
            
            this.TheActionList = new ItemList();
            this.LockShowItems();

            DirFilesCache dfc = new DirFilesCache();
            System.Diagnostics.Debug.Print(DateTime.Now.ToLongTimeString() + " Force Update Images: " + si.ShowName);

            if (!string.IsNullOrEmpty(si.AutoAdd_FolderBase) && (si.AllFolderLocations().Count > 0))
            {
                this.TheActionList.Add(DownloadIdentifiers.ForceUpdateShow(DownloadIdentifier.DownloadType.downloadImage, si));
                si.BannersLastUpdatedOnDisk = System.DateTime.Now;
                this.SetDirty();
            }

            // process each folder for each season...

            int[] numbers = new int[si.SeasonEpisodes.Keys.Count];
            si.SeasonEpisodes.Keys.CopyTo(numbers, 0);
            Dictionary<int, List<string>> allFolders = si.AllFolderLocations();

            foreach (int snum in numbers)
            {
                if ((si.IgnoreSeasons.Contains(snum)) || (!allFolders.ContainsKey(snum)))
                    continue; // ignore/skip this season

                if ((snum == 0) && (si.CountSpecials))
                    continue; // don't process the specials season, as they're merged into the seasons themselves

                // all the folders for this particular season
                List<string> folders = allFolders[snum];

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

                foreach (string folder in folders)
                {


                    //Image series checks here
                    this.TheActionList.Add(DownloadIdentifiers.ForceUpdateSeason(DownloadIdentifier.DownloadType.downloadImage, si, folder, snum));

                }

            } // for each season of this show

            this.UnlockShowItems();
            this.RemoveIgnored();

        }
Пример #9
0
            public override void OnMouseDown(CellContext sender, MouseEventArgs e)
            {
                if (e.Button != MouseButtons.Right)
                {
                    return;
                }
                gridSummary.showRightClickMenu.Items.Clear();

                Season seas = season;

                gridSummary.mLastFileList  = new List <FileInfo>();
                gridSummary.mFoldersToOpen = new List <string>();

                gridSummary.mLastShowClicked   = show;
                gridSummary.mLastSeasonClicked = season;

                List <string> added = new List <string>();

                if (show != null && seas == null)
                {
                    GenerateMenu(gridSummary.showRightClickMenu, "Force Refresh", RightClickCommands.kForceRefreshSeries);
                    GenerateSeparator(gridSummary.showRightClickMenu);
                    GenerateMenu(gridSummary.showRightClickMenu, "Visit thetvdb.com", RightClickCommands.kVisitTvdbSeries);
                }

                if (show != null && seas != null)
                {
                    GenerateMenu(gridSummary.showRightClickMenu, "Visit thetvdb.com",
                                 RightClickCommands.kVisitTvdbSeason);

                    Dictionary <int, List <string> > afl = show.AllFolderLocations();

                    if (afl.ContainsKey(seas.SeasonNumber))
                    {
                        int  n     = gridSummary.mFoldersToOpen.Count;
                        bool first = true;
                        foreach (string folder in afl[seas.SeasonNumber])
                        {
                            if ((!string.IsNullOrEmpty(folder)) && Directory.Exists(folder) && !added.Contains(folder))
                            {
                                added.Add(folder); // don't show the same folder more than once
                                if (first)
                                {
                                    GenerateSeparator(gridSummary.showRightClickMenu);
                                    first = false;
                                }

                                GenerateMenu(gridSummary.showRightClickMenu, "Open: " + folder,
                                             (int)RightClickCommands.kOpenFolderBase + n);

                                gridSummary.mFoldersToOpen.Add(folder);
                                n++;
                            }
                        }
                    }
                }
                if (show != null)
                {
                    int  n     = gridSummary.mFoldersToOpen.Count;
                    bool first = true;

                    foreach (KeyValuePair <int, List <string> > kvp in show.AllFolderLocations())
                    {
                        foreach (string folder in kvp.Value)
                        {
                            if ((!string.IsNullOrEmpty(folder)) && Directory.Exists(folder) && !added.Contains(folder))
                            {
                                added.Add(folder); // don't show the same folder more than once
                                if (first)
                                {
                                    GenerateSeparator(gridSummary.showRightClickMenu);
                                    first = false;
                                }

                                GenerateMenu(gridSummary.showRightClickMenu, "Open: " + folder, (int)RightClickCommands.kOpenFolderBase + n);
                                gridSummary.mFoldersToOpen.Add(folder);
                                n++;
                            }
                        }
                    }
                }

                if (seas != null && show != null)
                {
                    // for each episode in season, find it on disk
                    bool first = true;
                    foreach (ProcessedEpisode epds in show.SeasonEpisodes[seas.SeasonNumber])
                    {
                        List <FileInfo> fl = TVDoc.FindEpOnDisk(new DirFilesCache(), epds, false);
                        if ((fl != null) && (fl.Count > 0))
                        {
                            if (first)
                            {
                                GenerateSeparator(gridSummary.showRightClickMenu);
                                first = false;
                            }

                            int n = gridSummary.mLastFileList.Count;
                            foreach (FileInfo fi in fl)
                            {
                                GenerateMenu(gridSummary.showRightClickMenu, "Watch: " + fi.FullName, (int)RightClickCommands.kWatchBase + n);
                                gridSummary.mLastFileList.Add(fi);
                                n++;
                            }
                        }
                    }
                }

                Point pt = new Point(e.X, e.Y);

                gridSummary.showRightClickMenu.Show(sender.Grid.PointToScreen(pt));
            }