Esempio n. 1
0
        /// <summary>
        /// Creates or finds an existing folder by 'Name' with a specific parentid. Returns an out addedTitle
        /// parameter if a new title was created, if title allready exists
        /// </summary>
        /// <param name="parentid"></param>
        /// <param name="Name"></param>
        /// <param name="titletype"></param>
        /// <param name="seriesNumber"></param>
        /// <param name="addedTitle"></param>
        /// <returns></returns>
        public static Title CreateFolderNonDuplicate(int?parentid, string Name, TitleTypes titletype, short?seriesNumber, out bool titleCreated)
        {
            // Build filter
            TitleFilter        tf1 = new TitleFilter(TitleFilterType.Parent, parentid.ToString());
            TitleFilter        tf2 = new TitleFilter(TitleFilterType.Name, Name);
            List <TitleFilter> tf  = new List <TitleFilter>();

            tf.Add(tf1);
            tf.Add(tf2);
            List <Title> existingTitle = (from t in TitleCollectionManager.GetFilteredTitles(tf)
                                          where t.Name == Name
                                          select t).ToList();



            if (existingTitle.Count() > 0)
            {
                titleCreated = false;
                return(existingTitle[0]);
            }
            else
            {
                Title addedTitle = null;
                titleCreated = true;
                return(CreateFolder(parentid, Name, titletype, seriesNumber));
            }
        }
Esempio n. 2
0
        public static Title CreateFolder(int?parentid, string Name, TitleTypes titletype, short?seriesNumber)
        {
            if (parentid == null)
            {
                return(CreateTitle(null, Name, titletype, "", seriesNumber, null, null));
            }
            else
            {
                if ((titletype & TitleTypes.Unknown) != 0)
                {
                    // Title type is unknown. Attempt to find title type by looking at parent
                    Title parent = GetTitle((int)parentid);
                    if (parent != null)
                    {
                        if (((parent.TitleType & TitleTypes.TVShow) != 0) ||
                            (((parent.TitleType & TitleTypes.Season) != 0)))
                        {
                            titletype = TitleTypes.Season;
                        }

                        if ((parent.TitleType & TitleTypes.Collection) != 0)
                        {
                            titletype = TitleTypes.Collection;
                        }
                    }
                }
                return(CreateTitle(parentid, Name, titletype, null, seriesNumber, null, null));
            }
        }
Esempio n. 3
0
        public static IEnumerable <Title> GetTitlesByPercentComplete(TitleTypes _titleTypes, decimal _completeness)
        {
            IEnumerable <Title> titles = GetAllTitles(_titleTypes);

            return(from title in titles
                   where title.PercentComplete <= _completeness
                   select title);
        }
Esempio n. 4
0
        public static Title CreateTitle(int?parentid, string Name, TitleTypes titletype, string Tag, short?SeasonNumber, short?EpisodeNumber, Disk[] disks)
        {
            Title newTitle = new Title();

            newTitle.Name = Name;

            if (parentid == null)
            {
                newTitle.TitleType = TitleTypes.Root | titletype;
            }
            else
            {
                newTitle.TitleType     = titletype;
                newTitle.ParentTitleId = (int)parentid;

                if ((titletype & TitleTypes.Unknown) != 0)
                {
                    // Title type is unknown. Attempt to find title type by looking at parent
                    Title parent = GetTitle((int)parentid);
                    if (parent != null)
                    {
                        if (((parent.TitleType & TitleTypes.TVShow) != 0) ||
                            (((parent.TitleType & TitleTypes.Season) != 0)))
                        {
                            newTitle.TitleType = TitleTypes.Episode;
                        }

                        if ((parent.TitleType & TitleTypes.Collection) != 0)
                        {
                            newTitle.TitleType = TitleTypes.Movie;
                        }
                    }
                }
            }
            newTitle.DateAdded = DateTime.Now;

            newTitle.SeasonNumber  = SeasonNumber;
            newTitle.EpisodeNumber = EpisodeNumber;

            if (Tag != null)
            {
                newTitle.AddTag(Tag);
            }

            if (disks != null)
            {
                foreach (Disk disk in disks)
                {
                    newTitle.AddDisk(disk);
                }
            }

            // Add the title now to get the title ID
            TitleCollectionManager.AddTitle(newTitle);

            // Get the new title from the DB and add it to the title list
            return(TitleCollectionManager.GetTitle(newTitle.Id));
        }
