Exemple #1
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);
            }
        }
Exemple #2
0
        private static Artist ParseArtist(string artistName, string artistUrl, string artistImage)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(artistName))
                {
                    return(null);
                }

                bool   isNew;
                Artist artist = ArtistServices.Get(artistName, out isNew);

                if (artist == null)
                {
                    artist = new Artist();
                }

                if (string.IsNullOrWhiteSpace(artistUrl) == false)
                {
                    Uri strUrl = new Uri(artistUrl);

                    string description = Util.GetRest(strUrl);

                    if (string.IsNullOrWhiteSpace(description) == false)
                    {
                        artist.Bio = description;
                    }
                }

                artist.FulleName = artistName;

                if (string.IsNullOrWhiteSpace(artistImage) == false)
                {
                    byte[] image = Util.GetImage(artistImage);

                    if (image != null)
                    {
                        if (artist.Picture == null || artist.Picture.LongLength < image.LongLength)
                        {
                            artist.Picture = image;
                        }
                    }
                }

                return(artist);
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                return(null);
            }
        }
        public ArtistDetail(string fullname, EntityType entityType)
        {
            InitializeComponent();
            bool isNew;

            artistDetail.Artist     = ArtistServices.Get(fullname, out isNew);
            artistDetail.EntityType = entityType;

            if (artistDetail.Artist == null)
            {
                return;
            }

            artistDetail.Refresh();
        }
Exemple #4
0
        private static Artist ParseArtist(string artistName, string id)
        {
            try
            {
                bool   isNew;
                Artist artist = ArtistServices.Get(artistName, out isNew);

                if (MySettings.FastSearch == true)
                {
                    return(artist);
                }

                Uri    strUrl = new Uri(string.Format(@"http://api.ent.nokia.com/1.x/us/creators/images/320x320/random/?domain=music&app_id={1}&app_code={2}&id={0}", id, AppId, AppToken));
                byte[] image  = Util.GetImage(strUrl.ToString());

                if (image != null)
                {
                    if (artist.Picture == null || artist.Picture.LongLength < image.LongLength)
                    {
                        artist.Picture = image;
                    }
                }

                strUrl = new Uri(string.Format(@"http://api.ent.nokia.com/1.x/us/creators/{0}/products/?domain=music&app_id={1}&app_code={2}&orderby={3}", id, AppId, AppToken, "releasedate"));

                JObject restResponse = JObject.Parse(Util.GetRest(strUrl));

                NokiaMusic.ToArtist(restResponse, artist);

                return(artist);
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
                return(null);
            }
        }
Exemple #5
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, "TitreVF");
                    movie.OriginalTitle = Util.GetElementValue(node, "TitreVO");

                    int intValue;

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

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

                    movie.Description = Util.GetElementValue(node, "Synopsis");
                    movie.Comments    = Util.GetElementValue(node, "Commentaires");
                    movie.FileFormat  = MovieServices.GetFormat(Util.GetElementValue(node, "Support"));
                    movie.FilePath    = Util.GetElementValue(node, "MediaChemin");
                    movie.Media       = MediaServices.Get("None", true);

                    DateTime dateValue;

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

                    if (Util.GetElementValue(node, "FilmVu") == "OUI")
                    {
                        movie.Watched = true;
                    }


                    #region Types
                    string   allType = Util.GetElementValue(node, "Genre");
                    string[] types   = allType.Split('/');


                    foreach (string type in types)
                    {
                        MovieServices.AddTypes(type, movie);
                    }
                    #endregion
                    #region Artist
                    string   allArtist = Util.GetElementValue(node, "Acteurs");
                    string[] artists   = allArtist.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                    foreach (string artist in artists)
                    {
                        string fullName = artist.Trim();
                        if (string.IsNullOrWhiteSpace(fullName) == false)
                        {
                            bool   isNew;
                            Artist newArtist = ArtistServices.Get(fullName, out isNew);
                            ArtistServices.SaveArtist(newArtist, movie);
                        }
                    }
                    #endregion
                    #region Director
                    string   allDirector = Util.GetElementValue(node, "Realisateurs");
                    string[] directors   = allDirector.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                    foreach (string director in directors)
                    {
                        string fullName = director.Trim();
                        if (string.IsNullOrWhiteSpace(fullName) == false)
                        {
                            bool   isNew;
                            Artist newArtist = ArtistServices.Get(fullName, out isNew);
                            ArtistServices.AddDirector(new[] { newArtist }, movie);
                        }
                    }
                    #endregion
                    #region Audio
                    string       allAudio  = Util.GetElementValue(node, "Audio");
                    string[]     audios    = allAudio.Split(',');
                    List <Audio> audioList = new List <Audio>();

                    foreach (string audio in audios)
                    {
                        string cleanAudio = audio.Trim();
                        if (string.IsNullOrWhiteSpace(cleanAudio) == false)
                        {
                            string[] detailAudio = cleanAudio.Split(' ');
                            audioList.Add(MovieServices.GetMovieAudio(detailAudio[0], detailAudio[1]));
                        }
                    }
                    AudioServices.Add(audioList, movie);
                    #endregion
                    #region Sub

                    string   allSubs = Util.GetElementValue(node, "SousTitres");
                    string[] subs    = allSubs.Split(',');

                    SubTitleServices.Add(subs, movie);

                    #endregion
                    #region Link
                    LinksServices.AddLinks(Util.GetElementValue(node, "BAChemin"), movie, true);
                    #endregion

                    Dal.GetInstance.AddMovie(movie);
                    _intAddedItem++;
                    Current++;
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }
        }
Exemple #6
0
        public static AlloCine MovieToObject(XElement objRest)
        {
            AlloCine objItem = null;

            if (objRest != null)
            {
                objItem = new AlloCine();

                objItem.OriginalTitle  = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}originalTitle");
                objItem.Country        = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}nationality");
                objItem.Id             = Util.GetAttributValue(objRest, "code");
                objItem.Description    = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}synopsis");
                objItem.Tagline        = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}synopsisShort");
                objItem.PosterOriginal = Util.GetAttributValue(objRest, @"{http://www.allocine.net/v6/ns/}poster", "href");
                objItem.Title          = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}title");
                objItem.Url            = @"http://www.allocine.fr/film/fichefilm_gen_cfilm=" + objItem.Id + ".html";
                objItem.Trailer        = Util.GetAttributValue(objRest, @"{http://www.allocine.net/v6/ns/}trailer", "href");

                string runtime = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}runtime");
                int    intRunTime;
                if (int.TryParse(runtime, out intRunTime))
                {
                    objItem.Runtime = (int?)new TimeSpan(0, 0, intRunTime).TotalMinutes;
                }

                var released = from item in objRest.Elements()
                               where item.Name.LocalName == "release"
                               select((XElement)item.FirstNode).Value;

                IEnumerable <string> enumerable = released as IList <string> ?? released.ToList();
                if (enumerable.Any())
                {
                    string relased = enumerable.First();
                    if (string.IsNullOrWhiteSpace(relased) == false)
                    {
                        DateTime date;
                        if (DateTime.TryParse(relased, out date) == true)
                        {
                            objItem.Released = date;
                        }
                    }
                }

                var cast = from item in objRest.Descendants("{http://www.allocine.net/v6/ns/}castMember")
                           select item;

                XElement[] artists = cast.ToArray();
                objItem.Cast      = new List <Artist>();
                objItem.Directors = new List <Artist>();
                foreach (XElement item in artists)
                {
                    string picture = Util.GetAttributValue(item, @"{http://www.allocine.net/v6/ns/}picture", "href");
                    string name    = Util.GetElementValue(item, @"{http://www.allocine.net/v6/ns/}person");
                    string job     = Util.GetAttributValue(item, @"{http://www.allocine.net/v6/ns/}activity", "code");

                    if (string.IsNullOrWhiteSpace(name) == false)
                    {
                        bool   isNew;
                        Artist artist = (ArtistServices.Get(name, out isNew));

                        if (string.IsNullOrWhiteSpace(picture) == false && MySettings.FastSearch == false)
                        {
                            artist.Picture = Util.GetImage(picture);
                        }

                        if (job == "8002")
                        {
                            objItem.Directors.Add(artist);
                        }
                        else if (job == "8001")
                        {
                            objItem.Cast.Add(artist);
                        }
                    }
                }

                var genres = from item in objRest.Descendants("{http://www.allocine.net/v6/ns/}genre")
                             select item.Value;

                objItem.Genres = new List <string>(genres.ToArray());

                var imagesUrl = from item in objRest.Descendants("{http://www.allocine.net/v6/ns/}media")
                                let xElement = item.Element("{http://www.allocine.net/v6/ns/}type")
                                               where xElement != null && xElement.Value == "Photo"
                                               select item;

                Collection <XElement> images = new Collection <XElement>(imagesUrl.ToArray());
                if (images.Count > 0)
                {
                    objItem.BackdropOriginal = Util.GetAttributValue(images[0], @"{http://www.allocine.net/v6/ns/}thumbnail", "href");
                }

                var studio = from item in objRest.Elements()
                             where item.Name.LocalName == "release"
                             select item;

                Collection <XElement> studios = new Collection <XElement>(studio.ToArray());
                if (studios.Count > 0)
                {
                    objItem.Studio = Util.GetAttributValue(studios[0], @"{http://www.allocine.net/v6/ns/}distributor", "name");
                }

                var rating = from item in objRest.Elements()
                             where item.Name.LocalName == "statistics"
                             select item;

                Collection <XElement> lstRating = new Collection <XElement>(rating.ToArray());
                if (lstRating.Count > 0)
                {
                    string      strrating = Util.GetElementValue(lstRating[0], "{http://www.allocine.net/v6/ns/}userRating");
                    double      value;
                    CultureInfo cultureInfo = new CultureInfo("en-US", true);
                    if (double.TryParse(strrating, NumberStyles.Any, cultureInfo.NumberFormat, out value) == true)
                    {
                        objItem.Rating = value.ToString("F");
                    }
                    else if (double.TryParse(strrating.Replace(',', '.'), out value) == true)
                    {
                        objItem.Rating = value.ToString(CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        objItem.Rating = strrating;
                    }
                }
            }

            return(objItem);
        }
