// or choose among all the titles
        public OMLSDKTitle[] GetAvailableTitles()
        {
            OMLSDKTitle[] titles = new OMLSDKTitle[results.Count];
            for (int x = 0; x < results.Count; x++)
                titles[x] = results[x].Title;

            return titles;
        }
Beispiel #2
0
 public void TEST_BASE_CASE()
 {
     TheMovieDbMetadata.TheMovieDbMetadata plugin = new TheMovieDbMetadata.TheMovieDbMetadata();
     plugin.Initialize("", null);
     plugin.SearchForMovie("The Dark Knight", 999);
     OMLSDK.OMLSDKTitle t = plugin.GetBestMatch();
     plugin.GetTitle(0);
 }
        public static Title[] ConvertOMLSDKTitlesToTitles(OMLSDKTitle[] omlsdktitles)
        {
            List<Title> titles = new List<Title>();

            foreach (OMLSDKTitle omlsdktitle in omlsdktitles)
            {
                if (omlsdktitle != null)
                {
                    titles.Add(ConvertOMLSDKTitleToTitle(omlsdktitle));
                }
            }
            return titles.ToArray();
        }
        public void GetImagesForNewTitle(OMLSDKTitle newTitle)
        {
            string id = newTitle.MetadataSourceID;
            if (!string.IsNullOrEmpty(id))
            {
                if (imagesPath != null && Directory.Exists(imagesPath))
                {
                    if (File.Exists(Path.Combine(imagesPath, string.Format("{0}f.{1}", id, @"jpg"))))
                    {
                        newTitle.FrontCoverPath = Path.Combine(imagesPath, string.Format("{0}f.{1}", id, @"jpg"));
                    }

                    if (File.Exists(Path.Combine(imagesPath, string.Format("{0}b.{1}", id, @"jpg"))))
                    {
                        newTitle.BackCoverPath = Path.Combine(imagesPath, string.Format("{0}b.{1}", id, @"jpg"));
                    }
                }
            }
        }
Beispiel #5
0
        /// <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++;
            }
        }
        // Collection/DVD/Credits/*
        private void HandleCredits(OMLSDKTitle title, XPathNavigator creditsNavigator)
        {
            List<string> writersAlreadyAdded = new List<string>();
            List<string> producersAlreadyAdded = new List<string>();

            foreach (XPathNavigator creditNavigator in creditsNavigator.SelectChildren("Credit", string.Empty))
            {
                string creditType = creditNavigator.GetAttribute("CreditType", string.Empty);
                OMLSDKPerson person = new OMLSDKPerson(ReadFullName(creditNavigator));
                switch (creditType)
                {
                    case "Direction":
                        title.AddDirector(person);
                        break;
                    case "Writing":
                        title.AddWriter(person);
                        break;
                    case "Production":
                        title.AddProducer(person);
                        break;
                }
            }
        }
