示例#1
0
        public static Artist ToArtist(JObject objRest, Artist objItem)
        {
            if (objRest != null)
            {
                JArray albums = (JArray)objRest["items"];
                foreach (JObject album in albums)
                {
                    if ((string)album["category"]["id"] == "Album")
                    {
                        ArtistCredits credits = new ArtistCredits();

                        credits.Title      = (string)album["name"];
                        credits.BuyLink    = (string)album["storeuri"];
                        credits.EntityType = EntityType.Music;

                        if (string.IsNullOrWhiteSpace(credits.Title) == false && string.IsNullOrWhiteSpace(objItem.FulleName) == false)
                        {
                            if (Dal.GetInstance.GetArtistCredit(credits.Title, objItem.FulleName) == null)
                            {
                                objItem.ArtistCredits.Add(credits);
                            }
                        }
                    }
                }
            }
            return(objItem);
        }
示例#2
0
        private static Artist ParseArtist(string artistName)
        {
            try
            {
                bool   isNew;
                Artist artist = ArtistServices.Get(artistName, out isNew);
                if (artist == null)
                {
                    artist = new Artist();
                }

                Uri      strUrl       = new Uri(string.Format(@"http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&api_key=7e1cb1060b6150e4fbb60e119250f54c&artist={0}&autocorrect=1", artistName));
                XElement restResponse = XElement.Parse(Util.GetRest(strUrl));

                LastFm objLastFm = LastFm.ArtistToObject(restResponse);

                artist.Bio       = objLastFm.ArtistContent;
                artist.FulleName = objLastFm.ArtistName;

                if (objLastFm.ArtistExtraLargeImage != null)
                {
                    artist.Picture = Util.GetImage(objLastFm.ArtistLargeImage);
                }

                artist.WebSite = objLastFm.ArtistUrl;

                strUrl       = new Uri(string.Format(@"http://ws.audioscrobbler.com/2.0/?method=artist.getTopAlbums&api_key=7e1cb1060b6150e4fbb60e119250f54c&mbid={0}&limit=500", objLastFm.ArtistId));
                restResponse = XElement.Parse(Util.GetRest(strUrl));
                IEnumerable <LastFm> credits = LastFm.AlbumToCollection(restResponse);

                if (credits != null && artist.ArtistCredits != null)
                {
                    foreach (LastFm item in credits)
                    {
                        if (artist.ArtistCredits.Any(x => x.Title.Trim().ToUpper() == item.AlbumName.Trim().ToUpper()) == false)
                        {
                            ArtistCredits artistcredit = new ArtistCredits();
                            artistcredit.ArtistId   = artist.Id;
                            artistcredit.BuyLink    = item.AlbumUrl;
                            artistcredit.Title      = item.AlbumName;
                            artistcredit.EntityType = EntityType.Music;

                            artist.ArtistCredits.Add(artistcredit);
                        }
                    }
                }
                return(artist);
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                return(null);
            }
        }
示例#3
0
        private void worker_DoWork_XML(object sender, DoWorkEventArgs e)
        {
            try
            {
                Total = _selectedItems.Length;

                foreach (XElement node in _selectedItems)
                {
                    //exit if the user cancels
                    if (_isCancelationPending == true)
                    {
                        return;
                    }

                    Movie movie = new Movie();
                    movie.Title         = Util.GetElementValue(node, "Title");
                    movie.OriginalTitle = Util.GetElementValue(node, "OriginalTitle");
                    movie.BarCode       = Util.GetElementValue(node, "BarCode");
                    movie.Comments      = Util.GetElementValue(node, "Comments");
                    movie.Description   = Util.GetElementValue(node, "Description");
                    movie.FileName      = Util.GetElementValue(node, "FileName");
                    movie.FilePath      = Util.GetElementValue(node, "FilePath");
                    movie.Country       = Util.GetElementValue(node, "Country");
                    movie.AlloCine      = Util.GetElementValue(node, "AlloCine");
                    movie.Imdb          = Util.GetElementValue(node, "Imdb");
                    movie.Tagline       = Util.GetElementValue(node, "Tagline");

                    DateTime dateValue;

                    if (DateTime.TryParse(Util.GetElementValue(node, "AddedDate"), out dateValue) == true)
                    {
                        movie.AddedDate = dateValue;
                    }

                    if (DateTime.TryParse(Util.GetElementValue(node, "ReleaseDate"), out dateValue) == true)
                    {
                        movie.ReleaseDate = dateValue;
                    }

                    #region Bool
                    bool boolValue;

                    if (bool.TryParse(Util.GetElementValue(node, "IsComplete"), out boolValue) == true)
                    {
                        movie.IsComplete = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsDeleted"), out boolValue) == true)
                    {
                        movie.IsDeleted = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "Seen"), out boolValue) == true)
                    {
                        movie.Watched = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsWhish"), out boolValue) == true)
                    {
                        movie.IsWhish = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "ToBeDeleted"), out boolValue) == true)
                    {
                        movie.ToBeDeleted = boolValue;
                    }
                    #endregion
                    #region Int
                    int intValue;

                    if (int.TryParse(Util.GetElementValue(node, "Rated"), out intValue) == true)
                    {
                        movie.Rated = intValue.ToString(CultureInfo.InvariantCulture);
                    }

                    if (int.TryParse(Util.GetElementValue(node, "Rating"), out intValue) == true)
                    {
                        movie.MyRating = intValue;
                    }

                    if (int.TryParse(Util.GetElementValue(node, "Runtime"), out intValue) == true)
                    {
                        movie.Runtime = intValue;
                    }
                    #endregion
                    #region Media
                    var query = from item in node.Descendants("Media")
                                select item;

                    XElement[] movieNode = query.ToArray();

                    foreach (XElement media in movieNode)
                    {
                        Media newMedia = MediaServices.Get(Util.GetElementValue(media, "Name"), true);
                        newMedia.Path = Util.GetElementValue(media, "Path");
                        movie.Media   = newMedia;
                    }
                    #endregion
                    #region AspectRatio
                    query = from item in node.Descendants("AspectRatio")
                            select item;

                    movieNode = query.ToArray();

                    foreach (XElement aspectRatio in movieNode)
                    {
                        movie.AspectRatio = MovieServices.GetAspectRatio(Util.GetElementValue(aspectRatio, "Name"));
                    }
                    #endregion
                    #region FileFormat
                    query = from item in node.Descendants("FileFormat")
                            select item;

                    movieNode = query.ToArray();

                    foreach (XElement format in movieNode)
                    {
                        movie.FileFormat = MovieServices.GetFormat(Util.GetElementValue(format, "Name"));
                    }
                    #endregion
                    #region Studio
                    query = from item in node.Descendants("Studio")
                            select item;

                    movieNode = query.ToArray();

                    foreach (XElement studio in movieNode)
                    {
                        bool isNew;
                        movie.Publisher = PublisherServices.GetPublisher(Util.GetElementValue(studio, "Name"), out isNew, "Movie_Studio");
                        if (isNew == true)
                        {
                            Dal.GetInstance.AddPublisher("Movie_Studio", movie.Publisher);
                        }
                    }
                    #endregion
                    #region Links
                    query = from item in node.Descendants("Link")
                            select item;

                    movieNode = query.ToArray();

                    foreach (XElement link in movieNode)
                    {
                        LinksServices.AddLinks(Util.GetElementValue(link, "Path"), movie, true);
                    }

                    #endregion
                    #region Types
                    query = from item in node.Descendants("Type")
                            select item;

                    movieNode = query.ToArray();

                    foreach (XElement type in movieNode)
                    {
                        MovieServices.AddTypes(Util.GetElementValue(type, "RealName"), movie);
                    }
                    #endregion
                    #region Image
                    query = from item in node.Descendants("Ressource")
                            select item;

                    movieNode = query.ToArray();

                    foreach (XElement images in movieNode)
                    {
                        if (Util.GetElementValue(images, "ResourcesType") == "Image")
                        {
                            bool   isDefault = bool.Parse(Util.GetElementValue(images, "IsDefault"));
                            byte[] cover     = Convert.FromBase64String(Util.GetElementValue(images, "Value"));

                            if (cover.Length > 0)
                            {
                                RessourcesServices.AddImage(cover, movie, isDefault);
                            }
                        }
                        if (Util.GetElementValue(images, "ResourcesType") == "Background")
                        {
                            byte[] cover = Convert.FromBase64String(Util.GetElementValue(images, "Value"));

                            if (cover.Length > 0)
                            {
                                RessourcesServices.AddBackground(cover, movie);
                            }
                        }
                    }
                    #endregion
                    #region Artist
                    query = from item in node.Descendants("Artist")
                            select item;

                    XElement[] artistNode = query.ToArray();

                    foreach (XElement artist in artistNode)
                    {
                        bool   isNew;
                        string fullname  = Util.GetElementValue(artist, "FulleName");
                        Artist newArtist = ArtistServices.Get(fullname, out isNew);

                        if (string.IsNullOrWhiteSpace(newArtist.Aka))
                        {
                            newArtist.Aka = Util.GetElementValue(artist, "Aka");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.Bio))
                        {
                            newArtist.Bio = Util.GetElementValue(artist, "Bio");
                        }

                        if (newArtist.BirthDay == null && DateTime.TryParse(Util.GetElementValue(artist, "BirthDay"), out dateValue) == true)
                        {
                            newArtist.BirthDay = dateValue;
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.Breast))
                        {
                            newArtist.Breast = Util.GetElementValue(artist, "Breast");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.Ethnicity))
                        {
                            newArtist.Ethnicity = Util.GetElementValue(artist, "Ethnicity");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.FirstName))
                        {
                            newArtist.FirstName = Util.GetElementValue(artist, "FirstName");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.LastName))
                        {
                            newArtist.LastName = Util.GetElementValue(artist, "LastName");
                        }

                        if (newArtist.Picture == null)
                        {
                            newArtist.Picture = Convert.FromBase64String(Util.GetElementValue(artist, "Picture"));
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.PlaceBirth))
                        {
                            newArtist.PlaceBirth = Util.GetElementValue(artist, "PlaceBirth");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.WebSite))
                        {
                            newArtist.WebSite = Util.GetElementValue(artist, "WebSite");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.YearsActive))
                        {
                            newArtist.YearsActive = Util.GetElementValue(artist, "YearsActive");
                        }

                        query = from item in artist.Descendants("Credit")
                                select item;

                        XElement[] creditsNode = query.ToArray();

                        foreach (XElement artistCredit in creditsNode)
                        {
                            ArtistCredits artistCredits = new ArtistCredits();

                            artistCredits.Title      = Util.GetElementValue(artistCredit, "Title");
                            artistCredits.BuyLink    = Util.GetElementValue(artistCredit, "BuyLink");
                            artistCredits.EntityType = EntityType.Movie;
                            artistCredits.Notes      = Util.GetElementValue(artistCredit, "Notes");

                            DateTime releaseDate;
                            if (DateTime.TryParse(Util.GetElementValue(artistCredit, "ReleaseDate"), out releaseDate) == true)
                            {
                                artistCredits.ReleaseDate = releaseDate;
                            }

                            if (string.IsNullOrWhiteSpace(artistCredits.Title) == false && string.IsNullOrWhiteSpace(newArtist.FulleName) == false)
                            {
                                if (Dal.GetInstance.GetArtistCredit(artistCredits.Title, newArtist.FulleName) == null)
                                {
                                    newArtist.ArtistCredits.Add(artistCredits);
                                }
                            }
                        }

                        ArtistServices.AddArtist(new[] { newArtist }, movie);
                    }


                    #endregion

                    Dal.GetInstance.AddMovie(movie);
                    _intAddedItem++;

                    Current++;
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }
        }
