public static List <AvailablePlugin> FindPlugins(string strPath, string strInterface) { List <AvailablePlugin> Plugins = new List <AvailablePlugin>(); string[] strDLLs; int intIndex; Assembly objDLL; // Go through all DLLs in the directory, attempting to load them strDLLs = Directory.GetFileSystemEntries(strPath, "*.dll"); for (intIndex = 0; (intIndex <= (strDLLs.Length - 1)); intIndex++) { try { objDLL = Assembly.LoadFrom(strDLLs[intIndex]); ExamineAssembly(objDLL, strInterface, Plugins); } catch (Exception ex) { // Error loading DLL, we don't need to do anything special SDKUtilities.DebugLine("[PluginService] Loading plugin {0} Caused an Exception {1}", strDLLs[intIndex], ex.Message); } } // Return all plugins found if ((Plugins.Count != 0)) { return(Plugins); } else { return(null); } }
/// <summary> /// /// </summary> /// <returns></returns> protected virtual string[] GetFiles() { OpenFileDialog ofDiag = new OpenFileDialog(); ofDiag.InitialDirectory = Properties.Settings.Default.InitialDirectory; //"c:\\"; ofDiag.Filter = this.Filter; ofDiag.FilterIndex = this.FilterIndex; ofDiag.RestoreDirectory = true; ofDiag.AutoUpgradeEnabled = true; ofDiag.CheckFileExists = true; ofDiag.CheckPathExists = true; ofDiag.Multiselect = this.MultiSelect; ofDiag.Title = String.Format(@"Select {0} file to import", Name); DialogResult dlgRslt = ofDiag.ShowDialog(); if (dlgRslt == DialogResult.OK) { string sPath = string.Empty; SDKUtilities.DebugLine("[OMLPlugin] " + String.Format(@"[OMLImporter] Valid file found ({0})", ofDiag.FileName)); if (this.MultiSelect) { sPath = Path.GetDirectoryName(ofDiag.FileNames[0]); } else { sPath = Path.GetDirectoryName(ofDiag.FileName); } if (!string.IsNullOrEmpty(sPath)) { Properties.Settings.Default.InitialDirectory = sPath; Properties.Settings.Default.Save(); } if (this.MultiSelect) { return(ofDiag.FileNames); } else { return(new string[] { ofDiag.FileName }); } } else { return(null); } }
/// <summary> /// Performs a metadata search using the data and plugin passed in. /// </summary> /// <param name="metadata"></param> /// <param name="titletype"></param> /// <param name="titleNameSearch"></param> /// <param name="EpisodeName"></param> /// <param name="SeasonNo"></param> /// <param name="EpisodeNo"></param> /// <param name="title"></param> /// <returns></returns> private bool MetadataSearch(MetaDataPluginDescriptor metadata, TitleTypes titletype, string titleNameSearch, string EpisodeName, int?SeasonNo, int?EpisodeNo, out Title title) { title = null; if ((((titletype & TitleTypes.TVShow) != 0) || ((titletype & TitleTypes.Season) != 0) || ((titletype & TitleTypes.Episode) != 0)) && ((metadata.DataProviderCapabilities & MetadataPluginCapabilities.SupportsTVSearch) != 0)) { // Perform a tv show search. This will return true if it has found an exact show match, false // if it finds multiple shows matching the show name. bool SearchTVShowOnly = false; if (((titletype & TitleTypes.Season) != 0) || ((titletype & TitleTypes.TVShow) != 0)) { SearchTVShowOnly = true; } if (metadata.PluginDLL.SearchForTVSeries(titleNameSearch, EpisodeName, SeasonNo, EpisodeNo, 1, SearchTVShowOnly)) { // Requires a search drilldown metadata.PluginDLL.SearchForTVDrillDown(1, EpisodeName, SeasonNo, EpisodeNo, 1); } title = SDKUtilities.ConvertOMLSDKTitleToTitle(metadata.PluginDLL.GetBestMatch()); if (title != null) { Utilities.DebugLine("[OMLSDK] Found episode " + title.Name + " using plugin " + metadata.DataProviderName); } } else { if ((metadata.DataProviderCapabilities & MetadataPluginCapabilities.SupportsMovieSearch) != 0) { metadata.PluginDLL.SearchForMovie(titleNameSearch, 1); title = SDKUtilities.ConvertOMLSDKTitleToTitle(metadata.PluginDLL.GetBestMatch()); if (title != null) { Utilities.DebugLine("[OMLSDK] Found movie " + title.Name + " using plugin " + metadata.DataProviderName); } } } return(true); }
/// <summary> /// /// </summary> /// <param name="newTitle"></param> public void AddTitle(OMLSDKTitle newTitle) { if (string.IsNullOrEmpty(newTitle.AspectRatio)) { SDKUtilities.DebugLine("[OMLPlugin] Setting AspectRatio for Title: " + newTitle.Name); //SetAspectRatio(newTitle); } if (newTitle.DateAdded.CompareTo(new DateTime(0001, 1, 1)) == 0) { SDKUtilities.DebugLine("[OMLPlugin] Setting Date Added for title: " + newTitle.Name); newTitle.DateAdded = DateTime.Now; } if (!String.IsNullOrEmpty(newTitle.Name.Trim())) { titles.Add(newTitle); totalRowsAdded++; } }