Example #1
0
        /// <summary>
        /// Gets a list of <seealso cref="Items"/> objects based on a list of ASIN strings.
        /// </summary>
        /// <param name="asinList">The list of ASIN strings.</param>
        /// <returns>A list of <seealso cref="Items"/> </returns>
        public static IEnumerable <Items> GetItemsFromAsinList(IList <string> asinList)
        {
            var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

            basicHttpBinding.MaxReceivedMessageSize = int.MaxValue;

            var associateUrl    = ConfigurationManager.AppSettings["AssociateUrl"];
            var accessKeyId     = ConfigurationManager.AppSettings["AccessKeyId"];
            var associateSecret = ConfigurationManager.AppSettings["AssociateSecret"];
            var associateTag    = ConfigurationManager.AppSettings["AssociateTag"];

            using (var awseCommerceServicePortTypeClient = new AWSECommerceServicePortTypeClient(basicHttpBinding, new EndpointAddress(associateUrl)))
            {
                var amazonEndpointBehavior = new AmazonSigningEndpointBehavior(accessKeyId, associateSecret);
                awseCommerceServicePortTypeClient.ChannelFactory.Endpoint.Behaviors.Add(amazonEndpointBehavior);

                var itemLookupRequest = new ItemLookupRequest();
                itemLookupRequest.ItemId        = asinList.ToArray();
                itemLookupRequest.ResponseGroup = new string[] { "ItemAttributes", "Images", "Offers" };

                var itemLookup = new ItemLookup();
                itemLookup.AssociateTag   = associateTag;
                itemLookup.AWSAccessKeyId = accessKeyId;
                itemLookup.Request        = new ItemLookupRequest[] { itemLookupRequest };

                var itemLookupResponse = awseCommerceServicePortTypeClient.ItemLookup(itemLookup);
                var itemArray          = itemLookupResponse.Items;

                return(itemArray.Cast <Items>());
            }
        }
Example #2
0
        private static IEnumerable <ItemAlternateVersion> GetAlternateVersions(AWSECommerceServicePortTypeClient client, string asin)
        {
            ItemLookupRequest request = new ItemLookupRequest();

            request.IdType        = ItemLookupRequestIdType.ASIN;
            request.ItemId        = new string[] { asin };
            request.ResponseGroup = new string[] { "AlternateVersions" };

            ItemLookup lookup = new ItemLookup();

            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag   = associate_tag;
            lookup.Request        = new ItemLookupRequest[] { request };

            var response = client.ItemLookup(lookup);

            if (response.Items != null && response.Items.Count() > 0)
            {
                var items = response.Items[0];
                if (items.Item != null && items.Item.Count() > 0)
                {
                    var item = items.Item[0];
                    if (item.AlternateVersions != null && item.AlternateVersions.Count() > 0)
                    {
                        return(item.AlternateVersions);
                    }
                }
            }
            return(null);
        }
Example #3
0
        private static IEnumerable<ItemAlternateVersion> GetAlternateVersions(AWSECommerceServicePortTypeClient client, string asin)
        {
            ItemLookupRequest request = new ItemLookupRequest();
            request.IdType = ItemLookupRequestIdType.ASIN;
            request.ItemId = new string[] { asin };
            request.ResponseGroup = new string[] { "AlternateVersions" };

            ItemLookup lookup = new ItemLookup();
            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag = associate_tag;
            lookup.Request = new ItemLookupRequest[] { request };

            var response = client.ItemLookup(lookup);

            if (response.Items != null && response.Items.Count() > 0)
            {
                var items = response.Items[0];
                if (items.Item != null && items.Item.Count() > 0)
                {
                    var item = items.Item[0];
                    if (item.AlternateVersions != null && item.AlternateVersions.Count() > 0)
                        return item.AlternateVersions;
                }
            }
            return null;
        }