示例#4
0
        private static Hashtable Parse(string strUrl)
        {
            Hashtable objResults = new Hashtable();

            try
            {
                string strResults = Util.GetHtmlPage(strUrl, Encoding.Default, BrowserType.Firefox4);

                #region Image
                string strParsing = @"id=""headshot""";
                int    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"src=""";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"""";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (strTemp.StartsWith(@"http://"))
                    {
                        objResults.Add("Image", strTemp);
                    }
                    else
                    {
                        objResults.Add("Image", @"http://www.iafd.com" + strTemp);
                    }
                }
                #endregion
                #region Aka
                strParsing = @"Performer AKA";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Aka", strTemp);
                    }
                }
                #endregion
                #region Birthday
                strParsing = @"Birthday";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        strParsing = @">";
                        strTemp    = strTemp.Substring(strTemp.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"<";
                        intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                        if (intBegin > -1)
                        {
                            strTemp = strTemp.Substring(0, intBegin);

                            if (string.IsNullOrWhiteSpace(strTemp) == false)
                            {
                                DateTime birthday;
                                if (DateTime.TryParse(strTemp, out birthday) == true)
                                {
                                    objResults.Add("Birthday", birthday);
                                }
                            }
                        }
                    }
                }
                #endregion
                #region Astrology
                strParsing = @"Astrology";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        strParsing = @">";
                        strTemp    = strTemp.Substring(strTemp.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"<";
                        strTemp    = strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal));
                        objResults.Add("Astrology", strTemp);
                    }
                }
                #endregion
                #region Birthplace
                strParsing = @"Birthplace";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Birthplace", strTemp);
                    }
                }
                #endregion
                #region Years Active
                strParsing = @"Years Active";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("YearsActive", strTemp);
                    }
                }
                #endregion
                #region Ethnicity
                strParsing = @"Ethnicity";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Ethnicity", strTemp);
                    }
                }
                #endregion
                #region Nationality/Heritage
                strParsing = @"Nationality/Heritage";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Nationality/Heritage", strTemp);
                    }
                }
                #endregion
                #region Hair Color
                strParsing = @"Hair Color";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Hair Color", strTemp);
                    }
                }
                #endregion
                #region Measurements
                strParsing = @"Measurements";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Measurements", Util.BraConverter(strTemp.Split('-')[0]));
                    }
                }
                #endregion
                #region Height
                strParsing = @"Height";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Height", strTemp);
                    }
                }
                #endregion
                #region Weight
                strParsing = @"Weight";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Weight", strTemp);
                    }
                }
                #endregion
                #region Tattoos
                strParsing = @"Tattoos";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Tattoos", strTemp);
                    }
                }
                #endregion
                #region Piercings
                strParsing = @"Piercings";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Piercings", strTemp);
                    }
                }
                #endregion
                #region Comments
                strParsing = @"Comments";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<span";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "There are no comments for this performer.")
                    {
                        objResults.Add("Comments", Util.PurgeHtml(strTemp));
                    }
                }
                #endregion
                #region Website
                strParsing = @"Website";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<td>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp.Contains("No data") == false)
                    {
                        strParsing = @">";
                        strTemp    = strTemp.Substring(strTemp.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"<";
                        strTemp    = strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal));
                        objResults.Add("Website", strTemp);
                    }
                }
                #endregion
                #region Credits
                strParsing = @"id=""personal""";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"<tr";

                    string[] rows = Regex.Split(strResults, strParsing);

                    List <ArtistCredits> credits = new List <ArtistCredits>();
                    foreach (string row in rows)
                    {
                        if (row.StartsWith(" class="))
                        {
                            strParsing = "href=";
                            string temp = row.Substring(row.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                            strParsing = ">";
                            temp       = temp.Substring(temp.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                            strParsing = "<";
                            string title = temp.Substring(0, temp.IndexOf(strParsing, StringComparison.Ordinal));

                            strParsing = "<i>";
                            string notes = string.Empty;
                            int    index = temp.IndexOf(strParsing, StringComparison.Ordinal);
                            if (index > -1)
                            {
                                temp       = temp.Substring(index + strParsing.Length);
                                strParsing = "</i>";
                                notes      = temp.Substring(0, temp.IndexOf(strParsing, StringComparison.Ordinal));
                            }

                            strParsing = "<td>";
                            temp       = temp.Substring(temp.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                            strParsing = "</td>";
                            string year = temp.Substring(0, temp.IndexOf(strParsing, StringComparison.Ordinal));

                            strParsing = @"href=""/reviewpage";
                            index      = temp.IndexOf(strParsing, StringComparison.Ordinal);
                            if (index > -1)
                            {
                                temp = temp.Substring(index + strParsing.Length);
                            }

                            strParsing = @"href=""";
                            index      = temp.IndexOf(strParsing, StringComparison.Ordinal);

                            string buyLink = string.Empty;

                            if (index > -1)
                            {
                                temp       = temp.Substring(index + strParsing.Length);
                                strParsing = @"""";
                                buyLink    = temp.Substring(0, temp.IndexOf(strParsing, StringComparison.Ordinal));
                            }

                            ArtistCredits movie = new ArtistCredits();
                            movie.Title = title;

                            if (string.IsNullOrWhiteSpace(notes) == false)
                            {
                                movie.Notes = notes;
                            }

                            movie.EntityType = EntityType.XXX;

                            int relaeseDate;
                            if (int.TryParse(year, out relaeseDate) == true)
                            {
                                movie.ReleaseDate = new DateTime(relaeseDate, 1, 1);
                            }

                            if (string.IsNullOrWhiteSpace(buyLink) == false)
                            {
                                movie.BuyLink = @"http://www.iafd.com" + buyLink;
                            }

                            credits.Add(movie);
                        }
                    }

                    objResults.Add("Credits", credits);
                }
                #endregion

                return(objResults);
            }
            catch (Exception ex)
            {
                Util.LogException(ex, strUrl);
                return(null);
            }
        }
示例#5
0
        private void worker_DoWork_XML(object sender, DoWorkEventArgs e)
        {
            try
            {
                Total = _selectedNodes.Length;

                foreach (XElement node in _selectedNodes)
                {
                    //exit if the user cancels
                    if (_isCancelationPending == true)
                    {
                        return;
                    }

                    Music music = new Music();
                    music.Title    = Util.GetElementValue(node, "Title");
                    music.Album    = Util.GetElementValue(node, "Album");
                    music.BarCode  = Util.GetElementValue(node, "BarCode");
                    music.Comments = Util.GetElementValue(node, "Comments");
                    music.FileName = Util.GetElementValue(node, "FileName");
                    music.FilePath = Util.GetElementValue(node, "FilePath");

                    #region DateTime
                    DateTime dateValue;

                    if (DateTime.TryParse(Util.GetElementValue(node, "AddedDate"), out dateValue) == true)
                    {
                        music.AddedDate = dateValue;
                    }

                    if (DateTime.TryParse(Util.GetElementValue(node, "ReleaseDate"), out dateValue) == true)
                    {
                        music.ReleaseDate = dateValue;
                    }
                    #endregion
                    #region Bool
                    bool boolValue;

                    if (bool.TryParse(Util.GetElementValue(node, "IsComplete"), out boolValue) == true)
                    {
                        music.IsComplete = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsDeleted"), out boolValue) == true)
                    {
                        music.IsDeleted = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsHear"), out boolValue) == true)
                    {
                        music.Watched = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsWhish"), out boolValue) == true)
                    {
                        music.IsWhish = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "ToBeDeleted"), out boolValue) == true)
                    {
                        music.ToBeDeleted = boolValue;
                    }
                    #endregion
                    #region int
                    int intValue;

                    if (int.TryParse(Util.GetElementValue(node, "BitRate"), out intValue) == true)
                    {
                        music.BitRate = intValue;
                    }

                    if (int.TryParse(Util.GetElementValue(node, "Length"), out intValue) == true)
                    {
                        music.Runtime = intValue;
                    }

                    if (int.TryParse(Util.GetElementValue(node, "Rating"), out intValue) == true)
                    {
                        music.MyRating = intValue;
                    }
                    #endregion
                    #region Media
                    var query = from item in node.Descendants("Media")
                                select item;

                    XElement[] musicNode = query.ToArray();

                    foreach (XElement media in musicNode)
                    {
                        Media newMedia = MediaServices.Get(Util.GetElementValue(media, "Name"), true);
                        newMedia.Path = Util.GetElementValue(media, "Path");
                        music.Media   = newMedia;
                    }
                    #endregion
                    #region Studio
                    query = from item in node.Descendants("Studio")
                            select item;

                    musicNode = query.ToArray();

                    foreach (XElement editor in musicNode)
                    {
                        bool isNew;
                        music.Publisher = PublisherServices.GetPublisher(Util.GetElementValue(editor, "Name"), out isNew, "Music_Studio");
                        if (isNew == true)
                        {
                            Dal.GetInstance.AddPublisher("Music_Studio", music.Publisher);
                        }
                    }
                    #endregion
                    #region Track
                    query = from item in node.Descendants("Track")
                            select item;

                    musicNode = query.ToArray();

                    foreach (XElement track in musicNode)
                    {
                        MusicServices.AddTracks(new [] { Util.GetElementValue(track, "Title") }, music);
                    }
                    #endregion
                    #region Links
                    query = from item in node.Descendants("Link")
                            select item;

                    musicNode = query.ToArray();

                    foreach (XElement link in musicNode)
                    {
                        LinksServices.AddLinks(Util.GetElementValue(link, "Path"), music, true);
                    }

                    #endregion
                    #region Types
                    query = from item in node.Descendants("Type")
                            select item;

                    musicNode = query.ToArray();

                    foreach (XElement type in musicNode)
                    {
                        GenreServices.AddGenres(new[] { Util.GetElementValue(type, "RealName") }, music, true);
                    }
                    #endregion
                    #region Image
                    query = from item in node.Descendants("Ressource")
                            select item;

                    musicNode = query.ToArray();

                    foreach (XElement images in musicNode)
                    {
                        if (Util.GetElementValue(images, "ResourcesType") == "Image")
                        {
                            bool   isDefault = bool.Parse(Util.GetElementValue(images, "IsDefault"));
                            byte[] cover     = Convert.FromBase64String(Util.GetElementValue(images, "Value"));

                            if (cover.Length > 0)
                            {
                                RessourcesServices.AddImage(cover, music, isDefault);
                            }
                        }
                        if (Util.GetElementValue(images, "ResourcesType") == "Background")
                        {
                            byte[] cover = Convert.FromBase64String(Util.GetElementValue(images, "Value"));

                            if (cover.Length > 0)
                            {
                                RessourcesServices.AddBackground(cover, music);
                            }
                        }
                    }
                    #endregion
                    #region Artist
                    query = from item in node.Descendants("Artist")
                            select item;

                    XElement[] artistNode = query.ToArray();

                    foreach (XElement artist in artistNode)
                    {
                        bool   isNew;
                        string fullname  = Util.GetElementValue(artist, "FulleName");
                        Artist newArtist = ArtistServices.Get(fullname, out isNew);

                        if (string.IsNullOrWhiteSpace(newArtist.Aka))
                        {
                            newArtist.Aka = Util.GetElementValue(artist, "Aka");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.Bio))
                        {
                            newArtist.Bio = Util.GetElementValue(artist, "Bio");
                        }

                        if (newArtist.BirthDay == null && DateTime.TryParse(Util.GetElementValue(artist, "BirthDay"), out dateValue) == true)
                        {
                            newArtist.BirthDay = dateValue;
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.Breast))
                        {
                            newArtist.Breast = Util.GetElementValue(artist, "Breast");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.Ethnicity))
                        {
                            newArtist.Ethnicity = Util.GetElementValue(artist, "Ethnicity");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.FirstName))
                        {
                            newArtist.FirstName = Util.GetElementValue(artist, "FirstName");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.LastName))
                        {
                            newArtist.LastName = Util.GetElementValue(artist, "LastName");
                        }

                        if (newArtist.Picture == null)
                        {
                            newArtist.Picture = Convert.FromBase64String(Util.GetElementValue(artist, "Picture"));
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.PlaceBirth))
                        {
                            newArtist.PlaceBirth = Util.GetElementValue(artist, "PlaceBirth");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.WebSite))
                        {
                            newArtist.WebSite = Util.GetElementValue(artist, "WebSite");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.YearsActive))
                        {
                            newArtist.YearsActive = Util.GetElementValue(artist, "YearsActive");
                        }

                        query = from item in artist.Descendants("Credit")
                                select item;

                        XElement[] creditsNode = query.ToArray();

                        foreach (XElement artistCredit in creditsNode)
                        {
                            ArtistCredits artistCredits = new ArtistCredits();

                            artistCredits.Title      = Util.GetElementValue(artistCredit, "Title");
                            artistCredits.BuyLink    = Util.GetElementValue(artistCredit, "BuyLink");
                            artistCredits.EntityType = EntityType.Movie;
                            artistCredits.Notes      = Util.GetElementValue(artistCredit, "Notes");

                            DateTime releaseDate;
                            if (DateTime.TryParse(Util.GetElementValue(artistCredit, "ReleaseDate"), out releaseDate) == true)
                            {
                                artistCredits.ReleaseDate = releaseDate;
                            }

                            if (string.IsNullOrWhiteSpace(artistCredits.Title) == false && string.IsNullOrWhiteSpace(newArtist.FulleName) == false)
                            {
                                if (Dal.GetInstance.GetArtistCredit(artistCredits.Title, newArtist.FulleName) == null)
                                {
                                    newArtist.ArtistCredits.Add(artistCredits);
                                }
                            }
                        }

                        ArtistServices.SaveArtist(newArtist, music);
                    }

                    #endregion

                    Dal.GetInstance.AddMusic(music);
                    _intAddedItem++;

                    Current++;
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }
        }
示例#6
0
        public static void GetInfoFromWeb(Artist objItem, bool usePartialMatch, Provider provider, out string errorMessage, bool log)
        {
            errorMessage = String.Empty;
            //Fix 2.6.7.0
            if (objItem != null)
            {
                errorMessage = String.Empty;
                string    strSearch  = (objItem.FirstName + " " + objItem.LastName).Trim();
                Hashtable objResults = null;
                Artist    results    = null;

                if (log == true)
                {
                    Task.Factory.StartNew(() => Util.NotifyEvent("getInfoFromWeb:Artist " + provider + " " + strSearch));
                }

                try
                {
                    switch (provider)
                    {
                    case Provider.Bing:
                        objResults = BingServices.SearchPortrait(strSearch, usePartialMatch);
                        break;

                    case Provider.Iafd:
                        objResults = IafdServices.SearchPortrait(strSearch, usePartialMatch);
                        break;

                    case Provider.Tmdb:
                        results = TheMovieDbServices.SearchPortrait(strSearch, usePartialMatch, LanguageType.EN);
                        break;

                    case Provider.AlloCine:
                        results = AlloCineServices.SearchPortrait(strSearch, usePartialMatch, LanguageType.FR);
                        break;

                    case Provider.AduldtDvdEmpire:
                        objResults = AdultdvdempireServices.SearchPortrait(strSearch, usePartialMatch);
                        break;
                    }
                    if (objResults != null)
                    {
                        Fill(objResults, objItem, strSearch);
                    }

                    #region Artist

                    if (results != null)
                    {
                        if (results.Picture != null)
                        {
                            if (objItem.Picture == null || objItem.Picture.Length < results.Picture.Length)
                            {
                                objItem.Picture = results.Picture;
                            }
                        }

                        //FIX 2.8.0.0
                        if (results.ArtistCredits != null)
                        {
                            if (objItem.ArtistCredits == null)
                            {
                                objItem.ArtistCredits = new List <ArtistCredits>();
                            }

                            for (int i = 0; i < results.ArtistCredits.Count; i++)
                            {
                                ArtistCredits item = results.ArtistCredits.ElementAt(i);
                                if (
                                    objItem.ArtistCredits.Any(
                                        x => x.Title.ToUpperInvariant() == item.Title.ToUpperInvariant()) == false)
                                {
                                    objItem.ArtistCredits.Add(item);
                                }
                            }
                        }

                        if (results.BirthDay != null)
                        {
                            objItem.BirthDay = results.BirthDay;
                        }

                        if (String.IsNullOrWhiteSpace(results.Bio) == false)
                        {
                            objItem.Bio = results.Bio;
                        }

                        if (String.IsNullOrWhiteSpace(results.Breast) == false)
                        {
                            objItem.Breast = results.Breast;
                        }

                        if (String.IsNullOrWhiteSpace(results.Ethnicity) == false)
                        {
                            objItem.Ethnicity = results.Ethnicity;
                        }

                        objItem.FulleName = strSearch;

                        if (String.IsNullOrWhiteSpace(results.PlaceBirth) == false)
                        {
                            objItem.PlaceBirth = results.PlaceBirth;
                        }

                        if (String.IsNullOrWhiteSpace(results.WebSite) == false)
                        {
                            objItem.WebSite = results.WebSite;
                        }

                        if (String.IsNullOrWhiteSpace(results.YearsActive) == false)
                        {
                            objItem.YearsActive = results.YearsActive;
                        }
                    }

                    #endregion
                }
                catch (Exception ex)
                {
                    Util.LogException(ex);
                }
            }
        }
示例#7
0
        public static Artist CastToArtist(JObject objRest)
        {
            if (objRest == null)
            {
                return(null);
            }

            Artist objItem = new Artist();

            #region Name
            //Fix Since 2.6.7.0
            if (objRest["person"]["name"]["given"] != null)
            {
                objItem.FirstName = (string)objRest["person"]["name"]["given"];
            }

            objItem.LastName = (string)objRest["person"]["name"]["family"];

            objItem.FulleName = (objItem.FirstName + " " + objItem.LastName).Trim();
            #endregion
            #region Sex
            string sex = (string)objRest["person"]["gender"];
            if (sex == "1")
            {
                objItem.Sex = false;
            }
            else
            {
                objItem.Sex = true;
            }
            #endregion
            #region Birthday
            DateTime date;
            if (DateTime.TryParse((string)objRest["person"]["birthDate"], out date) == true)
            {
                objItem.BirthDay = date;
            }
            #endregion
            #region Picture
            if (objRest["person"]["picture"] != null)
            {
                objItem.Picture = Util.GetImage((string)objRest["person"]["picture"]["href"]);
            }
            #endregion
            #region Credits

            JArray credits = (JArray)objRest["person"]["participation"];

            //FIX 2.9.0.0
            if (credits != null)
            {
                Parallel.ForEach(credits, item =>
                {
                    if (item["movie"] != null)
                    {
                        ArtistCredits movie = new ArtistCredits();

                        movie.Title = (string)item["movie"]["title"];

                        if (string.IsNullOrWhiteSpace(movie.Title) == false)
                        {
                            //FIX 2.9.0.0
                            string code = (string)item["movie"]["code"];
                            if (string.IsNullOrWhiteSpace(code) == false)
                            {
                                movie.BuyLink =
                                    string.Format(@"http://www.allocine.fr/film/fichefilm_gen_cfilm={0}.html", code);
                            }

                            movie.EntityType = EntityType.Movie;
                            movie.Notes      = (string)item["movie"]["role"];
                            DateTime dateTime;
                            if (item["movie"]["release"] != null)
                            {
                                if (DateTime.TryParse((string)item["movie"]["release"]["releaseDate"], out dateTime) ==
                                    true)
                                {
                                    movie.ReleaseDate = dateTime;
                                }
                            }

                            if (objItem.ArtistCredits == null)
                            {
                                objItem.ArtistCredits = new List <ArtistCredits>();
                            }

                            movie.Title = movie.Title.Replace(@"""", " ");

                            if (Dal.GetInstance.GetArtistCredit(movie.Title, objItem.FulleName) == null)
                            {
                                objItem.ArtistCredits.Add(movie);
                            }
                        }
                    }
                });
            }

            #endregion
            #region Bio
            objItem.Bio = (string)objRest["person"]["biographyShort"];
            #endregion
            #region PlaceBirth
            objItem.PlaceBirth = (string)objRest["person"]["birthPlace"];
            #endregion

            return(objItem);
        }
示例#8
0
        public static Artist CastToArtist(XElement objRest)
        {
            if (objRest == null)
            {
                return(null);
            }

            XElement objTemp = objRest;
            Artist   objItem = new Artist();

            #region Name
            string firstName = Util.GetAttributValue(objTemp, @"{http://www.allocine.net/v6/ns/}name", "given");
            string lastName  = Util.GetAttributValue(objTemp, @"{http://www.allocine.net/v6/ns/}name", "family");

            objItem.FirstName = firstName;
            objItem.LastName  = lastName;

            objItem.FulleName = objItem.FirstName + " " + objItem.LastName;
            #endregion
            #region Sex
            string sex = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}gender");
            if (sex == "1")
            {
                objItem.Sex = false;
            }
            else
            {
                objItem.Sex = true;
            }
            #endregion
            #region Birthday
            DateTime objDate;
            if (DateTime.TryParse(Util.GetElementValue(objTemp, @"{http://www.allocine.net/v6/ns/}birthDate"), out objDate))
            {
                objItem.BirthDay = objDate;
            }
            #endregion
            #region Picture
            objItem.Picture = Util.GetImage(Util.GetAttributValue(objTemp, @"{http://www.allocine.net/v6/ns/}picture", "href"));
            #endregion
            #region Credits
            var creditsquery = from item in objTemp.Descendants(@"{http://www.allocine.net/v6/ns/}participation")
                               select item;

            XElement[] credits = creditsquery.ToArray();
            foreach (XElement item in credits)
            {
                ArtistCredits movie = new ArtistCredits();

                movie.Title = Util.GetElementValue(item, @"{http://www.allocine.net/v6/ns/}movie", @"{http://www.allocine.net/v6/ns/}title");

                if (string.IsNullOrWhiteSpace(movie.Title) == false)
                {
                    movie.BuyLink    = string.Format(@"http://www.allocine.fr/film/fichefilm_gen_cfilm={0}.html", Util.GetAttributValue(item, @"{http://www.allocine.net/v6/ns/}movie", "code"));
                    movie.EntityType = EntityType.Movie;
                    movie.Notes      = Util.GetElementValue(item, @"{http://www.allocine.net/v6/ns/}role");

                    var query = from dates in item.Descendants("{http://www.allocine.net/v6/ns/}movie").Elements()
                                where dates.Name.LocalName == "release"
                                select dates;

                    XElement[] releaseTab = query.ToArray();
                    if (releaseTab.Any())
                    {
                        string   date = Util.GetElementValue(releaseTab[0], @"{http://www.allocine.net/v6/ns/}releaseDate");
                        DateTime releaseDate;
                        if (DateTime.TryParse(date, CultureInfo.CreateSpecificCulture("fr-FR"), DateTimeStyles.None, out releaseDate) == true)
                        {
                            movie.ReleaseDate = releaseDate;
                        }
                    }

                    movie.Title = movie.Title.Replace(@"""", " ");

                    if (Dal.GetInstance.GetArtistCredit(movie.Title, objItem.FulleName) == null)
                    {
                        objItem.ArtistCredits.Add(movie);
                    }
                }
            }
            #endregion
            #region Bio
            objItem.Bio = Util.GetElementValue(objTemp, @"{http://www.allocine.net/v6/ns/}biography");
            #endregion
            #region PlaceBirth
            objItem.PlaceBirth = Util.GetElementValue(objTemp, @"{http://www.allocine.net/v6/ns/}birthPlace");
            #endregion

            return(objItem);
        }
示例#9
0
        private void worker_DoWork_XML(object sender, DoWorkEventArgs e)
        {
            try
            {
                Total = _selectedItems.Length;

                foreach (XElement node in _selectedItems)
                {
                    //exit if the user cancels
                    if (_isCancelationPending == true)
                    {
                        return;
                    }

                    Books books = new Books();
                    books.Title       = Util.GetElementValue(node, "Title");
                    books.BarCode     = Util.GetElementValue(node, "BarCode");
                    books.Comments    = Util.GetElementValue(node, "Comments");
                    books.Description = Util.GetElementValue(node, "Description");
                    books.FileName    = Util.GetElementValue(node, "FileName");
                    books.FilePath    = Util.GetElementValue(node, "FilePath");
                    books.Isbn        = Util.GetElementValue(node, "ISBN");

                    #region DateTime
                    DateTime dateValue;

                    if (DateTime.TryParse(Util.GetElementValue(node, "AddedDate"), out dateValue) == true)
                    {
                        books.AddedDate = dateValue;
                    }

                    if (DateTime.TryParse(Util.GetElementValue(node, "ReleaseDate"), out dateValue) == true)
                    {
                        books.ReleaseDate = dateValue;
                    }
                    #endregion
                    #region Bool
                    bool boolValue;

                    if (bool.TryParse(Util.GetElementValue(node, "IsComplete"), out boolValue) == true)
                    {
                        books.IsComplete = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsDeleted"), out boolValue) == true)
                    {
                        books.IsDeleted = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsRead"), out boolValue) == true)
                    {
                        books.Watched = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "IsWhish"), out boolValue) == true)
                    {
                        books.IsWhish = boolValue;
                    }

                    if (bool.TryParse(Util.GetElementValue(node, "ToBeDeleted"), out boolValue) == true)
                    {
                        books.ToBeDeleted = boolValue;
                    }
                    #endregion
                    #region Long
                    int longValue;

                    if (int.TryParse(Util.GetElementValue(node, "NbrPages"), out longValue) == true)
                    {
                        books.NbrPages = longValue;
                    }

                    if (int.TryParse(Util.GetElementValue(node, "Rated"), out longValue) == true)
                    {
                        books.Rated = longValue.ToString(CultureInfo.InvariantCulture);
                    }

                    if (int.TryParse(Util.GetElementValue(node, "Rating"), out longValue) == true)
                    {
                        books.MyRating = longValue;
                    }
                    #endregion
                    #region Media
                    var query = from item in node.Descendants("Media")
                                select item;

                    XElement[] bookNode = query.ToArray();

                    foreach (XElement media in bookNode)
                    {
                        Media newMedia = MediaServices.Get(Util.GetElementValue(media, "Name"), true);
                        newMedia.Path = Util.GetElementValue(media, "Path");
                        books.Media   = newMedia;
                    }
                    #endregion
                    #region Format
                    query = from item in node.Descendants("Format")
                            select item;

                    bookNode = query.ToArray();

                    foreach (XElement format in bookNode)
                    {
                        books.FileFormat = BookServices.GetFormat(Util.GetElementValue(format, "Name"), true);
                    }
                    #endregion
                    #region Artist
                    query = from item in node.Descendants("Artist")
                            select item;

                    XElement[] artistNode = query.ToArray();

                    Job objJob = ArtistServices.GetJob("Author");
                    foreach (XElement artist in artistNode)
                    {
                        bool   isNew;
                        string fullname  = Util.GetElementValue(artist, "FulleName");
                        Artist newArtist = ArtistServices.Get(fullname, out isNew);

                        if (string.IsNullOrWhiteSpace(newArtist.Aka))
                        {
                            newArtist.Aka = Util.GetElementValue(artist, "Aka");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.Bio))
                        {
                            newArtist.Bio = Util.GetElementValue(artist, "Bio");
                        }

                        if (newArtist.BirthDay == null && DateTime.TryParse(Util.GetElementValue(artist, "BirthDay"), out dateValue) == true)
                        {
                            newArtist.BirthDay = dateValue;
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.Breast))
                        {
                            newArtist.Breast = Util.GetElementValue(artist, "Breast");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.Ethnicity))
                        {
                            newArtist.Ethnicity = Util.GetElementValue(artist, "Ethnicity");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.FirstName))
                        {
                            newArtist.FirstName = Util.GetElementValue(artist, "FirstName");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.LastName))
                        {
                            newArtist.LastName = Util.GetElementValue(artist, "LastName");
                        }

                        if (newArtist.Picture == null)
                        {
                            newArtist.Picture = Convert.FromBase64String(Util.GetElementValue(artist, "Picture"));
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.PlaceBirth))
                        {
                            newArtist.PlaceBirth = Util.GetElementValue(artist, "PlaceBirth");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.WebSite))
                        {
                            newArtist.WebSite = Util.GetElementValue(artist, "WebSite");
                        }

                        if (string.IsNullOrWhiteSpace(newArtist.YearsActive))
                        {
                            newArtist.YearsActive = Util.GetElementValue(artist, "YearsActive");
                        }

                        query = from item in artist.Descendants("Credit")
                                select item;

                        XElement[] creditsNode = query.ToArray();

                        foreach (XElement artistCredit in creditsNode)
                        {
                            ArtistCredits artistCredits = new ArtistCredits();

                            artistCredits.Title      = Util.GetElementValue(artistCredit, "Title");
                            artistCredits.BuyLink    = Util.GetElementValue(artistCredit, "BuyLink");
                            artistCredits.EntityType = EntityType.Movie;
                            artistCredits.Notes      = Util.GetElementValue(artistCredit, "Notes");

                            DateTime releaseDate;
                            if (DateTime.TryParse(Util.GetElementValue(artistCredit, "ReleaseDate"), out releaseDate) == true)
                            {
                                artistCredits.ReleaseDate = releaseDate;
                            }

                            if (string.IsNullOrWhiteSpace(artistCredits.Title) == false && string.IsNullOrWhiteSpace(newArtist.FulleName) == false)
                            {
                                if (Dal.GetInstance.GetArtistCredit(artistCredits.Title, newArtist.FulleName) == null)
                                {
                                    newArtist.ArtistCredits.Add(artistCredits);
                                }
                            }
                        }
                        newArtist.Job = objJob;
                        books.Artists.Add(newArtist);
                        if (isNew == true)
                        {
                            Dal.GetInstance.AddArtist(newArtist, books);
                        }
                    }


                    #endregion
                    #region Editor
                    query = from item in node.Descendants("Editor")
                            select item;

                    bookNode = query.ToArray();

                    foreach (XElement editor in bookNode)
                    {
                        bool isNew;
                        books.Publisher = PublisherServices.GetPublisher(Util.GetElementValue(editor, "Name"), out isNew, "App_Editor");
                        if (isNew == true)
                        {
                            Dal.GetInstance.AddPublisher("App_Editor", books.Publisher);
                        }
                    }
                    #endregion
                    #region Language
                    query = from item in node.Descendants("Language")
                            select item;

                    bookNode = query.ToArray();

                    foreach (XElement languages in bookNode)
                    {
                        books.Language = LanguageServices.GetLanguage(Util.GetElementValue(languages, "DisplayName"), true);
                    }
                    #endregion
                    #region Links
                    query = from item in node.Descendants("Link")
                            select item;

                    bookNode = query.ToArray();

                    foreach (XElement link in bookNode)
                    {
                        LinksServices.AddLinks(Util.GetElementValue(link, "Path"), books, true);
                    }

                    #endregion
                    #region Types
                    query = from item in node.Descendants("Type")
                            select item;

                    bookNode = query.ToArray();

                    foreach (XElement type in bookNode)
                    {
                        GenreServices.AddGenre(Util.GetElementValue(type, "RealName"), books, true);
                    }
                    #endregion
                    #region Image
                    query = from item in node.Descendants("Ressource")
                            select item;

                    bookNode = query.ToArray();

                    foreach (XElement images in bookNode)
                    {
                        if (Util.GetElementValue(images, "ResourcesType") == "Image")
                        {
                            bool   isDefault = bool.Parse(Util.GetElementValue(images, "IsDefault"));
                            byte[] cover     = Convert.FromBase64String(Util.GetElementValue(images, "Value"));

                            if (cover.Length > 0)
                            {
                                RessourcesServices.AddImage(cover, books, isDefault);
                            }
                        }
                        if (Util.GetElementValue(images, "ResourcesType") == "Background")
                        {
                            byte[] cover = Convert.FromBase64String(Util.GetElementValue(images, "Value"));

                            if (cover.Length > 0)
                            {
                                RessourcesServices.AddBackground(cover, books);
                            }
                        }
                    }
                    #endregion

                    Dal.GetInstance.AddBook(books);
                    _intAddedItem++;

                    Current++;
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }
        }
示例#10
0
        private static void GetArtistCredits(Artist artist, AmazonIndex index, AmazonCountry country, int pageIndex)
        {
            ItemSearch        itemsearch = new ItemSearch();
            ItemSearchRequest request    = new ItemSearchRequest();

            request.SearchIndex = index.ToString();
            request.ItemPage    = pageIndex.ToString(CultureInfo.InvariantCulture);
            EntityType entityType = EntityType.Music;

            switch (index)
            {
            case AmazonIndex.Books:
                request.Author = artist.FulleName;
                entityType     = EntityType.Books;
                break;

            case AmazonIndex.Music:
                request.Artist = artist.FulleName;
                entityType     = EntityType.Music;
                break;
            }

            request.ResponseGroup     = new [] { "Small" };
            itemsearch.Request        = new [] { request };
            itemsearch.AWSAccessKeyId = Aws1;
            itemsearch.AssociateTag   = AssociateTag;

            AWSECommerceServicePortTypeClient client =
                new AWSECommerceServicePortTypeClient(
                    new BasicHttpBinding("AWSECommerceServiceBinding"),
                    new EndpointAddress(string.Format("https://webservices.amazon.{0}/onca/soap?Service=AWSECommerceService", country.ToString())));

            // add authentication to the ECS client
            client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(Aws1, Aws2));
            try
            {
                ItemSearchResponse response = client.ItemSearch(itemsearch);
                if (response.Items.GetLength(0) > 0)
                {
                    if (response.Items[0].Item != null)
                    {
                        foreach (Item item in response.Items[0].Item)
                        {
                            if (artist.ArtistCredits.Any(c => c.Title.ToUpperInvariant() == item.ItemAttributes.Title.ToUpperInvariant()) == false)
                            {
                                ArtistCredits credit = new ArtistCredits();
                                credit.Title = item.ItemAttributes.Title;
                                #region Released
                                if (string.IsNullOrWhiteSpace(item.ItemAttributes.ReleaseDate) == false)
                                {
                                    DateTime date;
                                    if (DateTime.TryParse(item.ItemAttributes.ReleaseDate, out date) == true)
                                    {
                                        credit.ReleaseDate = date;
                                    }
                                }
                                else if (string.IsNullOrWhiteSpace(item.ItemAttributes.PublicationDate) == false)
                                {
                                    DateTime date;
                                    if (DateTime.TryParse(item.ItemAttributes.PublicationDate, out date) == true)
                                    {
                                        credit.ReleaseDate = date;
                                    }
                                }
                                #endregion
                                credit.EntityType = entityType;
                                // credit.BuyLink = item.DetailPageURL;

                                //  credit.BuyLink = string.Format(@"http://www.amazon.{0}/gp/aws/cart/add.html?ASIN.1={1}&AWSAccessKeyId={2}&AssociateTag={3}",
                                //                              country.ToString(), item.ASIN, Aws1,AssociateTag);

                                credit.BuyLink = string.Format(@"http://www.amazon.{0}/exec/obidos/ASIN/{1}/{2}/", country, item.ASIN, AssociateTag);

                                #region Description
                                if (item.EditorialReviews != null)
                                {
                                    string description = string.Empty;
                                    foreach (EditorialReview edito in item.EditorialReviews)
                                    {
                                        if (edito.Content.Length > description.Length && edito.IsLinkSuppressed == false)
                                        {
                                            description = edito.Content;
                                            break;
                                        }
                                    }
                                    credit.Notes = Util.PurgeHtml(description);
                                }
                                #endregion

                                artist.ArtistCredits.Add(credit);
                            }
                        }

                        int totalpage;
                        if (int.TryParse(response.Items[0].TotalPages, out totalpage))
                        {
                            if (pageIndex < totalpage)
                            {
                                pageIndex++;
                                GetArtistCredits(artist, index, country, pageIndex);
                            }
                        }
                    }
                }
            }
            catch (ServerTooBusyException)
            {
            }
        }
        private static Hashtable ParsePortrait(string strUrl)
        {
            Hashtable objResults = new Hashtable();

            try
            {
                string strResults = Util.GetHtmlPage(strUrl, Encoding.Default, BrowserType.Firefox4);

                if (strResults == null)
                {
                    return(null);
                }

                #region Image
                string strParsing = @"Headshot";
                int    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"src='";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"'";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    objResults.Add("Image", strTemp);
                }
                #endregion
                #region Weight
                strParsing = @"Weight";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        strTemp = strTemp.Replace("lbs.", "").Trim();
                        objResults.Add("Weight", strTemp);
                    }
                }
                #endregion
                #region Height
                strParsing = @"Height";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Height", strTemp.Trim());
                    }
                }
                #endregion
                #region Eye Color
                strParsing = @"Eye Color";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Eye Color", strTemp.Trim());
                    }
                }
                #endregion
                #region Measurements
                strParsing = @"Meas.";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim();

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Measurements", Util.BraConverter(strTemp.Split('-')[0]));
                    }
                }
                #endregion
                #region Hair Color
                strParsing = @"Hair Color";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim();

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Hair Color", strTemp);
                    }
                }
                #endregion
                #region Ethnicity
                strParsing = @"Ethnicity";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim();

                    if (string.IsNullOrWhiteSpace(strTemp) == false && strTemp != "No data")
                    {
                        objResults.Add("Ethnicity", strTemp);
                    }
                }
                #endregion
                #region Credits
                strParsing = @"class=""rank""";
                string[] objTables = Regex.Split(strResults, strParsing);

                List <ArtistCredits> credits = new List <ArtistCredits>();
                foreach (string item in objTables)
                {
                    string temp = item.Trim();
                    strParsing = @">";

                    if (temp.StartsWith(strParsing) == true)
                    {
                        strParsing = @"href=""";

                        intBegin = temp.IndexOf(strParsing, StringComparison.Ordinal);
                        if (intBegin > -1)
                        {
                            temp       = temp.Substring(intBegin + strParsing.Length);
                            strParsing = @".html";

                            string buyLink = string.Format(@"http://www.adultdvdempire.com{0}?partner_id={1}", temp.Substring(0, temp.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length).Trim(), "86947268");

                            strParsing = @"title=""";
                            temp       = temp.Substring(temp.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                            strParsing = @"""";
                            string title = temp.Substring(0, temp.IndexOf(strParsing, StringComparison.Ordinal));

                            strParsing = "- Released ";
                            temp       = temp.Substring(temp.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                            strParsing = " ";
                            string year = temp.Substring(0, temp.IndexOf(strParsing, StringComparison.Ordinal)).Trim();

                            ArtistCredits movie = new ArtistCredits();
                            movie.Title = Util.PurgeHtml(title);

                            movie.EntityType = EntityType.XXX;

                            DateTime relaeseDate;
                            if (DateTime.TryParse(year, CultureInfo.CreateSpecificCulture("en-US"), DateTimeStyles.None, out relaeseDate) == true)
                            {
                                movie.ReleaseDate = relaeseDate;
                            }

                            if (string.IsNullOrWhiteSpace(buyLink) == false)
                            {
                                movie.BuyLink = buyLink;
                            }

                            credits.Add(movie);
                        }
                    }
                }
                if (credits.Count > 0)
                {
                    objResults.Add("Credits", credits);
                }
                #endregion
                #region Bio

                strParsing = @"class=""Bio""";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"href='";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"'";
                    string strTemp = @"http://www.adultdvdempire.com" +
                                     strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                    strResults = Util.GetHtmlPage(strTemp, Encoding.Default, BrowserType.Firefox4);
                }
                if (strResults != null)
                {
                    #region Aka

                    strParsing = @"Alias:";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                    if (intBegin > -1)
                    {
                        strResults = strResults.Substring(intBegin);
                        strParsing = @">";
                        strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"<";
                        string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim();

                        if (string.IsNullOrWhiteSpace(strTemp.Trim()) == false)
                        {
                            objResults.Add("Aka", strTemp);
                        }
                    }
                    #endregion
                    #region Birthplace
                    strParsing = @"Birthplace:";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                    if (intBegin > -1)
                    {
                        strResults = strResults.Substring(intBegin);
                        strParsing = @">";
                        strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"<";
                        string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim();

                        if (string.IsNullOrWhiteSpace(strTemp.Trim()) == false)
                        {
                            objResults.Add("Birthplace", strTemp);
                        }
                    }
                    #endregion
                    #region Birthday
                    strParsing = @"Born On:";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                    if (intBegin > -1)
                    {
                        strResults = strResults.Substring(intBegin);
                        strParsing = @">";
                        strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"<";
                        string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim();

                        if (string.IsNullOrWhiteSpace(strTemp) == false)
                        {
                            DateTime birthday;
                            if (DateTime.TryParse(strTemp, CultureInfo.CreateSpecificCulture("en-US"), DateTimeStyles.None, out birthday) == true)
                            {
                                if (birthday.Year < DateTime.Now.Year)
                                {
                                    objResults.Add("Birthday", birthday);
                                }
                            }
                        }
                    }

                    #endregion
                    #region Comments
                    strParsing = @"<p>";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                    if (intBegin > -1)
                    {
                        strResults = strResults.Substring(intBegin + strParsing.Length);
                        strParsing = @"</div";
                        string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                        if (string.IsNullOrWhiteSpace(strTemp.Trim()) == false)
                        {
                            objResults.Add("Comments", Util.PurgeHtml(strTemp));
                        }
                    }
                    #endregion
                    #endregion
                }

                return(objResults);
            }
            catch (Exception ex)
            {
                Util.LogException(ex, strUrl);
                return(null);
            }
        }
示例#12
0
        public void Refresh()
        {
            if (Artist != null && string.IsNullOrWhiteSpace(Artist.FulleName) == false)
            {
                string name = Artist.FulleName;
                Task.Factory.StartNew(() => Util.NotifyEvent("ArtistDetail:" + name));
            }

            IList <string> lstBooks  = ArtistServices.GetOwnedBooks(Artist);
            IList <string> lstMusic  = ArtistServices.GetOwnedMusic(Artist);
            IList <string> lstMovies = ArtistServices.GetOwnedMovies(Artist);
            IList <string> lstSeries = ArtistServices.GetOwnedSeries(Artist);
            IList <string> lstXxx    = ArtistServices.GetOwnedXxx(Artist);

            if (Artist != null && Artist.IsOld == false)
            {
                if (Artist.ArtistCredits == null || Artist.ArtistCredits.Any() == false)
                {
                    Artist.ArtistCredits = ArtistServices.GetCredits(Artist);
                }

                lblName.Text = Artist.FulleName;
                if (Artist.BirthDay.HasValue)
                {
                    lblBirth.Text      = Artist.BirthDay.Value.ToLongDateString();
                    txtAge.Text        = (DateTime.Now.Year - Artist.BirthDay.Value.Year).ToString(CultureInfo.InvariantCulture);
                    lblBorn.Visibility = Visibility.Visible;
                    txtAge.Visibility  = Visibility.Visible;
                    lblAge.Visibility  = Visibility.Visible;
                }
                else
                {
                    lblBorn.Visibility = Visibility.Collapsed;
                    txtAge.Visibility  = Visibility.Collapsed;
                    lblAge.Visibility  = Visibility.Collapsed;
                }

                ShowPicture();

                if (string.IsNullOrWhiteSpace(Artist.Ethnicity) == false)
                {
                    lblEthnicity.Text = Artist.Ethnicity;
                }

                if (string.IsNullOrWhiteSpace(Artist.Breast) == false)
                {
                    lblBreast.Text = Artist.Breast;
                }

                if (string.IsNullOrWhiteSpace(Artist.Bio) == false)
                {
                    lblBio.Text = Artist.Bio;
                }
                else
                {
                    lblBio.Text = "No Bio !";
                }

                if (string.IsNullOrWhiteSpace(Artist.PlaceBirth) == false)
                {
                    lblBirthPlace.Text = Artist.PlaceBirth;
                    lblIn.Visibility   = Visibility.Visible;
                    lblBorn.Visibility = Visibility.Visible;
                }
                else
                {
                    lblIn.Visibility = Visibility.Collapsed;
                }

                if (string.IsNullOrWhiteSpace(Artist.WebSite) == false)
                {
                    lblSites.Text = Artist.WebSite;
                }
            }

            if (Artist != null && string.IsNullOrWhiteSpace(Artist.Aka) == false)
            {
                lblAka.Text = Artist.Aka;
            }

            wrpOwnItems.Children.Clear();

            if (lstBooks != null)
            {
                foreach (string item in lstBooks)
                {
                    Label objLabel = new Label();
                    objLabel.Content = item;
                    wrpOwnItems.Children.Add(objLabel);
                }
            }

            if (lstMovies != null)
            {
                foreach (string item in lstMovies)
                {
                    Label objLabel = new Label();
                    objLabel.Content = item;
                    wrpOwnItems.Children.Add(objLabel);
                }
            }

            if (lstMusic != null)
            {
                foreach (string item in lstMusic)
                {
                    Label objLabel = new Label();
                    objLabel.Content = item;
                    wrpOwnItems.Children.Add(objLabel);
                }
            }

            if (lstSeries != null)
            {
                foreach (string item in lstSeries)
                {
                    Label objLabel = new Label();
                    objLabel.Content = item;
                    wrpOwnItems.Children.Add(objLabel);
                }
            }

            if (lstXxx != null)
            {
                foreach (string item in lstXxx)
                {
                    Label objLabel = new Label();
                    objLabel.Content = item;
                    if (Artist.ArtistCredits != null)
                    {
                        ArtistCredits credit = Artist.ArtistCredits.FirstOrDefault(x => x.Title.ToUpper() == item.ToUpper());

                        if (credit != null && string.IsNullOrEmpty(credit.Notes) == false)
                        {
                            objLabel.ToolTip = credit.Notes;
                        }
                    }

                    wrpOwnItems.Children.Add(objLabel);
                }
            }

            wrpToBuyItems.Children.Clear();
            if (Artist.ArtistCredits != null)
            {
                IEnumerable <ArtistCredits> credits = Artist.ArtistCredits.Distinct(new ArtistCreditComparer()).OrderBy(x => x.Title);
                foreach (ArtistCredits item in credits)
                {
                    if ((lstBooks == null || lstBooks.Contains(item.Title, StringComparer.InvariantCultureIgnoreCase) == false) &&
                        (lstMovies == null || lstMovies.Contains(item.Title, StringComparer.InvariantCultureIgnoreCase) == false) &&
                        (lstMusic == null || lstMusic.Contains(item.Title, StringComparer.InvariantCultureIgnoreCase) == false) &&
                        (lstSeries == null || lstSeries.Contains(item.Title, StringComparer.InvariantCultureIgnoreCase) == false) &&
                        (lstXxx == null || lstXxx.Contains(item.Title, StringComparer.InvariantCultureIgnoreCase) == false))
                    {
                        UcBuyLink objLabel = new UcBuyLink();
                        objLabel.lblTitle.Text = item.Title;

                        if (item.ReleaseDate.HasValue)
                        {
                            objLabel.lblTitle.ToolTip = (item.ReleaseDate.Value.Year + " " + item.Notes).Trim();
                        }
                        else if (item.Notes != null)
                        {
                            objLabel.lblTitle.ToolTip = item.Notes.Trim();
                        }

                        if (item.BuyLink != null && string.IsNullOrWhiteSpace(item.BuyLink) == false)
                        {
                            objLabel.lnkToBuy.NavigateUri = new Uri(item.BuyLink);
                            objLabel.lblToBuy.ToolTip     = item.BuyLink;
                        }
                        else
                        {
                            objLabel.lblToBuy.Visibility = Visibility.Collapsed;
                        }

                        wrpToBuyItems.Children.Add(objLabel);
                    }
                }
            }
        }
示例#13
0
        public static Artist CastToArtist(JObject objRest)
        {
            if (objRest == null)
            {
                return(null);
            }

            Artist objItem = new Artist();

            objItem.ArtistCredits = new List <ArtistCredits>();

            #region Name
            string[] name = ((string)objRest["name"]).Split(' ');
            foreach (string item in name)
            {
                if (string.IsNullOrEmpty(objItem.FirstName))
                {
                    objItem.FirstName = item;
                }
                else
                {
                    objItem.LastName += " " + item;
                }
            }
            if (objItem.LastName != null)
            {
                objItem.LastName = objItem.LastName.Trim();
            }
            else
            {
                objItem.LastName = string.Empty;
            }

            objItem.FulleName = objItem.FirstName + " " + objItem.LastName;
            #endregion
            #region Birthday
            DateTime objDate;
            if (DateTime.TryParse((string)objRest["birthday"], out objDate))
            {
                objItem.BirthDay = objDate;
            }
            #endregion
            #region Picture
            if (string.IsNullOrWhiteSpace((string)objRest["profile_path"]) == false)
            {
                objItem.Picture = Util.GetImage(ImageUrl + ProfileSize + (string)objRest["profile_path"]);
            }

            #endregion
            #region Credits

            JArray cast = (JArray)objRest["credits"]["cast"];

            foreach (JObject person in cast)
            {
                ArtistCredits movie = new ArtistCredits();

                movie.Title      = (string)person["title"];
                movie.BuyLink    = string.Format(@"http://www.themoviedb.org/movie/{0}", (string)person["id"]);
                movie.EntityType = EntityType.Movie;
                movie.Notes      = (string)person["character"];

                DateTime releaseDate;
                if (DateTime.TryParse((string)person["release_date"], out releaseDate) == true)
                {
                    movie.ReleaseDate = releaseDate;
                }

                movie.Title = movie.Title.Replace(@"""", " ");

                if (string.IsNullOrWhiteSpace(movie.Title) == false && string.IsNullOrWhiteSpace(objItem.FulleName) == false)
                {
                    if (Dal.GetInstance.GetArtistCredit(movie.Title, objItem.FulleName) == null)
                    {
                        objItem.ArtistCredits.Add(movie);
                    }
                }
            }

            #endregion
            #region Bio
            objItem.Bio = (string)objRest["biography"];
            #endregion
            #region PlaceBirth
            objItem.PlaceBirth = (string)objRest["place_of_birth"];
            #endregion


            return(objItem);
        }
示例#14
0
        public static Artist CastToArtist(XElement objRest)
        {
            if (objRest == null)
            {
                return(null);
            }

            Artist objItem = null;
            var    query   = from item in objRest.Descendants("person")
                             select item;

            XElement[] nodes = query.ToArray();
            if (nodes.Length > 0)
            {
                XElement objTemp = nodes[0];
                objItem = new Artist();

                #region Name
                string[] name = Util.GetElementValue(objTemp, "name").Split(' ');
                foreach (string item in name)
                {
                    if (string.IsNullOrEmpty(objItem.FirstName))
                    {
                        objItem.FirstName = item;
                    }
                    else
                    {
                        objItem.LastName += " " + item;
                    }
                }
                if (objItem.LastName != null)
                {
                    objItem.LastName = objItem.LastName.Trim();
                }
                else
                {
                    objItem.LastName = string.Empty;
                }

                objItem.FulleName = objItem.FirstName + " " + objItem.LastName;
                #endregion
                #region Birthday
                DateTime objDate;
                if (DateTime.TryParse(Util.GetElementValue(objTemp, "birthday"), out objDate))
                {
                    objItem.BirthDay = objDate;
                }
                #endregion
                #region Picture
                if (objTemp != null)
                {
                    var imagesUrl = from item in objTemp.Descendants("image")
                                    let attribute = item.Attribute("size")
                                                    let xAttribute = item.Attribute("type")
                                                                     where attribute != null && (xAttribute != null && (xAttribute.Value == "profile" &&
                                                                                                                        attribute.Value == "original"))
                                                                     let xAttribute1 = item.Attribute("url")
                                                                                       where xAttribute1 != null
                                                                                       select xAttribute1.Value;

                    string[] images = imagesUrl.ToArray();
                    if (images.Length > 0)
                    {
                        objItem.Picture = Util.GetImage(images[0]);
                    }
                }
                #endregion
                #region Credits

                if (objTemp != null)
                {
                    var creditsquery = from item in objTemp.Descendants("movie")
                                       where item.Attribute("job").Value == "Actor"
                                       select item;

                    XElement[] credits = creditsquery.ToArray();
                    foreach (XElement item in credits)
                    {
                        ArtistCredits movie = new ArtistCredits();

                        movie.Title      = Util.GetAttributValue(item, "name");
                        movie.BuyLink    = Util.GetAttributValue(item, "url");
                        movie.EntityType = EntityType.Movie;
                        movie.Notes      = Util.GetAttributValue(item, "character");

                        DateTime releaseDate;
                        if (DateTime.TryParse(Util.GetAttributValue(item, "release"), out releaseDate) == true)
                        {
                            movie.ReleaseDate = releaseDate;
                        }

                        movie.Title = movie.Title.Replace(@"""", " ");

                        if (string.IsNullOrWhiteSpace(movie.Title) == false && string.IsNullOrWhiteSpace(objItem.FulleName) == false)
                        {
                            if (Dal.GetInstance.GetArtistCredit(movie.Title, objItem.FulleName) == null)
                            {
                                objItem.ArtistCredits.Add(movie);
                            }
                        }
                    }
                }

                #endregion
                #region Bio
                objItem.Bio = Util.GetElementValue(objTemp, "biography");
                #endregion
                #region PlaceBirth
                objItem.PlaceBirth = Util.GetElementValue(objTemp, "birthplace");
                #endregion
            }

            return(objItem);
        }