/// <summary> /// Updates list of TV episodes found in scan directories. Performs a directory scan in background that /// only matches to files that are categorized as TV video. /// </summary> public static void DoUpdate(bool dirScanSearch) { if (!Organization.DoUpdating) { return; } // Run scan to look for TV files if (dirScanSearch) { scan.RunScan(Settings.ScanDirectories.ToList(), new List <OrgItem>(), true, true, true, true); Items = scan.Items; } // Update missing lock (Organization.Shows.ContentLock) foreach (TvShow show in Organization.Shows) { show.UpdateMissing(); } // Trigger event indicating update has occured OnItemsUpdate(); if (dirScanSearch) { Initialized = true; } }
/// <summary> /// Run through all TV shows all looks for episodes that may need to be renamed and for missing episodes. /// For missing episodes it attempts to match them to files from the search directories. /// </summary> /// <param name="shows">Shows to scan</param> /// <param name="queuedItems">Items currently in queue (to be skipped)</param> /// <returns></returns> public List <OrgItem> RunScan(List <ContentRootFolder> folders, List <OrgItem> queuedItems, bool fast) { // Set running flag scanRunning = true; cancelRequested = false; // Convert all TV folder to scan folders so we can do a scan of them List <OrgFolder> tvFoldersAsOrgFolders = new List <OrgFolder>(); foreach (ContentRootFolder tvFolder in folders) { OrgFolder orgFolder = new OrgFolder(tvFolder.FullPath, false, false, false, false); tvFoldersAsOrgFolders.Add(orgFolder); } // Do directory scan on all TV folders DirectoryScan dirScan = new DirectoryScan(false); dirScan.ProgressChange += dirScan_ProgressChange; dirScan.RunScan(tvFoldersAsOrgFolders, queuedItems, 90, true, false, fast, true); List <OrgItem> results = dirScan.Items; // Check if show folder needs to be renamed! int number = results.Count; foreach (ContentRootFolder tvFolder in folders) { for (int i = 0; i < Organization.Shows.Count; i++) { TvShow show = (TvShow)Organization.Shows[i]; if (show.Id <= 0 || show.RootFolder != tvFolder.FullPath) { continue; } string builtFolder = Path.Combine(show.RootFolder, FileHelper.GetSafeFileName(show.DatabaseName)); if (show.Path != builtFolder) { OrgItem newItem = new OrgItem(OrgStatus.Organization, OrgAction.Rename, show.Path, builtFolder, new TvEpisode("", show, -1, -1, "", ""), null, FileCategory.Folder, null); newItem.Enable = true; newItem.Number = number++; results.Add(newItem); } } } // Update progress OnProgressChange(ScanProcess.TvFolder, string.Empty, 100); // Clear flags scanRunning = false; // Return results return(results); }
/// <summary> /// Run through all TV shows all looks for episodes that may need to be renamed and for missing episodes. /// For missing episodes it attempts to match them to files from the search directories. /// </summary> /// <param name="shows">Shows to scan</param> /// <param name="queuedItems">Items currently in queue (to be skipped)</param> /// <returns></returns> public List<OrgItem> RunScan(List<ContentRootFolder> folders, List<OrgItem> queuedItems, bool fast) { // Set running flag scanRunning = true; cancelRequested = false; // Convert all TV folder to scan folders so we can do a scan of them List<OrgFolder> tvFoldersAsOrgFolders = new List<OrgFolder>(); foreach (ContentRootFolder tvFolder in folders) { OrgFolder orgFolder = new OrgFolder(tvFolder.FullPath, false, false, false, false); tvFoldersAsOrgFolders.Add(orgFolder); } // Do directory scan on all TV folders DirectoryScan dirScan = new DirectoryScan(false); dirScan.ProgressChange += dirScan_ProgressChange; dirScan.RunScan(tvFoldersAsOrgFolders, queuedItems, 90, true, false, fast, true); List<OrgItem> results = dirScan.Items; // Check if show folder needs to be renamed! int number = results.Count; foreach (ContentRootFolder tvFolder in folders) for (int i = 0; i < Organization.Shows.Count; i++) { TvShow show = (TvShow)Organization.Shows[i]; if (show.Id <= 0 || show.RootFolder != tvFolder.FullPath) continue; string builtFolder = Path.Combine(show.RootFolder, FileHelper.GetSafeFileName(show.DatabaseName)); if (show.Path != builtFolder) { OrgItem newItem = new OrgItem(OrgStatus.Organization, OrgAction.Rename, show.Path, builtFolder, new TvEpisode("", show, -1, -1, "", ""), null, FileCategory.Folder, null); newItem.Enable = true; newItem.Number = number++; results.Add(newItem); } } // Update progress OnProgressChange(ScanProcess.TvFolder, string.Empty, 100); // Clear flags scanRunning = false; // Return results return results; }