public static bool IsFresh(MediaBrowser.Model.IO.FileSystemMetadata fileInfo) { if (fileInfo.Exists && DateTime.UtcNow.Subtract(fileInfo.LastWriteTimeUtc).Days <= 10) { return(true); } return(false); }
public YTDLEpisodeProviderTest() { _jf_fs = new Mock <MediaBrowser.Model.IO.IFileSystem>(); _fs = new MockFileSystem(new Dictionary <string, MockFileData> { }); _config = new Mock <MediaBrowser.Controller.Configuration.IServerConfigurationManager>(); _config.Setup(config => config.ApplicationPaths.CachePath).Returns("\\cache"); _epInfo = new EpisodeInfo(); _fs_metadata = new MediaBrowser.Model.IO.FileSystemMetadata(); _token = new CancellationToken(); _provider = new YTDLEpisodeProvider(_jf_fs.Object, new Mock <Microsoft.Extensions.Logging.ILogger <YTDLEpisodeProvider> >().Object, _config.Object, _fs); }
/// <summary> /// It's not really meant to be used this way, but this is our library /// "scanner". It scans the files and folders, and conditionally filters /// out _some_ of the files and/or folders. /// </summary> /// <param name="fileInfo"></param> /// <param name="parent"></param> /// <returns>True if the entry should be ignored.</returns> public bool ShouldIgnore(MediaBrowser.Model.IO.FileSystemMetadata fileInfo, BaseItem parent) { // Everything in the root folder is ignored by us. var root = LibraryManager.RootFolder; if (fileInfo == null || parent == null || root == null || parent == root || !(parent is Folder) || fileInfo.FullName.StartsWith(root.Path)) { return(false); } try { // Enable the scanner if we selected to use the Shoko provider for any metadata type on the current root folder. var libraryOptions = LibraryManager.GetLibraryOptions(parent); if (!libraryOptions.TypeOptions.Any(o => o.MetadataFetchers.Contains("Shoko"))) { return(false); } var fullPath = fileInfo.FullName; var rootFolder = ApiManager.FindMediaFolder(fullPath, parent as Folder, root); var partialPath = fullPath.Substring(rootFolder.Path.Length); if (fileInfo.IsDirectory) { return(ScanDirectory(partialPath, fullPath, LibraryManager.GetInheritedContentType(parent))); } else { return(ScanFile(partialPath, fullPath)); } } catch (System.Exception e) { if (!(e is System.Net.Http.HttpRequestException && e.Message.Contains("Connection refused"))) { Logger.LogError(e, $"Threw unexpectedly - {e.Message}"); } return(false); } }