Example #4
0
        public ItemLookupResponse ItemLookUp(List <string> items, ItemLookupRequestIdType id)
        {
            try
            {
                var request = new ItemLookupRequest
                {
                    ItemId          = items.ToArray(),
                    IdType          = id,
                    IdTypeSpecified = true,
                    ResponseGroup   = new string[]
                    { "Large", "OfferFull", "OfferListings", "Offers", "OfferSummary", "Images" }
                };
                //new string[] { "132018245828" };

                if (id != ItemLookupRequestIdType.ASIN)
                {
                    request.SearchIndex = "All";
                }

                var amazon = new ItemLookup
                {
                    AssociateTag   = AssociateTag,
                    AWSAccessKeyId = AWSAccessKeyId,
                    Request        = new ItemLookupRequest[] { request }
                };
                var resultado = client.ItemLookup(amazon);

                return(resultado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private static Item[] DoAmazonItemLookup(string[] ASINs)
        {
            ItemLookupResponse response = null;

            AWSECommerceServicePortTypeClient ecs = GetClient();
            ItemLookupRequest request             = GetLookupRequest();

            request.ItemId = ASINs;

            ItemLookup lookup = new ItemLookup();

            lookup.AssociateTag   = _ASSOCIATE_TAG;
            lookup.AWSAccessKeyId = _ACCESS_KEY_ID;

            // Set the request on the search wrapper
            lookup.Request = new ItemLookupRequest[] { request };

            try
            {
                //Send the request and store the response
                response = ecs.ItemLookup(lookup);
            }
            catch (NullReferenceException e)
            {
                Debug.WriteLine(e.ToString());
            }

            if (response == null)
            {
                throw new Exception("Request did not return a response. Error using Amazon API");
            }

            return(response.Items[0].Item);
        }
        private ItemLookupResponse getItemLookupResponse(List <AmazonInfoFeed> infoFeeds)
        {
            // prepare the ItemLookup request
            var requests = new List <ItemLookupRequest>();

            // this should be 5 items only
            foreach (var infoFeed in infoFeeds)
            {
                // create request item type for asin - WE ONLY FIND PRODUCT INFO VIA ASIN ONLY!
                if (!string.IsNullOrEmpty(infoFeed.ASIN))
                {
                    requests.Add(createItemRequestLookup(infoFeed.ASIN, ItemLookupRequestIdType.ASIN));
                }
            }

            // return null if there is no request available
            if (!requests.Any())
            {
                return(null);
            }

            // create an ItemSearch wrapper
            var itemLookUp = new ItemLookup();

            itemLookUp.AssociateTag   = _associateKey;
            itemLookUp.AWSAccessKeyId = _accessKey;
            itemLookUp.Request        = requests.ToArray();

            // send the ItemLookup request
            return(_client.ItemLookup(itemLookUp));
        }
Example #7
0
        public string getCurrentPrice(string itemID)
        {
            const string accessKeyId = "AKIAINHOZEYXDKHXMYUQ";
            const string secretKey   = "julQsMkFls7gezSrs9pF5dQjv1zQ9OazqrPixgUj";

            // create a WCF Amazon ECS client
            AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
                new BasicHttpBinding(BasicHttpSecurityMode.Transport),
                new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

            // add authentication to the ECS client
            client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey));

            // prepare an ItemSearch request
            ItemLookupRequest request = new ItemLookupRequest();

            request.ItemId        = new string[] { itemID };
            request.ResponseGroup = new string[] { "OfferSummary" };
            request.MerchantId    = "Amazon";

            ItemLookup itemSearch = new ItemLookup();

            itemSearch.Request        = new ItemLookupRequest[] { request };
            itemSearch.AWSAccessKeyId = accessKeyId;
            itemSearch.AssociateTag   = "rgreuel-20";

            // issue the ItemSearch request
            ItemLookupResponse response = client.ItemLookup(itemSearch);

            // write out the results
            Item returnedItem = response.Items[0].Item.First();

            return((returnedItem.OfferSummary.LowestNewPrice.FormattedPrice).Substring(1, returnedItem.OfferSummary.LowestNewPrice.FormattedPrice.Length - 1));
        }
Example #8
0
    private string getImageURL(string asin)
    {
        const string accessKeyId = "AKIAINHOZEYXDKHXMYUQ";
        const string secretKey   = "julQsMkFls7gezSrs9pF5dQjv1zQ9OazqrPixgUj";

        // create a WCF Amazon ECS client
        AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
            new BasicHttpBinding(BasicHttpSecurityMode.Transport),
            new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

        // add authentication to the ECS client
        client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey));

        // prepare an ItemSearch request
        ItemLookupRequest request = new ItemLookupRequest();

        request.ItemId        = new string[] { asin };
        request.ResponseGroup = new string[] { "Images" };
        request.MerchantId    = "Amazon";

        ItemLookup itemSearch = new ItemLookup();

        itemSearch.Request        = new ItemLookupRequest[] { request };
        itemSearch.AWSAccessKeyId = accessKeyId;
        itemSearch.AssociateTag   = "rgreuel-20";

        // issue the ItemSearch request
        ItemLookupResponse response = client.ItemLookup(itemSearch);

        Item returnedItem = response.Items[0].Item.First();

        return("<img src=\"" + returnedItem.MediumImage.URL + "\"/>");
    }
