private static string NameFor(ProcessedSeason?s, string styleString, bool urlEncode) { string name = styleString; if (s is null) { return(string.Empty); } string showname = s.Show.ShowName; if (urlEncode) { showname = Uri.EscapeDataString(showname); } string seasonName = s.Show.CachedShow?.Season(s.SeasonNumber)?.SeasonName; name = name.ReplaceInsensitive("{ShowName}", showname); name = name.ReplaceInsensitive("{ShowNameInitial}", showname.Initial().ToLower()); name = name.ReplaceInsensitive("{ShowNameLower}", s.Show.ShowName.ToLower().Replace(' ', '-').RemoveCharactersFrom("()[]{}&$:")); name = name.ReplaceInsensitive("{Season}", s.SeasonNumber.ToString()); name = name.ReplaceInsensitive("{Season:2}", s.SeasonNumber.ToString("00")); name = name.ReplaceInsensitive("{SeasonNumber}", s.SeasonIndex.ToString()); name = name.ReplaceInsensitive("{SeasonNumber:2}", s.SeasonIndex.ToString("00")); name = name.ReplaceInsensitive("{SeasonName}", seasonName ?? string.Empty); name = name.ReplaceInsensitive("{StartYear}", s.MinYear().ToString()); name = name.ReplaceInsensitive("{EndYear}", s.MaxYear().ToString()); name = name.ReplaceInsensitive("{ShowImdb}", s.Show.CachedShow?.Imdb ?? string.Empty); return(TVSettings.DirectoryFriendly(name.Trim())); }
public bool Go(TVSettings settings, ref bool pause, TVRenameStats stats) { // read NTFS permissions (if any) System.Security.AccessControl.FileSecurity security = null; try { security = this.From.GetAccessControl(); } catch { } if (this.QuickOperation()) { this.OSMoveRename(stats); // ask the OS to do it for us, since it's easy and quick! } else { this.CopyItOurself(ref pause, stats); // do it ourself! } // set NTFS permissions try { if (security != null) { this.To.SetAccessControl(security); } } catch { } return(!this.Error); }
public bool Go(TVSettings settings, ref bool pause, TVRenameStats stats) { System.Net.WebClient wc = new System.Net.WebClient(); try { byte[] r = wc.DownloadData(this.RSS.URL); if ((r == null) || (r.Length == 0)) { this.Error = true; this.ErrorText = "No data downloaded"; this.Done = true; return(false); } string saveTemp = Path.GetTempPath() + System.IO.Path.DirectorySeparatorChar + settings.FilenameFriendly(this.RSS.Title); if (new FileInfo(saveTemp).Extension.ToLower() != "torrent") { saveTemp += ".torrent"; } File.WriteAllBytes(saveTemp, r); System.Diagnostics.Process.Start(settings.uTorrentPath, "/directory \"" + (new FileInfo(this.TheFileNoExt).Directory.FullName) + "\" \"" + saveTemp + "\""); this.Done = true; return(true); } catch (Exception e) { this.ErrorText = e.Message; this.Error = true; this.Done = true; return(false); } }
public string AutoFolderNameForSeason(int n, TVSettings settings) { bool leadingZero = settings.LeadingZeroOnSeason || this.PadSeasonToTwoDigits; string r = this.AutoAdd_FolderBase; if (string.IsNullOrEmpty(r)) { return(""); } if (!r.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString())) { r += System.IO.Path.DirectorySeparatorChar.ToString(); } if (this.AutoAdd_FolderPerSeason) { if (n == 0) { r += settings.SpecialsFolderName; } else { r += this.AutoAdd_SeasonFolderName; if ((n < 10) && leadingZero) { r += "0"; } r += n.ToString(); } } return(r); }
public static string NameFor(MovieConfiguration?m, string styleString, bool urlEncode, bool isfilename) { string name = styleString; if (m?.ShowName is null) { return(string.Empty); } string showname = m.ShowName; if (urlEncode) { showname = Uri.EscapeDataString(showname); } name = name.ReplaceInsensitive("{ShowName}", showname); name = name.ReplaceInsensitive("{ShowNameInitial}", showname.Initial().ToLower()); name = name.ReplaceInsensitive("{ShowNameLower}", showname.ToLower().Replace(' ', '-').RemoveCharactersFrom("()[]{}&$:")); name = name.ReplaceInsensitive("{ContentRating}", m.CachedMovie?.ContentRating); name = name.ReplaceInsensitive("{Year}", m.CachedMovie?.Year.ToString()); name = name.ReplaceInsensitive("{Imdb}", m.CachedMovie?.Imdb); return(isfilename ? TVSettings.DirectoryFriendly(name.Trim()) : name.Trim()); }
public bool Go(TVSettings settings, ref bool pause, TVRenameStats stats) { byte[] theData = this.SI.TVDB.GetPage(this.BannerPath, false, typeMaskBits.tmBanner, false); if ((theData == null) || (theData.Length == 0)) { this.ErrorText = "Unable to download " + this.BannerPath; this.Error = true; this.Done = true; return(false); } try { FileStream fs = new FileStream(this.Destination.FullName, FileMode.Create); fs.Write(theData, 0, theData.Length); fs.Close(); } catch (Exception e) { this.ErrorText = e.Message; this.Error = true; this.Done = true; return(false); } this.Done = true; return(true); }
private void bnDefaults_Click(object sender, System.EventArgs e) { DialogResult dr = MessageBox.Show("Restore to default matching expressions?", "Filename Processors", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { this.FillGrid(TVSettings.DefaultFNPList()); } }
private bool OkToClose() { if (!TheTVDB.LocalCache.Instance.HasSeries(codeFinderForm.SelectedCode())) //todo Get add show to work with TVMAZE { DialogResult dr = MessageBox.Show("tvdb code unknown, close anyway?", "TVRename Add/Edit Show", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.No) { return(false); } } if (chkCustomLanguage.Checked && string.IsNullOrWhiteSpace(cbLanguage.SelectedItem?.ToString())) { MessageBox.Show("Please enter language for the show or accept the default preferred language", "TVRename Add/Edit Show", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (chkAutoFolders.Checked && string.IsNullOrWhiteSpace(txtBaseFolder.Text)) { MessageBox.Show("Please enter base folder for this show or turn off automatic folders", "TVRename Add/Edit Show", MessageBoxButtons.OK, MessageBoxIcon.Warning); Folders.SelectedTab = tabPage5; txtBaseFolder.Focus(); return(false); } if (chkAutoFolders.Checked && !TVSettings.OKPath(txtBaseFolder.Text, false)) { MessageBox.Show("Please check the base folder is a valid one and has no invalid characters" , "TVRename Add/Edit Show", MessageBoxButtons.OK, MessageBoxIcon.Warning); Folders.SelectedTab = tabPage5; txtBaseFolder.Focus(); return(false); } if (chkAutoFolders.Checked && rdoFolderCustom.Checked && !txtSeasonFormat.Text.IsValidDirectory()) { MessageBox.Show("Please check the custom subdirectory is a valid one and has no invalid characters" , "TVRename Add/Edit Show", MessageBoxButtons.OK, MessageBoxIcon.Warning); Folders.SelectedTab = tabPage5; txtSeasonFormat.Focus(); return(false); } return(true); }
private bool OkToClose() { if (!TVDoc.GetMediaCache(GetProviderTypeInUse()).HasMovie(codeFinderForm.SelectedCode())) { DialogResult dr = MessageBox.Show($"{GetProviderType().PrettyPrint()} code unknown, close anyway?", "TVRename Add/Edit Movie", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.No) { return(false); } } if (chkCustomLanguage.Checked && string.IsNullOrWhiteSpace(cbLanguage.SelectedItem?.ToString())) { MessageBox.Show("Please enter language for the show or accept the default preferred language", "TVRename Add/Edit Movie", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } if (chkAutoFolders.Checked && string.IsNullOrWhiteSpace(cbDirectory.SelectedItem?.ToString())) { MessageBox.Show("Please enter base folder for this show or turn off automatic folders", "TVRename Add/Edit Movie", MessageBoxButtons.OK, MessageBoxIcon.Warning); Folders.SelectedTab = tabPage5; cbDirectory.Focus(); return(false); } if (chkAutoFolders.Checked && !TVSettings.OKPath(cbDirectory.SelectedItem?.ToString(), false)) { MessageBox.Show("Please check the base folder is a valid one and has no invalid characters" , "TVRename Add/Edit Movie", MessageBoxButtons.OK, MessageBoxIcon.Warning); Folders.SelectedTab = tabPage5; cbDirectory.Focus(); return(false); } if (chkAutoFolders.Checked && rdoFolderCustom.Checked && !txtFolderNameFormat.Text.IsValidDirectory()) { MessageBox.Show("Please check the custom subdirectory is a valid one and has no invalid characters" , "TVRename Add/Edit Show", MessageBoxButtons.OK, MessageBoxIcon.Warning); Folders.SelectedTab = tabPage5; txtFolderNameFormat.Focus(); return(false); } return(true); }
public Dictionary <int, List <string> > AllFolderLocations(TVSettings settings, bool manualToo) { Dictionary <int, List <string> > fld = new Dictionary <int, List <string> >(); if (manualToo) { foreach (KeyValuePair <int, List <string> > kvp in this.ManualFolderLocations) { if (!fld.ContainsKey(kvp.Key)) { fld[kvp.Key] = new List <String>(); } foreach (string s in kvp.Value) { fld[kvp.Key].Add(TTS(s)); } } } if (this.AutoAddNewSeasons && (!string.IsNullOrEmpty(this.AutoAdd_FolderBase))) { int highestThereIs = -1; foreach (KeyValuePair <int, List <ProcessedEpisode> > kvp in this.SeasonEpisodes) { if (kvp.Key > highestThereIs) { highestThereIs = kvp.Key; } } foreach (int i in SeasonEpisodes.Keys) { if (this.IgnoreSeasons.Contains(i)) { continue; } string newName = this.AutoFolderNameForSeason(i, settings); if ((!string.IsNullOrEmpty(newName)) && (Directory.Exists(newName))) { if (!fld.ContainsKey(i)) { fld[i] = new List <String>(); } if (!fld[i].Contains(newName)) { fld[i].Add(TTS(newName)); } } } } return(fld); }
public DirCacheEntry(FileInfo f, TVSettings theSettings) { this.TheFile = f; this.SimplifiedFullName = Helpers.SimplifyName(f.FullName); this.LowerName = f.Name.ToLower(); this.Length = f.Length; if (theSettings == null) { return; } this.HasUsefulExtension_NotOthersToo = theSettings.UsefulExtension(f.Extension, false); this.HasUsefulExtension_OthersToo = this.HasUsefulExtension_NotOthersToo | theSettings.UsefulExtension(f.Extension, true); }
private void bnReplaceRemove_Click(object sender, System.EventArgs e) { // multiselection is off, so we can cheat... int[] rowsIndex = this.ReplacementsGrid.Selection.GetSelectionRegion().GetRowsIndex(); if (rowsIndex.Length > 0) { // don't delete compulsory items int n = rowsIndex[0]; string from = (string)(this.ReplacementsGrid[n, 0].Value); if (string.IsNullOrEmpty(from) || (TVSettings.CompulsoryReplacements().IndexOf(from) == -1)) { this.ReplacementsGrid.Rows.Remove(n); } } }
public bool Go(TVSettings tvsettings, ref bool pause, TVRenameStats stats) { // "try" and silently fail. eg. when file is use by other... StreamWriter writer; try { // create folder if it does not exist. (Only really applies when .meta\ folder is being used.) if (!this.Where.Directory.Exists) { this.Where.Directory.Create(); } writer = new StreamWriter(this.Where.FullName); if (writer == null) { return(false); } } catch (Exception) { this.Done = true; return(true); } // See: http://pytivo.sourceforge.net/wiki/index.php/Metadata writer.WriteLine(string.Format("title : {0}", this.Episode.SI.ShowName)); writer.WriteLine(string.Format("seriesTitle : {0}", this.Episode.SI.ShowName)); writer.WriteLine(string.Format("episodeTitle : {0}", this.Episode.Name)); writer.WriteLine(string.Format("episodeNumber : {0}{1:0#}", this.Episode.SeasonNumber, this.Episode.EpNum)); writer.WriteLine("isEpisode : true"); writer.WriteLine(string.Format("description : {0}", this.Episode.Overview)); if (this.Episode.FirstAired != null) { writer.WriteLine(string.Format("originalAirDate : {0:yyyy-MM-dd}T00:00:00Z", this.Episode.FirstAired.Value)); } writer.WriteLine(string.Format("callsign : {0}", this.Episode.SI.TheSeries().GetItem("Network"))); WriteEntries(writer, "vDirector", this.Episode.EpisodeDirector); WriteEntries(writer, "vWriter", this.Episode.Writer); WriteEntries(writer, "vActor", this.Episode.SI.TheSeries().GetItem("Actors")); WriteEntries(writer, "vGuestStar", this.Episode.EpisodeGuestStars); // not worring about actors being repeated WriteEntries(writer, "vProgramGenre", this.Episode.SI.TheSeries().GetItem("Genre")); writer.Close(); this.Done = true; return(true); }
private void AddNewReplacementRow(string from, string to, bool ins) { SourceGrid.Cells.Views.Cell roModel = new SourceGrid.Cells.Views.Cell { ForeColor = Color.Gray }; int r = this.ReplacementsGrid.RowsCount; this.ReplacementsGrid.RowsCount = r + 1; this.ReplacementsGrid[r, 0] = new SourceGrid.Cells.Cell(from, typeof(string)); this.ReplacementsGrid[r, 1] = new SourceGrid.Cells.Cell(to, typeof(string)); this.ReplacementsGrid[r, 2] = new SourceGrid.Cells.CheckBox(null, ins); if (!string.IsNullOrEmpty(from) && (TVSettings.CompulsoryReplacements().IndexOf(from) != -1)) { this.ReplacementsGrid[r, 0].Editor.EnableEdit = false; this.ReplacementsGrid[r, 0].View = roModel; } }
public AddEditSeasEpFinders(List <FilenameProcessorRE> rex, List <ShowItem> sil, ShowItem initialShow, string initialFolder, TVSettings s) { this.Rex = rex; this.SIL = sil; this.TheSettings = s; this.InitializeComponent(); this.SetupGrid(); this.FillGrid(this.Rex); foreach (ShowItem si in this.SIL) { this.cbShowList.Items.Add(si.ShowName); if (si == initialShow) { this.cbShowList.SelectedIndex = this.cbShowList.Items.Count - 1; } } this.txtFolder.Text = initialFolder; }
public bool Go(TVSettings tvsettings, 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"); writer.WriteStartElement("title"); writer.WriteValue(this.Episode.Name); writer.WriteEndElement(); writer.WriteStartElement("rating"); writer.WriteValue(this.Episode.EpisodeRating); writer.WriteEndElement(); writer.WriteStartElement("season"); writer.WriteValue(this.Episode.SeasonNumber); writer.WriteEndElement(); writer.WriteStartElement("episode"); writer.WriteValue(this.Episode.EpNum); writer.WriteEndElement(); writer.WriteStartElement("plot"); writer.WriteValue(this.Episode.Overview); writer.WriteEndElement(); 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; } writer.WriteStartElement("director"); writer.WriteValue(Daa); writer.WriteEndElement(); } } } //Writers(s) if (!String.IsNullOrEmpty(this.Episode.Writer)) { string EpWriter = this.Episode.Writer; if (!string.IsNullOrEmpty(EpWriter)) { writer.WriteStartElement("credits"); writer.WriteValue(EpWriter); writer.WriteEndElement(); } } // 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"); writer.WriteStartElement("name"); writer.WriteValue(Gaa); writer.WriteEndElement(); // name 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"); writer.WriteStartElement("name"); writer.WriteValue(aa); writer.WriteEndElement(); // name 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"); writer.WriteStartElement("title"); writer.WriteValue(this.SI.ShowName); writer.WriteEndElement(); writer.WriteStartElement("episodeguideurl"); writer.WriteValue(TheTVDB.BuildURL(true, true, this.SI.TVDBCode, this.SI.TVDB.RequestLanguage)); writer.WriteEndElement(); WriteInfo(writer, this.SI, "Overview", "plot"); string genre = this.SI.TheSeries().GetItem("Genre"); if (!string.IsNullOrEmpty(genre)) { genre = genre.Trim('|'); genre = genre.Replace("|", " / "); writer.WriteStartElement("genre"); writer.WriteValue(genre); writer.WriteEndElement(); } 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"); writer.WriteStartElement("name"); writer.WriteValue(aa); writer.WriteEndElement(); // name writer.WriteEndElement(); // actor } } WriteInfo(writer, this.SI, "ContentRating", "mpaa"); WriteInfo(writer, this.SI, "IMDB_ID", "id", "moviedb", "imdb"); writer.WriteStartElement("tvdbid"); writer.WriteValue(this.SI.TheSeries().TVDBCode); writer.WriteEndElement(); string rt = this.SI.TheSeries().GetItem("Runtime"); if (!string.IsNullOrEmpty(rt)) { writer.WriteStartElement("runtime"); writer.WriteValue(rt + " minutes"); writer.WriteEndElement(); } writer.WriteEndElement(); // tvshow } writer.Close(); this.Done = true; return(true); }
public Dictionary <int, List <string> > AllFolderLocations(TVSettings settings) { return(this.AllFolderLocations(settings, true)); }
private void OKButton_Click(object sender, System.EventArgs e) { if (!TVSettings.OKExtensionsString(this.txtEmptyIgnoreExtensions.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.SelectedTab = tbFolderDeleting; this.txtVideoExtensions.Focus(); return; } 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.SelectedTab = tbFilesAndFolders; this.txtVideoExtensions.Focus(); return; } 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.SelectedTab = tbFilesAndFolders; 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.SelectedTab = tbFilesAndFolders; this.txtOtherExtensions.Focus(); return; } TVSettings S = TVSettings.Instance; 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.EpTBNs = this.cbEpTBNs.Checked; S.NFOs = this.cbNFOs.Checked; S.XBMCImages = this.cbXBMCImages.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; S.EpJPGs = this.cbEpThumbJpg.Checked; S.SeriesJpg = this.cbSeriesJpg.Checked; S.Mede8erXML = this.cbXMLFiles.Checked; S.ShrinkLargeMede8erImages = this.cbShrinkLarge.Checked; S.FanArtJpg = this.cbFantArtJpg.Checked; S.Tidyup.DeleteEmpty = this.cbDeleteEmpty.Checked; S.Tidyup.DeleteEmptyIsRecycle = this.cbRecycleNotDelete.Checked; S.Tidyup.EmptyIgnoreWords = this.cbEmptyIgnoreWords.Checked; S.Tidyup.EmptyIgnoreWordList = this.txtEmptyIgnoreWords.Text; S.Tidyup.EmptyIgnoreExtensions = this.cbEmptyIgnoreExtensions.Checked; S.Tidyup.EmptyIgnoreExtensionList = this.txtEmptyIgnoreExtensions.Text; S.Tidyup.EmptyMaxSizeCheck = this.cbEmptyMaxSize.Checked; int.TryParse(this.txtEmptyMaxSize.Text, out S.Tidyup.EmptyMaxSizeMB); if (this.rbFolderFanArt.Checked) { S.FolderJpgIs = TVSettings.FolderJpgIsType.FanArt; } else if (this.rbFolderBanner.Checked) { S.FolderJpgIs = TVSettings.FolderJpgIsType.Banner; } else if (this.rbFolderSeasonPoster.Checked) { S.FolderJpgIs = TVSettings.FolderJpgIsType.SeasonPoster; } else { S.FolderJpgIs = TVSettings.FolderJpgIsType.Poster; } if (this.rdoQuickScan.Checked) { S.MonitoredFoldersScanType = TVSettings.ScanType.Quick; } else if (this.rdoRecentScan.Checked) { S.MonitoredFoldersScanType = TVSettings.ScanType.Recent; } else { S.MonitoredFoldersScanType = TVSettings.ScanType.Full; } if (this.rdEden.Checked) { S.SelectedXBMCType = TVSettings.XBMCType.Eden; } else if (this.rdFrodo.Checked) { S.SelectedXBMCType = TVSettings.XBMCType.Frodo; } else { S.SelectedXBMCType = TVSettings.XBMCType.Both; } TheTVDB.Instance.GetLock("Preferences-OK"); foreach (Language l in TheTVDB.Instance.LanguageList) { if (l.name == cbLanguages.Text) { S.PreferredLanguage = l.abbreviation; break; } } if (rbWTWScan.Checked) { S.WTWDoubleClick = TVSettings.WTWDoubleClickAction.Scan; } else { S.WTWDoubleClick = TVSettings.WTWDoubleClickAction.Search; } TheTVDB.Instance.SaveCache(); TheTVDB.Instance.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 void Preferences_Load(object sender, System.EventArgs e) { this.SetupLanguages(); TVSettings S = TVSettings.Instance; int r = 1; foreach (Replacement R in S.Replacements) { this.AddNewReplacementRow(R.This, R.That, R.CaseInsensitive); r++; } this.txtMaxSampleSize.Text = S.SampleFileMaxSizeMB.ToString(); this.cbWTWRSS.Checked = S.ExportWTWRSS; this.txtWTWRSS.Text = S.ExportWTWRSSTo; this.txtWTWDays.Text = S.WTWRecentDays.ToString(); this.cbWTWXML.Checked = S.ExportWTWXML; this.txtWTWXML.Text = S.ExportWTWXMLTo; this.txtExportRSSMaxDays.Text = S.ExportRSSMaxDays.ToString(); this.txtExportRSSMaxShows.Text = S.ExportRSSMaxShows.ToString(); this.txtExportRSSDaysPast.Text = S.ExportRSSDaysPast.ToString(); this.cbMissingXML.Checked = S.ExportMissingXML; this.txtMissingXML.Text = S.ExportMissingXMLTo; this.cbMissingCSV.Checked = S.ExportMissingCSV; this.txtMissingCSV.Text = S.ExportMissingCSVTo; this.cbRenamingXML.Checked = S.ExportRenamingXML; this.txtRenamingXML.Text = S.ExportRenamingXMLTo; this.cbFOXML.Checked = S.ExportFOXML; this.txtFOXML.Text = S.ExportFOXMLTo; this.cbStartupTab.SelectedIndex = S.StartupTab; this.cbNotificationIcon.Checked = S.NotificationAreaIcon; this.txtVideoExtensions.Text = S.GetVideoExtensionsString(); this.txtOtherExtensions.Text = S.GetOtherExtensionsString(); this.cbKeepTogether.Checked = S.KeepTogether; this.cbKeepTogether_CheckedChanged(null, null); this.cbLeadingZero.Checked = S.LeadingZeroOnSeason; this.chkShowInTaskbar.Checked = S.ShowInTaskbar; this.cbTxtToSub.Checked = S.RenameTxtToSub; this.cbShowEpisodePictures.Checked = S.ShowEpisodePictures; this.cbAutoSelInMyShows.Checked = S.AutoSelectShowInMyShows; this.txtSpecialsFolderName.Text = S.SpecialsFolderName; this.cbForceLower.Checked = S.ForceLowercaseFilenames; this.cbIgnoreSamples.Checked = S.IgnoreSamples; this.txtRSSuTorrentPath.Text = S.uTorrentPath; this.txtUTResumeDatPath.Text = S.ResumeDatPath; this.txtSABHostPort.Text = S.SABHostPort; this.txtSABAPIKey.Text = S.SABAPIKey; this.cbCheckSABnzbd.Checked = S.CheckSABnzbd; this.txtParallelDownloads.Text = S.ParallelDownloads.ToString(); this.cbSearchRSS.Checked = S.SearchRSS; this.cbEpTBNs.Checked = S.EpTBNs; this.cbNFOs.Checked = S.NFOs; this.cbXBMCImages.Checked = S.XBMCImages; this.cbMeta.Checked = S.pyTivoMeta; this.cbMetaSubfolder.Checked = S.pyTivoMetaSubFolder; this.cbFolderJpg.Checked = S.FolderJpg; this.cbRenameCheck.Checked = S.RenameCheck; this.cbCheckuTorrent.Checked = S.CheckuTorrent; this.cbLookForAirdate.Checked = S.LookForDateInFilename; this.cbMonitorFolder.Checked = S.MonitorFolders; this.cbMissing.Checked = S.MissingCheck; this.cbSearchLocally.Checked = S.SearchLocally; this.cbLeaveOriginals.Checked = S.LeaveOriginals; this.EnterPreferredLanguage = S.PreferredLanguage; this.cbEpThumbJpg.Checked = S.EpJPGs; this.cbSeriesJpg.Checked = S.SeriesJpg; this.cbXMLFiles.Checked = S.Mede8erXML; this.cbShrinkLarge.Checked = S.ShrinkLargeMede8erImages; this.cbFantArtJpg.Checked = S.FanArtJpg; #if DEBUG System.Diagnostics.Debug.Assert(S.Tidyup != null); #endif this.cbDeleteEmpty.Checked = S.Tidyup.DeleteEmpty; this.cbRecycleNotDelete.Checked = S.Tidyup.DeleteEmptyIsRecycle; this.cbEmptyIgnoreWords.Checked = S.Tidyup.EmptyIgnoreWords; this.txtEmptyIgnoreWords.Text = S.Tidyup.EmptyIgnoreWordList; this.cbEmptyIgnoreExtensions.Checked = S.Tidyup.EmptyIgnoreExtensions; this.txtEmptyIgnoreExtensions.Text = S.Tidyup.EmptyIgnoreExtensionList; this.cbEmptyMaxSize.Checked = S.Tidyup.EmptyMaxSizeCheck; this.txtEmptyMaxSize.Text = S.Tidyup.EmptyMaxSizeMB.ToString(); switch (S.WTWDoubleClick) { case TVSettings.WTWDoubleClickAction.Search: default: this.rbWTWSearch.Checked = true; break; case TVSettings.WTWDoubleClickAction.Scan: this.rbWTWScan.Checked = true; break; } this.EnableDisable(null, null); this.ScanOptEnableDisable(); this.FillSearchFolderList(); foreach (string s in S.RSSURLs) { this.AddNewRSSRow(s); } switch (S.FolderJpgIs) { case TVSettings.FolderJpgIsType.FanArt: this.rbFolderFanArt.Checked = true; break; case TVSettings.FolderJpgIsType.Banner: this.rbFolderBanner.Checked = true; break; case TVSettings.FolderJpgIsType.SeasonPoster: this.rbFolderSeasonPoster.Checked = true; break; default: this.rbFolderPoster.Checked = true; break; } switch (S.MonitoredFoldersScanType) { case TVSettings.ScanType.Quick: this.rdoQuickScan.Checked = true; break; case TVSettings.ScanType.Recent: this.rdoRecentScan.Checked = true; break; default: this.rdoFullScan.Checked = true; break; } switch (S.SelectedXBMCType) { case TVSettings.XBMCType.Eden: this.rdEden.Checked = true; break; case TVSettings.XBMCType.Frodo: this.rdFrodo.Checked = true; break; default: this.rdBoth.Checked = true; break; } if (S.ShowStatusColors != null) { foreach ( System.Collections.Generic.KeyValuePair <ShowStatusColoringType, Color> showStatusColor in S.ShowStatusColors) { ListViewItem item = new ListViewItem(); item.Text = showStatusColor.Key.Text; item.Tag = showStatusColor.Key; item.SubItems.Add(TranslateColorToHtml(showStatusColor.Value)); item.ForeColor = showStatusColor.Value; this.lvwDefinedColors.Items.Add(item); } } FillTreeViewColoringShowStatusTypeCombobox(); }
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 }
private int BuildDirCache(SetProgressDelegate prog, int count, int totalFiles, string folder, bool subFolders, TVSettings theSettings) { if (!Directory.Exists(folder)) { MessageBox.Show("The search folder \"" + folder + " does not exist.\n", "Folder does not exist", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(count); } try { if (folder.Length >= 248) { MessageBox.Show("Skipping folder that has a name longer than the Windows permitted 247 characters: " + folder, "Path name too long", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(count); } DirectoryInfo di = new DirectoryInfo(folder); if (!di.Exists) { return(count); } // DirectorySecurity ^ds = di->GetAccessControl(); FileInfo[] f2 = di.GetFiles(); foreach (FileInfo ff in f2) { count++; if ((ff.Name.Length + folder.Length) >= 260) { MessageBox.Show("Skipping file that has a path+name longer than the Windows permitted 259 characters: " + ff.Name + " in " + folder, "File+Path name too long", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { this.Add(new DirCacheEntry(ff, theSettings)); } if ((prog != null) && (totalFiles != 0)) { prog.Invoke(100 * (count) / totalFiles); } } if (subFolders) { DirectoryInfo[] dirs = di.GetDirectories(); foreach (DirectoryInfo di2 in dirs) { count = this.BuildDirCache(prog, count, totalFiles, di2.FullName, subFolders, theSettings); } } } catch (UnauthorizedAccessException) { } catch { } return(count); }
public int AddFolder(SetProgressDelegate prog, int initialCount, int totalFiles, string folder, bool subFolders, TVSettings theSettings) { return(this.BuildDirCache(prog, initialCount, totalFiles, folder, subFolders, theSettings)); }
public DirCache(SetProgressDelegate prog, string folder, bool subFolders, TVSettings theSettings) { this.BuildDirCache(prog, 0, 0, folder, subFolders, theSettings); }