Esempio n. 5
0
        public static IEnumerable <Title> GetAllTitles(TitleTypes type)
        {
            var titles = from t in DBContext.Instance.Titles
                         where (t.TitleType & (int)type) != 0
                         orderby t.SortName
                         select t;

            return(titles);
        }
Esempio n. 6
0
        public static IEnumerable <Title> GetAllTitles(TitleTypes type)
        {
            TitleTypeFilter filter = new TitleTypeFilter(type);

            // get all the titles
            return(ConvertDaoTitlesToTitles(Dao.TitleCollectionDao.GetFilteredTitles(new List <TitleFilter> {
                filter
            })));
        }
Esempio n. 7
0
        public static IEnumerable <Title> GetAllTitles(TitleTypes type, int?parentId)
        {
            var titles = from t in DBContext.Instance.Titles
                         where (t.TitleType & (int)type) != 0 &&
                         object.Equals(t.ParentTitleId, parentId)
                         orderby t.SortName
                         select t;

            return(titles);
        }
Esempio n. 8
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);
        }
        private HtmlTextWriterTag GetTitleTag(TitleTypes titleType)
        {
            var tag = HtmlTextWriterTag.H1;

            switch (titleType)
            {
            case TitleTypes.H1:
                tag = HtmlTextWriterTag.H1;
                break;

            case TitleTypes.H2:
                tag = HtmlTextWriterTag.H2;
                break;

            case TitleTypes.H3:
                tag = HtmlTextWriterTag.H3;
                break;

            case TitleTypes.H4:
                tag = HtmlTextWriterTag.H4;
                break;

            case TitleTypes.H5:
                tag = HtmlTextWriterTag.H5;
                break;

            case TitleTypes.H6:
                tag = HtmlTextWriterTag.H6;
                break;

            default:
                break;
            }

            return(tag);
        }