Example #9
0
        public string ReviewsFrame()
        {
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.MaxBufferSize = int.MaxValue;

            AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient(
                        binding,
                        new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));
            // add authentication to the ECS client
            amazonClient.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(ConfigurationManager.AppSettings["accessKeyId"], ConfigurationManager.AppSettings["secretKey"]));

            ItemLookupRequest request = new ItemLookupRequest();
            request.ItemId = this.ItemIds;
            request.IdType = ItemLookupRequestIdType.ASIN;
            request.ResponseGroup = new string[] { "Reviews" };

            ItemLookup itemLookup = new ItemLookup();
            itemLookup.Request = new ItemLookupRequest[] { request };
            itemLookup.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
            itemLookup.AssociateTag = ConfigurationManager.AppSettings["associateTag"];

            ItemLookupResponse response = amazonClient.ItemLookup(itemLookup);
            string frameUrl = response.Items[0].Item[0].CustomerReviews.IFrameURL;
            return frameUrl;
        }
Example #10
0
        public string ReviewsFrame()
        {
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

            binding.MaxReceivedMessageSize = int.MaxValue;
            binding.MaxBufferSize          = int.MaxValue;

            AWSECommerceServicePortTypeClient amazonClient = new AWSECommerceServicePortTypeClient(
                binding,
                new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

            // add authentication to the ECS client
            amazonClient.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(ConfigurationManager.AppSettings["accessKeyId"], ConfigurationManager.AppSettings["secretKey"]));

            ItemLookupRequest request = new ItemLookupRequest();

            request.ItemId        = this.ItemIds;
            request.IdType        = ItemLookupRequestIdType.ASIN;
            request.ResponseGroup = new string[] { "Reviews" };

            ItemLookup itemLookup = new ItemLookup();

            itemLookup.Request        = new ItemLookupRequest[] { request };
            itemLookup.AWSAccessKeyId = ConfigurationManager.AppSettings["accessKeyId"];
            itemLookup.AssociateTag   = ConfigurationManager.AppSettings["associateTag"];

            ItemLookupResponse response = amazonClient.ItemLookup(itemLookup);
            string             frameUrl = response.Items[0].Item[0].CustomerReviews.IFrameURL;

            return(frameUrl);
        }
Example #11
0
        public ItemLookupResponse ItemLookupCustom(string asin)
        {
            var lookup  = new ItemLookup();
            var request = new ItemLookupRequest
            {
                IdType          = ItemLookupRequestIdType.ASIN,
                IdTypeSpecified = true,
                ItemId          = new[] { asin },
                ResponseGroup   = new[] { "ItemAttributes", "OfferFull", "Reviews", "Large" }
            };

            //request.SearchIndex = "All";
            lookup.AWSAccessKeyId = AccessKey;
            lookup.AssociateTag   = AssociateTag;
            lookup.Request        = new[] { request };

            return(client.ItemLookup(lookup));
        }
Example #12
0
        private static void GetVariations(AWSECommerceServicePortTypeClient client, string asin)
        {
            ItemLookupRequest request = new ItemLookupRequest();
            request.IdType = ItemLookupRequestIdType.ASIN;
            request.ItemId = new string[] { asin };
            request.ResponseGroup = new string[] { "Variations" };

            ItemLookup lookup = new ItemLookup();
            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag = associate_tag;
            lookup.Request = new ItemLookupRequest[] { request };

            var response = client.ItemLookup(lookup);
        }
Example #13
0
        private static void GetVariations(AWSECommerceServicePortTypeClient client, string asin)
        {
            ItemLookupRequest request = new ItemLookupRequest();

            request.IdType        = ItemLookupRequestIdType.ASIN;
            request.ItemId        = new string[] { asin };
            request.ResponseGroup = new string[] { "Variations" };

            ItemLookup lookup = new ItemLookup();

            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag   = associate_tag;
            lookup.Request        = new ItemLookupRequest[] { request };

            var response = client.ItemLookup(lookup);
        }