Exemple #7
0
        public static AlloCine SerieToObject(JObject objRest, string seasonNumber, LanguageType languageType)
        {
            AlloCine objItem = null;

            if (objRest != null)
            {
                objItem = new AlloCine();

                objItem.Id            = (string)objRest["tvseries"]["code"];
                objItem.OriginalTitle = (string)objRest["tvseries"]["originalTitle"];
                objItem.Title         = (string)objRest["tvseries"]["title"];

                string relased = string.Empty;
                if (objRest["tvseries"]["originalBroadcast"]["dateStart"] != null)
                {
                    relased = (string)objRest["tvseries"]["originalBroadcast"]["dateStart"];
                }

                if (string.IsNullOrWhiteSpace(relased) == false)
                {
                    DateTime date;
                    if (DateTime.TryParse(relased, out date) == true)
                    {
                        objItem.Released = date;
                    }
                }


                objItem.Runtime = (int)objRest["tvseries"]["formatTime"];

                string inProduction = (string)objRest["tvseries"]["productionStatus"]["code"];
                if (inProduction == "122004")
                {
                    objItem.IsInProduction = true;
                }

                objItem.NumberOfSeason   = (string)objRest["tvseries"]["seasonCount"];
                objItem.NumberOfEpisodes = (string)objRest["tvseries"]["episodeCount"];

                objItem.Country = (string)objRest["tvseries"]["nationality"][0]["$"];

                JArray genre = (JArray)objRest["tvseries"]["genre"];
                objItem.Genres = new List <string>();

                foreach (JObject item in genre)
                {
                    objItem.Genres.Add((string)item["$"]);
                }

                objItem.Tagline     = (string)objRest["tvseries"]["synopsisShort"];
                objItem.Description = (string)objRest["tvseries"]["synopsis"];

                JArray cast = (JArray)objRest["tvseries"]["castMember"];

                objItem.Cast      = new List <Artist>();
                objItem.Directors = new List <Artist>();
                foreach (JObject item in cast)
                {
                    string picture = string.Empty;
                    if (item["picture"] != null)
                    {
                        picture = (string)item["picture"]["href"];
                    }

                    string name = (string)item["person"]["name"];
                    string job  = (string)item["activity"]["code"];

                    if (string.IsNullOrWhiteSpace(name) == false)
                    {
                        bool   isNew;
                        Artist artist = (ArtistServices.Get(name, out isNew));

                        if (string.IsNullOrWhiteSpace(picture) == false && MySettings.FastSearch == false)
                        {
                            artist.Picture = Util.GetImage(picture);
                        }

                        if (job == "8002")
                        {
                            objItem.Directors.Add(artist);
                        }
                        else if (job == "8001")
                        {
                            objItem.Cast.Add(artist);
                        }
                    }
                }

                //FIX 2.8.0.0
                if (objRest["tvseries"]["poster"] != null)
                {
                    objItem.PosterOriginal = (string)objRest["tvseries"]["poster"]["href"];
                }

                switch (languageType)
                {
                case LanguageType.BR:
                case LanguageType.PT:
                    objItem.Url = @"http://www.adorocinema.com/filmes/filme-" + objItem.Id;
                    break;

                default:
                    objItem.Url = @"http://www.allocine.fr/series/ficheserie_gen_cserie=" + objItem.Id + ".html";
                    break;
                }

                //FIX 2.8.0.0
                if (objRest["tvseries"]["trailer"] != null)
                {
                    objItem.Trailer = (string)objRest["tvseries"]["trailer"]["href"];
                }

                JArray media = (JArray)objRest["tvseries"]["media"];

                //FIX 2.8.9.0
                if (media != null)
                {
                    foreach (JObject item in media)
                    {
                        if ((string)item["type"]["$"] == "Photo")
                        {
                            objItem.BackdropOriginal = (string)item["thumbnail"]["href"];
                            break;
                        }
                    }
                }

                objItem.Studio = (string)objRest["tvseries"]["originalChannel"]["$"];


                string      strrating = (string)objRest["tvseries"]["statistics"]["userRating"];
                double      value;
                CultureInfo cultureInfo = new CultureInfo("en-US", true);
                if (double.TryParse(strrating, NumberStyles.Any, cultureInfo.NumberFormat, out value) == true)
                {
                    objItem.SerieRating = (long)(value * 4);
                }
                else if (double.TryParse(strrating.Replace(',', '.'), out value) == true)
                {
                    objItem.SerieRating = (long)(value * 4);
                }
            }

            return(objItem);
        }
Exemple #8
0
        public static AlloCine SerieToObject(XElement objRest, string seasonNumber)
        {
            AlloCine objItem = null;

            if (objRest != null)
            {
                objItem               = new AlloCine();
                objItem.Id            = Util.GetAttributValue(objRest, "code");
                objItem.OriginalTitle = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}originalTitle");
                objItem.Title         = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}title");

                DateTime date;
                if (DateTime.TryParse(Util.GetAttributValue(objRest, @"{http://www.allocine.net/v6/ns/}originalBroadcast", "dateStart"), out date) == true)
                {
                    objItem.Released = date;
                }

                string runtime = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}formatTime");
                int    intRunTime;
                if (int.TryParse(runtime, out intRunTime))
                {
                    objItem.Runtime = intRunTime;
                }

                string inProduction = Util.GetAttributValue(objRest, @"{http://www.allocine.net/v6/ns/}productionStatus", "code");
                if (inProduction == "122004")
                {
                    objItem.IsInProduction = true;
                }

                objItem.NumberOfSeason   = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}seasonCount");
                objItem.NumberOfEpisodes = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}episodeCount");

                objItem.Country = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}nationalityList", @"{http://www.allocine.net/v6/ns/}nationality");

                var genres = from item in objRest.Descendants("{http://www.allocine.net/v6/ns/}genre")
                             select item.Value;

                objItem.Genres = new List <string>(genres.ToArray());

                objItem.Tagline     = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}synopsisShort");
                objItem.Description = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}synopsis");

                var cast = from item in objRest.Descendants("{http://www.allocine.net/v6/ns/}castMember")
                           select item;

                XElement[] artists = cast.ToArray();
                objItem.Cast      = new List <Artist>();
                objItem.Directors = new List <Artist>();
                foreach (XElement item in artists)
                {
                    string picture = Util.GetAttributValue(item, @"{http://www.allocine.net/v6/ns/}picture", "href");
                    string name    = Util.GetElementValue(item, @"{http://www.allocine.net/v6/ns/}person");
                    string job     = Util.GetAttributValue(item, @"{http://www.allocine.net/v6/ns/}activity", "code");

                    if (string.IsNullOrWhiteSpace(name) == false)
                    {
                        bool   isNew;
                        Artist artist = (ArtistServices.Get(name, out isNew));

                        if (string.IsNullOrWhiteSpace(picture) == false && MySettings.FastSearch == false)
                        {
                            artist.Picture = Util.GetImage(picture);
                        }

                        if (job == "8002")
                        {
                            objItem.Directors.Add(artist);
                        }
                        else if (job == "8001")
                        {
                            objItem.Cast.Add(artist);
                        }
                    }
                }

                objItem.PosterOriginal = Util.GetAttributValue(objRest, @"{http://www.allocine.net/v6/ns/}poster", "href");

                objItem.Url     = @"http://www.allocine.fr/series/ficheserie_gen_cserie=" + objItem.Id + ".html";
                objItem.Trailer = Util.GetAttributValue(objRest, @"{http://www.allocine.net/v6/ns/}trailer", "href");

                var imagesUrl = from item in objRest.Descendants("{http://www.allocine.net/v6/ns/}media")
                                let xElement = item.Element("{http://www.allocine.net/v6/ns/}type")
                                               where xElement != null && xElement.Value == "Photo"
                                               select item;

                Collection <XElement> images = new Collection <XElement>(imagesUrl.ToArray());
                if (images.Count > 0)
                {
                    objItem.BackdropOriginal = Util.GetAttributValue(images[0], @"{http://www.allocine.net/v6/ns/}thumbnail", "href");
                }

                objItem.Studio = Util.GetElementValue(objRest, @"{http://www.allocine.net/v6/ns/}originalChannel");

                var rating = from item in objRest.Elements()
                             where item.Name.LocalName == "statistics"
                             select item;

                Collection <XElement> lstRating = new Collection <XElement>(rating.ToArray());
                if (lstRating.Count > 0)
                {
                    string      strrating = Util.GetElementValue(lstRating[0], "{http://www.allocine.net/v6/ns/}userRating");
                    double      value;
                    CultureInfo cultureInfo = new CultureInfo("en-US", true);
                    if (double.TryParse(strrating, NumberStyles.Any, cultureInfo.NumberFormat, out value) == true)
                    {
                        objItem.SerieRating = (long)(value * 4);
                    }
                    else if (double.TryParse(strrating.Replace(',', '.'), out value) == true)
                    {
                        objItem.SerieRating = (long)(value * 4);
                    }
                }

                var episodes = from item in objRest.Descendants("{http://www.allocine.net/v6/ns/}season")
                               let xElement = item.Element("{http://www.allocine.net/v6/ns/}seasonNumber")
                                              where xElement != null && xElement.Value == seasonNumber
                                              select item;

                Collection <XElement> seasonEp = new Collection <XElement>(episodes.ToArray());
                if (seasonEp.Count > 0)
                {
                    objItem.SeasonEpisodes = Util.GetElementValue(seasonEp[0], @"{http://www.allocine.net/v6/ns/}episodeCount");
                }
            }

            return(objItem);
        }