Esempio n. 10
0
 public static Title CreateTitle(int?parentid, string Name, TitleTypes titletype, string Tag, Disk[] disks)
 {
     return(CreateTitle(parentid, Name, titletype, Tag, null, null, disks));
 }
        /// <summary>
        /// Looksup the preferred metadata on the passed in search criteria
        /// </summary>
        /// <param name="titletype"></param>
        /// <param name="coverArtOnly"></param>
        /// <param name="titleNameSearch"></param>
        /// <param name="EpisodeName"></param>
        /// <param name="SeasonNo"></param>
        /// <param name="EpisodeNo"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public bool MetadataSearchUsingPreferred(TitleTypes titletype, /*bool coverArtOnly,*/ string titleNameSearch, string EpisodeName, int? SeasonNo, int? EpisodeNo, out Title title)
        {
            title = null;

            string preferredplugin = OMLEngine.Settings.OMLSettings.DefaultMetadataPluginMovies;

            if ((((titletype & TitleTypes.TVShow) != 0) ||
                ((titletype & TitleTypes.Season) != 0) ||
                ((titletype & TitleTypes.Episode) != 0)) &&
                (!string.IsNullOrEmpty(OMLEngine.Settings.OMLSettings.DefaultMetadataPluginTV)))
            {
                // If we are looking for an episode and there is a preferred setting for this, use it
                preferredplugin = OMLEngine.Settings.OMLSettings.DefaultMetadataPluginTV;
            }

            if (string.IsNullOrEmpty(preferredplugin)) return false;

            if (FanArt == null)
            {
                FanArt = new List<string>();
            }
            else
            {
                FanArt.Clear();
            }

            try
            {
                if (titleNameSearch != null)
                {

                    // Import metadata based on field mappings and configured default plugin
                    Dictionary<string, List<string>> mappings = OMLEngine.Settings.SettingsManager.MetaDataMap_PropertiesByPlugin();

                    // Loop through configured mappings
                    Type tTitle = typeof(Title);
                    MetaDataPluginDescriptor metadata;

                    bool loadedfanart = false;

                    foreach (KeyValuePair<string, List<string>> map in mappings)
                    {
                        try
                        {
                            if (map.Key == preferredplugin) continue;
                            metadata = _metadataPlugins.First(p => p.DataProviderName == map.Key);

                            MetadataSearch(metadata, titletype, titleNameSearch, EpisodeName, SeasonNo, EpisodeNo, out title);

                            if (title != null)
                            {
                                foreach (string property in map.Value)
                                {
                                    switch (property)
                                    {
                                        case "FanArt":
                                            if ((metadata.DataProviderCapabilities & MetadataPluginCapabilities.SupportsBackDrops) != 0)
                                            {
                                                loadedfanart = true;
                                                FanArt.AddRange(metadata.PluginDLL.GetBackDropUrlsForTitle().ToList());
                                            }
                                            break;
                                        case "Genres":
                                            foreach (string genre in title.Genres.ToArray<string>())
                                                title.AddGenre(genre);
                                            break;
                                        default:
                                            Utilities.DebugLine("[OMLDatabaseEditor] Using value for " + property + " from plugin " + map.Key);
                                            System.Reflection.PropertyInfo prop = tTitle.GetProperty(property);
                                            prop.SetValue(title, prop.GetValue(title, null), null);
                                            break;
                                    }
                                }
                            }
                        }

                        catch (Exception ex)
                        {
                            Utilities.DebugLine("[OMLSDK] Processing date from {0} Caused an Exception {1}", map.Key, ex);

                        }
                    }
                    // Use default plugin for remaining fields
                    metadata = _metadataPlugins.First(p => p.DataProviderName == preferredplugin);

                    MetadataSearch(metadata, titletype, titleNameSearch, EpisodeName, SeasonNo, EpisodeNo, out title);

                    title.MetadataSourceName = metadata.DataProviderName;

                    if (title != null)
                    {
                        if (!loadedfanart)
                        {
                            if ((metadata.DataProviderCapabilities & MetadataPluginCapabilities.SupportsBackDrops) != 0)
                            {
                                List<string> images = metadata.PluginDLL.GetBackDropUrlsForTitle();
                                if (images != null)
                                {
                                    FanArt.AddRange(metadata.PluginDLL.GetBackDropUrlsForTitle().ToList());
                                }
                            }
                        }
                    }

                    ApplyGenreMappings(title, true);

                    return true;
                }

                return false;

            }
            catch (Exception ex)
            {
                Utilities.DebugLine("[OMLSDK] Exception {0}", ex);
                return false;
            }
        }
 public static Title CreateTitle(int? parentid, string Name, TitleTypes titletype, string Tag, Disk[] disks)
 {
     return CreateTitle(parentid, Name, titletype, Tag, null, null, disks);
 }
        /// <summary>
        /// Creates or finds an existing folder by 'Name' with a specific parentid. Returns an out addedTitle
        /// parameter if a new title was created, if title allready exists
        /// </summary>
        /// <param name="parentid"></param>
        /// <param name="Name"></param>
        /// <param name="titletype"></param>
        /// <param name="seriesNumber"></param>
        /// <param name="addedTitle"></param>
        /// <returns></returns>
        public static Title CreateFolderNonDuplicate(int? parentid, string Name, TitleTypes titletype, short? seriesNumber, out bool titleCreated)
        {
            // Build filter
            TitleFilter tf1 = new TitleFilter(TitleFilterType.Parent, parentid.ToString());
            TitleFilter tf2 = new TitleFilter(TitleFilterType.Name, Name);
            List<TitleFilter> tf = new List<TitleFilter>();
            tf.Add(tf1);
            tf.Add(tf2);
            List<Title> existingTitle = (from t in TitleCollectionManager.GetFilteredTitles(tf)
                                         where t.Name == Name
                                         select t).ToList();

            if (existingTitle.Count() > 0)
            {
                titleCreated = false;
                return existingTitle[0];
            }
            else
            {
                Title addedTitle = null;
                titleCreated = true;
                return CreateFolder(parentid, Name, titletype, seriesNumber);
            }
        }
