/// <summary> /// Sets new title to some files and takes care of storing it properly (last [TitleHistorySize] Titles are stored) /// </summary> /// <param name="files">files to which this title should be set to</param> /// <param name="title">name to be set</param> public void SetNewTitle(List <InfoEntry> files, string title) { string[] LastTitlesOld = Helper.ReadProperties(Config.LastTitles); foreach (InfoEntry ie in files) { if (ie.Showname != title) { ie.Showname = title; } } //check if list of titles contains new title int Index = -1; for (int i = 0; i < LastTitlesOld.Length; i++) { string str = LastTitlesOld[i]; if (str == title) { Index = i; break; } } //if the title is new if (Index == -1) { List <string> LastTitlesNew = new List <string>(); LastTitlesNew.Add(title); foreach (string s in LastTitlesOld) { LastTitlesNew.Add(s); } int size = Helper.ReadInt(Config.TitleHistorySize); Helper.WriteProperties(Config.LastTitles, LastTitlesNew.GetRange(0, Math.Min(LastTitlesNew.Count, size)).ToArray()); } //if the title is in the list already, bring it to the front else { List <string> items = new List <string>(LastTitlesOld); items.RemoveAt(Index); items.Insert(0, title); Helper.WriteProperties(Config.LastTitles, items.ToArray()); } }
/// <summary> /// Sets new episode to some files and takes care of storing it properly (last [TITLE_HISTORY_SIZE_KEY] Titles are stored) /// </summary> /// <param name="someMediaFiles">files to which this episode should be set to</param> /// <param name="newShowname">name to be set</param> public void setNewShowname(List <MediaFile> someMediaFiles, string newShowname) { foreach (MediaFile mediaFile in someMediaFiles) { if (mediaFile.Showname != newShowname) { mediaFile.Showname = newShowname; } } List <string> lastSearchedShownames = new List <string>(Helper.ReadProperties(ConfigKeyConstants.LAST_SEARCHED_SHOWNAMES_KEY)); //check if list of shownames contains new showname int Index = -1; for (int i = 0; i < lastSearchedShownames.Count; i++) { string searchedShowname = lastSearchedShownames[i]; if (searchedShowname == newShowname) { Index = i; break; } } //if the episode is new if (Index == -1) { lastSearchedShownames.Insert(0, newShowname); } //if the episode is in the list already, bring it to the front else { lastSearchedShownames.RemoveAt(Index); lastSearchedShownames.Insert(0, newShowname); } int shownameHistorySize = Helper.ReadInt(ConfigKeyConstants.SHOWNAME_HISTORY_SIZE_KEY); Helper.WriteProperties(ConfigKeyConstants.LAST_SEARCHED_SHOWNAMES_KEY, lastSearchedShownames.GetRange(0, Math.Min(lastSearchedShownames.Count, shownameHistorySize)).ToArray()); }