private void ProcessFile([NotNull] FileInfo droppedFile) { if ((droppedFile.Attributes & FileAttributes.Directory) == FileAttributes.Directory) { Logger.Error($"{droppedFile.FullName} is a directory, ignoring."); return; } if (!droppedFile.IsMovieFile()) { Logger.Info($"{droppedFile.FullName} is not a movie file, ignoring."); return; } ShowItem bestShow = cbShowList.SelectedItem == "<Auto>" ? FinderHelper.FindBestMatchingShow(droppedFile, mDoc.Library.Shows) : mDoc.Library.Shows.FirstOrDefault(item => item.ShowName == cbShowList.SelectedItem); if (bestShow is null) { if (TVSettings.Instance.AutoAddAsPartOfQuickRename) { List <ShowItem> addedShows = FinderHelper.FindShows(new List <string> { droppedFile.Name }, mDoc); bestShow = addedShows.FirstOrDefault(); } if (bestShow is null) { Logger.Info($"Cannot find show for {droppedFile.FullName}, ignoring this file."); return; } } if (!FinderHelper.FindSeasEp(droppedFile, out int seasonNum, out int episodeNum, out int _, bestShow, out TVSettings.FilenameProcessorRE _)) { Logger.Info($"Cannot find episode for {bestShow.ShowName} for {droppedFile.FullName}, ignoring this file."); return; } SeriesInfo s = bestShow.TheSeries(); if (s is null) { //We have not downloaded the series, so have to assume that we need the episode/file Logger.Info( $"Can't rename file for {bestShow.ShowName} for {droppedFile.FullName}, as it has not been downloaded yet, ignoring this file."); return; } try { Episode ep = s.GetEpisode(seasonNum, episodeNum, bestShow.DvdOrder); ProcessedEpisode episode = new ProcessedEpisode(ep, bestShow); string filename = TVSettings.Instance.FilenameFriendly( TVSettings.Instance.NamingStyle.NameFor(episode, droppedFile.Extension, droppedFile.DirectoryName.Length)); FileInfo targetFile = new FileInfo(droppedFile.DirectoryName + Path.DirectorySeparatorChar + filename); if (droppedFile.FullName == targetFile.FullName) { Logger.Info( $"Can't rename file for {bestShow.ShowName} for {droppedFile.FullName}, as it already has the appropriate name."); return; } mDoc.TheActionList.Add(new ActionCopyMoveRename(droppedFile, targetFile, episode)); // if we're copying/moving a file across, we might also want to make a thumbnail or NFO for it mDoc.TheActionList.AddRange(new DownloadIdentifiersController().ProcessEpisode(episode, targetFile)); //If keep together is active then we may want to copy over related files too if (TVSettings.Instance.KeepTogether) { FileFinder.KeepTogether(mDoc.TheActionList, false, true); } } catch (SeriesInfo.EpisodeNotFoundException) { Logger.Info( $"Can't rename file for {bestShow.ShowName} for {droppedFile.FullName}, as it does not have Episode {episodeNum} for Season {seasonNum}."); } }
public static string WebsiteShowUrl([NotNull] ShowItem si) { return(string.IsNullOrWhiteSpace(si.TheSeries()?.Slug) ? WebsiteShowUrl(si.TvdbCode) : WebsiteShowUrl(si.TheSeries()?.Slug)); }