Esempio n. 14
0
        private int CreateTitle(int? parentid, string Name, TitleTypes titletype, short? SeasonNumber, short? EpisodeNumber, Disk[] disks, bool RefreshUI)
        {
            Title addedTitle = TitleCollectionManager.CreateTitle(parentid, Name, titletype, null, SeasonNumber, EpisodeNumber, disks);

            AddCreatedTitle(addedTitle, RefreshUI);

            return addedTitle.Id;

            /*Title newTitle = new Title();
            newTitle.Name = Name;

            if (parentid == null)
            {
                newTitle.TitleType = TitleTypes.Root | titletype;
            }
            else
            {
                newTitle.TitleType = titletype;
                newTitle.ParentTitleId = (int)parentid;

                if ((titletype & TitleTypes.Unknown) != 0)
                {
                    // Title type is unknown. Attempt to find title type by looking at parent
                    if (((_movieList[(int)parentid].TitleType & TitleTypes.TVShow) != 0) ||
                    (((_movieList[(int)parentid].TitleType & TitleTypes.Season) != 0)))
                    {
                        newTitle.TitleType = TitleTypes.Episode;
                    }

                    if ((_movieList[(int)parentid].TitleType & TitleTypes.Collection) != 0)
                    {
                        newTitle.TitleType = TitleTypes.Movie;
                    }
                }
            }
            newTitle.DateAdded = DateTime.Now;

            newTitle.SeasonNumber = SeasonNumber;
            newTitle.EpisodeNumber = EpisodeNumber;

            if (disks != null)
            {
                foreach (Disk disk in disks)
                {
                    newTitle.AddDisk(disk);
                }
            }

            // Add the title now to get the title ID
            TitleCollectionManager.AddTitle(newTitle);

            // Get the new title from the DB and add it to the title list
            Title addedTitle = TitleCollectionManager.GetTitle(newTitle.Id);*/
        }
Esempio n. 15
0
 public TitleTypeFilter(TitleTypes titleTypes)
     : base(TitleFilterType.TitleType, ((int)titleTypes).ToString())
 {
 }
 public static Title CreateFolder(int? parentid, string Name, TitleTypes titletype)
 {
     return CreateFolder(parentid, Name, titletype, null);
 }
        public static Title CreateTitle(int? parentid, string Name, TitleTypes titletype, string Tag, short? SeasonNumber, short? EpisodeNumber, Disk[] disks)
        {
            Title newTitle = new Title();
            newTitle.Name = Name;

            if (parentid == null)
            {
                newTitle.TitleType = TitleTypes.Root | titletype;
            }
            else
            {
                newTitle.TitleType = titletype;
                newTitle.ParentTitleId = (int)parentid;

                if ((titletype & TitleTypes.Unknown) != 0)
                {
                    // Title type is unknown. Attempt to find title type by looking at parent
                    Title parent = GetTitle((int)parentid);
                    if (parent != null)
                    {
                        if (((parent.TitleType & TitleTypes.TVShow) != 0) ||
                        (((parent.TitleType & TitleTypes.Season) != 0)))
                        {
                            newTitle.TitleType = TitleTypes.Episode;
                        }

                        if ((parent.TitleType & TitleTypes.Collection) != 0)
                        {
                            newTitle.TitleType = TitleTypes.Movie;
                        }
                    }
                }
            }
            newTitle.DateAdded = DateTime.Now;

            newTitle.SeasonNumber = SeasonNumber;
            newTitle.EpisodeNumber = EpisodeNumber;

            if (Tag != null) newTitle.AddTag(Tag);

            if (disks != null)
            {
                foreach (Disk disk in disks)
                {
                    newTitle.AddDisk(disk);
                }
            }

            // Add the title now to get the title ID
            TitleCollectionManager.AddTitle(newTitle);

            // Get the new title from the DB and add it to the title list
            return TitleCollectionManager.GetTitle(newTitle.Id);
        }
        public static IEnumerable<Title> GetAllTitles(TitleTypes type)
        {
            TitleTypeFilter filter = new TitleTypeFilter(type);

            // get all the titles
            return ConvertDaoTitlesToTitles(Dao.TitleCollectionDao.GetFilteredTitles(new List<TitleFilter> { filter }));
        }
 public static IEnumerable<Title> GetTitlesByPercentComplete(TitleTypes _titleTypes, decimal _completeness)
 {
     IEnumerable<Title> titles = GetAllTitles(_titleTypes);
     return from title in titles
            where title.PercentComplete <= _completeness
            select title;
 }
        /// <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;
        }