Exemple #9
0
        public static Hashtable Parse(string strUrl, bool getPage, string strSearch)
        {
            Hashtable objResuls = new Hashtable();

            try
            {
                string strResults;

                if (getPage == true)
                {
                    strResults = Util.GetHtmlPage(strUrl, Encoding.UTF8);
                }
                else
                {
                    strResults = strUrl;
                }

                objResuls.Add("Title", strSearch);
                objResuls.Add("Links", strUrl);

                if (string.IsNullOrEmpty(strResults))
                {
                    return(null);
                }
                #region Image
                string strParsing = @"more-views";
                int    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"href=""";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"""";

                    objResuls.Add("Image", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                }
                #endregion
                #region Background
                strParsing = @"href=""";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"""";

                    objResuls.Add("Background", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                }
                #endregion
                #region Director
                strParsing = @"Réalisateur :";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"dd>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";
                    objResuls.Add("Directed", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim());
                }
                #endregion
                #region Studio
                strParsing = @"Marque :";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"dd>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";
                    objResuls.Add("Studio", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim());
                }
                #endregion
                #region Released
                strParsing = @"Année :";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"dd>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";
                    string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.InvariantCulture)).Trim();
                    int    date;
                    if (int.TryParse(strTemp, out date) == true)
                    {
                        objResuls.Add("Released", new DateTime(date, 1, 1));
                    }
                }
                #endregion
                #region Actors
                strParsing = @"Actrice :";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"</dd>";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intBegin > -1)
                    {
                        string strActors = strResults.Substring(0, intBegin);
                        strParsing = @"dd>";
                        strActors  = strActors.Substring(strActors.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @",";

                        string[]      objTables = strActors.Split(new [] { strParsing }, StringSplitOptions.RemoveEmptyEntries);
                        List <Artist> lstActors = new List <Artist>();

                        foreach (string item in objTables)
                        {
                            if (string.IsNullOrEmpty(item.Trim()) == false)
                            {
                                string name = item.Trim();
                                bool   isNew;
                                Artist artist = (ArtistServices.Get(name, out isNew));

                                if (MySettings.FastSearch == false)
                                {
                                    string errorMessage;
                                    ArtistServices.GetInfoFromWeb(artist, false, Provider.Iafd, out errorMessage, false);
                                }

                                lstActors.Add(artist);
                            }
                        }

                        objResuls.Add("Actors", lstActors);
                    }
                }
                #endregion
                #region Runtime
                strParsing = @"Durée :";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"dd>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";
                    objResuls.Add("Runtime", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim());
                }
                #endregion
                #region Description
                strParsing = @"Description :";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"<p>";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"</p>";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    objResuls.Add("Description", Util.PurgeHtml(strResults.Substring(0, intBegin)));
                }
                #endregion
                return(objResuls);
            }
            catch (Exception ex)
            {
                Util.LogException(ex, strUrl);
                return(null);
            }
        }
Exemple #10
0
        public static Hashtable Parse(string strUrl, bool getPage)
        {
            Hashtable objResuls = new Hashtable();

            try
            {
                string strResults;
                string strTemp;

                if (getPage)
                {
                    strResults = Util.GetHtmlPage(strUrl, Encoding.UTF8);
                }
                else
                {
                    strResults = strUrl;
                }

                objResuls.Add("Links", strUrl);
                #region Released
                string strParsing = @"Movie Year: ";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"<br />";

                objResuls.Add("Released", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                #endregion
                #region Studio
                strParsing = @"<a href=";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @">";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"</a>";

                objResuls.Add("Studio", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                #endregion
                #region Genres
                strParsing = @"Genres:";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"Director:";
                int intTemp = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp == -1)
                {
                    strParsing = @"Starring:";
                    intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                }
                if (intTemp == -1)
                {
                    strParsing = @"E-mail this movie to a friend";
                    intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                }
                string strGenres = strResults.Substring(0, intTemp);
                strParsing = @"<a href=";

                string[]      objTables = strGenres.Split(new[] { strParsing }, StringSplitOptions.RemoveEmptyEntries);
                List <string> lstGenres = new List <string>();

                foreach (string item in objTables)
                {
                    if (string.IsNullOrEmpty(item.Trim()) == false &&
                        item.Contains(" Our Picks!") == false &&
                        item.Contains(@"adult-"))
                    {
                        strParsing = @">";
                        strTemp    = item.Trim().Substring(item.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"<";
                        lstGenres.Add(strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal)));
                    }
                }
                objResuls.Add("Genre", lstGenres);
                #endregion
                #region Director
                strParsing = @"Director:";
                intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</a>";

                    objResuls.Add("Directed", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                }
                #endregion
                #region Actors
                strParsing = @"Starring:";

                intTemp = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @"<a style";

                    intTemp = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intTemp > -1)
                    {
                        string strActors = strResults.Substring(0, intTemp);
                        strParsing = @"<a href=";

                        objTables = strActors.Split(new[] { strParsing }, StringSplitOptions.RemoveEmptyEntries);
                        List <Artist> lstActors = new List <Artist>();

                        foreach (string item in objTables)
                        {
                            if (string.IsNullOrEmpty(item.Trim()) == false && item.Contains(@"adult-"))
                            {
                                strParsing = @">";
                                strTemp    = item.Trim().Substring(item.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                                strParsing = @"<";

                                string name = strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal));

                                bool   isNew;
                                Artist artist = (ArtistServices.Get(name, out isNew));

                                if (MySettings.FastSearch == false)
                                {
                                    string errorMessage;
                                    ArtistServices.GetInfoFromWeb(artist, false, Provider.Iafd, out errorMessage, false);
                                }

                                lstActors.Add(artist);
                            }
                        }

                        objResuls.Add("Actors", lstActors);
                    }
                }
                #endregion
                #region Image
                strParsing = @"name=""ProductPic";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"src=""";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"""";
                strTemp    = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                objResuls.Add("Image", "http://www.adultblurayhddvd.com/" + strTemp);
                #endregion
                #region Background
                objResuls.Add("Background", "http://www.adultblurayhddvd.com/" + strTemp.Replace(@"/medium/", "/large/"));
                #endregion
                #region Description
                strParsing = @"<hr style=""clear:both"" />";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"<";

                if (strResults.IndexOf(strParsing, StringComparison.Ordinal) > -1)
                {
                    strTemp = Util.PurgeHtml(strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                    if (string.IsNullOrWhiteSpace(strTemp) == false)
                    {
                        objResuls.Add("Description", strTemp);
                    }
                }

                #endregion
                return(objResuls);
            }
            catch (Exception ex)
            {
                Util.LogException(ex, strUrl);
                return(null);
            }
        }
Exemple #11
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                Total = _selectedItems.Length;

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

                    BibTex bibtex = BibTex.XmlToBibTex(item);
                    if (bibtex != null)
                    {
                        Books books = new Books();
                        books.Title         = bibtex.title;
                        books.FileFormat    = new FileFormat();
                        books.FileFormat.Id = _formatId;
                        books.Media         = new Media();
                        books.Media.Id      = _mediaId;
                        books.AddedDate     = DateTime.Now;

                        #region Publisher

                        bool isNew;
                        books.Publisher = PublisherServices.GetPublisher(bibtex.editor, out isNew, "App_Editor");
                        if (isNew == true)
                        {
                            Dal.GetInstance.AddPublisher("App_Editor", books.Publisher);
                        }

                        #endregion
                        #region Artist

                        Artist artist = ArtistServices.Get(bibtex.author.Trim(), out isNew);
                        books.Artists.Add(artist);
                        if (isNew == true)
                        {
                            Dal.GetInstance.AddArtist(artist, books);
                        }

                        #endregion
                        books.Description = bibtex.booktitle;
                        books.Isbn        = bibtex.isbn;

                        int pages;
                        if (int.TryParse(bibtex.pages, out pages))
                        {
                            books.NbrPages = pages;
                        }

                        int year;
                        if (int.TryParse(bibtex.year, out year))
                        {
                            books.ReleaseDate = new DateTime(year, 1, 1);
                        }

                        Books bExist = Dal.GetInstance.GetBooks(_mediaName, books.Title);
                        if (bExist == null)
                        {
                            Dal.GetInstance.AddBook(books);
                            _intAddedItem++;
                        }
                        else
                        {
                            _intNotAddedItem++;
                        }
                    }
                    Current++;
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }
        }
Exemple #12
0
        public static Hashtable Parse(string asin, AmazonCountry country, bool isBarcode, AmazonIndex index, string barcodeType)
        {
            Hashtable objResults = new Hashtable();

            try
            {
                ItemLookupRequest request = new ItemLookupRequest();

                if (isBarcode)
                {
                    switch (barcodeType)
                    {
                    case "EAN_8":
                    case "EAN_13":
                        request.IdType = ItemLookupRequestIdType.EAN;
                        break;

                    case "UPC_A":
                    case "UPC_E":
                    case "UPC_EAN_EXTENSION":
                        request.IdType = ItemLookupRequestIdType.UPC;
                        break;

                    default:
                        request.IdType = ItemLookupRequestIdType.EAN;
                        break;
                    }
                    request.SearchIndex = index.ToString();
                }
                else
                {
                    request.IdType = ItemLookupRequestIdType.ASIN;
                }

                request.IdTypeSpecified = true;
                request.ItemId          = new [] { asin };


                request.ResponseGroup = new [] { "EditorialReview",
                                                 "Images", "ItemAttributes", "Large", "Tracks" };

                ItemLookup itemLookup = new ItemLookup();
                itemLookup.AWSAccessKeyId = Aws1;
                itemLookup.AssociateTag   = AssociateTag;
                itemLookup.Request        = new [] { request };

                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));

                ItemLookupResponse response = client.ItemLookup(itemLookup);

                if (response.Items.GetLength(0) > 0)
                {
                    if (response.Items[0].Item != null)
                    {
                        if (response.Items[0].Item.GetLength(0) > 0)
                        {
                            Item item = response.Items[0].Item[0];
                            #region Actor

                            bool isNew;
                            if (item.ItemAttributes.Actor != null)
                            {
                                List <Artist> actors = item.ItemAttributes.Actor.Select(actor => ArtistServices.Get(actor, out isNew)).ToList();
                                objResults.Add("Actors", actors);
                            }
                            #endregion
                            #region Album
                            if (string.IsNullOrWhiteSpace(item.ItemAttributes.Title) == false)
                            {
                                objResults.Add("Album", item.ItemAttributes.Title);
                            }
                            #endregion
                            #region AlternateVersions
                            if (item.AlternateVersions != null)
                            {
                                if (item.AlternateVersions.GetLength(0) > 0)
                                {
                                    objResults.Add("OriginalTitle", item.AlternateVersions[0].Title);
                                }
                            }
                            #endregion
                            #region Artist
                            if (item.ItemAttributes.Artist != null)
                            {
                                if (item.ItemAttributes.Artist.GetLength(0) > 0)
                                {
                                    if (MySettings.FastSearch == false && index == AmazonIndex.Music)
                                    {
                                        Artist artist = ArtistServices.Get(item.ItemAttributes.Artist[0], out isNew);

                                        GetArtistCredits(artist, index, country, 1);
                                        objResults.Add("Artist", artist);
                                    }
                                    else
                                    {
                                        objResults.Add("Artist", ArtistServices.Get(item.ItemAttributes.Artist[0], out isNew));
                                    }
                                }
                            }
                            #endregion
                            #region AspectRatio
                            if (string.IsNullOrWhiteSpace(item.ItemAttributes.AspectRatio) == false)
                            {
                                objResults.Add("DisplayAspectRatio", MovieServices.GetAspectRatio(item.ItemAttributes.AspectRatio));
                            }
                            #endregion
                            #region Author

                            if (item.ItemAttributes.Author != null)
                            {
                                if (item.ItemAttributes.Author.GetLength(0) > 0)
                                {
                                    if (MySettings.FastSearch == false && index == AmazonIndex.Books)
                                    {
                                        //Fix since 2.6.7.0
                                        Artist artist = ArtistServices.Get(item.ItemAttributes.Author[0], out isNew);
                                        GetArtistCredits(artist, index, country, 1);
                                        objResults.Add("Author", artist);
                                    }
                                    else
                                    {
                                        objResults.Add("Author", ArtistServices.Get(item.ItemAttributes.Author[0], out isNew));
                                    }
                                }
                            }
                            #endregion
                            #region Background
                            if (item.ImageSets != null && item.LargeImage != null)
                            {
                                if (item.ImageSets.GetLength(0) > 0 && item.ImageSets[0].LargeImage.URL != item.LargeImage.URL)
                                {
                                    objResults.Add("Background", item.ImageSets[0].LargeImage.URL);
                                }
                                else if (item.ImageSets.GetLength(0) > 1 && item.ImageSets[1].LargeImage.URL != item.LargeImage.URL)
                                {
                                    objResults.Add("Background", item.ImageSets[1].LargeImage.URL);
                                }
                            }
                            #endregion
                            #region BarCode
                            if (string.IsNullOrWhiteSpace(item.ItemAttributes.EAN) == false)
                            {
                                objResults.Add("BarCode", item.ItemAttributes.EAN);
                            }
                            else if (string.IsNullOrWhiteSpace(item.ItemAttributes.UPC) == false)
                            {
                                objResults.Add("BarCode", item.ItemAttributes.UPC);
                            }
                            else if (string.IsNullOrWhiteSpace(item.ASIN) == false)
                            {
                                objResults.Add("BarCode", item.ASIN);
                            }
                            #endregion
                            #region Comments
                            if (item.CustomerReviews != null)
                            {
                                if (item.CustomerReviews.HasReviews == true)
                                {
                                    objResults.Add("Comments", Util.PurgeHtml(GetReview(item.CustomerReviews.IFrameURL, country)));
                                }
                            }
                            #endregion
                            #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;
                                    }
                                }
                                objResults.Add("Description", Util.PurgeHtml(description));
                            }
                            #endregion
                            #region Director
                            if (item.ItemAttributes.Director != null)
                            {
                                List <Artist> directors = item.ItemAttributes.Director.Select(director => ArtistServices.Get(director, out isNew)).ToList();
                                objResults.Add("Director", directors);
                            }
                            #endregion
                            #region Editor
                            if (string.IsNullOrEmpty(item.ItemAttributes.Publisher) == false)
                            {
                                objResults.Add("Editor", item.ItemAttributes.Publisher);
                            }

                            if (objResults.ContainsKey("Editor") == false)
                            {
                                if (string.IsNullOrEmpty(item.ItemAttributes.Label) == false)
                                {
                                    objResults.Add("Editor", item.ItemAttributes.Label);
                                }
                            }

                            if (objResults.ContainsKey("Editor") == false)
                            {
                                if (string.IsNullOrEmpty(item.ItemAttributes.Manufacturer) == false)
                                {
                                    objResults.Add("Editor", item.ItemAttributes.Manufacturer);
                                }
                            }

                            if (objResults.ContainsKey("Editor") == false)
                            {
                                if (string.IsNullOrEmpty(item.ItemAttributes.Studio) == false)
                                {
                                    objResults.Add("Editor", item.ItemAttributes.Studio);
                                }
                            }

                            #endregion
                            #region Format
                            if (item.ItemAttributes.Format != null)
                            {
                                if (item.ItemAttributes.Format.GetLength(0) > 0)
                                {
                                    objResults.Add("Format", item.ItemAttributes.Format[0]);
                                }
                            }
                            #endregion
                            #region Feature
                            if (item.ItemAttributes.Feature != null)
                            {
                                if (item.ItemAttributes.Feature.GetLength(0) > 0)
                                {
                                    if (objResults.ContainsKey("Description") == false)
                                    {
                                        objResults.Add("Description", item.ItemAttributes.Feature[0]);
                                    }
                                    else if (objResults.ContainsKey("Comments") == false)
                                    {
                                        objResults.Add("Comments", item.ItemAttributes.Feature[0]);
                                    }
                                }
                            }
                            #endregion
                            #region Image
                            if (item.LargeImage != null)
                            {
                                objResults.Add("Image", item.LargeImage.URL);
                            }
                            #endregion
                            #region ISBN
                            if (string.IsNullOrWhiteSpace(item.ItemAttributes.ISBN) == false)
                            {
                                objResults.Add("ISBN", item.ItemAttributes.ISBN);
                            }
                            #endregion
                            #region Language
                            if (item.ItemAttributes.Languages != null)
                            {
                                if (item.ItemAttributes.Languages.GetLength(0) > 0)
                                {
                                    objResults.Add("Language", item.ItemAttributes.Languages[0].Name);
                                }
                            }
                            #endregion
                            #region Links
                            if (string.IsNullOrEmpty(item.DetailPageURL) == false)
                            {
                                objResults.Add("Links", item.DetailPageURL);
                            }
                            #endregion
                            #region Pages
                            if (string.IsNullOrEmpty(item.ItemAttributes.NumberOfPages) == false)
                            {
                                objResults.Add("Pages", item.ItemAttributes.NumberOfPages);
                            }
                            #endregion
                            #region Platform
                            if (item.ItemAttributes.Platform != null)
                            {
                                if (item.ItemAttributes.Platform.GetLength(0) > 0)
                                {
                                    objResults.Add("Platform", item.ItemAttributes.Platform[0]);
                                }
                            }
                            #endregion
                            #region ProductGroup
                            if (string.IsNullOrEmpty(item.ItemAttributes.ProductGroup) == false)
                            {
                                objResults.Add("ProductGroup", item.ItemAttributes.ProductGroup);
                            }
                            #endregion
                            #region ProductTypeName
                            if (string.IsNullOrEmpty(item.ItemAttributes.ProductTypeName) == false)
                            {
                                objResults.Add("ProductTypeName", item.ItemAttributes.ProductTypeName);
                            }
                            #endregion
                            #region Price
                            if (item.ItemAttributes.ListPrice != null)
                            {
                                objResults.Add("Price", item.ItemAttributes.ListPrice.Amount);
                            }
                            #endregion
                            #region Rated
                            if (string.IsNullOrEmpty(item.ItemAttributes.AudienceRating) == false)
                            {
                                if (item.ItemAttributes.AudienceRating.Contains("PG-13"))
                                {
                                    objResults.Add("Rated", "PG-13");
                                }
                                else if (item.ItemAttributes.AudienceRating.Contains("NC-17"))
                                {
                                    objResults.Add("Rated", "NC-17");
                                }
                                else if (item.ItemAttributes.AudienceRating.Contains("PG"))
                                {
                                    objResults.Add("Rated", "PG");
                                }
                                else if (item.ItemAttributes.AudienceRating.Contains("R"))
                                {
                                    objResults.Add("Rated", "R");
                                }
                                else if (item.ItemAttributes.AudienceRating.Contains("G") || item.ItemAttributes.AudienceRating.Contains("Tous publics"))
                                {
                                    objResults.Add("Rated", "G");
                                }
                            }
                            #endregion
                            #region Rating
                            if (objResults.ContainsKey("Rating") == false)
                            {
                                if (item.CustomerReviews != null)
                                {
                                    if (item.CustomerReviews.HasReviews == true)
                                    {
                                        objResults.Add("Rating", GetRating(item.CustomerReviews.IFrameURL));
                                    }
                                }
                            }
                            #endregion
                            #region Released
                            if (string.IsNullOrWhiteSpace(item.ItemAttributes.ReleaseDate) == false)
                            {
                                DateTime date;
                                if (DateTime.TryParse(item.ItemAttributes.ReleaseDate, out date) == true)
                                {
                                    objResults.Add("Released", date);
                                }
                            }
                            else if (string.IsNullOrWhiteSpace(item.ItemAttributes.PublicationDate) == false)
                            {
                                DateTime date;
                                if (DateTime.TryParse(item.ItemAttributes.PublicationDate, out date) == true)
                                {
                                    objResults.Add("Released", date);
                                }
                            }
                            #endregion
                            #region RunTime
                            if (item.ItemAttributes.RunningTime != null)
                            {
                                objResults.Add("Runtime", (int?)item.ItemAttributes.RunningTime.Value);
                            }
                            #endregion
                            #region Studio
                            if (string.IsNullOrWhiteSpace(item.ItemAttributes.Studio) == false)
                            {
                                objResults.Add("Studio", item.ItemAttributes.Studio);
                            }
                            #endregion
                            #region Title
                            if (string.IsNullOrWhiteSpace(item.ItemAttributes.Title) == false)
                            {
                                objResults.Add("Title", item.ItemAttributes.Title);
                            }
                            #endregion
                            #region Tracks
                            if (item.Tracks != null)
                            {
                                if (item.Tracks[0].Track.GetLength(0) > 0)
                                {
                                    List <string> tracks = item.Tracks[0].Track.Select(node => node.Value).ToList();
                                    objResults.Add("Tracks", tracks);
                                }
                            }
                            #endregion
                            #region Types
                            if (item.BrowseNodes != null)
                            {
                                if (item.BrowseNodes.BrowseNode.GetLength(0) > 0)
                                {
                                    List <string> types = new List <string>();
                                    foreach (BrowseNode node in item.BrowseNodes.BrowseNode)
                                    {
                                        if (node.Ancestors.GetLength(0) > 0)
                                        {
                                            if (node.Ancestors[0].Name == "Genres" ||
                                                node.Ancestors[0].Name == "Styles" ||
                                                node.Ancestors[0].Name == "Nintendo DS" ||
                                                node.Ancestors[0].Name == "Categories" ||
                                                node.Ancestors[0].Name == "Categorías" ||
                                                node.Ancestors[0].Name == "Thèmes" ||
                                                node.Ancestors[0].Name == "Juegos" ||
                                                node.Ancestors[0].Name == "Genre (theme_browse-bin)" ||
                                                node.Ancestors[0].Name == "Les collections" ||
                                                node.Ancestors[0].Name == "Literature & Fiction" ||
                                                node.Ancestors[0].BrowseNodeId == "301138" ||
                                                node.Ancestors[0].BrowseNodeId == "301134" ||
                                                (node.Ancestors[0].BrowseNodeId == "425527031" && node.BrowseNodeId != "2486268031") ||
                                                node.Ancestors[0].BrowseNodeId == "466276" ||
                                                node.Ancestors[0].BrowseNodeId == "302068" ||
                                                node.Ancestors[0].BrowseNodeId == "924340031" ||
                                                node.Ancestors[0].BrowseNodeId == "301132" ||
                                                node.Ancestors[0].BrowseNodeId == "2" ||
                                                node.Ancestors[0].BrowseNodeId == "2396" ||
                                                node.Ancestors[0].Name == "Literatura y ficción")
                                            {
                                                types.Add(node.Name);
                                            }
                                            else if (node.Ancestors[0].IsCategoryRoot == false && node.Ancestors[0].Ancestors != null)
                                            {
                                                if (node.Ancestors[0].Ancestors.GetLength(0) > 0)
                                                {
                                                    if (node.Ancestors[0].Ancestors[0].Name == "Genres" ||
                                                        node.Ancestors[0].Name == "Nintendo DS" ||
                                                        node.Ancestors[0].Name == "Styles" ||
                                                        node.Ancestors[0].Name == "Categories" ||
                                                        node.Ancestors[0].Name == "Categorías" ||
                                                        node.Ancestors[0].Name == "Les collections" ||
                                                        node.Ancestors[0].Name == "Juegos" ||
                                                        node.Ancestors[0].Name == "Genre (theme_browse-bin)" ||
                                                        node.Ancestors[0].Name == "Literature & Fiction" ||
                                                        node.Ancestors[0].Name == "Literatura y ficción")
                                                    {
                                                        types.Add(node.Name);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    objResults.Add("Types", types);
                                }
                            }
                            #endregion
                        }
                    }
                }
                return(objResults);
            }
            catch (Exception ex)
            {
                Util.LogException(ex, asin);
                return(null);
            }
        }
        public static Hashtable Parse(string strUrl, bool getPage, string strSearch)
        {
            Hashtable objResuls = new Hashtable();

            try
            {
                string strResults;
                string strTemp;
                string coverlink = string.Empty;

                if (getPage == true)
                {
                    strResults = Util.GetHtmlPage(strUrl, Encoding.Default);
                }
                else
                {
                    strResults = strUrl;
                }

                objResuls.Add("Title", strSearch);
                objResuls.Add("Links", strUrl);

                if (string.IsNullOrEmpty(strResults))
                {
                    return(null);
                }

                #region Rating
                string strParsing = @"img_Rating";
                int    intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @"Item_StudioProductionRating";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = " out";
                    intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intTemp > -1)
                    {
                        string  rating = strResults.Substring(0, intTemp).Trim();
                        decimal decRating;
                        if (decimal.TryParse(rating, out decRating) == true)
                        {
                            decRating = decRating * 4;
                            objResuls.Add("Rating", (int)decRating);
                        }
                        else
                        {
                            rating = rating.Replace('.', ',');
                            if (decimal.TryParse(rating, out decRating) == true)
                            {
                                decRating = decRating * 4;
                                objResuls.Add("Rating", (int)decRating);
                            }
                        }
                    }
                }
                #endregion
                #region CoverUrl
                strParsing = @"Boxcover";
                intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @"href=""";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"""";
                    coverlink  = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                }

                #endregion
                #region Description
                strParsing = @"Section Synopsis";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"Tagline"">";
                int intBegin = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"</div";
                    objResuls.Add("Description", Util.PurgeHtml(strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal))));
                }
                else
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"</span>";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"<";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intBegin > -1)
                    {
                        objResuls.Add("Description", Util.PurgeHtml(strResults.Substring(0, intBegin)));
                    }
                }
                #endregion
                #region Runtime
                strParsing = @"Length</strong>";
                intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @"<";
                    strTemp    = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                    strParsing = "hrs.";
                    intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    int total = 0;
                    if (intTemp > -1)
                    {
                        string strHour = strTemp.Substring(0, intTemp).Trim();
                        int    hour;
                        if (int.TryParse(strHour, out hour) == true)
                        {
                            total = hour * 60;
                        }

                        string strMin = strTemp.Substring(intTemp + strParsing.Length, strTemp.IndexOf("mins", StringComparison.Ordinal) - (intTemp + strParsing.Length)).Trim();
                        int    min;
                        if (int.TryParse(strMin, out min) == true)
                        {
                            total += min;
                        }

                        if (total > 0)
                        {
                            objResuls.Add("Runtime", total);
                        }
                    }
                }
                #endregion
                #region Released
                strParsing = @"Released</strong>";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.InvariantCulture) + strParsing.Length);
                strParsing = @"<";
                strTemp    = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.InvariantCulture)).Trim();
                DateTime date;
                if (DateTime.TryParse(strTemp, CultureInfo.CreateSpecificCulture("en-US"), DateTimeStyles.None, out date) == true)
                {
                    objResuls.Add("Released", date);
                }
                #endregion
                #region Studio
                strParsing = @"Studio</strong>";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @""">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";

                    objResuls.Add("Studio", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim());
                }
                #endregion
                #region Actors
                strParsing = @"Section Cast";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"<li>";
                    string[]      objTables = Regex.Split(strResults, strParsing);
                    List <Artist> lstActors = new List <Artist>();

                    foreach (string item in objTables)
                    {
                        if (string.IsNullOrEmpty(item.Trim()) == false && item.StartsWith(@"<a href") == true && item.Contains("pornstars.html"))
                        {
                            strParsing = @"href=""";
                            strTemp    = item.Trim().Substring(item.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                            strParsing = @"""";
                            string url = strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal));
                            strParsing = @">";
                            strTemp    = strTemp.Substring(strTemp.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                            strParsing = @"<";
                            string name = strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal));

                            if (string.IsNullOrWhiteSpace(name) == false)
                            {
                                bool   isNew;
                                Artist artist = (ArtistServices.Get(name, out isNew));

                                lstActors.Add(artist);

                                if (MySettings.FastSearch == false)
                                {
                                    if (url.Contains("http:") == false)
                                    {
                                        url = "http://www.adultdvdempire.com" + url;
                                    }

                                    ArtistServices.Fill(ParsePortrait(url), artist, name);
                                }
                            }
                        }
                    }

                    objResuls.Add("Actors", lstActors);
                }
                #endregion
                #region Genres
                strParsing = @"Section Categories";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"href=";

                    string[]      objTables = strResults.Split(new[] { strParsing }, StringSplitOptions.RemoveEmptyEntries);
                    List <string> lstGenres = new List <string>();

                    foreach (string item in objTables)
                    {
                        if (item.Contains(@"/category/") && item.StartsWith("http:"))
                        {
                            strParsing = @">";
                            strTemp    = item.Trim().Substring(item.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                            strParsing = @"<";
                            strTemp    = strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal));
                            if (string.IsNullOrWhiteSpace(strTemp) == false)
                            {
                                lstGenres.Add(Util.PurgeHtml(strTemp));
                            }
                        }
                    }
                    objResuls.Add("Genre", lstGenres);
                }
                #endregion
                #region Image

                if (string.IsNullOrWhiteSpace(coverlink) == false)
                {
                    objResuls.Add("Image", coverlink);
                }

                #endregion
                #region Background
                if (string.IsNullOrWhiteSpace(coverlink) == false)
                {
                    coverlink = coverlink.Replace("h.jpg", "bh.jpg");
                    objResuls.Add("Background", coverlink);
                }
                #endregion


                return(objResuls);
            }
            catch (Exception ex)
            {
                Util.LogException(ex, strUrl);
                return(null);
            }
        }
Exemple #14
0
        public static Hashtable Parse(string strUrl, bool getPage, string strSearch)
        {
            Hashtable objResuls = new Hashtable();

            try
            {
                string   strResults;
                string   strTemp;
                string[] objTables;

                if (getPage == true)
                {
                    strResults = Util.GetHtmlPage(strUrl, Encoding.Default, BrowserType.Firefox10, true);
                }
                else
                {
                    strResults = strUrl;
                }

                objResuls.Add("Title", strSearch);
                objResuls.Add("Links", strUrl);

                if (string.IsNullOrEmpty(strResults))
                {
                    return(null);
                }

                #region Image
                string strParsing = @"/images.asp?pid=";
                int    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin);
                    strParsing = @"""";
                    strTemp    = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                    string imagePage = Util.GetHtmlPage(@"http://www.cduniverse.com/" + strTemp.Replace("amp;", ""), Encoding.Default, BrowserType.Firefox10, true);

                    if (string.IsNullOrWhiteSpace(imagePage) == false)
                    {
                        strParsing = @"<center><p><img src=""";
                        imagePage  = imagePage.Substring(imagePage.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"""";


                        objResuls.Add("Image", imagePage.Substring(0, imagePage.IndexOf(strParsing, StringComparison.Ordinal)));
                    }
                }
                #endregion
                #region Genres
                strParsing = @"nobr>Category </nobr>";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"<nobr>Director </nobr>";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                if (intBegin == -1)
                {
                    strParsing = @"<nobr>Starring </nobr>";
                }

                intBegin = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    string strGenres = strResults.Substring(0, intBegin);

                    strParsing = @"href=";

                    objTables = strGenres.Split(new[] { strParsing }, StringSplitOptions.RemoveEmptyEntries);
                    List <string> lstGenres = new List <string>();

                    foreach (string item in objTables)
                    {
                        strParsing = @">";
                        strTemp    = item.Trim().Substring(item.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"<";
                        strTemp    = strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal));
                        if (string.IsNullOrWhiteSpace(strTemp) == false)
                        {
                            lstGenres.Add(Util.PurgeHtml(strTemp));
                        }
                    }
                    objResuls.Add("Genre", lstGenres);
                }

                #endregion
                #region Director
                strParsing = @"<nobr>Director </nobr>";
                int intTemp = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @""">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";
                    objResuls.Add("Directed", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                }
                #endregion
                #region Actors
                strParsing = @"<nobr>Starring </nobr>";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"<!---- trimable --->";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    string strActors = strResults.Substring(0, intBegin);
                    strParsing = @"categorylink";

                    objTables = strActors.Split(new[] { strParsing }, StringSplitOptions.RemoveEmptyEntries);
                    List <Artist> lstActors = new List <Artist>();

                    foreach (string item in objTables)
                    {
                        if (string.IsNullOrEmpty(item.Trim()) == false &&
                            item.StartsWith(@"' href="))
                        {
                            strParsing = @">";
                            strTemp    = item.Trim().Substring(item.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                            strParsing = @"<";
                            string name = strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal));
                            bool   isNew;
                            Artist artist = (ArtistServices.Get(name, out isNew));
                            if (MySettings.FastSearch == false)
                            {
                                string errorMessage;
                                ArtistServices.GetInfoFromWeb(artist, false, Provider.Iafd, out errorMessage, false);
                            }

                            lstActors.Add(artist);
                        }
                    }


                    objResuls.Add("Actors", lstActors);
                }
                #endregion
                #region Description
                strParsing = @"<span itemprop=""description"">";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"</span>";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    objResuls.Add("Description", Util.PurgeHtml(strResults.Substring(0, intBegin)));
                }
                #endregion
                #region Publisher
                strParsing = @"<nobr>Studio </nobr>";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @""">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</a></td>";

                    objResuls.Add("Studio", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                }
                #endregion
                #region Released
                strParsing = @"<nobr>Release Date </nobr>";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.InvariantCulture) + strParsing.Length);
                strParsing = @"<td>";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.InvariantCulture) + strParsing.Length);
                strParsing = @"</td>";

                objResuls.Add("Released", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.InvariantCulture)));
                #endregion
                #region Background
                strParsing = @"class='screenshot'";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"src='";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"'";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intBegin > -1)
                    {
                        objResuls.Add("Background", strResults.Substring(0, intBegin));
                    }
                }
                #endregion
                #region Rating
                strParsing = @"Average Rating:";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"(";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"out";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intBegin > -1)
                    {
                        strTemp = strResults.Substring(0, intBegin);
                        if (int.TryParse(strTemp, out intBegin) == true)
                        {
                            objResuls.Add("Rating", intBegin * 4);
                        }
                    }
                }
                #endregion
                #region Comments
                strParsing = @"reviewtext";
                intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intBegin > -1)
                {
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @">";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    strResults = strResults.Substring(intBegin + strParsing.Length);
                    strParsing = @"<";
                    intBegin   = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intBegin > -1)
                    {
                        objResuls.Add("Comments", Util.PurgeHtml(strResults.Substring(0, intBegin)));
                    }
                }
                #endregion

                return(objResuls);
            }
            catch (Exception ex)
            {
                Util.LogException(ex, strUrl);
                return(null);
            }
        }
        public static Hashtable Parse(string strUrl, bool getPage, string strSearch)
        {
            Hashtable objResuls = new Hashtable();

            try
            {
                string strResults;
                string temp;

                if (getPage)
                {
                    strResults = Util.GetHtmlPage(strUrl, Encoding.Default);
                }
                else
                {
                    strResults = strUrl;
                }

                objResuls.Add("Title", strSearch);
                objResuls.Add("Links", strUrl);
                #region Studio
                string strParsing = @"<SPAN CLASS=""details_title_studio_text"">";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @">";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"</A>";

                objResuls.Add("Studio", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                #endregion
                #region Image
                strParsing = @"<a id=""productimg_1""";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"<img src=""";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @""" name=";

                objResuls.Add("Image", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                #endregion
                #region Rating
                strParsing = @"Avg Rating";
                int intTemp = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @"</B>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"stars";
                    temp       = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                    double rating;
                    if (double.TryParse(temp, out rating) == true)
                    {
                        objResuls.Add("Rating", (double?)(rating * 4));
                    }
                    else
                    {
                        temp = temp.Replace(".", ",");
                        if (double.TryParse(temp, out rating) == true)
                        {
                            objResuls.Add("Rating", (double?)(rating * 4));
                        }
                    }
                }
                #endregion
                #region Background
                strParsing = @"javascript:goLoginPage";
                intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);

                    strParsing = @"SRC=""";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"""";

                    temp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                    if (string.IsNullOrWhiteSpace(temp) == false)
                    {
                        objResuls.Add("Background", temp.Replace("_sm", "_hu"));
                    }
                }
                #endregion
                #region Description
                strParsing = @"Synopsis:</B></TD><TD ALIGN=""left"">";
                intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @"</TD>";

                    objResuls.Add("Description", Util.PurgeHtml(strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal))));
                }
                #endregion
                #region RunTime
                strParsing = @"<B>Running Time:</B></TD><TD ALIGN=""left"">";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"</TD>";
                string strTemp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                strParsing = @"minutes";
                if (strTemp.IndexOf(strParsing, StringComparison.Ordinal) > -1)
                {
                    objResuls.Add("Runtime", strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal)));
                }
                #endregion
                #region Released
                strParsing = @"<B>Added on:</B></TD><TD ALIGN=""left"">";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"</TD>";
                temp       = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                temp       = temp.Replace("th, ", " ");
                objResuls.Add("Released", temp);
                #endregion
                #region Genre
                strParsing = @"Categories:";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"Directed By:";

                string strGenres = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                strParsing = @"<A HREF=""";
                string[]      objTables = strGenres.Split(new[] { strParsing }, StringSplitOptions.RemoveEmptyEntries);
                List <string> lstGenres = new List <string>();

                foreach (string item in objTables)
                {
                    if (string.IsNullOrEmpty(item.Trim()) == false)
                    {
                        strParsing = @">";
                        strTemp    = item.Trim().Substring(item.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"<";
                        string genre = strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal));
                        if (string.IsNullOrWhiteSpace(genre) == false)
                        {
                            lstGenres.Add(genre);
                        }
                    }
                }
                objResuls.Add("Genre", lstGenres);

                #endregion
                #region Director
                strParsing = @"<B>Directed By:</B></TD><TD ALIGN=""left"">";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"</TD>";

                objResuls.Add("Directed", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                #endregion
                #region Actors
                strParsing = @"Starring:</B></TD><TD ALIGN=""left""><A HREF=""";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"</A></TD></TR></TABLE>";
                intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    string[]      strActors = strResults.Substring(0, intTemp).Split(new[] { @"http:" }, StringSplitOptions.RemoveEmptyEntries);
                    List <Artist> lstActors = new List <Artist>();
                    Parallel.ForEach(strActors, item =>
                    {
                        strTemp = item;
                        if (strTemp.StartsWith(@"//"))
                        {
                            strParsing = ">";
                            strTemp    =
                                strTemp.Substring(strTemp.IndexOf(strParsing, StringComparison.Ordinal) +
                                                  strParsing.Length);
                            strParsing = "<";
                            intTemp    = strTemp.IndexOf(strParsing, StringComparison.CurrentCultureIgnoreCase);
                            if (intTemp > -1)
                            {
                                string name = strTemp.Substring(0, intTemp);
                                bool isNew;
                                Artist artist = (ArtistServices.Get(name, out isNew));
                                if (MySettings.FastSearch == false)
                                {
                                    string errorMessage;
                                    ArtistServices.GetInfoFromWeb(artist, false, Provider.Iafd, out errorMessage, false);
                                }

                                lstActors.Add(artist);
                            }
                        }
                    });
                    if (lstActors.Count > 0)
                    {
                        objResuls.Add("Actors", lstActors);
                    }
                }

                #endregion
                return(objResuls);
            }
            catch (Exception ex)
            {
                Util.LogException(ex, strUrl);
                return(null);
            }
        }