Example #14
0
        private static ItemLookupResponse ItemLookup(AWSECommerceServicePortTypeClient client, string asin)
        {
            ItemLookupRequest request = new ItemLookupRequest();

            request.IdType        = ItemLookupRequestIdType.ASIN;
            request.ItemId        = new string[] { asin };
            request.ResponseGroup = new string[] { "Large", "ItemAttributes", "AlternateVersions", "Variations" };

            ItemLookup lookup = new ItemLookup();

            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag   = associate_tag;
            lookup.Request        = new ItemLookupRequest[] { request };

            var response = client.ItemLookup(lookup);

            return(response);
        }
        public Item[] LookupItems(string itemIds)
        {
            var ids = itemIds.Split(',');

            if (ids.Length == 0)
            {
                return(new Item[] { });
            }

            var itemLookup = new ItemLookup {
                AssociateTag   = AmazonAssociateTag,
                AWSAccessKeyId = AmazonAccessKey,
                Request        = new ItemLookupRequest[] {
                    new ItemLookupRequest {
                        ItemId          = ids.Length > 10 ? ids.Take(10).ToArray() : ids,
                        IdType          = ItemLookupRequestIdType.ASIN,
                        IdTypeSpecified = true,
                        ResponseGroup   = new string[] { "Images", "ItemAttributes" }
                    }
                }
            };

            var lookupResult = _amazonClient.ItemLookup(itemLookup);
            var items        = new List <Item>();

            foreach (var amazonItem in lookupResult.Items[0].Item)
            {
                var item = new Item {
                    Id         = amazonItem.ASIN,
                    ListPrice  = decimal.Parse(amazonItem.ItemAttributes.ListPrice.Amount),
                    Title      = amazonItem.ItemAttributes.Title,
                    ListingUrl = amazonItem.DetailPageURL,
                    ImageUrl   = amazonItem.SmallImage == null ? "" : amazonItem.SmallImage.URL
                };
                items.Add(item);
            }

            return(items.ToArray());
        }