Esempio n. 21
0
 public static Title CreateFolder(int?parentid, string Name, TitleTypes titletype)
 {
     return(CreateFolder(parentid, Name, titletype, null));
 }
Esempio n. 22
0
        private int CreateFolder(int? parentid, string Name, TitleTypes titletype, bool RefreshUI)
        {
            Title addedTitle = TitleCollectionManager.CreateFolder(parentid, Name, titletype);

            AddCreatedTitle(addedTitle, RefreshUI);

            return addedTitle.Id;

            /*if (parentid == null)
            {
                // Root Node
                return CreateTitle(null, Name, titletype, null, RefreshUI);
            }
            else
            {
                if ((titletype & TitleTypes.Unknown) != 0)
                {
                    // Title type is unknown. Attempt to find title type by looking at parent
                    if (((_movieList[(int)parentid].TitleType & TitleTypes.TVShow) != 0) ||
                    (((_movieList[(int)parentid].TitleType & TitleTypes.Season) != 0)))
                    {
                        titletype = TitleTypes.Season;
                    }

                    if ((_movieList[(int)parentid].TitleType & TitleTypes.Collection) != 0)
                    {
                        titletype = TitleTypes.Collection;
                    }
                }
                return CreateTitle(parentid, Name, titletype, null, RefreshUI);
            }*/
        }
Esempio n. 23
0
        private int CreateFolder(string Name, TitleTypes titletype, bool RefreshUI)
        {
            if (treeMedia.SelectedNode.Name == "All Media")
            {
                // Root Node
                return CreateFolder(null, Name, titletype, RefreshUI);
            }
            else
            {
                int parentid = Convert.ToInt32(treeMedia.SelectedNode.Name);

                /*if ((titletype & TitleTypes.Unknown) != 0)
                {
                    // Title type is unknown. Attempt to find title type by looking at parent
                    if (((_movieList[(int)parentid].TitleType & TitleTypes.TVShow) != 0) ||
                    (((_movieList[(int)parentid].TitleType & TitleTypes.Season) != 0)))
                    {
                        titletype = TitleTypes.Season;
                    }

                    if ((_movieList[(int)parentid].TitleType & TitleTypes.Collection) != 0)
                    {
                        titletype = TitleTypes.Collection;
                    }
                }*/
                return CreateFolder(parentid, Name, titletype, RefreshUI);
            }
        }
Esempio n. 24
0
        // These wrap the functionality provided by the engine with
        // some code to update the editor with the added titles
        private int CreateTitle(int? parentid, string Name, TitleTypes titletype, Disk[] disks, bool RefreshUI)
        {
            Title addedTitle = TitleCollectionManager.CreateTitle(parentid, Name, titletype, null, null, null, disks);

            AddCreatedTitle(addedTitle, RefreshUI);

            return addedTitle.Id;
        }
