private void AddResult(MetaDataPluginDescriptor plugin, object value, string defaultPlugin)
 {
     LabelControl lblPlugin = new LabelControl();
     lblPlugin.Text = plugin.DataProviderName;
     if (defaultPlugin == plugin.DataProviderName)
         lblPlugin.Font = new Font(lblPlugin.Font, FontStyle.Bold);
     // Add context menu of other search results
     ContextMenu menu = new ContextMenu();
     menu.Tag = plugin;
     Title[] matches = OMLSDK.SDKUtilities.ConvertOMLSDKTitlesToTitles(plugin.PluginDLL.GetAvailableTitles());
     for (int i = 0; i < matches.Length; i++)
     {
         MenuItem item = new MenuItem(matches[i].Name, new EventHandler(otherTitle_Click));
         item.Tag = i;
         menu.MenuItems.Add(item);
     }
     lblPlugin.ContextMenu = menu;
     Control ctrl = CreateValueControl(plugin.DataProviderName, value);
     if (ctrl != null)
     {
         tblData.Controls.Add(lblPlugin);
         tblData.Controls.Add(ctrl);
     }
     Application.DoEvents();
 }
Beispiel #2
0
        /// <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);
        }
        public bool SelectedPlugin(out MetaDataPluginDescriptor selectedplugin)
        {
            selectedplugin = null;

            if (cmbPlugins.SelectedItem == "From Preferred Sources")
            {
                // Preferred metadata selected. Leave selectedplugin as null
                return true;
            }

            var qry = from t in _metadataPlugins
                      where t.DataProviderName == (cmbPlugins.SelectedItem as string)
                      select t;

            if (qry.Count() > 0)
            {
                // A Plugin has been selected
                selectedplugin = qry.First();
                return true;
            }

            // Nothing selected
            return false;
        }
        private bool StartMetadataImport(Title title, MetaDataPluginDescriptor plugin, bool coverArtOnly)
        {
            int? SeasonNo = null;
            int? EpisodeNo = null;

            if (((title.TitleType & TitleTypes.Episode) != 0) ||
            ((title.TitleType & TitleTypes.Season) != 0) ||
            ((title.TitleType & TitleTypes.TVShow) != 0))
            {
                // TV Search
                if (title.SeasonNumber != null) SeasonNo = title.SeasonNumber.Value;
                if (title.EpisodeNumber != null) EpisodeNo = title.EpisodeNumber.Value;
                string Showname = null;

                // Try to find show name be looking up the folder structure.
                Title parenttitle = title;
                while ((parenttitle.TitleType & TitleTypes.Root) == 0)
                {
                    // Get parent
                    parenttitle = parenttitle.ParentTitle;
                    if ((parenttitle.TitleType & TitleTypes.TVShow) != 0)
                    {
                        Showname = parenttitle.Name;
                        break;
                    }
                }

                if (string.IsNullOrEmpty(Showname))
                {
                    // Cannot find a show name in the folder structure
                    return StartMetadataImport(title, plugin, coverArtOnly, title.Name, "", SeasonNo, EpisodeNo);
                }
                else
                {
                    return StartMetadataImport(title, plugin, coverArtOnly, Showname, title.Name, SeasonNo, EpisodeNo);
                }
            }
            else
            {
                // Movie Search
                return StartMetadataImport(title, plugin, coverArtOnly, title.Name, "", SeasonNo, EpisodeNo);
            }
        }
 private void LoadFanartFromPlugin(MetaDataPluginDescriptor metadata, Title title)
 {
     if ((metadata.DataProviderCapabilities & MetadataPluginCapabilities.SupportsBackDrops) != 0)
     {
         List<string> _images = metadata.PluginDLL.GetBackDropUrlsForTitle();
         if (_images != null)
         {
             LoadFanart(metadata.PluginDLL.GetBackDropUrlsForTitle(), title);
         }
     }
 }
        internal bool StartMetadataImport(Title title, MetaDataPluginDescriptor plugin, bool coverArtOnly, string titleNameSearch, string EpisodeName, int? SeasonNo, int? EpisodeNo)
        {
            try
            {
                if (titleNameSearch != null)
                {
                    if (plugin != null)
                    {
                        frmSearchResult searchResultForm = null;

                        if ((plugin.DataProviderCapabilities & MetadataPluginCapabilities.SupportsTVSearch) != 0)
                        {
                            // TV Search
                            if (((title.TitleType & TitleTypes.Season) != 0) ||
                                ((title.TitleType & TitleTypes.TVShow) != 0))
                            {
                                // Only searching for the Show / season
                                searchResultForm = new frmSearchResult(plugin, titleNameSearch, "", 0, 0, true, true);
                            }
                            else
                            {
                                // Searching for an episode
                                searchResultForm = new frmSearchResult(plugin, titleNameSearch, EpisodeName, SeasonNo, EpisodeNo, true, false);
                            }
                        }
                        else
                        {
                            searchResultForm = new frmSearchResult(plugin, titleNameSearch, EpisodeName, SeasonNo, EpisodeNo, false, false);
                        }

                        DialogResult result = searchResultForm.ShowDialog(); // ShowResults(plugin.GetAvailableTitles());
                        if (result == DialogResult.OK)
                        {
                            Cursor = Cursors.WaitCursor;
                            Title searchresult = OMLSDK.SDKUtilities.ConvertOMLSDKTitleToTitle(plugin.PluginDLL.GetTitle(searchResultForm.SelectedTitleIndex));
                            title.MetadataSourceName = plugin.DataProviderName;

                            if (searchresult != null)
                            {
                                if (coverArtOnly)
                                {
                                    title.FrontCoverPath = searchresult.FrontCoverPath;
                                    title.BackCoverPath = searchresult.BackCoverPath;
                                }
                                else
                                {
                                    title.CopyMetadata(searchresult,
                                        OMLEngine.Settings.OMLSettings.MetadataLookupOverwriteExistingDataManual,
                                        OMLEngine.Settings.OMLSettings.MetadataLookupUpdateNameManual,
                                        OMLEngine.Settings.OMLSettings.MetadataLookupOverwriteExistingDataManual);
                                }

                                LoadFanartFromPlugin(plugin, title);

                            }
                            CheckGenresAgainstSupported(title);
                            titleEditor.RefreshEditor();
                            Cursor = Cursors.Default;

                            return true;
                        }
                        else
                            return false;
                    }
                    else
                    {
                        // Preferred lookup. Offload the search to the MetadataSearchManagement class
                        Title searchresult = null;

                        MetadataSearchManagement mds = new MetadataSearchManagement(_metadataPlugins);

                        bool retval = mds.MetadataSearchUsingPreferred(title);

                        if (retval)
                        {
                            // Successful lookup, process
                            LoadFanart(mds.FanArt, title);
                            titleEditor.RefreshEditor();
                            Cursor = Cursors.Default;
                            return true;
                        }
                    }
                }
                Cursor = Cursors.Default;
                return false;

            }
            catch (Exception ex)
            {
                Utilities.DebugLine("[OMLDatabaseEditor] Exception {0}", ex);
                Cursor = Cursors.Default;
                return false;
            }
        }
        /// <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;
        }