Exemple #16
0
        public static Hashtable Parse(string strUrl, bool getPage, string strSearch)
        {
            Hashtable objResults = new Hashtable();

            try
            {
                string strResults;

                if (getPage)
                {
                    strResults = Util.GetHtmlPage(strUrl, Encoding.Default, BrowserType.Firefox4);
                    objResults.Add("Links", strUrl);
                }
                else
                {
                    strResults = strUrl;
                }

                if (string.IsNullOrWhiteSpace(strResults) == false)
                {
                    string strParsing;
                    if (strSearch.Contains("("))
                    {
                        strParsing = @"(";
                        strSearch  = strSearch.Substring(0, strSearch.IndexOf(strParsing, StringComparison.Ordinal));
                        objResults.Add("Title", strSearch);
                    }

                    #region Image
                    strParsing = @"img_primary";
                    int    intTmp = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    string strTemp;
                    if (intTmp > -1)
                    {
                        strResults = strResults.Substring(intTmp + strParsing.Length);
                        strParsing = @"<img";
                        strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"src=""";
                        strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"""";
                        strTemp    = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                        if (strTemp.Contains("name.png") == false)
                        {
                            objResults.Add("Image", strTemp);
                        }
                    }
                    #endregion
                    #region Rated
                    strParsing = @"contentRating";
                    intTmp     = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intTmp > -1)
                    {
                        strResults = strResults.Substring(intTmp + strParsing.Length);
                        strParsing = @"content=""";
                        strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"""";
                        string rated = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                        if (string.IsNullOrWhiteSpace(rated) == false)
                        {
                            objResults.Add("Rated", rated);
                        }
                    }
                    #endregion
                    #region IMDB
                    strParsing = @"ratingValue"">";
                    intTmp     = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intTmp > -1)
                    {
                        strResults = strResults.Substring(intTmp + strParsing.Length);
                        strParsing = @"</";
                        intTmp     = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                        if (intTmp > -1)
                        {
                            string  strRating = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                            decimal dclTemp;

                            if (decimal.TryParse(strRating, out dclTemp) == false)
                            {
                                decimal.TryParse(strRating.Replace(".", ","), out dclTemp);
                            }

                            if (dclTemp > 0)
                            {
                                objResults.Add("Rating", (long)(dclTemp * 2));
                            }
                        }
                    }
                    #endregion
                    #region Directed
                    strParsing = @"Director:</h4>";
                    intTmp     = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intTmp > -1)
                    {
                        strResults = strResults.Substring(intTmp + strParsing.Length);
                        strParsing = @"itemprop=""name"">";
                        strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"</";

                        string director = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                        if (string.IsNullOrWhiteSpace(director) == false)
                        {
                            List <Artist> directors = new List <Artist>();
                            bool          isNew;
                            directors.Add(ArtistServices.Get(director, out isNew));

                            objResults.Add("Director", directors);
                        }
                    }
                    #endregion
                    #region Actors
                    strParsing = @"cast_list";
                    intTmp     = strResults.IndexOf(strParsing, StringComparison.InvariantCultureIgnoreCase);
                    if (intTmp > -1)
                    {
                        strResults = strResults.Substring(intTmp + strParsing.Length);
                        strParsing = @"</table>";
                        intTmp     = strResults.IndexOf(strParsing, StringComparison.CurrentCultureIgnoreCase);
                        if (intTmp > -1)
                        {
                            string[]      strActors = strResults.Substring(0, intTmp).Split(new[] { @"<tr" }, StringSplitOptions.RemoveEmptyEntries);
                            List <Artist> lstActors = new List <Artist>();
                            foreach (string item in strActors)
                            {
                                strTemp = item;
                                string image = string.Empty;
                                strParsing = @"loadlate=""";
                                intTmp     = strTemp.IndexOf(strParsing, StringComparison.Ordinal);
                                if (intTmp > -1)
                                {
                                    strTemp    = strTemp.Substring(intTmp + strParsing.Length);
                                    strParsing = @"""";
                                    image      = strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal));
                                }

                                strParsing = @"itemprop=""name"">";
                                intTmp     = strTemp.IndexOf(strParsing, StringComparison.Ordinal);
                                if (intTmp > -1)
                                {
                                    strTemp    = strTemp.Substring(intTmp + strParsing.Length);
                                    strParsing = @"</";
                                    intTmp     = strTemp.IndexOf(strParsing, StringComparison.CurrentCultureIgnoreCase);
                                    if (intTmp > -1)
                                    {
                                        string fullname = strTemp.Substring(0, intTmp);
                                        bool   isNew;
                                        Artist objArtist = ArtistServices.Get(fullname, out isNew);

                                        if (string.IsNullOrWhiteSpace(image) == false && MySettings.FastSearch == false)
                                        {
                                            if (image.Contains(@"noname.png") == false)
                                            {
                                                objArtist.Picture = Util.GetImage(image);
                                            }
                                        }

                                        lstActors.Add(objArtist);
                                    }
                                }
                            }
                            if (lstActors.Count > 0)
                            {
                                objResults.Add("Actors", lstActors);
                            }
                        }
                    }
                    #endregion
                    #region Description
                    strParsing = @"Storyline";
                    intTmp     = strResults.IndexOf(strParsing, StringComparison.InvariantCultureIgnoreCase);
                    if (intTmp > -1)
                    {
                        strResults = strResults.Substring(intTmp + strParsing.Length);
                        int tmp2 = strResults.IndexOf(@"Plot Keywords:", StringComparison.Ordinal);
                        strParsing = @"<p>";
                        intTmp     = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                        if (intTmp > -1 && (intTmp < tmp2 || tmp2 == -1))
                        {
                            strResults = strResults.Substring(intTmp + strParsing.Length);
                            strParsing = @"</p>";
                            intTmp     = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                            strParsing = @"<em";
                            tmp2       = strResults.IndexOf(strParsing, StringComparison.Ordinal);

                            if (tmp2 > -1 && tmp2 < intTmp)
                            {
                                intTmp = tmp2;
                            }

                            if (strResults.Substring(0, intTmp).Contains("full synopsis") == false)
                            {
                                objResults.Add("Description", Util.PurgeHtml(strResults.Substring(0, intTmp)));
                            }
                        }
                    }
                    #endregion
                    #region Genre
                    strParsing = @"Genres:";
                    intTmp     = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intTmp > -1)
                    {
                        strResults = strResults.Substring(intTmp + strParsing.Length);

                        int intPosDiv   = strResults.IndexOf("</div>", StringComparison.Ordinal);
                        int intPosClass = strResults.IndexOf("</a> <a class", StringComparison.Ordinal);

                        if (intPosDiv < intPosClass || intPosClass == -1)
                        {
                            strParsing = @"</div>";
                        }
                        else
                        {
                            strParsing = @" <a class=";
                        }

                        string strGenre = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                        strParsing = @"<a href=""";
                        string[]      strGenres = strGenre.Split(new[] { strParsing }, StringSplitOptions.RemoveEmptyEntries);
                        List <string> lstGenres = new List <string>();

                        foreach (string item in strGenres)
                        {
                            if (string.IsNullOrEmpty(item.Trim()) == false && item.StartsWith(@"/"))
                            {
                                strParsing = @">";
                                strTemp    = item.Trim();
                                intTmp     = strTemp.IndexOf(strParsing, StringComparison.Ordinal);
                                if (intTmp > -1)
                                {
                                    strTemp    = strTemp.Substring(intTmp + strParsing.Length);
                                    strParsing = @"<";
                                    string genre = strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal));
                                    genre = Util.PurgeHtml(genre);
                                    lstGenres.Add(genre);
                                }
                            }
                        }
                        objResults.Add("Types", lstGenres);
                    }
                    #endregion
                    #region Released
                    strParsing = @"Release Date:</h4>";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"(";

                    string relased = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                    if (string.IsNullOrWhiteSpace(relased) == false)
                    {
                        DateTime date;
                        if (DateTime.TryParse(relased.Trim(), out date) == true)
                        {
                            objResults.Add("Released", date);
                        }
                    }
                    #endregion
                    #region Studio
                    strParsing = @"Production Co:";
                    intTmp     = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intTmp > -1)
                    {
                        strResults = strResults.Substring(intTmp + strParsing.Length);
                        strParsing = @"itemprop=""name"">";
                        strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"<";

                        string studio = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim();
                        if (string.IsNullOrWhiteSpace(studio) == false)
                        {
                            objResults.Add("Studio", studio);
                        }
                    }
                    #endregion
                    #region Runtime
                    strParsing = @"Runtime:";
                    intTmp     = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intTmp > -1)
                    {
                        strResults = strResults.Substring(intTmp + strParsing.Length);
                        strParsing = @""">";
                        strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"<";

                        string runtime = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim();
                        if (string.IsNullOrWhiteSpace(runtime) == false)
                        {
                            runtime = runtime.Replace("min", "");
                            int intvalue;
                            if (int.TryParse(runtime, out intvalue) == true)
                            {
                                objResults.Add("Runtime", intvalue);
                            }
                        }
                    }
                    #endregion
                    #region Comments
                    if (getPage)
                    {
                        strResults = Util.GetHtmlPage(strUrl + "usercomments?filter=love&spoiler=hide", Encoding.Default, BrowserType.Firefox4);
                        if (string.IsNullOrWhiteSpace(strResults) == false)
                        {
                            strParsing = @"reviewBody"">";
                            intTmp     = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                            if (intTmp > -1)
                            {
                                strResults = strResults.Substring(intTmp + strParsing.Length);

                                intTmp = strResults.IndexOf("</p>", StringComparison.Ordinal);

                                objResults.Add("Comments", Util.PurgeHtml(strResults.Substring(0, intTmp)));
                            }
                        }
                    }
                    #endregion
                }

                return(objResults);
            }
            catch (Exception ex)
            {
                Util.LogException(ex, strUrl);
                return(null);
            }
        }
        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);
            }
        }
Exemple #18
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);
            }
        }
        public static Hashtable Parse(string strUrl, bool getPage, string strSearch)
        {
            Hashtable objResuls = new Hashtable();

            try
            {
                string strResults;

                if (getPage == true)
                {
                    strResults = Util.GetHtmlPage(strUrl, Encoding.Default);
                }
                else
                {
                    strResults = strUrl;
                }

                string[] objTables;

                objResuls.Add("Title", strSearch);
                objResuls.Add("Links", strUrl);
                #region Publisher
                string strParsing = @"Studio / Publisher:  ";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.InvariantCulture) + strParsing.Length);
                strParsing = @">";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.InvariantCulture) + strParsing.Length);
                strParsing = @"<";

                objResuls.Add("Studio", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.InvariantCulture)));
                #endregion
                #region Image
                strParsing = @"id=""COVER:";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"src=""";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"""";

                objResuls.Add("Image", "http://e.orgazmik.com" + strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                #endregion
                #region Directed
                strParsing = @"<strong>Director</strong>";
                int intTmp = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTmp > -1)
                {
                    strResults = strResults.Substring(intTmp + strParsing.Length);
                    strParsing = @"#183D74"">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";

                    objResuls.Add("Directed", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                }
                #endregion
                #region Actors
                strParsing = @"<strong>Actors</strong>";
                intTmp     = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTmp > -1)
                {
                    strResults = strResults.Substring(intTmp + strParsing.Length);
                    strParsing = @"#183D74"">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"</td>";
                    string strActors = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                    strParsing = @",";

                    objTables = strActors.Split(new[] { strParsing }, StringSplitOptions.RemoveEmptyEntries);
                    List <Artist> lstActors = new List <Artist>();

                    foreach (string item in objTables)
                    {
                        if (string.IsNullOrEmpty(item.Trim()) == false)
                        {
                            bool   isNew;
                            Artist actor = ArtistServices.Get(item.Trim(), out isNew);

                            if (MySettings.FastSearch == false)
                            {
                                string errorMessage;
                                ArtistServices.GetInfoFromWeb(actor, false, Provider.Iafd, out errorMessage, false);
                            }

                            lstActors.Add(actor);
                        }
                    }

                    objResuls.Add("Actors", lstActors);
                }
                #endregion
                #region Genres
                strParsing = @"<strong>Categories</strong>";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"#183D74"">";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"</td>";

                string strGenres = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                strParsing = @"<a href=";

                objTables = strGenres.Split(new[] { strParsing }, StringSplitOptions.RemoveEmptyEntries);
                List <string> lstGenres = new List <string>();

                foreach (string item in objTables)
                {
                    if (string.IsNullOrEmpty(item.Trim()) == false &&
                        item.StartsWith(@"""/film"))
                    {
                        strParsing = @">";
                        string strTemp = item.Trim().Substring(item.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                        strParsing = @"<";
                        lstGenres.Add(strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal)));
                    }
                }
                objResuls.Add("Genre", lstGenres);
                #endregion
                #region Released
                strParsing = @"Catalog Date: ";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);

                objResuls.Add("Released", strResults.Substring(0, 10));
                #endregion
                #region RunTime
                intTmp = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTmp > -1)
                {
                    strParsing = @"<strong>Length:</strong>";
                    strResults = strResults.Substring(intTmp + strParsing.Length);
                    strParsing = @"Min.";
                    intTmp     = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                    if (intTmp > -1)
                    {
                        objResuls.Add("Runtime", strResults.Substring(0, intTmp).Trim());
                    }
                }

                #endregion
                return(objResuls);
            }
            catch (Exception ex)
            {
                Util.LogException(ex, strUrl);
                return(null);
            }
        }