Beispiel #7
0
 private void DownloadImage(OMLSDKTitle title, string imageUrl)
 {
     if (!string.IsNullOrEmpty(imageUrl))
     {
         string tempFileName = Path.GetTempFileName();
         WebClient web = new WebClient();
         try
         {
             web.DownloadFile(imageUrl, tempFileName);
             title.FrontCoverPath = tempFileName;
         }
         catch
         {
             File.Delete(tempFileName);
         }
     }
 }
 // Collection/DVD/PurchaseInfo/*
 private void HandlePurchaseInfo(OMLSDKTitle title, XPathNavigator dvdElement)
 {
     XPathNavigator purchaseDateNavigator = dvdElement.SelectSingleNode("PurchaseDate");
     if (purchaseDateNavigator != null)
     {
         DateTime purchaseDate;
         if (TryReadItemDate(purchaseDateNavigator, DateTimeKind.Local, out purchaseDate))
         {
             title.DateAdded = purchaseDate;
         }
     }
 }
 public TheMovieDbResult()
 {
     Title = new OMLSDKTitle();
 }
        public void GetMovies( string startFolder )
        {
            try
            {
                List<string> moviePaths = new List<string>();

                List<string> dirList = new List<string>();
                List<string> fileList = new List<string>();
                GetSubFolders(startFolder, dirList);

                // the share or link may not exist nowbb
                if (Directory.Exists(startFolder))
                {
                    dirList.Add(startFolder);
                }

                foreach (string currentFolder in dirList)
                {
                    SDKUtilities.DebugLine("DVDImporter: folder " + currentFolder);
                    if (currentFolder.ToUpperInvariant().Contains("fanart".ToUpperInvariant()))
                        SDKUtilities.DebugLine("[DVDImporter] Skipping fanart directory");
                    else
                    {
                        OMLSDKTitle dvd = GetDVDMetaData(currentFolder);
                        string[] fileNames = null;
                        try
                        {
                            fileNames = Directory.GetFiles(currentFolder);
                        }
                        catch
                        {
                            fileNames = null;
                        }

                        if (dvd != null)
                        {
                            // if any video files are found in the DVD folder assume they are trailers
                            if (fileNames != null)
                            {
                                foreach (string video in fileNames)
                                {
                                    string extension = Path.GetExtension(video).ToUpper();
                                    if (Enum.IsDefined(typeof(OMLSDKVideoFormat), extension.ToUpperInvariant()))
                                    {
                                        foreach (OMLSDKVideoFormat format in Enum.GetValues(typeof(OMLSDKVideoFormat)))
                                        {
                                            if (Enum.GetName(typeof(OMLSDKVideoFormat), format).ToLowerInvariant() == extension)
                                            {
                                                dvd.AddTrailer(video);
                                            }
                                        }
                                    }
                                }
                            }
                            AddTitle(dvd);
                        }// found dvd
                        else
                        {
                            if (fileNames != null && fileNames.Length > 0)
                            {
                                if (OMLEngine.Settings.OMLSettings.TreatFoldersAsTitles)
                                {
                                    OMLSDKTitle newVideo = new OMLSDKTitle();

                                    // Create the title name
                                    DirectoryInfo di = new DirectoryInfo(currentFolder);
                                    newVideo.Name = "";
                                    if (OMLEngine.Settings.OMLSettings.AddParentFoldersToTitleName)
                                    {
                                        // If AddParentFolderToTitleName is true then check if the parent folder
                                        // Is the startfolder. If not add parent folder to name
                                        DirectoryInfo st = new DirectoryInfo(startFolder);
                                        if (st.Name != di.Parent.Name)
                                        {
                                            newVideo.Name = di.Parent.Name + " - ";
                                        }
                                    }
                                    newVideo.Name += (new DirectoryInfo(currentFolder)).Name;

                                    int diskNumber = 1;
                                    foreach (string video in fileNames)
                                    {
                                        try
                                        {
                                            string extension = Path.GetExtension(video).ToUpper().Substring(1);
                                            extension = extension.Replace("-", "");

                                            if (Enum.IsDefined(typeof(OMLSDKVideoFormat), extension.ToUpperInvariant()))
                                            {
                                                OMLSDKDisk disk = new OMLSDKDisk();
                                                disk.Path = video;
                                                disk.Format = (OMLSDKVideoFormat)Enum.Parse(typeof(OMLSDKVideoFormat), extension, true);
                                                disk.Name = string.Format("Disk {0}", diskNumber++);
                                                newVideo.AddDisk(disk);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            SDKUtilities.DebugLine("[DVDLibraryImporter] Problem importing file " + video + " : " + ex.Message);
                                        }
                                    }

                                    if (File.Exists(Path.Combine(currentFolder, "folder.jpg")))
                                        newVideo.FrontCoverPath = Path.Combine(currentFolder, "folder.jpg");

                                    if (newVideo.Disks.Count > 0)
                                    {
                                        // There is one or more valid disks for this title. Add it.
                                        //string temp = newVideo.BackDropFolder; // This initialises the fanart folder forcing a search for fanart
                                        AddTitle(newVideo);
                                    }
                                }
                                else
                                {
                                    foreach (string video in fileNames)
                                    {
                                        try
                                        {
                                            string extension = Path.GetExtension(video).ToUpper().Substring(1);
                                            extension = extension.Replace("-", "");

                                            if (Enum.IsDefined(typeof(OMLSDKVideoFormat), extension.ToUpperInvariant()))
                                            {
                                                // this isn't 100% safe since there are videoformats that don't map 1-1 to extensions
                                                OMLSDKVideoFormat videoFormat = (OMLSDKVideoFormat)Enum.Parse(typeof(OMLSDKVideoFormat), extension, true);

                                                OMLSDKTitle newVideo = new OMLSDKTitle();
                                                newVideo.Name = GetSuggestedMovieName(Path.GetFileNameWithoutExtension(video));
                                                OMLSDKDisk disk = new OMLSDKDisk();
                                                disk.Path = video;
                                                disk.Name = "Disk 1";
                                                disk.Format = videoFormat;

                                                string pathWithNoExtension = Path.GetDirectoryName(video) + "\\" + Path.GetFileNameWithoutExtension(video);
                                                if (File.Exists(pathWithNoExtension + ".jpg"))
                                                {
                                                    newVideo.FrontCoverPath = pathWithNoExtension + ".jpg";
                                                }
                                                else if (File.Exists(video + ".jpg"))
                                                {
                                                    newVideo.FrontCoverPath = video + ".jpg";
                                                }
                                                else if (File.Exists(Path.GetDirectoryName(video) + "\\folder.jpg"))
                                                {
                                                    newVideo.FrontCoverPath = Path.GetDirectoryName(video) + "\\folder.jpg";
                                                }

                                                newVideo.AddDisk(disk);
                                                //string temp = newVideo.BackDropFolder; // This initialises the fanart folder forcing a search for fanart
                                                AddTitle(newVideo);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            SDKUtilities.DebugLine("[DVDLibraryImporter] Problem importing file " + video + " : " + ex.Message);
                                        }
                                    }
                                }
                            }
                        }
                    }
                } // loop through the sub folders

            }
            catch (Exception ex)
            {
                SDKUtilities.DebugLine("[DVDLibraryImporter] An error occured: " + ex.Message);
            }
        }
Beispiel #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="title_to_validate"></param>
 /// <returns></returns>
 public bool ValidateTitle(OMLSDKTitle title_to_validate)
 {
     return true;
 }
Beispiel #12
0
        /// <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++;
            }
        }
        public bool SearchForMovie(string movieName, int maxResults)
        {
            if (_xmlFile == null) Initialize(PluginName, null);
            if (_xmlFile == null) return false;

            if (!File.Exists(_xmlFile)) return false;
            DataSet ds = new DataSet();
            ds.ReadXml(_xmlFile);
            movieName = movieName.ToLowerInvariant();
            List<DataRow> dvds = (from dvd in ds.Tables["DVD"].AsEnumerable()
                                  where dvd.Field<String>("Title").ToLowerInvariant().Contains(movieName)
                                  select dvd).ToList<DataRow>();

            List<OMLSDKTitle> dvdList = new List<OMLSDKTitle>();
            foreach (DataRow dr in dvds)
            {
                OMLSDKTitle t = new OMLSDKTitle();
                t.Name = (String)dr["Title"];

                t.ParentalRating = (String)dr["Rating"];
                t.Synopsis = (String)dr["Overview"];
                t.CountryOfOrigin = (String)dr["CountryOfOrigin"];
                t.UPC = (String)dr["UPC"];
                t.OriginalName = (String)dr["OriginalTitle"];
                t.SortName = (String)dr["SortTitle"];

                int runTime;
                if (int.TryParse((String)dr["RunningTime"], out runTime))
                    t.Runtime = runTime;
                DateTime dtReleased;
                if (DateTime.TryParse((String)dr["Released"], out dtReleased))
                    t.ReleaseDate = dtReleased;
                int prodYr;
                if (int.TryParse((String)dr["ProductionYear"], out prodYr))
                    t.ProductionYear = prodYr;

                t.FrontCoverPath = Path.Combine(DVDProfilerImageDir, (String)dr["ID"] + @"f.jpg");
                t.BackCoverPath = Path.Combine(DVDProfilerImageDir, (String)dr["ID"] + @"b.jpg");

                if (ds.Relations.Contains("DVD_Format"))
                {
                    DataRow Format = dr.GetChildRows("DVD_Format")[0];
                    t.VideoStandard = (String)Format["FormatVideoStandard"];
                    t.VideoResolution = (String)Format["FormatAspectRatio"];
                }

                if (ds.Relations.Contains("DVD_Genres") && ds.Relations.Contains("Genres_Genre"))
                {
                    DataRow genres = dr.GetChildRows("DVD_Genres")[0];
                    foreach (DataRow gen in genres.GetChildRows("Genres_Genre"))
                    {
                        String genre = (String)gen[0];
                        t.Genres.Add(genre);
                    }
                }

                if (ds.Relations.Contains("DVD_Actors") && ds.Relations.Contains("Actors_Actor"))
                {
                    DataRow actors = dr.GetChildRows("DVD_Actors")[0];
                    foreach (DataRow actor in actors.GetChildRows("Actors_Actor"))
                    {
                        String fullName = String.Format(@"{0} {1}", actor["FirstName"], actor["LastName"]);
                        t.AddActingRole(fullName, (String)actor["Role"]);
                    }
                }

                if (ds.Relations.Contains("DVD_Credits") && ds.Relations.Contains("Credits_Credit"))
                {
                    DataRow credits = dr.GetChildRows("DVD_Credits")[0];
                    foreach (DataRow credit in credits.GetChildRows("Credits_Credit"))
                    {
                        String CreditType = (String)credit["CreditType"];
                        String fullName = String.Format(@"{0} {1}", credit["FirstName"], credit["LastName"]);
                        if (CreditType == "Direction")
                        {
                            t.AddDirector(new OMLSDKPerson(fullName));
                        }
                        else if (CreditType == "Writing")
                        {
                            t.AddWriter(new OMLSDKPerson(fullName));
                        }
                        else if (CreditType == "Production")
                        {
                            t.AddProducer(new OMLSDKPerson(fullName));
                        }
                    }
                }

                List<String> _studios = new List<String>();
                if (ds.Relations.Contains("DVD_Studios") && ds.Relations.Contains("Studios_Studio"))
                {
                    DataRow studios = dr.GetChildRows("DVD_Studios")[0];
                    foreach (DataRow studio in studios.GetChildRows("Studios_Studio"))
                    {
                        _studios.Add((String)studio[0]);
                    }
                }
                t.Studio = String.Join("; ", _studios.ToArray<String>());
                dvdList.Add(t);
            }
            _searchResult = new DVDProfilerSearchResult(dvdList, dvds.Count, dvds.Count);
            bool rslt = (dvds.Count > 0);
            ds.Dispose(); ds = null;
            return rslt;
        }
        public OMLSDKTitle LoadTitle(XPathNavigator dvdNavigator, bool lookForDiskInfo)
        {
            OMLSDKTitle title = new OMLSDKTitle();
            OMLSDKVideoFormat videoFormat = OMLSDKVideoFormat.DVD;
            string notes = string.Empty;
            var discs = new Dictionary<string, string>(); // The key is on the form "1a", "10b", etc - the value is the description

            foreach (XPathNavigator dvdElement in dvdNavigator.SelectChildren(XPathNodeType.Element))
            {
                switch (dvdElement.Name)
                {
                    case "ID":
                        title.MetadataSourceID = dvdElement.Value;
                        break;
                    case "MediaTypes":
                        videoFormat = HandleMediaTypes(dvdElement);
                        break;
                    case "UPC":
                        title.UPC = dvdElement.Value;
                        break;
                    case "Title":
                        title.Name = dvdElement.Value;
                        break;
                    case "OriginalTitle":
                        title.OriginalName = dvdElement.Value;
                        break;
                    case "SortTitle":
                        title.SortName = dvdElement.Value;
                        break;
                    case "CountryOfOrigin":
                        title.CountryOfOrigin = dvdElement.Value;
                        break;
                    /*case "ProductionYear":
                        // Set to January first in the appropriate year in lack of better...
                        int releaseYear;
                        if (TryReadItemInt(dvdElement, out releaseYear))
                        {
                            title.ReleaseDate = new DateTime(releaseYear, 1, 1);
                        }
                        break;*/

                    // Fix from DVDJunkie
                    // http://www.ornskov.dk/forum/index.php?topic=1605.msg12171#msg12171
                    case "ProductionYear":
                        string ryear = dvdElement.Value;
                        try
                        {
                            if (!string.IsNullOrEmpty(ryear)) title.ProductionYear = Convert.ToInt32(ryear);
                        }
                        catch (FormatException) { }
                        break;
                    case "Released":
                        string rdate = dvdElement.Value;
                        try
                        {
                            if (!string.IsNullOrEmpty(rdate)) title.ReleaseDate = DateTime.Parse(rdate);
                        }
                        catch (ArgumentException) { }
                        catch (FormatException) { }
                        break;
                    case "RunningTime":
                        int runningTime;
                        if (TryReadItemInt(dvdElement, out runningTime)) title.Runtime = runningTime;
                        break;
                    case "Rating":
                        title.ParentalRating = dvdElement.Value;
                        break;
                    case "RatingDetails":
                        title.ParentalRatingReason = dvdElement.Value;
                        break;
                    case "Genres":
                        foreach (XPathNavigator genreNavigator in dvdElement.Select("Genre[. != '']"))
                        {
                            title.AddGenre(genreNavigator.Value);
                        }
                        break;
                    case "Format":
                        HandleFormat(title, dvdElement);
                        break;
                    case "Studios":
                        var studioNavigator = dvdElement.SelectSingleNode("Studio[. != '']");
                        if (studioNavigator != null) title.Studio = studioNavigator.Value;
                        break;
                    case "Audio":
                        HandleAudio(title, dvdElement);
                        break;
                    case "Subtitles":
                        foreach (XPathNavigator subtitleNavigator in dvdElement.SelectChildren("Subtitle", string.Empty))
                        {
                            title.AddSubtitle(subtitleNavigator.Value);
                        }
                        break;
                    case "Actors":
                        HandleActors(title, dvdElement);
                        break;
                    case "Credits":
                        HandleCredits(title, dvdElement);
                        break;
                    case "Review":
                        ReadFilmReview(title, dvdElement);
                        break;
                    case "Overview":
                        string synopsis = removeFormattingRegex.Replace(dvdElement.Value, string.Empty);
                        title.Synopsis = removeExtraLinebreaksRegex.Replace(synopsis, "\r\n").Trim();
                        break;
                    case "Discs":
                        discs = HandleDiscs(dvdElement);
                        break;
                    case "Notes":
                        notes = dvdElement.Value;
                        break;
                    case "PurchaseInfo":
                        HandlePurchaseInfo(title, dvdElement);
                        break;
                }
            }
            if (lookForDiskInfo)
                MergeDiscInfo(title, videoFormat, discs, notes);

            ApplyTags(title, dvdNavigator);
            return title;
        }
 private void ReadFilmReview(OMLSDKTitle title, XPathNavigator reviewNavigator)
 {
     switch (reviewNavigator.GetAttribute("Film", String.Empty))
     {
         case "9": title.UserStarRating = 100; break;
         case "8": title.UserStarRating = 90; break;
         case "7": title.UserStarRating = 80; break;
         case "6": title.UserStarRating = 70; break;
         case "5": title.UserStarRating = 60; break;
         case "4": title.UserStarRating = 50; break;
         case "3": title.UserStarRating = 40; break;
         case "2": title.UserStarRating = 20; break; // Have to skip somewhere to avoid fractions :(
         case "1": title.UserStarRating = 10; break;
     }
 }
        /// <summary>
        /// Merges the information from the Notes field with the DVD Profiler Disc data to create the Disk entries for the title
        /// </summary>
        private void MergeDiscInfo(OMLSDKTitle title, OMLSDKVideoFormat dvdProfilerVideoFormat, Dictionary<string, string> discs, string notes)
        {
            if (string.IsNullOrEmpty(notes)) return;

            var matches = filepathRegex.Matches(notes);
            int lastDiskNumber = 0;
            foreach (Match m in matches)
            {
                string discNumberString = m.Groups["discNumber"].Value;
                int discNumber = Convert.ToInt32(string.IsNullOrEmpty(discNumberString) ? "0" : discNumberString,
                                                 CultureInfo.InvariantCulture);
                if (discNumber == 0) discNumber = lastDiskNumber + 1;
                string sideString = m.Groups["side"].Value;
                if (string.IsNullOrEmpty(sideString)) sideString = "a";

                string description;
                string discKey = discNumber.ToString(CultureInfo.InvariantCulture) + sideString.ToLowerInvariant();
                if (!discs.TryGetValue(discKey, out description))
                {
                    // TODO: I18N
                    if (matches.Count == 1) description = "Movie";
                    else description = "Disc " + discKey;
                }
                string path = m.Groups["path"].Value;
                OMLSDKVideoFormat discVideoFormat = GetFormatFromExtension(Path.GetExtension(path), dvdProfilerVideoFormat);

                if (!string.IsNullOrEmpty(path))
                {
                    // validate that the path to the file/directory is valid
                    if (!File.Exists(path) && !Directory.Exists(path))
                    {
                        this.AddError("Invalid path \"" + path + "\" for movie \"" + title.Name + "\"");
                    }
                }

                title.AddDisk(new OMLSDKDisk(description, path, discVideoFormat));
                lastDiskNumber++;
            }
        }
        private OMLSDKTitle GetDVDMetaData(string folderName)
        {
            try
            {
                string xmlFile = "";

                DirectoryType dirType = GetDirectoryType(folderName);

                if (dirType != DirectoryType.Normal )
                {
                    string[] xmlFiles = Directory.GetFiles(folderName, "*dvdid.xml");
                    if (xmlFiles.Length > 0)
                    {
                        //xmlFile = Path.GetFileName(xmlFiles[0]); // get the first one
                        xmlFile = xmlFiles[0];
                    }
                    //else
                    //{
                    //    xmlFiles = Directory.GetFiles(folderName, "*xml");
                    //    if (xmlFiles.Length > 0)
                    //        //xmlFile = Path.GetFileName(xmlFiles[0]); // get the first one
                    //        xmlFile = xmlFiles[0]; // get the first one
                    //    else
                    //        xmlFile = "";
                    //}

                    OMLSDKTitle t = null;
                    // xmlFile contains the dvdid - then we need to lookup in the cache folder based on this id
                    if (xmlFile != "" && File.Exists(xmlFile))
                    {
                        string dvdid = GetDVDID(xmlFile);
                        string xmlDetailsFile = GetDVDCacheFileName(dvdid);
                        t = ReadMetaData(folderName, xmlDetailsFile);
                    }

                    if( t == null )
                    {
                        // for DVDs with no dvdid.xml add a stripped down title with just a suggested name
                        t = new OMLSDKTitle();
                        t.Name = GetSuggestedMovieName(folderName);

                    }

                    if (!File.Exists(t.FrontCoverPath))
                    {
                        if( File.Exists( folderName + "\\folder.jpg") )
                            t.FrontCoverPath = folderName + "\\folder.jpg";
                    }

                    t.ImporterSource = "VMCDVDLibraryPlugin";
                    OMLSDKDisk disk = new OMLSDKDisk();
                    disk.Name = "Disk 1";

                    switch (dirType)
                    {
                        case DirectoryType.BluRay:
                            disk.Format = OMLSDKVideoFormat.BLURAY;
                            disk.Path = folderName;
                            break;

                        case DirectoryType.HDDvd:
                            disk.Format = OMLSDKVideoFormat.HDDVD;
                            disk.Path = folderName;
                            break;

                        case DirectoryType.DVD_Flat:
                            disk.Format = OMLSDKVideoFormat.DVD;
                            disk.Path = folderName;
                            break;

                        case DirectoryType.DVD_Ripped:
                            disk.Format = OMLSDKVideoFormat.DVD;
                            disk.Path = folderName;
                            break;
                    }

                    t.AddDisk(disk);
                    t.MetadataSourceName = "VMC DVD Library";
                    return t;
                }
            }
            catch (Exception ex)
            {
                SDKUtilities.DebugLine("[DVDLibraryImporter] An error occured: " + ex.Message);
            }

            return null;
        }
 public TheTVDBDbResult()
 {
     Title = new OMLSDKTitle();
 }
        private OMLSDKTitle ReadMetaData(string movieFolder, string dvdCacheXMLFile)
        {
            OMLSDKTitle t = new OMLSDKTitle();
            try
            {
                if (File.Exists(dvdCacheXMLFile))
                {
                    XmlReaderSettings xmlSettings = new XmlReaderSettings();
                    xmlSettings.IgnoreWhitespace = false;
                    using (XmlReader reader = XmlReader.Create(dvdCacheXMLFile, xmlSettings))
                    {
                        bool bFound = reader.ReadToFollowing("MDR-DVD");
                        if (!bFound) return null;

                        bFound = reader.ReadToFollowing("dvdTitle");
                        if (!bFound) return null;
                        t.Name = reader.ReadString().Trim();

                        bFound = reader.ReadToFollowing("studio");
                        if (bFound)
                            t.Studio = reader.ReadString().Trim();

                        bFound = reader.ReadToFollowing("leadPerformer");
                        if (bFound)
                        {
                            string leadPerformer = reader.ReadString();
                            string[] actors = leadPerformer.Split(new char[] { ';', ',', '|' });
                            foreach (string actor in actors)
                            {
                                t.AddActingRole(actor.Trim(), "");
                            }
                        }

                        bFound = reader.ReadToFollowing("director");
                        if (bFound)
                        {
                            string directorList = reader.ReadString();
                            string[] directors = directorList.Split(new char[] { ';', ',', '|' });
                            foreach (string director in directors)
                            {
                                t.AddDirector(new OMLSDKPerson(director.Trim()));
                            }
                        }

                        bFound = reader.ReadToFollowing("MPAARating");
                        if (bFound)
                            t.ParentalRating = reader.ReadString().Trim();

                        bFound = reader.ReadToFollowing("language");
                        if (bFound)
                            t.AddAudioTrack(reader.ReadString().Trim());

                        bFound = reader.ReadToFollowing("releaseDate");
                        if (bFound)
                        {
                            string releaseDate = reader.ReadString().Trim();
                            DateTime dt;
                            if (DateTime.TryParse(releaseDate, out dt))
                            {
                                t.ReleaseDate = dt;
                            }
                        }

                        bFound = reader.ReadToFollowing("genre");
                        if (bFound)
                        {
                            string genreList = reader.ReadString();
                            string[] genres = genreList.Split(new char[] { ';', ',', '|' });
                            foreach (string genre in genres)
                            {
                                t.AddGenre(genre.Trim());
                            }
                        }

                        string imageFileName = "";
                        bFound = reader.ReadToFollowing("largeCoverParams");
                        if (bFound)
                        {
                            imageFileName = reader.ReadString().Trim();
                            if (!File.Exists(imageFileName) && File.Exists(movieFolder + "\\folder.jpg"))
                            {
                                imageFileName = movieFolder + "\\folder.jpg";
                            }
                        }
                        else if( File.Exists(movieFolder + "\\folder.jpg" ) )
                        {
                            imageFileName = movieFolder + "\\folder.jpg";
                        }

                        t.FrontCoverPath = imageFileName;

                        bFound = reader.ReadToFollowing("duration");
                        if (bFound)
                        {
                            int runtime;
                            if( Int32.TryParse(reader.ReadString(), out runtime))
                            {
                                t.Runtime = runtime;
                            }
                        }

                        bFound = reader.ReadToFollowing("synopsis");
                        if (bFound)
                            t.Synopsis = reader.ReadString().Trim();

                    }
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                SDKUtilities.DebugLine("[DVDLibraryImporter] An error occured: " + ex.Message);
                return null;
            }

            return t;
        }
        public override void ProcessFile(string file)
        {
            SDKUtilities.DebugLine("[MyMoviesImporter] created[filename("+file+")]");

            currentFile = file;
            if (File.Exists(currentFile))
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(file);
                SDKUtilities.DebugLine("[MyMoviesImporter] file loaded");

                XmlNodeList nodeList = xDoc.SelectNodes("//Titles/Title");
                if (nodeList.Count == 0)
                    nodeList = xDoc.SelectNodes("Title");

                foreach (XmlNode movieNode in nodeList)
                {
                    SDKUtilities.DebugLine("[MyMoviesImporter] Found base Title node");

                    OMLSDKTitle newTitle = new OMLSDKTitle();

                    XPathNavigator navigator = movieNode.CreateNavigator();
                    newTitle.Name = GetChildNodesValue(navigator, "LocalTitle");
                    loadDataFromNavigatorToTitle(ref navigator, ref newTitle);

                    if (ValidateTitle(newTitle, file))
                    {
                        SDKUtilities.DebugLine("[MyMoviesImporter] Validating title");
                        try { AddTitle(newTitle); }
                        catch (Exception e) { SDKUtilities.DebugLine("[MyMoviesImporter] Error adding row: " + e.Message); }
                    }
                    else SDKUtilities.DebugLine("[MyMoviesImporter] Error saving row");
                }
            }
            else
            {
                AddError("[MyMoviesImporter] File not found when trying to load file: {0}", currentFile);
            }
        }
 private void UpdateTitleFromOMLXML(OMLSDKTitle t)
 {
 }
        private void extractDisksFromXML(XPathNodeIterator nIter, XPathNavigator localNav, OMLSDKTitle newTitle)
        {
            SDKUtilities.DebugLine("[MyMoviesImporter] Scanning for Discs...");
            SDKUtilities.DebugLine("[MyMoviesImporter] {0} entries found", nIter.Count);
            for (int i = 0; i < nIter.Count; i++)
            {
                bool isDoubleSided = (((string)GetChildNodesValue(localNav, "DoubleSided")).CompareTo("False") == 0)
                                     ? false : true;

                string discName = (string)GetChildNodesValue(localNav, "Name");
                string sideAId = (string)GetChildNodesValue(localNav, "DiscIdSideA");
                string sideALocation = (string)GetChildNodesValue(localNav, "LocationSideA");
                string sideALocationType = (string)GetChildNodesValue(localNav, "LocationTypeSideA");
                string changerSlot = (string)GetChildNodesValue(localNav, "ChangerSlot");

                string sideBId = string.Empty;
                string sideBLocation = string.Empty;
                string sideBLocationType = string.Empty;
                if (isDoubleSided)
                {
                    sideBId = (string)GetChildNodesValue(localNav, "DiscIdSideB");
                    sideBLocation = (string)GetChildNodesValue(localNav, "LocationSideB");
                    sideBLocationType = (string)GetChildNodesValue(localNav, "LocationTypeSideB");
                }

                SDKUtilities.DebugLine("[MyMoviesImporter] Ok, I've collected some info... now we actually start looking for files");
                IList<OMLSDKDisk> sideAdisks = GetDisksForLocation(sideALocation, sideALocationType);

                int j = 1;
                SDKUtilities.DebugLine("[MyMoviesImporter] Ok, we found {0} possible files", sideAdisks.Count);
                foreach (OMLSDKDisk disk in sideAdisks)
                {
                    disk.Name = string.Format(@"Disk{0}", j++);
                    newTitle.AddDisk(disk);
                }

                if (isDoubleSided)
                {
                    SDKUtilities.DebugLine("[MyMoviesImporter] Whoa... this thing appears to be double-sided (old schooling it huh?)");
                    IList<OMLSDKDisk> sideBdisks = GetDisksForLocation(sideBLocation, sideBLocationType);
                    SDKUtilities.DebugLine("[MyMoviesImporter] We found {0} disks on the B side", sideBdisks.Count);
                    foreach (OMLSDKDisk disk in sideBdisks)
                    {
                        disk.Name = string.Format(@"Disk{0}", j++);
                        newTitle.AddDisk(disk);
                    }
                }

                localNav.MoveToNext("Disc", "");
            }
        }
 public AmazonSearchResult(OMLSDKTitle[] dvdList, int totalPages, int totalItems)
 {
     m_DVDList = dvdList;
     m_TotalPages = totalPages;
     m_TotalItems = totalItems;
 }
 // Collection/DVD/Format/*
 private void HandleFormat(OMLSDKTitle title, XPathNavigator formatNavigator)
 {
     foreach (XPathNavigator formatChildElementNavigator in formatNavigator.SelectChildren(XPathNodeType.Element))
     {
         switch (formatChildElementNavigator.Name)
         {
             case "FormatAspectRatio":
                 title.AspectRatio = formatChildElementNavigator.Value;
                 break;
             case "FormatVideoStandard":
                 title.VideoStandard = formatChildElementNavigator.Value;
                 break;
             case "FormatLetterBox":
             case "FormatPanAndScan":
             case "FormatFullFrame":
                 if (string.IsNullOrEmpty(title.AspectRatio))
                 {
                     title.AspectRatio = "1.33";
                 }
                 break;
         }
     }
 }
        public bool ValidateTitle(OMLSDKTitle title_to_validate, string file)
        {
            SDKUtilities.DebugLine("[MyMoviesImporter] This is the part where we validate (or not) your shiny new title, wouldn't want you to drive off the lot with it untested now would we");
            if (title_to_validate.Disks.Count == 0)
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Whoa... you dont appear to have any discs... lets double check that");
                string directoryName = Path.GetDirectoryName(file);
                if (Directory.Exists(directoryName))
                {
                    if (SDKUtilities.IsBluRay(directoryName))
                    {
                        SDKUtilities.DebugLine("[MyMoviesImporter] its a bluray, adding a new disk");
                        title_to_validate.AddDisk(new OMLSDKDisk("Disk1", directoryName, OMLSDKVideoFormat.BLURAY));
                        return true;
                    }

                    if (SDKUtilities.IsHDDVD(directoryName))
                    {
                        SDKUtilities.DebugLine("[MyMoviesImporter] its an hddvd, adding a new disk");
                        title_to_validate.AddDisk(new OMLSDKDisk("Disk1", directoryName, OMLSDKVideoFormat.HDDVD));
                        return true;
                    }

                    if (SDKUtilities.IsDVD(directoryName))
                    {
                        SDKUtilities.DebugLine("[MyMoviesImporter] its a dvd, adding a new disk");
                        title_to_validate.AddDisk(new OMLSDKDisk("Disk1", directoryName, OMLSDKVideoFormat.DVD));
                        return true;
                    }

                    string[] files = Directory.GetFiles(directoryName);
                    SDKUtilities.DebugLine("[MyMoviesImporter] You have {0} files in the current location {1}", files.Length, directoryName);

                    /* patch from KingManon to limit files only to those of valid file types */
                    string localExt;
                    List<string> newFiles = new List<string>();
                    List<string> allowedExtensions = new List<string>(Enum.GetNames(typeof(OMLSDKVideoFormat)));
                    foreach (string singleFile in files)
                    {
                        localExt = Path.GetExtension(singleFile).Substring(1);
                        if (allowedExtensions.Contains(localExt.ToUpper()))
                            newFiles.Add(singleFile);
                    }
                    files = newFiles.ToArray();

                    Array.Sort(files);
                    for (int i = 0; i < files.Length; i++)
                    {

                        string ext = Path.GetExtension(files[i]).Substring(1);
                        try
                        {
                            if (new List<string>(Enum.GetNames(typeof(OMLSDKVideoFormat))).Contains(ext.ToUpper()))
                            {
                                OMLSDKVideoFormat format;
                                try
                                {
                                    SDKUtilities.DebugLine("[MyMoviesImporter] Checking file for format {0}", files[i]);
                                    format = (OMLSDKVideoFormat)Enum.Parse(typeof(OMLSDKVideoFormat), ext, true);
                                    OMLSDKDisk disk = new OMLSDKDisk();
                                    disk.Name = string.Format("Disk{0}", i + 1);
                                    disk.Path = Path.Combine(directoryName, files[i]);
                                    disk.Format = format;
                                    title_to_validate.AddDisk(disk);
                                }
                                catch (Exception)
                                {
                                    AddError("[MyMoviesImporter] Unable to determine format for extension: {0}", ext);
                                }
                            }
                        }
                        catch
                        {
                            SDKUtilities.DebugLine("[MyMoviesImporter] Yeah, no extention on file ({0}), skip it!", files[i]);
                            // didnt get the extension, its not a valid file, skip it
                        }
                    }
                    if (title_to_validate.Disks.Count == 0)
                    {
                        SDKUtilities.DebugLine("[MyMoviesImporter] No disks found on the title, we'll skip it");
                        return false;
                    }
                }
            }
            return true;
        }
        public bool SearchForMovie(string movieName, int maxResults)
        {
            _locale = AmazonLocale.FromString(Properties.Settings.Default.AmazonLocale);

            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            binding.MaxReceivedMessageSize = int.MaxValue;

            client = new AWSECommerceServicePortTypeClient(
                binding, new EndpointAddress(_locale.URL)
            );

            client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior());

            try
            {
                ItemSearchRequest req = new ItemSearchRequest();
                req.SearchIndex = Properties.Settings.Default.AmazonSearchMode;
                req.Title = movieName;
                req.ItemPage = @"1";
                req.ResponseGroup = new string[] { "Medium", "Subjects" };

                ItemSearch iSearch = new ItemSearch();
                iSearch.Request = new ItemSearchRequest[] { req };
                iSearch.AWSAccessKeyId = Properties.Settings.Default.AWEAccessKeyId;

                ItemSearchResponse res = client.ItemSearch(iSearch);
                if (res.Items[0].Item.Length > 0)
                {
                    Item[] amazonItems = res.Items[0].Item;
                    int itemsToProcess = Math.Min(amazonItems.Length, maxResults);

                    if (amazonItems != null)
                    {
                        // convert Amazon Items to generic collection of DVDs
                        OMLSDKTitle[] searchResults = new OMLSDKTitle[itemsToProcess];

                        for (int i = 0; i < itemsToProcess; i++)
                        {
                            searchResults[i] = AmazonToOML.TitleFromAmazonItem(amazonItems[i]);
                        }
                        int totalPages = 0;
                        int totalItems = 0;
                        if (res.Items[0].TotalPages != null) totalPages = Convert.ToInt32(res.Items[0].TotalPages);
                        if (res.Items[0].TotalResults != null) totalItems = Convert.ToInt32(res.Items[0].TotalResults);

                        _searchResult = (new AmazonSearchResult(searchResults, totalPages, totalItems));
                    }
                    else
                    {
                        _searchResult = (new AmazonSearchResult(null, 0, 0));
                    }

                    return true;
                }
            }
            catch
            {
                _searchResult = (new AmazonSearchResult(null, 0, 0));
            }

            return false;
        }
        private void loadDataFromNavigatorToTitle(ref XPathNavigator navigator, ref OMLSDKTitle newTitle)
        {
            SDKUtilities.DebugLine("[MyMoviesImporter] Loading data for a new title");
            newTitle.MetadataSourceID = GetChildNodesValue(navigator, "WebServiceID");

            #region covers
            SDKUtilities.DebugLine("[MyMoviesImporter] Scanning for {0} node", "Covers");
            if (navigator.MoveToChild("Covers", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Covers found, processing");
                SDKUtilities.DebugLine("[MyMoviesImporter] Scanning for {0} node", "Front");
                if (navigator.MoveToChild("Front", ""))
                {
                    string imagePath = navigator.Value;
                    string finalImagePath = FindFinalImagePath(imagePath);
                    SDKUtilities.DebugLine("[MyMoviesImporter] Final image path is: {0}", finalImagePath);
                    if (File.Exists(finalImagePath))
                    {
                        SDKUtilities.DebugLine("[MyMoviesImporter] This file appears to be valid, we'll set it on the title");
                        newTitle.FrontCoverPath = finalImagePath;
                    }
                    navigator.MoveToParent();
                }
                SDKUtilities.DebugLine("[MyMoviesImporter] Scanning for {0} node", "Back");
                if (navigator.MoveToChild("Back", ""))
                {
                    string imagePath = navigator.Value;
                    if (File.Exists(imagePath))
                    {
                        SDKUtilities.DebugLine("[MyMoviesImporter] Found Back cover image");
                        newTitle.BackCoverPath = imagePath;
                    }
                    navigator.MoveToParent();
                }

                navigator.MoveToParent();
            }
            #endregion

            newTitle.Synopsis = GetChildNodesValue(navigator, "Description");

            #region production year
            if (navigator.MoveToChild("ProductionYear", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Found production year, I hope the format is something we can read");
                try
                {
                    string year = navigator.Value;
                    if (!string.IsNullOrEmpty(year))
                    {
                        DateTime rls_date = new DateTime(int.Parse(year), 1, 1);
                        if (rls_date != null)
                        {
                            SDKUtilities.DebugLine("[MyMoviesImporter] Got it, loading the production year");
                            newTitle.ReleaseDate = rls_date;
                        }
                    }
                    navigator.MoveToParent();
                }
                catch (Exception e)
                {
                    navigator.MoveToParent();
                    SDKUtilities.DebugLine("[MyMoviesImporter] error reading ProductionYear: " + e.Message);
                }
            }
            #endregion

            #region parental rating (mpaa rating)
            if (navigator.MoveToChild("ParentalRating", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Scanning for the ParentalRating");
                if (navigator.HasChildren)
                {
                    string ratingId = GetChildNodesValue(navigator, "Value");
                    if (!string.IsNullOrEmpty(ratingId))
                    {
                        int mmRatingId;
                        if (int.TryParse(ratingId, out mmRatingId))
                            switch (mmRatingId)
                            {
                                case 0:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] This appears to be unrated");
                                    newTitle.ParentalRating = "Unrated";
                                    break;
                                case 1:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] This appears to be rated G");
                                    newTitle.ParentalRating = "G";
                                    break;
                                case 2:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] I have no idea what rating this is");
                                    break;
                                case 3:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] This appears to be rated PG");
                                    newTitle.ParentalRating = "PG";
                                    break;
                                case 4:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] This appears to be rated PG13");
                                    newTitle.ParentalRating = "PG13";
                                    break;
                                case 5:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] I have NO idea what rating this is");
                                    break;
                                case 6:
                                    SDKUtilities.DebugLine("[MyMoviesImporter] This appears to be rated R");
                                    newTitle.ParentalRating = "R";
                                    break;
                            }
                        else
                            SDKUtilities.DebugLine("[MyMoviesImporter] Error parsing rating: {0} not a number", ratingId);
                    }
                    string ratingReason = GetChildNodesValue(navigator, "Description");
                    if (!string.IsNullOrEmpty(ratingReason))
                        newTitle.ParentalRatingReason = ratingReason;
                }
                navigator.MoveToParent();
            }
            #endregion

            newTitle.Runtime = Int32.Parse(GetChildNodesValue(navigator, "RunningTime"));

            #region persons
            if (navigator.MoveToChild("Persons", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Beginning the long, painful process of scanning people");
                if (navigator.HasChildren)
                {
                    XPathNodeIterator nIter = navigator.SelectChildren("Person", "");
                    if (navigator.MoveToFirstChild())
                    {
                        XPathNavigator localNav = navigator.CreateNavigator();
                        navigator.MoveToParent();
                        for (int i = 0; i < nIter.Count; i++)
                        {
                            string name = GetChildNodesValue(localNav, "Name");
                            string role = GetChildNodesValue(localNav, "Role");
                            string type = GetChildNodesValue(localNav, "Type");

                            if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(type))
                            {
                                switch (type)
                                {
                                    case "Actor":
                                        SDKUtilities.DebugLine("[MyMoviesImporter] actor {0}, {1}", name, role);

                                        newTitle.AddActingRole(name, role);
                                        break;
                                    case "Director":
                                        SDKUtilities.DebugLine("[MyMoviesImporter] director {0}", name);

                                        newTitle.AddDirector(new OMLSDKPerson(name));
                                        break;

                                    default:
                                        break;
                                }
                            }
                            localNav.MoveToNext("Person", "");
                        }
                    }
                }
                navigator.MoveToParent();
            }
            #endregion

            #region studio (s)
            if (navigator.MoveToChild("Studios", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Ahh... Studios (pssst.. we only copy the last entry from here... dont tell anyone)");
                if (navigator.HasChildren)
                {
                    XPathNodeIterator nIter = navigator.SelectChildren("Studio", "");
                    if (navigator.MoveToFirstChild())
                    {
                        XPathNavigator localNav = navigator.CreateNavigator();
                        navigator.MoveToParent();
                        for (int i = 0; i < nIter.Count; i++)
                        {
                            newTitle.Studio = localNav.Value;
                        }
                    }
                }
                navigator.MoveToParent();
            }
            #endregion

            newTitle.CountryOfOrigin = GetChildNodesValue(navigator, "Country");
            newTitle.AspectRatio = GetChildNodesValue(navigator, "AspectRatio");
            newTitle.VideoStandard = GetChildNodesValue(navigator, "VideoStandard");
            newTitle.OriginalName = GetChildNodesValue(navigator, "OriginalTitle");
            newTitle.SortName = GetChildNodesValue(navigator, "SortTitle");

            #region genres
            if (navigator.MoveToChild("Genres", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Genres... good old genres");
                XPathNodeIterator nIter = navigator.SelectChildren("Genre", "");
                if (navigator.MoveToFirstChild())
                {
                    XPathNavigator localNav = navigator.CreateNavigator();
                    navigator.MoveToParent();
                    for (int i = 0; i < nIter.Count; i++)
                    {
                        newTitle.AddGenre(localNav.Value);
                        localNav.MoveToNext("Genre", "");
                    }
                }
                navigator.MoveToParent();
            }
            #endregion

            #region audio tracks
            if (navigator.MoveToChild("AudioTracks", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] AudioTracks.. yeah, like you can even change them anyway");
                XPathNodeIterator nIter = navigator.SelectChildren("AudioTrack", "");
                if (navigator.MoveToFirstChild())
                {
                    XPathNavigator localNav = navigator.CreateNavigator();
                    navigator.MoveToParent();
                    for (int i = 0; i < nIter.Count; i++)
                    {
                        string audioLanguage = localNav.GetAttribute("Language", "");
                        string audioType = localNav.GetAttribute("Type", "");
                        string audioChannels = localNav.GetAttribute("Channels", "");

                        if (!string.IsNullOrEmpty(audioLanguage))
                        {
                            string audioTrackString = audioLanguage;
                            if (!string.IsNullOrEmpty(audioType))
                                audioTrackString += string.Format(", {0}", audioType);

                            if (!string.IsNullOrEmpty(audioChannels))
                                audioTrackString += string.Format(", {0}", audioChannels);

                            SDKUtilities.DebugLine("[MyMoviesImporter] Got one: {0}, {1}, {2}", audioLanguage, audioType, audioChannels);
                            newTitle.AddAudioTrack(audioTrackString);
                        }
                        localNav.MoveToNext("AudioTrack", "");
                    }
                }
                navigator.MoveToParent();
            }
            #endregion

            #region watched status (Submitted by yodine from our forums)
            if (navigator.MoveToChild("Watched", ""))
            {
                navigator.MoveToParent(); // move back, we just wanted to know this field existed.
                SDKUtilities.DebugLine("[MyMoviesImporter] Found Watched status. Trying to decode");
                string watched = GetChildNodesValue(navigator, "Watched");
                if (!string.IsNullOrEmpty(watched))
                {
                    if (Boolean.Parse(watched))
                        newTitle.WatchedCount++;
                }
            }
            #endregion

            #region subtitles
            if (navigator.MoveToChild("Subtitles", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Subtitles here we come!");
                if (navigator.GetAttribute("NotPresent", "").CompareTo("False") == 0)
                {
                    XPathNodeIterator nIter = navigator.SelectChildren("Subtitle", "");
                    if (navigator.MoveToFirstChild())
                    {
                        XPathNavigator localNav = navigator.CreateNavigator();
                        navigator.MoveToParent();
                        for (int i = 0; i < nIter.Count; i++)
                        {
                            string subtitleLanguage = localNav.GetAttribute("Language", "");
                            if (!string.IsNullOrEmpty(subtitleLanguage))
                            {
                                SDKUtilities.DebugLine("[MyMoviesImporter] Subtitle {0}", subtitleLanguage);
                                newTitle.AddSubtitle(subtitleLanguage);
                            }

                            localNav.MoveToNext("Subtitle", "");
                        }
                    }
                }
                navigator.MoveToParent();
            }
            #endregion

            #region discs
            if (navigator.MoveToChild("Discs", ""))
            {
                SDKUtilities.DebugLine("[MyMoviesImporter] Discs... ok here is the good one, we'll passing this off to some other method to handle.");
                XPathNodeIterator nIter = navigator.SelectChildren("Disc", "");
                if (navigator.MoveToFirstChild())
                {
                    XPathNavigator localNav = navigator.CreateNavigator();
                    extractDisksFromXML(nIter, localNav, newTitle);
                    navigator.MoveToParent();
                }
                navigator.MoveToParent();
            }
            #endregion
        }
        public bool SearchForMovie(string movieName, int maxResults)
        {
            movieName = CleanString(movieName);

            foundTitle = null;
            List<string> possibleIds = new List<string>();

            if (dvdsByName.ContainsKey(movieName))
            {
                possibleIds.Add(dvdsByName[movieName]);
            }
            else if ( dvdsBySortName.ContainsKey(movieName))
            {
                possibleIds.Add(dvdsBySortName[movieName]);
            }
            else
            {
                foreach (string key in dvdsByName.Keys)
                {
                    if (key.StartsWith(movieName, StringComparison.OrdinalIgnoreCase))
                    {
                        possibleIds.Add(dvdsByName[key]);
                    }
                }
            }

            // try the sort names if none of the other names panned out
            if (possibleIds.Count == 0)
            {
                foreach (string key in dvdsBySortName.Keys)
                {
                    if (key.StartsWith(movieName, StringComparison.OrdinalIgnoreCase))
                    {
                        possibleIds.Add(dvdsBySortName[key]);
                    }
                }
            }

            IEnumerable<string> unusedPossibleIds = SDKUtilities.GetUniqueMetaIds(possibleIds, this.PluginName);

            foreach (string possibleId in unusedPossibleIds)
            {
                var navigator = document.CreateNavigator();

                foreach (XPathNavigator dvd in navigator.Select("/Collection/DVD|/DVD")) // Allow both collection file and single profile export
                {
                    foreach (XPathNavigator child in dvd.SelectChildren(XPathNodeType.Element))
                    {
                        if (child.Name == "ID")
                        {
                            if (child.Value == possibleId)
                            {
                                child.MoveToParent();

                                DVDProfilerImporter importer = new DVDProfilerImporter();
                                foundTitle = importer.LoadTitle(child, false);
                                importer.GetImagesForNewTitle(foundTitle);
                            }
                        }

                        if (foundTitle != null)
                            break;
                    }

                    if (foundTitle != null)
                        break;
                }

                // we only care about the first one for now
                break;
            }

            return foundTitle != null;
        }
Beispiel #29
0
 public NetFlixDbResult()
 {
     Title = new OMLSDKTitle();
 }
        public override void ProcessFile(string file)
        {
            OMLSDKTitle newTitle = new OMLSDKTitle();
            String fPath = Path.GetDirectoryName(file);
            newTitle.Name = Path.GetFileNameWithoutExtension(file);
            IDictionary meta;
            DvrmsMetadataEditor editor = new DvrmsMetadataEditor(file);
            meta = editor.GetAttributes();
            foreach (string item in meta.Keys)
            {
                MetadataItem attr = (MetadataItem)meta[item];
                switch (item)
                {
                    case DvrmsMetadataEditor.Title:
                        string sTitle = (string)attr.Value;
                        sTitle = sTitle.Trim();
                        if (!String.IsNullOrEmpty(sTitle))
                        {
                            newTitle.Name = sTitle;
                        }
                        newTitle.ImporterSource = @"DVRMSImporter";
                        newTitle.MetadataSourceName = @"DVR-MS";
                        OMLSDKDisk disk = new OMLSDKDisk();
                        string ext = Path.GetExtension(file).Substring(1).Replace(@"-", @"");
                        disk.Format = (OMLSDKVideoFormat)Enum.Parse(typeof(OMLSDKVideoFormat), ext, true);
                        SDKUtilities.DebugLine("[DVRMSPlugin] Adding file: " + Path.GetFullPath(file));
                        disk.Path = Path.GetFullPath(file);
                        disk.Name = @"Disk 1";
                        newTitle.AddDisk(disk);
                        //newTitle.FileLocation = file;
                        if (!String.IsNullOrEmpty(newTitle.AspectRatio))
                        {
                            newTitle.AspectRatio = @"Widescreen";
                        }
                        //string ext = Path.GetExtension(file).Substring(1).Replace(@"-", @"");
                        //newTitle.VideoFormat = (VideoFormat)Enum.Parse(typeof(VideoFormat), ext, true);
                        string cover = fPath + @"\" + Path.GetFileNameWithoutExtension(file) + @".jpg";
                        if (File.Exists(cover))
                        {
                            SDKUtilities.DebugLine("[DVRMSPlugin] Setting CoverArt: " + Path.GetFullPath(cover));
                            newTitle.FrontCoverPath = Path.GetFullPath(cover);
                            //newTitle.FrontCoverPath = cover;
                        }
                        else
                        {
                            SDKUtilities.DebugLine("[DVRMSPlugin] No coverart found");
                        }
                        break;
                    case DvrmsMetadataEditor.MediaOriginalBroadcastDateTime:
                        string sDT = (string)attr.Value;
                        if (!String.IsNullOrEmpty(sDT))
                        {
                            DateTime dt;
                            if (DateTime.TryParse(sDT, out dt))
                            {
                                newTitle.ReleaseDate = dt;
                            }
                        }
                        break;
                    case DvrmsMetadataEditor.Genre:
                        if (!String.IsNullOrEmpty((string)attr.Value))
                        {
                            string sGenre = (string)attr.Value;
                            string[] gen = sGenre.Split(',');
                            newTitle.Genres.Clear();
                            foreach (string genre in gen)
                            {
                                string uGenre = genre.ToUpper().Trim();
                                if (String.IsNullOrEmpty(uGenre)) continue;
                                if (uGenre.StartsWith(@"MOVIE")) continue;
                                uGenre = genre.Trim();
                                newTitle.AddGenre(uGenre);
                            }
                        }
                        break;
                    case DvrmsMetadataEditor.Duration:
                        Int64 rTime = (long)attr.Value;
                        rTime = rTime / 600 / 1000000;
                        newTitle.Runtime = (int)rTime;
                        break;
                    case DvrmsMetadataEditor.ParentalRating:
                        if (!String.IsNullOrEmpty((string)attr.Value))
                        {
                            newTitle.ParentalRating = (string)attr.Value;
                        }
                        break;
                    case DvrmsMetadataEditor.Credits:
                        string persona = (string)attr.Value;
                        persona += @";;;;";
                        string[] credits = persona.Split(';');
                        string[] cast = credits[0].Split('/');
                        foreach (string nm in cast)
                        {
                            if (!String.IsNullOrEmpty(nm)) newTitle.AddActingRole(nm, "");
                        }
                        string[] dirs = credits[1].Split('/');
                        if (dirs.Length > 0)
                        {
                            if (!String.IsNullOrEmpty(dirs[0]))
                            {
                                string nm = dirs[0];
                                newTitle.AddDirector(new OMLSDKPerson(nm));
                            }
                        }

                        break;
                    case DvrmsMetadataEditor.SubtitleDescription:
                        newTitle.Synopsis = (string)attr.Value;
                        break;
                }
                attr = null;
            }

            if (ValidateTitle(newTitle))
            {
                try
                {
                    if (String.IsNullOrEmpty(newTitle.Name))
                    {
                        newTitle.Name = Path.GetFileNameWithoutExtension(file);
                        newTitle.ImporterSource = @"DVRMSImporter";
                        newTitle.MetadataSourceName = @"DVR-MS";
                        OMLSDKDisk disk = new OMLSDKDisk();
                        disk.Name = @"Disk 1";
                        disk.Path = file;
                        //newTitle.FileLocation = file;
                        string ext = Path.GetExtension(file).Substring(1).Replace(@"-", @"");
                        //newTitle.VideoFormat = (VideoFormat)Enum.Parse(typeof(VideoFormat), ext, true);
                        disk.Format = (OMLSDKVideoFormat)Enum.Parse(typeof(OMLSDKVideoFormat), ext, true);
                        newTitle.AddDisk(disk);
                        string cover = fPath + @"\" + Path.GetFileNameWithoutExtension(file) + @".jpg";
                        if (File.Exists(Path.GetFullPath(cover)))
                        {
                            SDKUtilities.DebugLine("[DVRMSPlugin] Setting CoverArt: " + Path.GetFullPath(cover));
                            newTitle.FrontCoverPath = cover;
                        }
                        else
                        {
                            SDKUtilities.DebugLine("[DVRMSPlugin] No coverart found");
                        }
                    }
                    if (String.IsNullOrEmpty(newTitle.AspectRatio))
                    {
                        newTitle.AspectRatio = @"Widescreen";
                    }
                    if (String.IsNullOrEmpty(newTitle.ParentalRating))
                    {
                        newTitle.ParentalRating = @"--";
                    }
                    AddTitle(newTitle);
                }
                catch (Exception e)
                {
                    Trace.WriteLine("[DVRMSPlugin] Error adding row: " + e.Message);
                }
            }
            else
            {
                Trace.WriteLine("[DVRMSPlugin] Error saving row");
            }
        }
Beispiel #31
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="title_to_validate"></param>
 /// <returns></returns>
 public bool ValidateTitle(OMLSDKTitle title_to_validate)
 {
     return(true);
 }
        public static OMLSDKTitle TitleFromAmazonItem(Item amazonItem)
        {
            try
            {
                OMLSDKTitle t = new OMLSDKTitle();

                t.Name = amazonItem.ItemAttributes.Title;
                if (!String.IsNullOrEmpty(amazonItem.ASIN.ToString())) t.UPC = amazonItem.ASIN.ToString();
                t.Synopsis = AmazonItemDescriptionToString(amazonItem);

                if (amazonItem.ItemAttributes.Actor != null)
                {
                    foreach (string actor in amazonItem.ItemAttributes.Actor)
                    {
                        t.AddActingRole(actor, "");
                    }
                }

                if (amazonItem.ItemAttributes.Director != null)
                {
                    foreach (string director in amazonItem.ItemAttributes.Director)
                    {
                        t.AddDirector(new OMLSDKPerson(director));
                    }
                }

                if (amazonItem.ItemAttributes.AudienceRating != null)
                    t.ParentalRating = AmazonRatingToString(amazonItem.ItemAttributes.AudienceRating);

                if (amazonItem.ItemAttributes.RunningTime != null)
                    t.Runtime = Convert.ToInt32(amazonItem.ItemAttributes.RunningTime.Value);

                if (amazonItem.ItemAttributes.TheatricalReleaseDate != null)
                    t.ReleaseDate = AmazonYearToDateTime(amazonItem.ItemAttributes.TheatricalReleaseDate);

                if (amazonItem.DetailPageURL != null)
                    t.OfficialWebsiteURL = amazonItem.DetailPageURL;

                if (amazonItem.ItemAttributes.Studio != null)
                    t.Studio = amazonItem.ItemAttributes.Studio;

                if (amazonItem.ItemAttributes.AspectRatio != null) t.AspectRatio = amazonItem.ItemAttributes.AspectRatio;

                // add only the genres that we have in our list otherwise we get too much crap
                if (amazonItem.Subjects != null)
                {
                    foreach (string subject in amazonItem.Subjects)
                    {
                        if (Properties.Settings.Default.Genres.Contains(subject))
                        {
                            t.AddGenre(subject);
                        }
                    }
                }

                if (amazonItem.LargeImage.URL != null)
                {
                    t.FrontCoverPath = amazonItem.LargeImage.URL;// title.ImageUrl;
                }

                //DownloadImage(t, amazonItem);

                return t;
            }
            catch
            {
                return null;
            }
        }
        public static Title ConvertOMLSDKTitleToTitle(OMLSDKTitle omlsdktitle)
        {
            Title _title = new Title();

            if (omlsdktitle != null)
            {
                _title.NameTrimmed = CopyString(omlsdktitle.Name);
                _title.OriginalNameTrimmed = CopyString(omlsdktitle.OriginalName);
                _title.SortNameTrimmed = CopyString(omlsdktitle.SortName);
                _title.Synopsis = CopyString(omlsdktitle.Synopsis);
                _title.ProductionYear = omlsdktitle.ProductionYear;
                _title.ReleaseDate = omlsdktitle.ReleaseDate;
                _title.DateAdded = omlsdktitle.DateAdded;
                _title.Runtime = omlsdktitle.Runtime;
                _title.StudioTrimmed = CopyString(omlsdktitle.Studio);
                _title.UPCTrimmed = CopyString(omlsdktitle.UPC);
                _title.WatchedCount = omlsdktitle.WatchedCount;
                _title.UserStarRating = omlsdktitle.UserStarRating;

                _title.EpisodeNumber = omlsdktitle.EpisodeNumber;
                _title.SeasonNumber = omlsdktitle.SeasonNumber;

                _title.AspectRatioTrimmed = CopyString(omlsdktitle.AspectRatio);
                _title.VideoDetails = CopyString(omlsdktitle.VideoDetails);
                _title.VideoResolutionTrimmed = CopyString(omlsdktitle.VideoResolution);
                _title.VideoStandardTrimmed = CopyString(omlsdktitle.VideoStandard);
                //_title.VideoFormat = (VideoFormat)Enum.Parse(typeof(VideoFormat), omlsdktitle.VideoFormat.ToString());

                _title.FrontCoverPath = CopyString(omlsdktitle.FrontCoverPath);
                _title.BackCoverPath = CopyString(omlsdktitle.BackCoverPath);

                _title.CountryOfOriginTrimmed = CopyString(omlsdktitle.CountryOfOrigin);

                _title.MetadataSourceIDTrimmed = CopyString(omlsdktitle.MetadataSourceID);
                _title.MetadataSourceNameTrimmed = CopyString(omlsdktitle.MetadataSourceName);
                _title.ImporterSourceTrimmed = CopyString(omlsdktitle.ImporterSource);

                _title.OfficialWebsiteURLTrimmed = CopyString(omlsdktitle.OfficialWebsiteURL);
                _title.ParentalRatingTrimmed = CopyString(omlsdktitle.ParentalRating);
                _title.ParentalRatingReasonTrimmed = CopyString(omlsdktitle.ParentalRatingReason);

                #region Disks
                foreach (OMLSDKDisk omlsdkdisk in omlsdktitle.Disks)
                {
                    Disk disk = new Disk();
                    disk.Name = omlsdkdisk.Name;
                    disk.Path = omlsdkdisk.Path;
                    disk.Format = (VideoFormat)Enum.Parse(typeof(VideoFormat), omlsdkdisk.Format.ToString());
                    disk.ExtraOptions = omlsdkdisk.ExtraOptions;
                    _title.AddDisk(disk);
                }
                #endregion

                #region Extra Features
                _title.ExtraFeatures = omlsdktitle.ExtraFeatures;
                #endregion

                #region Trailers
                foreach (string Trailer in omlsdktitle.Trailers)
                {
                    _title.AddTrailer(Trailer);
                }
                #endregion

                #region Genres
                if (omlsdktitle.Genres != null)
                {
                    foreach (string genre in omlsdktitle.Genres)
                    {
                        _title.AddGenre(genre);
                    }
                }
                #endregion

                #region Actring Roles
                if (omlsdktitle.ActingRoles != null)
                {
                    foreach (OMLSDKRole role in omlsdktitle.ActingRoles)
                    {
                        _title.AddActingRole(role.PersonName, role.RoleName);
                    }
                }
                #endregion

                #region Non Acting Roles
                if (omlsdktitle.NonActingRoles != null)
                {
                    foreach (OMLSDKRole role in omlsdktitle.NonActingRoles)
                    {
                        _title.AddNonActingRole(role.PersonName, role.RoleName);
                    }
                }
                #endregion

                #region Directors
                if (omlsdktitle.Directors != null)
                {
                    foreach (OMLSDKPerson person in omlsdktitle.Directors)
                    {
                        _title.AddDirector(ConvertOMLSDKPersonToPerson(person));
                    }
                }
                #endregion

                #region Writers
                if (omlsdktitle.Writers != null)
                {
                    foreach (OMLSDKPerson person in omlsdktitle.Writers)
                    {
                        _title.AddWriter(ConvertOMLSDKPersonToPerson(person));
                    }
                }
                #endregion

                #region Producers
                if (omlsdktitle.Producers != null)
                {
                    foreach (OMLSDKPerson person in omlsdktitle.Producers)
                    {
                        _title.AddProducer(ConvertOMLSDKPersonToPerson(person));
                    }
                }
                #endregion

                #region Tags
                if (omlsdktitle.Tags != null)
                {
                    foreach (string tag in omlsdktitle.Tags)
                    {
                        _title.AddTag(tag);
                    }
                }
                #endregion

                #region Audio Tracks
                if (omlsdktitle.AudioTracks != null)
                {
                    foreach (string track in omlsdktitle.AudioTracks)
                    {
                        _title.AddAudioTrack(track);
                    }
                }
                #endregion

                #region Subtitles
                if (omlsdktitle.Subtitles != null)
                {
                    foreach (string subtitles in omlsdktitle.Subtitles)
                    {
                        _title.AddSubtitle(subtitles);
                    }
                }
                #endregion

                #region Fanart Paths
                if (omlsdktitle.FanArtPaths != null)
                {
                    foreach (string path in omlsdktitle.FanArtPaths)
                    {
                        _title.AddFanArtImage(path);
                    }
                }
                #endregion
            }

            return _title;
        }
Beispiel #34
0
        public static Title ConvertOMLSDKTitleToTitle(OMLSDKTitle omlsdktitle)
        {
            Title _title = new Title();

            if (omlsdktitle != null)
            {
                _title.NameTrimmed         = CopyString(omlsdktitle.Name);
                _title.OriginalNameTrimmed = CopyString(omlsdktitle.OriginalName);
                _title.SortNameTrimmed     = CopyString(omlsdktitle.SortName);
                _title.Synopsis            = CopyString(omlsdktitle.Synopsis);
                _title.ProductionYear      = omlsdktitle.ProductionYear;
                _title.ReleaseDate         = omlsdktitle.ReleaseDate;
                _title.DateAdded           = omlsdktitle.DateAdded;
                _title.Runtime             = omlsdktitle.Runtime;
                _title.StudioTrimmed       = CopyString(omlsdktitle.Studio);
                _title.UPCTrimmed          = CopyString(omlsdktitle.UPC);
                _title.WatchedCount        = omlsdktitle.WatchedCount;
                _title.UserStarRating      = omlsdktitle.UserStarRating;

                _title.EpisodeNumber = omlsdktitle.EpisodeNumber;
                _title.SeasonNumber  = omlsdktitle.SeasonNumber;

                _title.AspectRatioTrimmed     = CopyString(omlsdktitle.AspectRatio);
                _title.VideoDetails           = CopyString(omlsdktitle.VideoDetails);
                _title.VideoResolutionTrimmed = CopyString(omlsdktitle.VideoResolution);
                _title.VideoStandardTrimmed   = CopyString(omlsdktitle.VideoStandard);
                //_title.VideoFormat = (VideoFormat)Enum.Parse(typeof(VideoFormat), omlsdktitle.VideoFormat.ToString());

                _title.FrontCoverPath = CopyString(omlsdktitle.FrontCoverPath);
                _title.BackCoverPath  = CopyString(omlsdktitle.BackCoverPath);

                _title.CountryOfOriginTrimmed = CopyString(omlsdktitle.CountryOfOrigin);

                _title.MetadataSourceIDTrimmed   = CopyString(omlsdktitle.MetadataSourceID);
                _title.MetadataSourceNameTrimmed = CopyString(omlsdktitle.MetadataSourceName);
                _title.ImporterSourceTrimmed     = CopyString(omlsdktitle.ImporterSource);

                _title.OfficialWebsiteURLTrimmed   = CopyString(omlsdktitle.OfficialWebsiteURL);
                _title.ParentalRatingTrimmed       = CopyString(omlsdktitle.ParentalRating);
                _title.ParentalRatingReasonTrimmed = CopyString(omlsdktitle.ParentalRatingReason);


                #region Disks
                foreach (OMLSDKDisk omlsdkdisk in omlsdktitle.Disks)
                {
                    Disk disk = new Disk();
                    disk.Name         = omlsdkdisk.Name;
                    disk.Path         = omlsdkdisk.Path;
                    disk.Format       = (VideoFormat)Enum.Parse(typeof(VideoFormat), omlsdkdisk.Format.ToString());
                    disk.ExtraOptions = omlsdkdisk.ExtraOptions;
                    _title.AddDisk(disk);
                }
                #endregion


                #region Extra Features
                _title.ExtraFeatures = omlsdktitle.ExtraFeatures;
                #endregion


                #region Trailers
                foreach (string Trailer in omlsdktitle.Trailers)
                {
                    _title.AddTrailer(Trailer);
                }
                #endregion


                #region Genres
                if (omlsdktitle.Genres != null)
                {
                    foreach (string genre in omlsdktitle.Genres)
                    {
                        _title.AddGenre(genre);
                    }
                }
                #endregion


                #region Actring Roles
                if (omlsdktitle.ActingRoles != null)
                {
                    foreach (OMLSDKRole role in omlsdktitle.ActingRoles)
                    {
                        _title.AddActingRole(role.PersonName, role.RoleName);
                    }
                }
                #endregion


                #region Non Acting Roles
                if (omlsdktitle.NonActingRoles != null)
                {
                    foreach (OMLSDKRole role in omlsdktitle.NonActingRoles)
                    {
                        _title.AddNonActingRole(role.PersonName, role.RoleName);
                    }
                }
                #endregion


                #region Directors
                if (omlsdktitle.Directors != null)
                {
                    foreach (OMLSDKPerson person in omlsdktitle.Directors)
                    {
                        _title.AddDirector(ConvertOMLSDKPersonToPerson(person));
                    }
                }
                #endregion


                #region Writers
                if (omlsdktitle.Writers != null)
                {
                    foreach (OMLSDKPerson person in omlsdktitle.Writers)
                    {
                        _title.AddWriter(ConvertOMLSDKPersonToPerson(person));
                    }
                }
                #endregion


                #region Producers
                if (omlsdktitle.Producers != null)
                {
                    foreach (OMLSDKPerson person in omlsdktitle.Producers)
                    {
                        _title.AddProducer(ConvertOMLSDKPersonToPerson(person));
                    }
                }
                #endregion


                #region Tags
                if (omlsdktitle.Tags != null)
                {
                    foreach (string tag in omlsdktitle.Tags)
                    {
                        _title.AddTag(tag);
                    }
                }
                #endregion


                #region Audio Tracks
                if (omlsdktitle.AudioTracks != null)
                {
                    foreach (string track in omlsdktitle.AudioTracks)
                    {
                        _title.AddAudioTrack(track);
                    }
                }
                #endregion


                #region Subtitles
                if (omlsdktitle.Subtitles != null)
                {
                    foreach (string subtitles in omlsdktitle.Subtitles)
                    {
                        _title.AddSubtitle(subtitles);
                    }
                }
                #endregion


                #region Fanart Paths
                if (omlsdktitle.FanArtPaths != null)
                {
                    foreach (string path in omlsdktitle.FanArtPaths)
                    {
                        _title.AddFanArtImage(path);
                    }
                }
                #endregion
            }

            return(_title);
        }