Example #16
0
        private void btnLivreAmazonRecherche_Click(object sender, EventArgs e)
        {
            ItemLookupResponse response;
            AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient("AWSECommerceServicePort");

            client.ChannelFactory.Endpoint.EndpointBehaviors.Add(
                new AmazonSigningEndpointBehavior(ConfigurationManager.AppSettings.Get("accessKeyId"),
                                                  ConfigurationManager.AppSettings.Get("secretKey")));

            ItemLookupRequest recherche_ISBN = new ItemLookupRequest();
            recherche_ISBN.SearchIndex = "Books";
            recherche_ISBN.ItemId = new string[] { txtISBN.Text };
            recherche_ISBN.IdType = ItemLookupRequestIdType.ISBN;
            recherche_ISBN.IdTypeSpecified = true;
            recherche_ISBN.ResponseGroup = new string[] { "Images", "Small" };

            ItemLookup itemlookup = new ItemLookup();
            itemlookup.Request = new ItemLookupRequest[] { recherche_ISBN };
            itemlookup.AWSAccessKeyId = ConfigurationManager.AppSettings.Get("accessKeyId");
            itemlookup.AssociateTag = ConfigurationManager.AppSettings.Get("associateTag");

            try
            {
                response = client.ItemLookup(itemlookup);

                foreach (var item in response.Items[0].Item)
                {
                    txtTitre.Text = item.ItemAttributes.Title;
                    txtAuteur.Text = item.ItemAttributes.Author[0];

                    // Create a web request to the URL for the picture
                    WebRequest webRequest = HttpWebRequest.Create(item.MediumImage.URL);

                    // Execute the request synchronuously
                    HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

                    // Create an image from the stream returned by the web request
                    pictureBoxLivre.Image = new System.Drawing.Bitmap(webResponse.GetResponseStream());

                    WebClient clientWeb = new WebClient();
                    _cover = clientWeb.DownloadData(item.MediumImage.URL);

                    // Finally, close the request
                    webResponse.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #17
0
        /// <summary>
        /// by UPC or ASIN
        /// </summary>
        /// <param name="product"></param>
        public static void Do(Product product)
        {
            // create a WCF Amazon ECS client
            AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
                new BasicHttpBinding(BasicHttpSecurityMode.Transport)
                    {
                        MaxReceivedMessageSize = int.MaxValue,
                        MaxBufferSize=int.MaxValue,
                        ReaderQuotas = new XmlDictionaryReaderQuotas()
                        {
                            MaxStringContentLength = int.MaxValue
                        }
                    },
                new EndpointAddress(DESTINATION));

            // add authentication to the ECS client
            client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(MY_AWS_ID, MY_AWS_SECRET));

            // prepare an ItemSearch request
            ItemLookup itemLookup = new ItemLookup();
            itemLookup.AWSAccessKeyId = MY_AWS_ID;
            itemLookup.AssociateTag = "modkitdesgui-20";

            ItemLookupRequest itemLookupRequest = new ItemLookupRequest();

            if (!string.IsNullOrEmpty(product.UPC))
            {
                itemLookupRequest.IdType = ItemLookupRequestIdType.UPC;
                itemLookupRequest.IdTypeSpecified = true;
                itemLookupRequest.ItemId = new[] { product.UPC };
            }
            else if (!string.IsNullOrEmpty(product.AmazonASIN))
            {
                itemLookupRequest.IdType = ItemLookupRequestIdType.ASIN;
                itemLookupRequest.IdTypeSpecified = true;
                itemLookupRequest.ItemId = new[] { product.AmazonASIN };
            }
            else
            {
                return;
            }

            itemLookupRequest.SearchIndex = "All";
            itemLookupRequest.ResponseGroup = new String[] { "Large" };
            itemLookup.Request = new ItemLookupRequest[] { itemLookupRequest };

            // make the call and print the title if it succeeds
            try
            {
                ItemLookupResponse itemLookupResponse = client.ItemLookup(itemLookup);
                //search by upc, it may return more than 1 items!!!

                if (itemLookupResponse.Items.Length == 0
                    || itemLookupResponse.Items[0].Item == null
                    || itemLookupResponse.Items[0].Item.Length == 0)
                    return;

                Item item = itemLookupResponse.Items[0].Item[0];
                foreach (Item ritem in itemLookupResponse.Items[0].Item)
                {
                    if (!string.IsNullOrEmpty(product.UPC) && ritem.ItemAttributes.UPC == product.UPC)
                    {
                        item = ritem;
                        break;
                    }
                }

                //
                if (item.ItemAttributes.Feature != null)
                    foreach (var feature in item.ItemAttributes.Feature)
                    {
                        product.Features.Add(new Feature() { Desc = feature });
                    }

                //
                product.AmazonDetailsUrl = item.DetailPageURL;
                int.TryParse(item.SalesRank, out product.AmazonSaleRank);
                product.AmazonASIN = item.ASIN;
                product.UPC = item.ItemAttributes.UPC;

                if (string.IsNullOrEmpty(product.Name))
                    product.Name = item.ItemAttributes.Title;

                if (item.ItemAttributes.ListPrice != null)
                {
                    decimal.TryParse(item.ItemAttributes.ListPrice.Amount, out product.AmazonPrice);
                }

                if (item.OfferSummary.LowestNewPrice != null)
                {
                    decimal lowestPrice;
                    if (decimal.TryParse(item.OfferSummary.LowestNewPrice.Amount, out lowestPrice)
                        && lowestPrice > 0)
                        product.AmazonPrice = lowestPrice;
                }
                product.AmazonPrice /= 100;

                if (string.IsNullOrEmpty(product.LargeImageUrl) || product.LargeImageUrl.Contains("default_hardlines"))
                    product.LargeImageUrl = item.LargeImage.URL;
                if (string.IsNullOrEmpty(product.ThumbnailImageUrl) || product.LargeImageUrl.Contains("default_hardlines"))
                    product.ThumbnailImageUrl = item.SmallImage.URL;

                //
                if (item.SimilarProducts != null)
                {
                    foreach (var similarProduct in item.SimilarProducts)
                    {
                        product.SimilarProducts.Add(new Product() { AmazonASIN = similarProduct.ASIN, Name = similarProduct.Title });
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error("Amazon Error", e);
            }
        }
    private string getImageURL(string asin)
    {
        const string accessKeyId = "AKIAINHOZEYXDKHXMYUQ";
        const string secretKey = "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";

        // create a WCF Amazon ECS client
        AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
            new BasicHttpBinding(BasicHttpSecurityMode.Transport),
            new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

        // add authentication to the ECS client
        client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey));

        // prepare an ItemSearch request
        ItemLookupRequest request = new ItemLookupRequest();
        request.ItemId = new string[] { asin };
        request.ResponseGroup = new string[] { "Images" };
        request.MerchantId = "Amazon";

        ItemLookup itemSearch = new ItemLookup();
        itemSearch.Request = new ItemLookupRequest[] { request };
        itemSearch.AWSAccessKeyId = accessKeyId;
        itemSearch.AssociateTag = "rgreuel-20";

        // issue the ItemSearch request
        ItemLookupResponse response = client.ItemLookup(itemSearch);

        Item returnedItem = response.Items[0].Item.First();

        return "<img src=\"" + returnedItem.MediumImage.URL + "\"/>";
    }
Example #19
0
        private void updateBooksDetail(string[] ISBNs)
        {
            ItemLookupRequest request = new ItemLookupRequest();

            if (ISBNs.Count() < 1)
            {
                //appendLineToLog("**No books selected");
                return;
            }

            string[] toProcess;
            /***** batch in 10s *****/
            for (int i = 0; i < ISBNs.Length; i = i + 10)
            {
                toProcess = ISBNs.Skip(i).Take(10).ToArray();

                //mark unprocessed books as'processed' by setting dummy values (but retain existing non null values)
                AmazonCrawlerEntities c = DbUtil.getNewContext();
                foreach (var isbn in toProcess)
                {
                    Book b = DbUtil.getBook(c, isbn);

                    if (chkTitle.Checked && b.title == null)
                    {
                        b.title = "-";
                    }

                    if (chkDetailUrl.Checked && b.detailPageURL == null)
                    {
                        b.detailPageURL = "-";
                    }
                }

                try
                {
                    c.SaveChanges();
                }
                catch (Exception ex)
                {
                    appendLineToLog("[error] preparing books from Db: " + ex.Message);
                    appendLineToLog("\t" + ex.StackTrace);
                    return;
                }

                request.ItemId = toProcess;
                request.IdType = ItemLookupRequestIdType.ISBN;
                //request.SearchIndex = "Books";

                request.ResponseGroup = new string[] { "ItemAttributes" };
                //request.ResponseGroup = new string[] { "Reviews", "Large", "SalesRank" };

                ItemLookup itemLookup = new ItemLookup();
                itemLookup.Request      = new ItemLookupRequest[] { request };
                itemLookup.AssociateTag = "notag"; //this is a required param, so I just use a dummy value which seems to work

                // send the ItemSearch request
                ItemLookupResponse response = amazonClient.ItemLookup(itemLookup);

                if (response.Items != null && response.Items.Count() > 0 && response.Items[0].Item != null)
                {
                    AmazonCrawlerEntities context = DbUtil.getNewContext();

                    // write out the results from the ItemSearch request
                    foreach (var item in response.Items[0].Item)
                    {
                        Book toUpdate = DbUtil.getBook(context, item.ASIN);

                        if (toUpdate != null)
                        {
                            int      parseOutput;
                            DateTime parseOutputDate = DateTime.MinValue;

                            if (item.ItemAttributes != null && item.ItemAttributes.Title != null)
                            {
                                toUpdate.title = item.ItemAttributes.Title;
                            }

                            //2012-10-31 21:51
                            //Not going to get sales rank from here. There are multiple ranks listed on the details page
                            //so will crawl that separately instead.
                            //The plan is to crawl it same time as getting rating stats AND author ranks so the stats are
                            //collected at roughly the same time.

                            //int.TryParse(item.SalesRank, out parseOutput);
                            //toUpdate.salesRank = parseOutput;

                            int.TryParse(item.ItemAttributes.NumberOfPages, out parseOutput);
                            if (parseOutput > 0)
                            {
                                toUpdate.pages = parseOutput;
                            }
                            else
                            {
                                toUpdate.pages = null;
                            }

                            toUpdate.publisher = item.ItemAttributes.Publisher;

                            DateTime.TryParse(item.ItemAttributes.PublicationDate, out parseOutputDate);
                            if (parseOutputDate.Equals(DateTime.MinValue))
                            {
                                //date format is just a year number.
                                DateTime.TryParse(item.ItemAttributes.PublicationDate + "/01/01", out parseOutputDate);
                            }
                            if (parseOutputDate > DateTime.MinValue)
                            {
                                toUpdate.publicationDate = parseOutputDate;
                            }
                            else
                            {
                                toUpdate.publicationDate = null;
                            }

                            toUpdate.detailPageURL = item.DetailPageURL.Substring(0, item.DetailPageURL.IndexOf("%3F"));

                            context.SaveChanges();
                            appendLineToLog(item.ItemAttributes.Title + " (" + item.ASIN + ") updated.");
                        }
                        else
                        {
                            appendLineToLog("[error] ISBN " + item.ASIN + " not found in database");
                        }
                    }
                    if (response.Items[0].Item.Count() != toProcess.Count())
                    {
                        appendLineToLog((toProcess.Count() - response.Items[0].Item.Count()) + " books skipped");
                    }
                }
                else
                {
                    appendLineToLog(toProcess.Count() + " books skipped.");

                    /********************
                    * Check if it's due to ItemID invalid error, if so then continue as normal
                    * ItemID invalid error just means the ISBN doesn't exist in Amazon's API.
                    * ******************/
                    if (response.Items != null && response.Items[0].Request != null && response.Items[0].Request.Errors != null)
                    {
                        var errorCode = response.Items[0].Request.Errors[0].Code;
                        if (errorCode == "AWS.InvalidParameterValue")
                        {
                            sleep();
                            continue;
                        }
                    }
                    //Otherwise there may be an API error
                    //undo the 'process' marker.
                    else
                    {
                        foreach (var isbn in toProcess)
                        {
                            Book b = DbUtil.getBook(c, isbn);

                            if (b.title == "-")
                            {
                                b.title = null;
                            }

                            if (b.detailPageURL == "-")
                            {
                                b.detailPageURL = null;
                            }
                        }

                        try
                        {
                            c.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            appendLineToLog("[error] preparing books from Db: " + ex.Message);
                            appendLineToLog("\t" + ex.StackTrace);
                            return;
                        }

                        //sleep between 3 and 10 minutes before continuing
                        TimeSpan duration = new TimeSpan(0, 0, ((3 * 60) + (RANDOM.Next(10 * 60))));
                        appendLineToLog(string.Format("Sleeping for {0}:{1} mins and secs", duration.Minutes, duration.Seconds));
                        System.Threading.Thread.Sleep(duration);
                    }
                }

                sleep(); //delay each API call
            }
        }
Example #20
0
        private static ItemLookupResponse ItemLookup(AWSECommerceServicePortTypeClient client, string asin)
        {
            ItemLookupRequest request = new ItemLookupRequest();
            request.IdType = ItemLookupRequestIdType.ASIN;
            request.ItemId = new string[] { asin };
            request.ResponseGroup = new string[] { "Large", "ItemAttributes", "AlternateVersions", "Variations" };

            ItemLookup lookup = new ItemLookup();
            lookup.AWSAccessKeyId = access_key_id;
            lookup.AssociateTag = associate_tag;
            lookup.Request = new ItemLookupRequest[] { request };

            var response = client.ItemLookup(lookup);
            return response;
        }
    public string getCurrentPrice(string itemID)
    {
        const string accessKeyId = "AKIAINHOZEYXDKHXMYUQ";
        const string secretKey = "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";

        // create a WCF Amazon ECS client
        AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
            new BasicHttpBinding(BasicHttpSecurityMode.Transport),
            new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

        // add authentication to the ECS client
        client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey));

        // prepare an ItemSearch request
        ItemLookupRequest request = new ItemLookupRequest();
        request.ItemId = new string[] { itemID };
        request.ResponseGroup = new string[] { "OfferSummary" };
        request.MerchantId = "Amazon";

        ItemLookup itemSearch = new ItemLookup();
        itemSearch.Request = new ItemLookupRequest[] { request };
        itemSearch.AWSAccessKeyId = accessKeyId;
        itemSearch.AssociateTag = "rgreuel-20";

        // issue the ItemSearch request
        ItemLookupResponse response = client.ItemLookup(itemSearch);

        // write out the results
        Item returnedItem = response.Items[0].Item.First();

        return (returnedItem.OfferSummary.LowestNewPrice.FormattedPrice).Substring(1, returnedItem.OfferSummary.LowestNewPrice.FormattedPrice.Length - 1);
    }
        // the program starts here
        static void Main(string[] args)
        {
            // create a WCF Amazon ECS client
            BasicHttpBinding binding		= new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            binding.MaxReceivedMessageSize	= int.MaxValue;
            AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient(
                binding,
                new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));

            // add authentication to the ECS client
            client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey));

            ItemLookupRequest request2 = new ItemLookupRequest();
            request2.ItemId = new String[] { "2817801997" };
            request2.IdType = ItemLookupRequestIdType.ISBN;
            request2.ResponseGroup = new String[] { "Medium" };
            request2.IdTypeSpecified = true;
            request2.SearchIndex = "Books";

            ItemLookup itemLookup = new ItemLookup();
            itemLookup.Request = new ItemLookupRequest[] { request2 };
            itemLookup.AWSAccessKeyId = accessKeyId;
            itemLookup.AssociateTag = "213";

            ItemLookupResponse response2 = client.ItemLookup(itemLookup);

            foreach (var item in response2.Items[0].Item) {
                // Create a web request to the URL for the picture
                System.Net.WebRequest webRequest = HttpWebRequest.Create(item.MediumImage.URL);
                // Execute the request synchronuously
                HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

                // Create an image from the stream returned by the web request
                //pCover.Image = new System.Drawing.Bitmap(webResponse.GetResponseStream());

                // Finally, close the request
                webResponse.Close();
                Console.WriteLine(item.ItemAttributes.Title);
            }

            // prepare an ItemSearch request
            ItemSearchRequest request	= new ItemSearchRequest();
            request.SearchIndex			= "Books";
            request.Title				= "Node.js";
            request.ResponseGroup 		= new string[] { "Small" };

            ItemSearch itemSearch		= new ItemSearch();
            itemSearch.Request			= new ItemSearchRequest[] { request };
            //itemSearch.AssociateTag 	= "testsite09f-21";
            itemSearch.AssociateTag 	= "213";
            itemSearch.AWSAccessKeyId	= accessKeyId;

            // issue the ItemSearch request
            ItemSearchResponse response	= client.ItemSearch(itemSearch);

            // write out the results
            foreach (var item in response.Items[0].Item) {
                Console.WriteLine(item.ItemAttributes.Title);
            }
            Console.ReadLine();
        }
        public MarketplaceProduct GetProductInfo(AmazonInfoFeed infoFeed)
        {
            // create a WCF Amazon ECS client
            var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

            binding.MaxReceivedMessageSize = int.MaxValue;
            var client = new AWSECommerceServicePortTypeClient(
                binding,
                new EndpointAddress("https://webservices.amazon.com/onca/soap?Service=AWSECommerceService"));
            var requests = new List <ItemLookupRequest>();

            // add authentication to the ECS client
            client.ChannelFactory.Endpoint.Behaviors
            .Add(new AmazonSigningEndpointBehavior(_credential.SearchAccessKeyId, _credential.SearchSecretKey));

            // create request item type for asin - WE ONLY ALLOW ASIN ONLY
            if (!string.IsNullOrEmpty(infoFeed.ASIN))
            {
                requests.Add(createItemRequestLookup(infoFeed.ASIN, ItemLookupRequestIdType.ASIN));
            }

            // return null if there is no request available
            if (!requests.Any())
            {
                return(null);
            }

            // create an ItemSearch wrapper
            var itemLookUp = new ItemLookup();

            itemLookUp.AssociateTag   = _credential.AssociateId;
            itemLookUp.AWSAccessKeyId = _credential.SearchAccessKeyId;
            itemLookUp.Request        = requests.ToArray();

            // send the ItemLookup request
            var response = client.ItemLookup(itemLookUp);

            if (response == null || response.Items == null)
            {
                _logger.LogError(LogEntryType.AmazonProduct, string.Format("Item Lookup for {0} failed! Error Message: {1}", infoFeed.EisSKU, response.OperationRequest.Errors[0].Message), string.Empty);
                return(null);
            }

            AmazonService.Item itemResult = null;
            var errorMessages             = new List <string>();

            for (var i = 0; i < requests.Count; i++)
            {
                if (response.Items[i].Request.Errors != null)
                {
                    errorMessages.Add(response.Items[i].Request.Errors[0].Message);
                }

                if (response.Items[i].Item != null)
                {
                    // set the initial value for the item result
                    itemResult = response.Items[i].Item[0];

                    foreach (var item in response.Items[i].Item)
                    {
                        // let's find from the result which has large image available
                        if (item.LargeImage != null)
                        {
                            itemResult = item;
                            break;
                        }
                    }
                }
            }

            // exit if there is no really result
            if (itemResult == null)
            {
                _logger.LogError(LogEntryType.AmazonProduct, string.Join("\n", errorMessages), string.Empty);
                return(null);
            }

            var product = parsedToMarketplaceProduct(itemResult);

            product.EisSKU = infoFeed.EisSKU;

            // log info
            _logger.LogInfo(LogEntryType.AmazonProduct, string.Format("Get product info for \'{0}\' was successful!", infoFeed.ASIN));

            return(product);
        }
Example #24
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);
            }
        }