Esempio n. 25
0
        /// <summary>
        /// Looksup the preferred metadata on the passed in search criteria
        /// </summary>
        /// <param name="titletype"></param>
        /// <param name="coverArtOnly"></param>
        /// <param name="titleNameSearch"></param>
        /// <param name="EpisodeName"></param>
        /// <param name="SeasonNo"></param>
        /// <param name="EpisodeNo"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public bool MetadataSearchUsingPreferred(TitleTypes titletype, /*bool coverArtOnly,*/ string titleNameSearch, string EpisodeName, int?SeasonNo, int?EpisodeNo, out Title title)
        {
            title = null;

            string preferredplugin = OMLEngine.Settings.OMLSettings.DefaultMetadataPluginMovies;

            if ((((titletype & TitleTypes.TVShow) != 0) ||
                 ((titletype & TitleTypes.Season) != 0) ||
                 ((titletype & TitleTypes.Episode) != 0)) &&
                (!string.IsNullOrEmpty(OMLEngine.Settings.OMLSettings.DefaultMetadataPluginTV)))
            {
                // If we are looking for an episode and there is a preferred setting for this, use it
                preferredplugin = OMLEngine.Settings.OMLSettings.DefaultMetadataPluginTV;
            }

            if (string.IsNullOrEmpty(preferredplugin))
            {
                return(false);
            }

            if (FanArt == null)
            {
                FanArt = new List <string>();
            }
            else
            {
                FanArt.Clear();
            }

            try
            {
                if (titleNameSearch != null)
                {
                    // Import metadata based on field mappings and configured default plugin
                    Dictionary <string, List <string> > mappings = OMLEngine.Settings.SettingsManager.MetaDataMap_PropertiesByPlugin();

                    // Loop through configured mappings
                    Type tTitle = typeof(Title);
                    MetaDataPluginDescriptor metadata;

                    bool loadedfanart = false;

                    foreach (KeyValuePair <string, List <string> > map in mappings)
                    {
                        try
                        {
                            if (map.Key == preferredplugin)
                            {
                                continue;
                            }
                            metadata = _metadataPlugins.First(p => p.DataProviderName == map.Key);

                            MetadataSearch(metadata, titletype, titleNameSearch, EpisodeName, SeasonNo, EpisodeNo, out title);

                            if (title != null)
                            {
                                foreach (string property in map.Value)
                                {
                                    switch (property)
                                    {
                                    case "FanArt":
                                        if ((metadata.DataProviderCapabilities & MetadataPluginCapabilities.SupportsBackDrops) != 0)
                                        {
                                            loadedfanart = true;
                                            FanArt.AddRange(metadata.PluginDLL.GetBackDropUrlsForTitle().ToList());
                                        }
                                        break;

                                    case "Genres":
                                        foreach (string genre in title.Genres.ToArray <string>())
                                        {
                                            title.AddGenre(genre);
                                        }
                                        break;

                                    default:
                                        Utilities.DebugLine("[OMLDatabaseEditor] Using value for " + property + " from plugin " + map.Key);
                                        System.Reflection.PropertyInfo prop = tTitle.GetProperty(property);
                                        prop.SetValue(title, prop.GetValue(title, null), null);
                                        break;
                                    }
                                }
                            }
                        }

                        catch (Exception ex)
                        {
                            Utilities.DebugLine("[OMLSDK] Processing date from {0} Caused an Exception {1}", map.Key, ex);
                        }
                    }
                    // Use default plugin for remaining fields
                    metadata = _metadataPlugins.First(p => p.DataProviderName == preferredplugin);

                    MetadataSearch(metadata, titletype, titleNameSearch, EpisodeName, SeasonNo, EpisodeNo, out title);

                    title.MetadataSourceName = metadata.DataProviderName;

                    if (title != null)
                    {
                        if (!loadedfanart)
                        {
                            if ((metadata.DataProviderCapabilities & MetadataPluginCapabilities.SupportsBackDrops) != 0)
                            {
                                List <string> images = metadata.PluginDLL.GetBackDropUrlsForTitle();
                                if (images != null)
                                {
                                    FanArt.AddRange(metadata.PluginDLL.GetBackDropUrlsForTitle().ToList());
                                }
                            }
                        }
                    }

                    ApplyGenreMappings(title, true);

                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                Utilities.DebugLine("[OMLSDK] Exception {0}", ex);
                return(false);
            }
        }
        public static Title CreateFolder(int? parentid, string Name, TitleTypes titletype, short? seriesNumber)
        {
            if (parentid == null)
            {
                return CreateTitle(null, Name, titletype, "", seriesNumber, null, null);
            }
            else
            {
                if ((titletype & TitleTypes.Unknown) != 0)
                {
                    // Title type is unknown. Attempt to find title type by looking at parent
                    Title parent = GetTitle((int)parentid);
                    if (parent != null)
                    {
                        if (((parent.TitleType & TitleTypes.TVShow) != 0) ||
                        (((parent.TitleType & TitleTypes.Season) != 0)))
                        {
                            titletype = TitleTypes.Season;
                        }

                        if ((parent.TitleType & TitleTypes.Collection) != 0)
                        {
                            titletype = TitleTypes.Collection;
                        }
                    }
                }
                return CreateTitle(parentid, Name, titletype, null, seriesNumber, null, null);
            }
        }