internal static bool CreateNewMediaSnapshotScanDirectoriesImportMediaFiles (string importRootFolder, FileInfo[] allfilesFI, IMLSection moviesSection, ref ArrayList extensionsToIgnore, string[] filmLocations, string[] videoExtensions, string[] audioExtensions, IEnumerable <string> combinedSceneTags, string pluginPath, string mediaSnapshotLocation, IEnumerable <string> videoExtensionsCommon) { if (Settings.EnableMediaSnapshots) { MediaSnapshotEngine .ConstructAndWriteNewMediaSnapshot (allfilesFI, mediaSnapshotLocation); } return(RecursiveDirectoryScanner .ScanSubDirectoriesAndImportMediaFiles (importRootFolder, allfilesFI, moviesSection, ref extensionsToIgnore, filmLocations, videoExtensions, audioExtensions, combinedSceneTags, pluginPath, videoExtensionsCommon)); }
internal static bool ImportBook(FileSystemInfo file, IMLSection booksSection, string fileName, string ext) { if (ext != ".pdf" && ext != ".PDF" && ext != ".djvu" && ext != ".DJVU") return false; if (!Settings.EnableBooksImporter) return false; bool itemfound = false; IMLItemList list = booksSection.SearchByLocation(file.FullName); foreach (IMLItem item in list.Where(item => item.Location == file.FullName)) itemfound = true; if (itemfound) return true; Application.DoEvents(); Debugger.LogMessageToFile("Importing book " + file.Name + "..."); Importer.ThisProgress.Progress(Importer.CurrentProgress, "Importing book " + file.Name + "..."); IMLItem Item; Helpers.AddFileToSection(out Item, booksSection, fileName, file.FullName, file.FullName); return true; }
private static bool CountSectionItems(IMLSection section, out int totalSectionItems) { Helpers.LogMessageToFile("Counting section items..."); totalSectionItems = section.ItemCount; return totalSectionItems != 0; }
internal static bool DetectAndImportMultipartMovie(IMLSection moviesSection, MediaInfo mediaInfo, bool isUNC, FileSystemInfo dir, string externalID, ArrayList filesInDir, string[] videoexts, int videosCount) { videosCount = CountVideosInDirectory(videoexts, videosCount, filesInDir); if (!Settings.EnableMediaDetection || videosCount <= 1 || videosCount >= 4) return false; MainImportingEngine.ThisProgress.Progress(MainImportingEngine.CurrentProgress, "Detecting film parts..."); int parts = 0; string locationTag = String.Empty; int count = 1; foreach (FileInfo file in filesInDir) { var fileIsVideo = DetermineIfFileIsVideoByExtensionMatching(videoexts, file); parts = DetectMoviePart(parts, mediaInfo, videosCount, fileIsVideo, file, isUNC, ref count, ref locationTag, ref externalID); } return OnMultiplePartsDetectionAddToMoviesSection(moviesSection, locationTag, externalID, parts, dir); }
internal static bool UpdateMediaSection(IMLSection section, string pluginPath) { Helpers.LogMessageToFile("Media Section Updater started."); int totalSectionItems; if (!CountSectionItems (section, out totalSectionItems)) return true; #region Section varibales Helpers.LogMessageToFile ("Initializing section variables..."); string[] videoExtensions; string[] videoExtensionsCommon; ImportProgress.CurrentProgress = 0; ImportProgress.GeneralStatus = "Updating Media Section"; ImportProgress.SpecialStatus = ""; MainImportingEngine.ThisProgress.Progress (ImportProgress.CurrentProgress, "Preparing to update media section..."); //Thread.Sleep(500); #endregion FileTypeVerifier.CacheMediaExtensionsTables (pluginPath, out videoExtensions, out videoExtensionsCommon); return TryToPerfrormMediaSectionUpdate (section, pluginPath, videoExtensions, videoExtensionsCommon, totalSectionItems); }
internal static void AddFileToSection (out IMLItem item, IMLSection section, string itemName, string itemLocation, string externalID) { //TODO: Implement option to not update the Media Section on each imported item. if (Settings.UpdateMediaSectionOnEachImportedItem) { section.BeginUpdate(); } item = section.AddNewItem (itemName, itemLocation); item.ExternalID = externalID; item.SaveTags(); if (Settings.UpdateMediaSectionOnEachImportedItem) { section.EndUpdate(); } }
internal static bool PopulateMediaSection (FileInfo file, IMLSection moviesSection, IEnumerable <string> videoexts, DirectoryInfo parent, bool isVideo, bool isAudio, string fileName, string parentName, IEnumerable <string> combinedSceneTags) { if (!isVideo && !isAudio) { return(true); } if (Helpers.UserCancels (MainImportingEngine.SpecialStatus)) { return(false); } ImportVideo (file, moviesSection, videoexts, parent, isVideo, fileName, parentName, combinedSceneTags); return(true); }
internal static bool ScanConstructedArrayAndImportMediaFiles (IMLSection moviesSection, IMLSection tvSection, IMLSection musicSection, ref IList<string> extensionsToIgnore, string[] filmLocations, string[] tvShowsLocations, string[] musicLocations, string[] videoExtensions, string[] audioExtensions, IEnumerable<string> combinedSceneTags, ICollection<FileInfo> filesToImport, MediaInfo mediaInfo, string pluginPath, IEnumerable<string> videoExtensionsCommon) { if (!Settings.UpdateMediaSectionOnEachImportedItem) ImportingEngineHelpers.BeginUpdatingSections(); if ( !ImportFilesInArray(moviesSection, tvSection, musicSection, ref extensionsToIgnore, filmLocations, tvShowsLocations, musicLocations, videoExtensions, audioExtensions, combinedSceneTags, filesToImport, mediaInfo, pluginPath, videoExtensionsCommon) ) return false; if (!Settings.UpdateMediaSectionOnEachImportedItem) ImportingEngineHelpers.EndUpdatingSections(); return true; }
public static void ReplaceTag(string tagName, string[] searchStrings, IMLSection section) { foreach (string searchReplaceString in searchStrings) { MessageBox.Show(searchReplaceString); string[] replaces = searchReplaceString.Split('|'); string searchString = replaces[0]; string replaceString = replaces[1]; MessageBox.Show(@"Will replace with: " + replaceString); IMLItemList itemList = section.SearchByTag(tagName, searchString); section.BeginUpdate(); foreach (IMLItem t in itemList) { MessageBox.Show(tagName); t.Tags[tagName] = replaceString; MessageBox.Show((string)t.Tags[tagName]); t.SaveTags(); } section.EndUpdate(); } }
//TODO: make all these parameters a struct private static bool ScanSubDirectories (IMLSection moviesSection, ref ArrayList extensionsToIgnore, ref string[] filmLocations, string[] videoExtensions, string[] audioExtensions, int totalFiles, ref int currentFile, string pluginPath, IEnumerable <string> directories, IEnumerable <string> combinedSceneTags, IEnumerable <string> videoExtensionsCommon) { foreach (string strDirSub in directories) { if (!ScanDirectoryRecursively (strDirSub, moviesSection, ref extensionsToIgnore, ref filmLocations, videoExtensions, audioExtensions, totalFiles, ref currentFile, pluginPath, combinedSceneTags, videoExtensionsCommon)) { return(false); } } return(true); }
private static bool TryToPerfrormMediaSectionUpdate(IMLSection section, string pluginPath, string[] videoExtensions, string[] videoExtensionsCommon, int totalSectionItems) { try { int currentSectionItem = 1; section.BeginUpdate(); Helpers.LogMessageToFile ("Section update was started."); if (section.GetAllItemIDs().Any (id => !SingleMovieItemUpdater.UpdateSectionItem (id, section, pluginPath, ref currentSectionItem, totalSectionItems, videoExtensions, videoExtensionsCommon))) { return false; } section.EndUpdate(); Helpers.LogMessageToFile ("Section update is complete."); } catch (Exception e) { AcknowledgeMediaSectionUpdaterErrorAndTerminateImportSequence(e); } return true; }
private static void DownloadRssFeedAndPopulateFeedEntries (IMLSection newsSection, string url, WebClient webClient) { try { RssFeed feed; var feedEntries = DownloadFeedGetFeedEntries(url, out feed); PopulateFeedEntries(newsSection, feed, feedEntries, webClient); } catch (Exception e) { StatusForm.statusForm.TrayIcon.ShowBalloonTip(5000, "Error downloading RSS newsfeed", "MediaFairy encountered an error trying to download an RSS newsfeed you provided. Please see Debug.log for details on this error.", ToolTipIcon.Warning); Debugger.LogMessageToFile( "[RSS news downloader] An unexpected error occured while trying to download an RSS newsfeed." + " The error was: " + e); } }
internal static bool AnalyzeFileAndAddToMediaSection(FileInfo file, IMLSection section, IList extensionsToIgnore, IEnumerable<string> videoExtensions, IEnumerable<string> combinedSceneTags, string fileExtension, bool isAudio, bool isVideo, DirectoryInfo parent, string parentName, string fileName) { Application.DoEvents(); MediaTypeDetector.AddFileToIgnoredExtensions (file, extensionsToIgnore, fileName, isAudio, isVideo, fileExtension); Application.DoEvents(); if (!PopulateMediaSection (file, section, videoExtensions, parent, isVideo, isAudio, fileName, parentName, combinedSceneTags)) return false; Application.DoEvents(); return true; }
internal static void BeginUpdatingSections (IMLSection section) { section.BeginUpdate(); }
internal static void EndUpdatingSections (IMLSection moviesSection) { moviesSection.EndUpdate(); }
private static bool SearchForExistingItemInMoviesSection(FileSystemInfo file, IEnumerable<string> filmLocations, IMLSection section) { if (filmLocations == null) return false; // ReSharper disable LoopCanBeConvertedToQuery foreach (var movieFolder in Settings.FilmsFolders) // ReSharper restore LoopCanBeConvertedToQuery { if (!file.FullName.Contains(movieFolder)) continue; //if (filmLocations.Any(location => location == file.FullName)) // return true; IMLItem item = section.FindItemByExternalID (file.FullName); if (item != null) return true; } return false; }
//RUN MAIN CODE ON NEW THREAD // ReSharper disable UnusedParameter.Global public void IdentifyDisc(IMLSection moviesSection, IMLSection tvSeriesSection) // ReSharper restore UnusedParameter.Global { //string PluginDir = Debugger.GetPluginPath(); //string DataDirectory = ToolBox.MeedioUtils.GetPluginDataDir(PluginName, PluginType); ///////////////////////////////////////PROCESS DISC//////////////////////////////// //GET DRIVE LETTER FROM DISK INSERT NOTIFICATION string drive = Settings.DvdDrive; string d2 = drive + ":"; //GET DRIVE LETTER PLUS ":" FOR DISK EJECT Importer.ThisProgress.Progress(Importer.CurrentProgress, "Reading drive " + drive + "..."); IdentifyDvdDisc(moviesSection, drive, d2); IdentifyBluRayDisc(drive, moviesSection, d2); Helpers.UpdateProgress(Importer.GeneralStatus, "Offline media importing complete.", null); return; }
internal static string[] CacheMoviesSection (IMLSection section) { MainImportingEngine.CurrentProgress = 0; MainImportingEngine.ThisProgress.Progress (MainImportingEngine.CurrentProgress, "Caching Movies section..."); int[] itemIDs = section != null ? section.GetAllItemIDs() : new int[] { }; int itemsCount = itemIDs.Length; string[] filmLocations = new string[itemsCount]; int cacheCounter = 0; foreach (IMLItem item in itemIDs.Select (id => section != null ? section.FindItemByID(id) : null)) { filmLocations[cacheCounter] = item.Location; cacheCounter++; } return(filmLocations); }
internal static bool ScanMediaDirectories ( string[] mediaFolders, ref ArrayList extensionsToIgnore, string[] filmLocations, string[] videoExtensions, string[] audioExtensions, IEnumerable <string> combinedSceneTags, IEnumerable <string> videoExtensionsCommon, Importer importer, IMLSection section ) { string pluginpath = Debugger.GetPluginPath(); foreach (string importRootFolder in mediaFolders) { if ( !CalculateExaminationtimeAndScanMediaFolder (section, ref extensionsToIgnore, filmLocations, videoExtensions, audioExtensions, importRootFolder, pluginpath, combinedSceneTags, videoExtensionsCommon) ) { return(false); } } return(true); }
internal static bool PopulateMediaSection (FileInfo file, IMLSection moviesSection, IMLSection tvSection, IMLSection musicSection, IEnumerable<string> videoexts, int audioDuration, string filesize, MediaInfo mi, DirectoryInfo parent, string filecodec, bool isVideo, bool isAudio, int videoDuration, string fileName, string parentName, IEnumerable<string> combinedSceneTags) { if (String.IsNullOrEmpty(filecodec) && !isVideo && !isAudio) return true; //Debugger.LogMessageToFile(Environment.NewLine + "The file " + file.Name + //" has been detected as a valid media file." + Environment.NewLine + //" Proceeding to media type recognition..."); if (Helpers.UserCancels(MainImportingEngine.SpecialStatus, null)) return false; ImportVideo(file, moviesSection, tvSection, videoexts, filesize, mi, parent, filecodec, isVideo, videoDuration, fileName, parentName, combinedSceneTags); if (Helpers.UserCancels(MainImportingEngine.SpecialStatus, null)) return false; ImportAudio(file, musicSection, audioDuration, filesize, mi, filecodec, isAudio, fileName); return true; }
internal static bool CompareMediaSnapshotsAndImportNewMediaFiles (FileInfo[] allfilesFI, IMLSection moviesSection, ref ArrayList extensionsToIgnore, string[] filmLocations, string[] videoExtensions, string[] audioExtensions, IEnumerable <string> combinedSceneTags, string mediaSnapshotLocation, string pluginPath, IEnumerable <string> videoExtensionsCommon) { Application.DoEvents(); var filesToImport = CompareSnapshotsAndConstructArrayOfFilesToImport (allfilesFI, filmLocations, mediaSnapshotLocation); Application.DoEvents(); return(MediaSnapshotEngine .ScanConstructedArrayAndImportMediaFiles( moviesSection, ref extensionsToIgnore, filmLocations, videoExtensions, audioExtensions, combinedSceneTags, filesToImport, pluginPath, videoExtensionsCommon)); }
private static void ImportMovie (FileInfo file, IMLSection moviesSection, IEnumerable <string> videoexts, DirectoryInfo parent, string fileName, string parentName, IEnumerable <string> combinedSceneTags) { Debugger.LogMessageToFile ("[Media File Importers]" + " Movie File Importer is enabled."); if (!MediaSectionPopulatorHelpers .ProceedToImportMovie(file)) { return; } LocateTitle_AddToMoviesSection_ImportMediaInfo (file, moviesSection, videoexts, parent, fileName, parentName, combinedSceneTags); }
internal static bool OnMultiplePartsDetectionAddToMoviesSection (IMLSection moviesSection, string locationTag, string externalID, int parts, FileSystemInfo dir) { if (parts == 2 || parts == 3) { Debugger.LogMessageToFile ( "Found multi-part video: " + dir.Name + " . Proceeding to add the movie to the Movies section." ); IMLItem item; MediaSectionPopulator .AddFileToSection (out item, moviesSection, dir.Name, locationTag + "|", externalID); return(true); } return(false); }
protected internal static void ScanDiskForEntertainmentMedia(IEnumerable<string> combinedSceneTags, string[] videoExtensions, string[] audioExtensions, string pluginpath, string[] filmLocations, ArrayList extensionsToIgnore, IEnumerable<string> videoExtensionsCommon, Importer importer, IMLSection section) { ImportingEngineHelpers .BeginUpdatingSections (section); extensionsToIgnore = ScanDiskForMovies (combinedSceneTags, videoExtensions, audioExtensions, filmLocations, extensionsToIgnore, videoExtensionsCommon, importer, section); MediaImportingEngineHelpers .WriteNonMediaExtensionsToFile (extensionsToIgnore, pluginpath); ImportingEngineHelpers .EndUpdatingSections (section); }
private static void DeleteMediaImagesAndLibraryItem (IMLSection section, IMLItem item) { Debugger.LogMessageToFile(String.Format("The non-existent item {0}will be deleted from section.", item.Name)); Helpers.UpdateProgress ("Performing Diagnostic Operations", String.Format("The non-existent item " + "{0} will be deleted from section.", item.Name), item); Thread.Sleep(100); string imageFile = item.ImageFile; string fanart = (string) item.Tags["fanart"]; DeleteCoverAndFanartImages (fanart, imageFile); section.DeleteItem(item); }
public bool Import(IMLSection section, IMLImportProgress progress) { return MainImportingEngine.DoImport(this, section, progress); }
public static bool UpdateMediaSections (IBaseSystem iBaseSystem, IMLSection section, IEnumerable <string> combinedSceneTags) { string pluginpath = Debugger.GetPluginPath(); MainImportingEngine .CurrentProgress = 0; MainImportingEngine.GeneralStatus = "Starting media updating process..."; MainImportingEngine.SpecialStatus = ""; try { if ( !MoviesSectionUpdater .UpdateMoviesSection (pluginpath, iBaseSystem, combinedSceneTags, section)) { return(true); } } catch (Exception e) { Debugger.LogMessageToFile (Environment.NewLine + "An unexpected error occured" + " in DoImport() method." + " The error was: " + Environment.NewLine + e + Environment.NewLine); MainImportingEngine .CurrentProgress = 100; MainImportingEngine.ThisProgress.Progress (MainImportingEngine.CurrentProgress, "The import process terminated" + " unexpectidly due to an error."); } return(true); }
internal static void LinkFilmItemChains (IMLSection moviesSection, IMLItemList allFilmItems, IMLItem Item) { if (!MeediFier.Settings .FilmItemChainLinkerIsEnabled) return; if (allFilmItems == null || allFilmItems.Count <= 0) return; MainImportingEngine.ThisProgress.Progress (MainImportingEngine.CurrentProgress, "scanning for un-linked files..."); Application.DoEvents(); foreach (IMLItem item in allFilmItems) { string itemImdbID = Helpers .GetTagValueFromItem (item, "ImdbID"); string itemToCompareImdbID = Helpers .GetTagValueFromItem (Item, "ImdbID"); if (item.Location == Item.Location || itemImdbID != itemToCompareImdbID) continue; if (item.Location.StartsWith("|") || Item.Location.StartsWith("|")) continue; Item.Location = "|" + Item.Location + "|" + item.Location + "|"; Item.SaveTags(); moviesSection.DeleteItem(item); } }
public bool Import (IMLSection section, IMLImportProgress progress) { return MainImportingEngine.DoImport (this, Ibs, section, progress); }
private static void ImportAudio(FileInfo file, IMLSection musicSection, int audioDuration, string filesize, MediaInfo mi, string filecodec, bool isAudio, string fileName) { if (!MediaSectionPopulatorHelpers.ProceedToImportAudioTrack(file, isAudio)) return; AddToMusicSection_ImportMediaInfo(file, musicSection, audioDuration, filesize, mi, filecodec, fileName); }
public static bool DoImport (Importer importer, IBaseSystem iBaseSystem, IMLSection section, IMLImportProgress progress) { try { ThisProgress = progress; Settings.ImportingStarted = false; Settings.ImportingCompleted = false; MediaLocationsRetriever .RetrieveMediaLocations (importer); if (ImportingEngineHelpers .PerformInitializationTasks(section)) { return(true); } var combinedSceneTags = VideoFilenameCleaner .ReadDictionaryReturnAllTags(); StartMainImportingEngine (importer, iBaseSystem, section, combinedSceneTags); ImportingEngineHelpers .FinishImport(); return(true); } catch (Exception e) { Debugger.LogMessageToFile ("An unexpected error ocurred " + "in the main import method DoImport(). " + "The error was: " + e); } return(true); }
private static bool CalculateExaminationtimeAndScanMediaFolder (IMLSection moviesSection, ref ArrayList extensionsToIgnore, string[] filmLocations, string[] videoExtensions, string[] audioExtensions, string importRootFolder, string pluginpath, IEnumerable <string> combinedSceneTags, IEnumerable <string> videoExtensionsCommon) { if (ValidateRootDirectory (importRootFolder)) { return(true); } #region File Importer varibales MainImportingEngine.CurrentProgress = 0; MainImportingEngine.GeneralStatus = "Importing Media files"; MainImportingEngine.SpecialStatus = String.Empty; #endregion try { var allfiles = ScanDirectoriesConstructIncludedDirectoriesAndFilesArrays (importRootFolder); Application.DoEvents(); if ( !MediaSnapshotEngine .IfMediaSnaphotExists_ScanDirectoriesAndImportNewFiles_ElseCreateNewSnapshotAndImportFilesFromScratch (importRootFolder, pluginpath, allfiles, moviesSection, ref extensionsToIgnore, filmLocations, videoExtensions, audioExtensions, combinedSceneTags, videoExtensionsCommon)) { return(false); } } catch (Exception e) { Debugger .LogMessageToFile (e.ToString()); } return(true); }
internal static void ImportMeePopupProviderField(IMLSection section) { if (!Settings.MeePopupProviderCompatibility) return; #region Process initialization feedback MainImportingEngine.ThisProgress.Progress(0, "Adding field meePopupProvider..."); Thread.Sleep(300); #endregion section.AddNewTag("meePopupProvider"); var itemsProcessed = 0; section.BeginUpdate(); #region Update Section items foreach (var readOnlyItem in section.GetReadOnlyItems()) { string id = readOnlyItem.ID.ToString(CultureInfo.InvariantCulture); #region Calculate progress int percentComplete = (int)(itemsProcessed * (100.0 / section.ItemCount ) ); if (percentComplete > 100) percentComplete = 100; itemsProcessed++; #endregion #region Poll for user cancellation request if (!MainImportingEngine.ThisProgress.Progress(percentComplete, "Processing Items")) { section.CancelUpdate(); MainImportingEngine.ThisProgress.Progress(100, "Import Canceled"); return; } #endregion #region If field is populated, continue to next item if ( (string) readOnlyItem.Tags.Get("meePopupProvider", "") == id) continue; #endregion #region Populate the item's field IMLItem item = section.FindItemByID(readOnlyItem.ID); item.Tags["meePopupProvider"] = id; item.SaveTags(); #endregion } //endof foreach #endregion section.EndUpdate(); } //endof function
internal static bool SkipAlreadyImportedFiles(FileSystemInfo file, IEnumerable<string> filmLocations, IMLSection section) { Helpers.UpdateProgress("Importing Media Files...", "Searching media library for existing file entry..."); return SearchForExistingItemInMoviesSection (file, filmLocations, section); }
internal static bool ImportPcGame(WshShell shell, string linkPathName, IMLSection pcGamesSection ) { IWshShortcut link = (IWshShortcut)shell.CreateShortcut(linkPathName); FileInfo linkFile = new FileInfo(link.FullName); string shortcutName = linkFile.Name; shortcutName = shortcutName.Remove(shortcutName.Length - 4, 4); FileVersionInfo myFileVersionInfo; try { myFileVersionInfo = FileVersionInfo.GetVersionInfo(link.TargetPath); } catch (Exception e) { Debugger.LogMessageToFile("An unexpected error ocurred while trying to retrieve this game's version information from the game's executable. The error was: " + Environment.NewLine + e ); return false; } string title = myFileVersionInfo.ProductName; string company = myFileVersionInfo.CompanyName; string language = myFileVersionInfo.Language; string description = myFileVersionInfo.FileDescription; string version = myFileVersionInfo.FileVersion; IMLItem item = pcGamesSection.FindItemByLocation(link.TargetPath); if (item == null) item = pcGamesSection.AddNewItem(title, link.TargetPath); else return false; if (!String.IsNullOrEmpty(title)) { item.Name = title; item.Tags["Title"] = title; } else { item.Name = shortcutName; item.Tags["Title"] = shortcutName; } item.Tags["Company"] = company; item.Tags["Language"] = language; item.Tags["Description"] = description; item.Tags["Version"] = version; item.SaveTags(); return true; }
internal static bool UpdateSectionItem(int itemId, IMLSection section, string pluginpath, ref int currentItem, int totalItems, string[] videoExtensions, string[] videoExtensionsCommon) { Helpers.LogMessageToFile("Calculating import progress..."); ImportProgress.CurrentProgress = ImportProgress.CalculateImportProgress (currentItem, totalItems); #region item variables Helpers.LogMessageToFile("Locating item by ID: " + itemId); var item = section.FindItemByID(itemId); if (item == null) return true; Helpers.LogMessageToFile("Section entry was verified."); Helpers.LogMessageToFile("Initializing item keys..."); string location = item.Location; string fileExtension; #endregion string rootDirectory; if ( !RetrieveFileInfo (location, out rootDirectory, out fileExtension) ) return true; if ( !Diagnostics.FileTypeVerifier.FileIsVideo (videoExtensions, fileExtension, videoExtensionsCommon) ) return true; VideoHashConstructor.VideoFingerprintIdentifier.RetrieveFileHash (item, location); if (ImportProgress.UserCancels(ImportProgress.SpecialStatus, item)) return false; VideoSubtitleDownloaderHelpers. SearchForAndDownloadSubtitleForPrimaryOrSecondaryLanguage(item); if (ImportProgress.UserCancels(ImportProgress.SpecialStatus, item)) return false; item.SaveTags(); currentItem++; return true; }
internal static bool RunMediaSectionsUpdatingEngine (Importer importer, IBaseSystem iBaseSystem, IMLSection section, IEnumerable <string> combinedSceneTags) { return(!MediaUpdaters .UpdateMediaSections (iBaseSystem, section, combinedSceneTags)); }
public UpdateMediaSectionsParams (IMLSection section, IBaseSystem iBaseSystem, IEnumerable <string> combinedSceneTags) { Section = section; Ibs = iBaseSystem; CombinedSceneTags = combinedSceneTags; }
internal static void PerformPreImportCaching ( IList <FileInfo> datfiles, string pluginpath, out string[] filmLocations, out ArrayList extensionsToIgnore, out string[] videoExtensions, out string[] audioExtensions, out string[] videoExtensionsCommon, IMLSection section ) { int moviesItemcount; CountMediaSectionsItems (out moviesItemcount, section); DeleteSnapshotsOnEmptySectionsDetection (datfiles, moviesItemcount); CacheMediaSnapshots(datfiles); extensionsToIgnore = CacheMediaExtensionsTables (pluginpath, out audioExtensions, out videoExtensions, out videoExtensionsCommon); #region Cache Media Sections Helpers.UpdateProgress("", "Caching media sections..."); Debugger.LogMessageToFile("Caching media sections..."); try { filmLocations = CacheMoviesSection(section); } catch (Exception e) { Helpers.UpdateProgress("", "Unable to cache media sections."); throw; } #endregion }
// ReSharper disable InconsistentNaming private static void AddToMusicSection_ImportMediaInfo(FileSystemInfo file, IMLSection musicSection, int audioDuration, // ReSharper restore InconsistentNaming string filesize, MediaInfo mi, string filecodec, string fileName) { Application.DoEvents(); //Debugger.LogMessageToFile("Importing audio track " + fileName + "..."); MainImportingEngine.ThisProgress.Progress(MainImportingEngine.CurrentProgress, "Importing audio track " + fileName + "..."); IMLItem item; AddFileToSection(out item, musicSection, fileName, file.FullName, file.FullName); MediaInformation.ImportMediaInfoforAudio(mi, item, filesize, filecodec, audioDuration); }
internal static bool SkipAlreadyImportedFiles (FileSystemInfo file, IEnumerable <string> filmLocations, IMLSection section) { Helpers.UpdateProgress("Importing Media Files...", "Searching media library for existing file entry..."); return(SearchForExistingItemInMoviesSection (file, filmLocations, section)); }
public UpdateMediaSectionsParams(IMLSection section, string mdfSettingsa, IBaseSystem iBaseSystem, string mdfSettingsb, string mdfSettingsc, IEnumerable<string> combinedSceneTags) { Section = section; MdfSettingsa = mdfSettingsa; Ibs = iBaseSystem; MdfSettingsb = mdfSettingsb; MdfSettingsc = mdfSettingsc; CombinedSceneTags = combinedSceneTags; }
internal static string IMDbDetailer (IMLSection moviesSection, IMDbOperations imdbOp, IMLItem item, string itemTitle, string imdbid) { if (!MeediFier.Settings.FilmIMDbDetailsDownloaderIsEnabled) return imdbid; Debugger.LogMessageToFile ("IMDb film details downloader is enabled"); if (String.IsNullOrEmpty(imdbid)) return imdbid; if (!imdbid.StartsWith("tt")) imdbid = "tt" + imdbid; MainImportingEngine.ThisProgress.Progress (MainImportingEngine.CurrentProgress, "Downloading details from IMDb for '" + itemTitle + "'..."); Debugger.LogMessageToFile ("[IMDb film details downloader] " + "Proceeding to phase 1"); IIMDbMovie movie = IMDbMovieDetailsDownloader.DownloadMovieDetailsFromIMDb (imdbid, true); if (movie == null) return imdbid; imdbOp.SaveIMDbMovieDetails (item, moviesSection, movie); return imdbid; }
private static bool CalculateExaminationtimeAndScanMediaFolder (IMLSection moviesSection, IMLSection tvSection, IMLSection musicSection, ref IList<string> extensionsToIgnore, string[] filmLocations, string[] tvShowsLocations, string[] musicLocations, string[] videoExtensions, string[] audioExtensions, string importRootFolder, string pluginpath, IEnumerable<string> combinedSceneTags, IEnumerable<string> videoExtensionsCommon) { if (ValidateRootDirectory(importRootFolder)) return true; #region File Importer varibales MainImportingEngine.CurrentProgress = 0; MainImportingEngine.GeneralStatus = "Importing Media files"; MainImportingEngine.SpecialStatus = String.Empty; #endregion try { var allfiles = ScanDirectoriesConstructIncludedDirectoriesAndFilesArrays(importRootFolder); Application.DoEvents(); if ( !MediaSnapshotEngine .IfMediaSnaphotExists_ScanDirectoriesAndImportNewFiles_ElseCreateNewSnapshotAndImportFilesFromScratch (importRootFolder, pluginpath, allfiles, moviesSection, tvSection, musicSection, ref extensionsToIgnore, filmLocations, tvShowsLocations, musicLocations, videoExtensions, audioExtensions, combinedSceneTags, videoExtensionsCommon)) return false; } catch (Exception e) { Debugger.LogMessageToFile(e.ToString()); } return true; }
private static void AddToMoviesSectionAndImportMediaInfo (FileSystemInfo file, IMLSection moviesSection, string fileName, string parentName, bool useParentFolder) { Application.DoEvents(); IMLItem item; AddToMoviesSection (file, moviesSection, fileName, parentName, useParentFolder, out item); }
private static void DownloadRssFeedsAndPopulateFeedEntries (IMLSection newsSection, WebClient webClient) { newsSection.BeginUpdate(); foreach (string url in Settings.RsSfeeds) DownloadRssFeedAndPopulateFeedEntries(newsSection, url, webClient); newsSection.EndUpdate(); }
public static void ImportMediaFilesMain (IEnumerable <string> combinedSceneTags, Importer importer, IMLSection section) { string pluginpath; FileInfo[] mediaSnapshotsFI = MediaImportingEngineHelpers.LoadMediaSnapshots (out pluginpath); Debugger.LogMessageToFile ("Media File Importer is enabled."); if (Settings.RootMediaFolders == null || Settings.RootMediaFolders.Length == 0) { return; } #region Declare Vars string[] filmLocations; string[] musicLocations; string[] tvShowsLocations; ArrayList extensionsToIgnore; string[] videoExtensions; string[] videoExtensionsCommon; string[] audioExtensions; #endregion MediaImportingEngineHelpers.PerformPreImportCaching (mediaSnapshotsFI, pluginpath, out filmLocations, out extensionsToIgnore, out videoExtensions, out audioExtensions, out videoExtensionsCommon, section); DiskMediaScanInitiator.ScanDiskForEntertainmentMedia (combinedSceneTags, videoExtensions, audioExtensions, pluginpath, filmLocations, extensionsToIgnore, videoExtensionsCommon, importer, section); }
public static bool UpdateMediaSections(IBaseSystem iBaseSystem, IMLSection section, IEnumerable<string> combinedSceneTags) { string pluginpath = Debugger.GetPluginPath(); MainImportingEngine .CurrentProgress = 0; MainImportingEngine.GeneralStatus = "Starting media updating process..."; MainImportingEngine.SpecialStatus = ""; try { if ( !MoviesSectionUpdater .UpdateMoviesSection (pluginpath, iBaseSystem, combinedSceneTags, section)) return true; } catch (Exception e) { Debugger.LogMessageToFile (Environment.NewLine + "An unexpected error occured" + " in DoImport() method." + " The error was: " + Environment.NewLine + e + Environment.NewLine); MainImportingEngine .CurrentProgress = 100; MainImportingEngine.ThisProgress.Progress (MainImportingEngine.CurrentProgress, "The import process terminated" + " unexpectidly due to an error."); } return true; }
internal static bool PerformSecondaryFilmItemUpdating (IMLSection moviesSection, IMLItemList allFilmItems, IMLItem item) { if (MeediFier.Helpers.UserCancels (MainImportingEngine .SpecialStatus, item)) return false; //VideoSusbtitleDownloader // .DownloadSubtitleForVideoParent // (moviehash, imdbid, Item, // location, connectionresult, // Settings.UseSameSubtitlesFolder, // Settings.SubtitlesFolder, true); //MediaArchivers // .ArchiveFilm // (Item, parent, // Settings.ArchiveLocation); if (MeediFier.Helpers.UserCancels (MainImportingEngine .SpecialStatus, item)) return false; FilmItemChainLinker .LinkFilmItemChains (moviesSection, allFilmItems, item); if (MeediFier.Helpers.UserCancels (MainImportingEngine .SpecialStatus, item)) return false; FilmItemProccessSigner .SignFilmItemProcess(item); return true; }
internal static bool PerformInitializationTasks(IMLSection section) { MainImportingEngine.CurrentProgress = 0; MainImportingEngine.GeneralStatus = "Performing startup operations..."; MainImportingEngine.SpecialStatus = String.Empty; if (Helpers.UserCancels("MediaFairy is initializing...", null)) return true; #region Write first debug lines for the importing proccess Debugger.LogMessageToFile(Environment.NewLine); Debugger.LogMessageToFile(Environment.NewLine); Debugger.LogMessageToFile(@"---------------------- START OF MAIN IMPORTING PROCCESS ----------------"); Debugger.LogMessageToFile("Plugin path: " + Debugger.GetPluginPath()); #endregion if (Helpers.UserCancels("MediaFairy is initializing...", null)) return true; ConfigureDepedentSettings(); if (Helpers.UserCancels("Allocatiing Media Sections...", null)) return true; MediaSectionsAllocator .AllocateMediaSections(section); //if (Helpers.UserCancels("Configuring Media Watcher...", null)) // return true; //MediaWatcherAgents.ConfigureMediaWatcher(section); VideoFilenameCleaner.ReadDictionaryReturnAllTags(); return false; }
internal static bool ScanSubDirectoriesAndImportMediaFiles (string importRootFolder, ICollection <FileInfo> allfilesFI, IMLSection moviesSection, ref ArrayList extensionsToIgnore, string[] filmLocations, string[] videoExtensions, string[] audioExtensions, IEnumerable <string> combinedSceneTags, string pluginPath, IEnumerable <string> videoExtensionsCommon) { try { Application.DoEvents(); int currentFile = 0; if ( !ScanDirectoryRecursively ( importRootFolder, moviesSection, ref extensionsToIgnore, ref filmLocations, videoExtensions, audioExtensions, allfilesFI.Count, ref currentFile, pluginPath, combinedSceneTags, videoExtensionsCommon ) ) { return(false); } Application.DoEvents(); } catch (Exception e) { Debugger.LogMessageToFile ("The root media directory scanner" + " returned an exception: " + e); } return(true); }
internal static bool DetectAndImportMultipartMovie (IMLSection moviesSection, bool isUNC, FileSystemInfo dir, string externalID, ArrayList filesInDir, string[] videoexts, int videosCount) { videosCount = CountVideosInDirectory (videoexts, videosCount, filesInDir); if (!Settings.EnableMediaDetection || videosCount <= 1 || videosCount >= 4) { return(false); } MainImportingEngine. ThisProgress.Progress (MainImportingEngine.CurrentProgress, "Detecting film parts..."); int parts = 0; string locationTag = String.Empty; int count = 1; foreach (FileInfo file in filesInDir) { var fileIsVideo = DetermineIfFileIsVideoByExtensionMatching (videoexts, file); parts = DetectMoviePart (parts, fileIsVideo, file, isUNC, ref count, ref locationTag); } return(OnMultiplePartsDetectionAddToMoviesSection (moviesSection, locationTag, externalID, parts, dir)); }
internal static void AllocateMediaSections (IMLSection section) { Debugger.LogMessageToFile ("Allocating Media Sections.."); AllocateMoviesSection(section); AllocateTvSections(section); AllocateMusicSection(section); AllocateRssNewsSection(section); }
// ReSharper disable InconsistentNaming private static void LocateTitle_AddToMoviesSection_ImportMediaInfo (FileSystemInfo file, IMLSection moviesSection, // ReSharper restore InconsistentNaming IEnumerable <string> videoexts, DirectoryInfo parent, string fileName, string parentName, IEnumerable <string> combinedSceneTags) { Application.DoEvents(); Debugger.LogMessageToFile ("This video file is considered to be a film"); MainImportingEngine.ThisProgress.Progress (MainImportingEngine.CurrentProgress, String.Format("Importing film {0}...", fileName)); Debugger.LogMessageToFile (String.Format ("Importing film {0}...", fileName)); Application.DoEvents(); var useParentFolder = MovieTitleLocatingEngine .MovieTitleLocator (file, videoexts, parent, fileName, ref parentName, combinedSceneTags); Application.DoEvents(); AddToMoviesSectionAndImportMediaInfo (file, moviesSection, fileName, parentName, useParentFolder); }
internal static bool ImportFilesFromDirectory ( string directoryStr, IMLSection moviesSection, ref ArrayList extensionsToIgnore, ref string[] filmLocations, string[] videoExtensions, string[] audioExtensions, int totalFiles, ref int currentFile, string pluginPath, IEnumerable <string> combinedSceneTags, IEnumerable <string> videoExtensionsCommon ) { DirectoryInfo directory; var filesInDirectory = MediaImportingEngineHelpers .TestDirectoryAccessGetFileList (directoryStr, totalFiles, currentFile, out directory); if (filesInDirectory == null) { return(true); } return(MediaImportingEngineHelpers .ImportEachFileInDirectory (moviesSection, ref extensionsToIgnore, ref filmLocations, videoExtensions, audioExtensions, totalFiles, ref currentFile, combinedSceneTags, filesInDirectory, pluginPath, videoExtensionsCommon)); }
PerformInitializationTasks (IMLSection section) { MainImportingEngine .CurrentProgress = 0; MainImportingEngine.GeneralStatus = "Performing startup operations..."; MainImportingEngine.SpecialStatus = String.Empty; if (Helpers.UserCancels ("E.F.I. is initializing...")) return true; #region Write first debug lines for the importing proccess Debugger.LogMessageToFile (Environment.NewLine); Debugger.LogMessageToFile (Environment.NewLine); Debugger.LogMessageToFile (@"---------------------- START OF MAIN IMPORTING PROCCESS ----------------"); Debugger.LogMessageToFile ("Plugin path: " + Debugger.GetPluginPath()); #endregion return false; }
internal static bool ScanConstructedArrayAndImportMediaFiles (IMLSection section, ref ArrayList extensionsToIgnore, string[] filmLocations, string[] videoExtensions, string[] audioExtensions, IEnumerable <string> combinedSceneTags, ICollection <FileInfo> filesToImport, string pluginPath, IEnumerable <string> videoExtensionsCommon) { if (!Settings.UpdateMediaSectionOnEachImportedItem) { ImportingEngineHelpers .BeginUpdatingSections (section); } if (!ImportFilesInArray (section, ref extensionsToIgnore, filmLocations, videoExtensions, audioExtensions, combinedSceneTags, filesToImport, pluginPath, videoExtensionsCommon) ) { return(false); } if (!Settings.UpdateMediaSectionOnEachImportedItem) { ImportingEngineHelpers.EndUpdatingSections (section); } return(true); }
private static void AddToMoviesSection (FileSystemInfo file, IMLSection moviesSection, string fileName, string parentName, bool useParentFolder, out IMLItem item) { Application.DoEvents(); if (useParentFolder) { Debugger.LogMessageToFile ("Will use the parent directory's" + " name as Item's name."); Debugger.LogMessageToFile (String.Format ("Adding file {0} to Films section...", file.FullName)); AddFileToSection (out item, moviesSection, parentName, file.FullName, file.FullName); } else { Debugger.LogMessageToFile ("Will use the file's" + " name as Item's name."); Debugger.LogMessageToFile (String.Format ("Adding file {0}" + " to Films section...", file.FullName)); AddFileToSection (out item, moviesSection, fileName, file.FullName, file.FullName); } }
internal static void StartMainImportingEngine (Importer importer, IBaseSystem iBaseSystem, IMLSection section, IEnumerable <string> combinedSceneTags) { GeneralStatus = "Performing media importing..."; SpecialStatus = String.Empty; MediaImportingEngine.ImportMediaFilesMain (combinedSceneTags, importer, section); MediaImportingEngineHelpers .RunMediaSectionsUpdatingEngine (importer, iBaseSystem, section, combinedSceneTags); }
protected internal static void ScanDiskForEntertainmentMedia (IEnumerable <string> combinedSceneTags, string[] videoExtensions, string[] audioExtensions, string pluginpath, string[] filmLocations, ArrayList extensionsToIgnore, IEnumerable <string> videoExtensionsCommon, Importer importer, IMLSection section) { ImportingEngineHelpers .BeginUpdatingSections (section); extensionsToIgnore = ScanDiskForMovies (combinedSceneTags, videoExtensions, audioExtensions, filmLocations, extensionsToIgnore, videoExtensionsCommon, importer, section); MediaImportingEngineHelpers .WriteNonMediaExtensionsToFile (extensionsToIgnore, pluginpath); ImportingEngineHelpers .EndUpdatingSections (section); }