Exemple #20
0
        public static Hashtable Parse(string strUrl, bool getPage)
        {
            Hashtable objResuls = new Hashtable();

            try
            {
                string strResults;
                strUrl = strUrl.Replace(@"/fr/", @"/en/");

                if (getPage)
                {
                    strResults = Util.GetHtmlPage(strUrl, Encoding.Default);
                }
                else
                {
                    strResults = strUrl;
                }
                objResuls.Add("Links", strUrl);
                #region Image
                string strParsing = @"onmouseout=""document.getElementById('cover').src='";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"'";

                string temp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));

                objResuls.Add("Image", temp);
                #endregion
                #region Rating
                strParsing = @"images/stars-";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @".png";

                temp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                temp = temp.Replace("-", ".");

                double rating;
                if (double.TryParse(temp, out rating) == true)
                {
                    objResuls.Add("Rating", rating * 4);
                }
                else
                {
                    temp = temp.Replace(".", ",");
                    if (double.TryParse(temp, out rating) == true)
                    {
                        objResuls.Add("Rating", rating * 4);
                    }
                }
                #endregion
                #region Studio
                strParsing = @"Studio:";
                int intTemp = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @"title=""";
                    strResults =
                        strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) +
                                             strParsing.Length);
                    strParsing = @"""";
                    temp       = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim();
                    if (string.IsNullOrWhiteSpace(temp) == false)
                    {
                        objResuls.Add("Studio", temp);
                    }
                }

                #endregion
                #region Director
                strParsing = @"Director:";
                intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @"title=""";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"""";

                    objResuls.Add("Directed", strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                }
                #endregion
                #region RunTime
                strParsing = @"Approximate Running Time:</strong>";
                intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @"duration";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";
                    temp       = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)).Trim();
                    if (string.IsNullOrWhiteSpace(temp) == false)
                    {
                        TimeSpan time;
                        if (TimeSpan.TryParse(temp, out time))
                        {
                            objResuls.Add("Runtime", time.TotalMinutes);
                        }
                    }
                }
                #endregion
                #region Released
                strParsing = @"Released:</strong>";
                intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @">";
                    strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                    strParsing = @"<";

                    temp = Util.PurgeHtml(strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal)));
                    if (string.IsNullOrEmpty(temp) == false)
                    {
                        DateTime date;
                        if (DateTime.TryParseExact(temp, "yyyy", new CultureInfo("en-US"), DateTimeStyles.None, out date))
                        {
                            objResuls.Add("Released", date);
                        }
                    }
                }
                #endregion
                #region Description
                strParsing = @"class=""video_description""";
                intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @">";
                    strResults =
                        strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) +
                                             strParsing.Length);
                    strParsing = @"<span id=";

                    objResuls.Add("Description",
                                  Util.PurgeHtml(strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal))));
                }

                #endregion
                #region Genre
                strParsing = @"Categories";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"</div>";
                string strGenres = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                strParsing = @"title=";

                string[]      objTables = strGenres.Split(new[] { strParsing }, StringSplitOptions.RemoveEmptyEntries);
                List <string> lstGenres = new List <string>();

                foreach (string item in objTables)
                {
                    if (string.IsNullOrEmpty(item.Trim()) == false && item.StartsWith(":") == false)
                    {
                        strParsing = @"->";
                        intTemp    = item.IndexOf(strParsing, StringComparison.Ordinal);
                        if (intTemp > -1)
                        {
                            string strTemp = item.Trim().Substring(intTemp + strParsing.Length);
                            strParsing = @"""";
                            lstGenres.Add(strTemp.Substring(0, strTemp.IndexOf(strParsing, StringComparison.Ordinal)));
                        }
                    }
                }
                objResuls.Add("Genre", lstGenres);
                #endregion
                #region Background
                strParsing = @"<img class=""shot""";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"src=""";
                strResults = strResults.Substring(strResults.IndexOf(strParsing, StringComparison.Ordinal) + strParsing.Length);
                strParsing = @"""";

                temp = strResults.Substring(0, strResults.IndexOf(strParsing, StringComparison.Ordinal));
                if (string.IsNullOrWhiteSpace(temp) == false)
                {
                    objResuls.Add("Background", temp);
                }
                #endregion
                #region Actors
                strParsing = @"Stars:";
                intTemp    = strResults.IndexOf(strParsing, StringComparison.Ordinal);
                if (intTemp > -1)
                {
                    strResults = strResults.Substring(intTemp + strParsing.Length);
                    strParsing = @"</div>";

                    intTemp = strResults.IndexOf(strParsing, StringComparison.CurrentCultureIgnoreCase);
                    if (intTemp > -1)
                    {
                        string[]      strActors = strResults.Substring(0, intTemp).Split(new string[] { @"<a href=""" }, StringSplitOptions.RemoveEmptyEntries);
                        List <Artist> lstActors = new List <Artist>();
                        Parallel.ForEach(strActors, item =>
                        {
                            if (item.StartsWith(@"http://"))
                            {
                                strParsing  = @"title=""";
                                string name =
                                    item.Substring(item.IndexOf(strParsing, StringComparison.Ordinal) +
                                                   strParsing.Length);
                                strParsing = @"""";
                                name       = name.Substring(0, name.IndexOf(strParsing, StringComparison.Ordinal));

                                bool isNew;
                                Artist artist = (ArtistServices.Get(name, out isNew));
                                if (MySettings.FastSearch == false)
                                {
                                    string errorMessage;
                                    ArtistServices.GetInfoFromWeb(artist, false, Provider.Iafd, out errorMessage, false);
                                }

                                lstActors.Add(artist);
                            }
                        });
                        if (lstActors.Count > 0)
                        {
                            objResuls.Add("Actors", lstActors);
                        }
                    }
                }
                #endregion
                return(objResuls);
            }
            catch (Exception ex)
            {
                Util.LogException(ex, strUrl);
                return(null);
            }
        }
Exemple #21
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);
            }
        }
Exemple #22
0
        public static AlloCine MovieToObject(JObject objRest, LanguageType languageType)
        {
            AlloCine objItem = null;

            if (objRest != null)
            {
                //Fix since v2.7.12.0
                if (objRest["movie"] != null)
                {
                    objItem = new AlloCine();

                    if (objRest["movie"]["originalTitle"] != null)
                    {
                        objItem.OriginalTitle = (string)objRest["movie"]["originalTitle"];
                    }
                    if (objRest["movie"]["nationality"] != null)
                    {
                        objItem.Country = (string)objRest["movie"]["nationality"][0]["$"];
                    }

                    objItem.Id          = (string)objRest["movie"]["code"];
                    objItem.Description = (string)objRest["movie"]["synopsis"];

                    if (objRest["movie"]["synopsisShort"] != null)
                    {
                        objItem.Tagline = (string)objRest["movie"]["synopsisShort"];
                    }

                    if (objRest["movie"]["poster"] != null)
                    {
                        objItem.PosterOriginal = (string)objRest["movie"]["poster"]["href"];
                    }

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

                    switch (languageType)
                    {
                    case LanguageType.BR:
                    case LanguageType.PT:
                        objItem.Url = @"http://www.adorocinema.com/filmes/filme-" + objItem.Id;
                        break;

                    default:
                        objItem.Url = @"http://www.allocine.fr/film/fichefilm_gen_cfilm=" + objItem.Id + ".html";
                        break;
                    }

                    if (objRest["movie"]["trailer"] != null)
                    {
                        objItem.Trailer = (string)objRest["movie"]["trailer"]["href"];
                    }

                    string runtime = (string)objRest["movie"]["runtime"];
                    int    intRunTime;
                    if (int.TryParse(runtime, out intRunTime))
                    {
                        objItem.Runtime = (int?)new TimeSpan(0, 0, intRunTime).TotalMinutes;
                    }

                    string relased = string.Empty;
                    if (objRest["movie"]["release"] != null)
                    {
                        relased = (string)objRest["movie"]["release"]["releaseDate"];
                    }

                    if (string.IsNullOrWhiteSpace(relased) == false)
                    {
                        DateTime date;
                        if (DateTime.TryParse(relased, out date) == true)
                        {
                            objItem.Released = date;
                        }
                    }

                    JArray cast = (JArray)objRest["movie"]["castMember"];

                    //Fix since 2.6.0.0
                    if (cast != null)
                    {
                        objItem.Cast      = new List <Artist>();
                        objItem.Directors = new List <Artist>();

                        foreach (JObject item in cast)
                        {
                            string picture = string.Empty;
                            if (item["picture"] != null)
                            {
                                picture = (string)item["picture"]["href"];
                            }

                            string name = (string)item["person"]["name"];
                            string job  = (string)item["activity"]["code"];

                            if (string.IsNullOrWhiteSpace(name) == false)
                            {
                                bool   isNew;
                                Artist artist = (ArtistServices.Get(name, out isNew));

                                if (string.IsNullOrWhiteSpace(picture) == false && MySettings.FastSearch == false)
                                {
                                    artist.Picture = Util.GetImage(picture);
                                }

                                if (job == "8002")
                                {
                                    objItem.Directors.Add(artist);
                                }
                                else if (job == "8001")
                                {
                                    objItem.Cast.Add(artist);
                                }
                            }
                        }
                    }

                    JArray genre = (JArray)objRest["movie"]["genre"];
                    objItem.Genres = new List <string>();

                    foreach (JObject item in genre)
                    {
                        objItem.Genres.Add((string)item["$"]);
                    }

                    JArray media = (JArray)objRest["movie"]["media"];

                    //Fix Since version 2.5.5.0
                    if (media != null)
                    {
                        foreach (JObject item in media)
                        {
                            if ((string)item["type"]["$"] == "Photo")
                            {
                                objItem.BackdropOriginal = (string)item["thumbnail"]["href"];
                                break;
                            }
                        }
                    }

                    if (objRest["movie"]["release"] != null)
                    {
                        if (objRest["movie"]["release"]["distributor"] != null)
                        {
                            objItem.Studio = (string)objRest["movie"]["release"]["distributor"]["name"];
                        }
                    }

                    if (objRest["movie"]["statistics"] != null)
                    {
                        string strrating = (string)objRest["movie"]["statistics"]["userRating"];
                        if (string.IsNullOrWhiteSpace(strrating) == false)
                        {
                            double      value;
                            CultureInfo cultureInfo = new CultureInfo("en-US", true);
                            if (double.TryParse(strrating, NumberStyles.Any, cultureInfo.NumberFormat, out value) ==
                                true)
                            {
                                objItem.Rating = value.ToString("F");
                            }
                            else if (double.TryParse(strrating.Replace(',', '.'), out value) == true)
                            {
                                objItem.Rating = value.ToString(CultureInfo.InvariantCulture);
                            }
                            else
                            {
                                objItem.Rating = strrating;
                            }
                        }
                    }
                }
            }

            return(objItem);
        }